:root {
  --bg-0: #f5f7f2;
  --bg-1: #e7efe1;
  --panel: #ffffff;
  --ink: #1a1f19;
  --muted: #5c6a5d;
  --accent: #1f7a52;
  --accent-ink: #ffffff;
  --danger: #9f2a2a;
  --ring: rgba(31, 122, 82, 0.2);
  --shadow: 0 14px 36px rgba(20, 50, 32, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  min-height: 100vh;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(700px 420px at 15% -10%, #d9e8cd 0%, transparent 70%),
    radial-gradient(860px 460px at 95% 0%, #dce9f6 0%, transparent 72%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  z-index: -1;
}

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.brand-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 8px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

#status-text {
  min-height: 20px;
}

#status-text.skeleton-status,
#folder-title.skeleton-title,
#folder-meta.skeleton-meta {
  color: transparent !important;
  border-radius: 10px;
  background: linear-gradient(90deg, #eef3ee 20%, #f8fbf8 50%, #eef3ee 80%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
}

#status-text.skeleton-status {
  display: inline-block;
  width: min(360px, 78vw);
}

#folder-title.skeleton-title {
  width: min(420px, 82%);
}

#folder-meta.skeleton-meta {
  width: 140px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-height: 44px;
}

.alert-danger {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #f0c0c0;
  background: #fff0f0;
  color: #7f1e1e;
  font-size: 14px;
  line-height: 1.45;
}

.top-login {
  display: grid;
  grid-template-columns: 140px 140px auto auto;
  gap: 6px;
}

.top-login input {
  padding: 8px 10px;
}

.top-login button {
  padding: 8px 12px;
}

.card {
  background: var(--panel);
  border: 1px solid #e3eadf;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 12px;
  animation: card-in 180ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.stack {
  display: grid;
  gap: 10px;
}

.inline {
  grid-template-columns: 1fr auto;
}

input,
button {
  border-radius: 12px;
  border: 1px solid #cad8cd;
  font: inherit;
}

input {
  padding: 11px 12px;
  outline: none;
  background: #fbfdfb;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

button {
  padding: 11px 14px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.04);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ghost {
  color: var(--ink);
  background: #f3f8f3;
  border-color: #d6e0d8;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.crumb-btn {
  border: 0;
  background: transparent;
  color: #2d5c42;
  padding: 2px 4px;
  border-radius: 8px;
  cursor: pointer;
}

.crumb-btn:hover {
  background: #eef5f0;
}

.crumb-current {
  color: var(--ink);
  font-weight: 600;
}

.crumb-sep {
  color: #8ca397;
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
}

.lk-step {
  margin: 6px 0;
}

.lk-step-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.lk-form {
  margin-bottom: 8px;
}

.tg-bot-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid #cfe0d2;
  background: #f2f8f4;
  color: #1a5036;
  text-decoration: none;
  font-weight: 600;
}

.tg-bot-link:hover {
  background: #eaf4ed;
}

.tg-bot-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.search-wrap {
  margin: 0 0 12px;
  min-height: 44px;
}

.search-wrap input {
  width: 100%;
}

.banner {
  margin: 10px 0;
  background: #fff4df;
  color: #593d00;
  border: 1px solid #f0d6a5;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

.banner-line + .banner-line {
  margin-top: 4px;
}

.banner-price-old {
  text-decoration: line-through;
  opacity: 0.75;
}

.banner-price-new {
  font-weight: 800;
  color: #7a3f00;
}

.payment {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin: 0 0 12px;
}

.items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}

.items button,
.items a {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d7e2da;
  background: #fbfdfc;
  color: var(--ink);
  text-decoration: none;
  display: block;
}

.item-row {
  display: grid !important;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
}

.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-badge {
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid #c8d8cc;
  color: #2f4f3b;
  background: #eef5f0;
}

.item-icon {
  position: relative;
  width: 18px;
  height: 14px;
  display: inline-block;
}

.item-icon.folder {
  border: 1.5px solid #3d7a53;
  border-radius: 3px;
  background: #d9f0df;
}

.item-icon.folder::before {
  content: "";
  position: absolute;
  width: 9px;
  height: 4px;
  left: 1px;
  top: -4px;
  border: 1.5px solid #3d7a53;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: #e8f7ec;
}

.item-icon.file {
  border: 1.5px solid #58708f;
  border-radius: 3px;
  background: #ecf2fa;
}

.item-icon.file::before {
  content: "";
  position: absolute;
  right: -1px;
  top: -1px;
  width: 7px;
  height: 7px;
  background: #dce7f7;
  border-left: 1.5px solid #58708f;
  border-bottom: 1.5px solid #58708f;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.items button:hover,
.items a:hover {
  border-color: #b9cec0;
  background: #f3f8f4;
}

.items.compact {
  gap: 6px;
}

.items.compact li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
}

.items.compact li.lk-group {
  display: block;
  margin-top: 6px;
  padding: 2px 2px 0;
}

.items.compact li.lk-group:first-child {
  margin-top: 0;
}

.lk-group-top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.lk-group-title {
  color: #274635;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lk-group-meta {
  color: #6e7f72;
  font-size: 12px;
  white-space: nowrap;
}

.lk-access-row .row-main {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.items.compact .row-main {
  border: 1px solid #d7e2da;
  background: #fbfdfc;
  border-radius: 12px;
  padding: 8px 10px;
}

.items.compact .mini {
  padding: 8px 10px;
}

.skeleton-row {
  list-style: none;
}

.skeleton-row .skeleton-block {
  height: 42px;
  border-radius: 12px;
  border: 1px solid #d7e2da;
  background: linear-gradient(90deg, #eef3ee 20%, #f8fbf8 50%, #eef3ee 80%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
}

.skeleton-row.compact {
  display: grid;
  grid-template-columns: 1fr 74px 74px;
  gap: 6px;
  align-items: center;
}

.skeleton-row.compact .skeleton-block {
  height: 34px;
}

.skeleton-row.compact .skeleton-action {
  border-radius: 10px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.admin-grid {
  display: grid;
  gap: 16px;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.admin-head h3 {
  margin: 0;
  font-size: 16px;
}

.codebox {
  margin: 0;
  border: 1px solid #d7e2da;
  background: #f8fbf8;
  padding: 10px;
  border-radius: 12px;
  font-size: 13px;
  max-height: 220px;
  overflow: auto;
}

.viewer-head {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.viewer-head h3 {
  margin: 0;
  font-size: 17px;
  text-align: center;
}

#viewer-close-btn {
  margin: 0 auto;
  min-width: 140px;
}

#viewer-text {
  margin: 0;
  border: 1px solid #d7e2da;
  border-radius: 12px;
  background: #f9fbfa;
  padding: 14px;
  max-height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.45;
}

#viewer-text.skeleton-text {
  color: transparent;
  background: linear-gradient(90deg, #eef3ee 20%, #f8fbf8 50%, #eef3ee 80%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
}

#viewer-pdf {
  width: 100%;
  height: 72vh;
  border: 1px solid #d7e2da;
  border-radius: 12px;
  background: #fff;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 14, 0.42);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(96vw, 520px);
  background: #ffffff;
  border: 1px solid #dbe6df;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  padding: 10px;
  z-index: 31;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  background: #cfd8d2;
  border-radius: 99px;
  margin: 4px auto 10px;
}

.sheet-title {
  font-weight: 600;
  margin: 0 0 10px;
  padding: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

#sheet-cancel-btn {
  display: block;
  margin: 0 auto;
  min-width: 140px;
}

.consent-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 11, 0.54);
  z-index: 40;
}

.consent-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 660px);
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid #d6e1d8;
  border-radius: 16px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.3);
  z-index: 41;
  padding: 16px;
}

.consent-title {
  margin: 0 0 10px;
  font-size: 20px;
}

.consent-body {
  color: #2f3d33;
  font-size: 14px;
  line-height: 1.5;
}

.consent-body p {
  margin: 0 0 10px;
}

.consent-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}

.consent-links a {
  color: #1f7a52;
  text-decoration: none;
  border: 1px solid #cae0d2;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  background: #f4fbf7;
}

.consent-links a:hover {
  background: #eaf7ef;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  color: #1c2e23;
}

.consent-check input {
  margin-top: 2px;
  flex: 0 0 auto;
}

.consent-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  min-width: 260px;
  max-width: calc(100vw - 32px);
  background: #101512;
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
  z-index: 50;
}

.toast.error {
  background: var(--danger);
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
}

.footer-link {
  color: #6a776c;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.footer-link:hover {
  color: #233628;
  background: #edf3ee;
  border-color: #d7e2da;
}

@media (max-width: 740px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    width: 100%;
    justify-content: stretch;
  }

  .top-login {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .top-login button {
    width: 100%;
  }

  .tg-bot-link {
    width: 100%;
  }

  .payment,
  .inline,
  .sheet-actions {
    grid-template-columns: 1fr;
  }

  .consent-modal {
    width: calc(100vw - 14px);
    max-height: calc(100vh - 14px);
    border-radius: 14px;
    padding: 14px;
  }

  .consent-actions {
    flex-direction: column-reverse;
  }

  .consent-actions button {
    width: 100%;
  }

  .breadcrumbs {
    font-size: 12px;
  }

  .app-shell {
    padding-top: 18px;
    padding-bottom: 120px;
  }

  .sheet {
    bottom: max(6px, env(safe-area-inset-bottom));
    width: calc(100vw - 12px);
    border-radius: 18px;
  }

  #viewer-pdf {
    height: 58vh;
  }
}
