:root {
  --navy: #172f59;
  --navy-2: #213f72;
  --blue: #3d39b8;
  --blue-hover: #302c9b;
  --mint: #d8f8e8;
  --mint-strong: #82e6b5;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #dce5ef;
  --text: #15243d;
  --muted: #66758c;
  --danger: #dc3545;
  --shadow: 0 10px 30px rgba(23, 47, 89, 0.07);
  --radius: 18px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }
body { min-height: 100vh; display: flex; flex-direction: column; color: var(--text); background: var(--bg); font-family: var(--font); line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.container { width: min(1280px, calc(100% - 40px)); margin: 0 auto; }

/* Public shell */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92); border-bottom: 1px solid rgba(220,229,239,.85); backdrop-filter: blur(14px); }
.header-inner { position: relative; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { min-width: 0; display: inline-flex; align-items: center; gap: 12px; color: var(--navy); text-decoration: none; }
.brand-logo { display: block; width: auto; height: 64px; object-fit: contain; }
.header-page-title { position: absolute; left: 50%; width: max-content; max-width: calc(100% - 440px); min-width: 0; display: flex; align-items: baseline; justify-content: center; gap: 6px; overflow: hidden; color: var(--navy); white-space: nowrap; transform: translateX(-50%); text-align: center; }
.header-page-title strong, .header-page-title span { overflow: hidden; text-overflow: ellipsis; }
.header-page-title strong { flex: 0 1 auto; font-size: clamp(.9rem,1.45vw,1.18rem); }
.header-page-title span { flex: 1 1 auto; color: var(--muted); font-size: clamp(.7rem,1vw,.82rem); }
.site-nav { display: flex; align-items: center; gap: 8px; }
.site-nav a { min-height: 42px; display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 600; }
.site-nav a:hover { color: var(--navy); background: var(--surface-2); }
.site-nav .nav-ai { color: var(--blue); background: #eeedff; }
.nav-ai-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint-strong); box-shadow: 0 0 0 4px rgba(130,230,181,.2); }
.site-nav .nav-login { color: #fff; background: var(--navy); }
.site-nav .nav-login:hover { color: #fff; background: var(--navy-2); }
.main { flex: 1; padding-top: 34px; padding-bottom: 40px; }
.site-footer { margin-top: auto; padding: 24px 0; color: var(--muted); background: #fff; border-top: 1px solid var(--line); font-size: .82rem; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.footer-inner > div:first-child { display: flex; flex-direction: column; }
.footer-inner strong { color: var(--navy); }

/* Typography and controls */
.page-title { margin: 0; color: var(--navy); font-size: clamp(1.55rem, 2.5vw, 2.25rem); line-height: 1.12; letter-spacing: -.035em; }
.section-title { margin: 26px 0 12px; color: var(--navy); font-size: 1.02rem; }
.empty { color: var(--muted); }
.error-msg { padding: 12px 14px; color: #9f2634; background: #fff0f2; border: 1px solid #ffcbd1; border-radius: 12px; }
.success-msg { padding: 12px 14px; color: #17663c; background: #effbf4; border: 1px solid #bde8ce; border-radius: 12px; }
.input { width: 100%; min-height: 44px; padding: 10px 13px; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 11px; outline: none; transition: border-color .16s, box-shadow .16s; }
.input:hover { border-color: #c7d4e3; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(61,57,184,.1); }
.textarea { min-height: 80px; resize: vertical; }
.input-num { width: 90px; }
.input-file { min-width: 180px; color: var(--muted); }
.btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 0; border-radius: 11px; cursor: pointer; text-decoration: none; font-weight: 700; transition: transform .15s, background .15s, box-shadow .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--blue); box-shadow: 0 7px 18px rgba(61,57,184,.18); }
.btn-primary:hover { background: var(--blue-hover); }
.btn-small { min-height: 36px; padding: 7px 11px; font-size: .78rem; }
.btn-danger { color: var(--danger); background: #fff1f2; border: 1px solid #ffc8ce; }
.btn-danger:hover { background: #ffe5e8; }
.btn-ghost { color: var(--muted); background: transparent; }

/* Public link/file cards */
.home-hero { display: grid; grid-template-columns: 1.25fr .75fr; gap: 20px; margin-bottom: 34px; }
.hero-copy, .hero-card { min-height: 310px; padding: clamp(26px,4vw,48px); border-radius: 26px; }
.hero-copy { display: flex; align-items: flex-start; justify-content: center; flex-direction: column; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero-copy h1 { max-width: 720px; margin: 0; color: var(--navy); font-size: clamp(2.1rem,5vw,4rem); line-height: .98; letter-spacing: -.055em; }
.hero-copy p { max-width: 670px; margin: 20px 0 0; color: var(--muted); font-size: 1rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-secondary { color: var(--navy); background: var(--surface-2); border: 1px solid var(--line); }
.hero-card { display: flex; justify-content: center; flex-direction: column; color: #fff; background: var(--navy); box-shadow: 0 18px 40px rgba(23,47,89,.18); }
.hero-card-label { width: max-content; padding: 5px 9px; color: var(--navy); background: var(--mint-strong); border-radius: 99px; font-size: .64rem; font-weight: 900; letter-spacing: .09em; }
.hero-card strong { margin-top: 22px; font-size: clamp(1.5rem,3vw,2.25rem); }
.hero-card p { margin: 4px 0 0; color: #c9d6e4; }
.hero-card small { margin-top: 22px; color: #aebdd0; line-height: 1.45; }
.hero-route { display: flex; align-items: center; margin-top: 26px; }
.hero-route i { width: 12px; height: 12px; flex: 0 0 12px; background: var(--mint-strong); border: 3px solid rgba(255,255,255,.2); border-radius: 50%; }
.hero-route span { height: 2px; flex: 1; background: linear-gradient(90deg,var(--mint-strong),rgba(130,230,181,.3)); }
.resource-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 14px; }
.resource-heading h2 { margin: 0; color: var(--navy); font-size: 1.5rem; }
.resource-heading p { margin: 0; color: var(--muted); font-size: .84rem; }
.block { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.block + .block { margin-top: 18px; }
.block-title { margin: 0 0 16px; padding-bottom: 12px; color: var(--navy); border-bottom: 1px solid var(--line); font-size: 1.05rem; }
.link-list, .file-list { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin: 0; padding: 0; }
.link-item, .file-item { min-width: 0; display: flex; align-items: center; gap: 7px; }
.link-card, .file-card { min-width: 0; flex: 1; display: block; padding: 13px 14px; color: var(--text); background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; text-decoration: none; transition: background .15s, border-color .15s, transform .15s; }
.link-card:hover, .file-card:hover { background: #fff; border-color: var(--mint-strong); transform: translateY(-1px); }
.link-title, .file-name { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--navy); font-size: .9rem; font-weight: 700; }
.link-desc, .file-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; }
.btn-copy { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 10px; cursor: pointer; }
.btn-copy:hover { color: var(--blue); background: #eeedff; }
.copy-toast { position: fixed; left: 50%; bottom: 24px; z-index: 1000; transform: translateX(-50%); padding: 10px 16px; color: #fff; background: var(--navy); border-radius: 12px; box-shadow: var(--shadow); transition: opacity .25s; }
.copy-toast-hide { opacity: 0; }

/* Authentication */
.auth-section { width: min(440px, 100%); margin: 7vh auto; }
.auth-card { padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.auth-card .page-title { font-size: 1.65rem; }
.auth-form { display: grid; gap: 16px; margin-top: 22px; }
.label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .8rem; font-weight: 700; }

/* Chat */
.chat-only-page { width: min(1200px, 100%); margin: 0 auto; }
.ai-heading { display: grid; gap: 8px; margin-bottom: 18px; }
.ai-heading .empty { margin: 0; }
.chat-card { height: calc(100dvh - 225px); min-height: 600px; max-height: 980px; display: flex; flex-direction: column; overflow: hidden; background: #eef4f9; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 20px 50px rgba(23,47,89,.11); }
.chat-toolbar { min-height: 68px; flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.toolbar-avatar { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; color: var(--navy); background: var(--mint-strong); border-radius: 50%; font-size: .76rem; font-weight: 900; }
.toolbar-identity { display: flex; flex-direction: column; color: var(--navy); line-height: 1.2; }
.toolbar-identity strong { font-size: .92rem; }
.toolbar-identity span { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--muted); font-size: .71rem; }
.chat-status-dot { width: 7px; height: 7px; display: inline-block; background: #4ade80; border-radius: 50%; }
.chat-reference { min-height: 42px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 14px; color: var(--muted); background: #fff; border-bottom: 1px solid var(--line); font-size: .72rem; }
.chat-reference[hidden] { display: none; }
.chat-reference strong { color: var(--navy); }
.chat-reference-actions { display: flex; align-items: center; gap: 6px; }
.chat-reference button { min-height: 30px; padding: 0 10px; color: var(--blue); background: #eeedff; border: 0; border-radius: 8px; cursor: pointer; font-size: .7rem; font-weight: 800; }
.chat-reference #new-chat { color: #17663c; background: #e5f8ee; }
.chat-messages { min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 7px; padding: 18px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #b8c6d5 transparent; }
.chat-day { align-self: center; margin: 0 0 8px; padding: 4px 11px; color: var(--muted); background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 99px; font-size: .7rem; box-shadow: 0 3px 10px rgba(23,47,89,.05); }
.chat-row { width: 100%; display: flex; }
.chat-row.assistant { justify-content: flex-start; }
.chat-row.user { justify-content: flex-end; }
.chat-content { max-width: min(78%, 720px); }
.chat-message { display: flex; align-items: flex-end; gap: 8px; padding: 9px 12px 7px; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 15px 15px 15px 4px; box-shadow: 0 5px 16px rgba(23,47,89,.06); line-height: 1.45; }
.chat-row.user .chat-message { color: #fff; background: var(--navy-2); border-color: var(--navy-2); border-radius: 15px 15px 4px 15px; box-shadow: 0 7px 18px rgba(23,47,89,.14); }
.message-body { min-width: 0; overflow-wrap: anywhere; font-size: .9rem; }
.chat-row.assistant:not(.pending) .message-body { color: #0b1728; }
.message-time { flex: 0 0 auto; margin-bottom: -1px; color: #8b9aac; font-size: .61rem; white-space: nowrap; }
.chat-row.user .message-time { color: rgba(255,255,255,.66); }
.message-actions { min-height: 32px; display: flex; align-items: center; gap: 3px; padding: 3px 2px 0; }
.chat-row.user .message-actions { justify-content: flex-end; }
.message-copy-button { appearance: none; -webkit-appearance: none; width: 30px !important; min-width: 30px !important; max-width: 30px; height: 30px !important; min-height: 30px !important; max-height: 30px; flex: 0 0 30px; display: inline-flex !important; align-items: center; justify-content: center; margin: 0; padding: 0 !important; color: #617188; background: rgba(255,255,255,.82); border: 1px solid #d8e1eb; border-radius: 9px; cursor: pointer; opacity: 1; line-height: 1; box-shadow: 0 2px 7px rgba(23,47,89,.07); transition: color .16s, background .16s, border-color .16s, transform .16s, box-shadow .16s; }
.message-copy-button:hover, .message-copy-button:focus-visible { color: var(--blue); background: #fff; border-color: #aaa7ef; outline: none; transform: translateY(-1px); box-shadow: 0 4px 11px rgba(23,47,89,.13); }
.message-copy-button:active { transform: translateY(0); }
.message-copy-button.is-copied { color: #16845b; background: #e8f8f1; border-color: #9edabd; }
.message-copy-button svg { width: 17px !important; min-width: 17px; height: 17px !important; display: block; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.message-heading { margin-top: 2px; color: var(--navy); font-size: .75rem; font-weight: 900; letter-spacing: .08em; }
.chat-row.user .message-heading { color: #fff; }
.message-total { margin: 4px -3px; padding: 8px 10px; color: var(--blue); background: var(--mint); border-radius: 9px; font-size: 1.05rem; font-weight: 900; }
.message-note { color: #26364d; font-size: .78rem; }
.proposal-download { display: block; width: fit-content; margin-top: 14px; padding: 10px 14px; border: 1px solid #c8d5ff; border-radius: 10px; background: #f4f7ff; color: #2935b8; font-size: 13px; font-weight: 700; line-height: 1.2; text-decoration: none; }
.proposal-download:hover { border-color: #8fa2ff; background: #e9eeff; }
.share-calculation-button { display: block; width: fit-content; margin-top: 8px; padding: 9px 13px; color: #2935b8; background: transparent; border: 1px solid #c8d5ff; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.share-calculation-button:hover { background: #f4f7ff; }
.share-calculation-button:disabled { cursor: wait; opacity: .75; }
.chat-help-button { display: block; width: fit-content; margin-top: 12px; padding: 9px 13px; color: #2935b8; background: #f4f7ff; border: 1px solid #c8d5ff; border-radius: 10px; font: inherit; font-size: .78rem; font-weight: 800; cursor: pointer; }
.chat-help-button:hover, .chat-help-button:focus-visible { background: #e9eeff; border-color: #8fa2ff; outline: none; }
.chat-row.instruction .chat-content { max-width: min(88%, 780px); }
.shared-calculation-page { width: min(880px, calc(100% - 32px)); margin: 42px auto; }
.shared-calculation-card { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.shared-calculation-heading { padding: 28px 32px 20px; border-bottom: 1px solid var(--line); }
.shared-calculation-heading h1 { margin: 7px 0 10px; color: var(--navy); }
.shared-message { padding: 28px 32px; white-space: pre-wrap; line-height: 1.65; }
.shared-calculation-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--line); font-size: .84rem; }
@media (max-width: 600px) { .shared-calculation-page { width: 100%; margin: 0; } .shared-calculation-card { border-width: 0; border-radius: 0; } .shared-calculation-heading, .shared-message { padding: 22px 18px; } .shared-calculation-footer { align-items: stretch; flex-direction: column; padding: 18px; } }
.method-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.method-selector label { display: flex; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8faff; cursor: pointer; }
.method-selector span { display: grid; gap: 4px; }
.method-selector small { color: var(--muted); }
.destination-tariff-form { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; }
.destination-tariff-row .form-row { display: grid; flex: 1; grid-template-columns: 2fr repeat(4, 1fr) auto; }
.region-coefficient-form { display: grid; grid-template-columns: 1.2fr 2fr .7fr auto auto; }
.region-coefficient-row .form-row { display: grid; flex: 1; grid-template-columns: 1.2fr 2fr .7fr auto auto; }
@media (max-width: 760px) { .method-selector { grid-template-columns: 1fr; } .destination-tariff-form, .destination-tariff-row .form-row, .region-coefficient-form, .region-coefficient-row .form-row { grid-template-columns: 1fr; } }
.chat-message.pending .message-body { color: var(--muted); }
.chat-message.pending .message-body { display: flex; align-items: center; gap: 9px; }
.chat-message.pending .message-body::after { content: ""; width: 14px; height: 14px; flex: 0 0 14px; border: 2px solid #86dcb2; border-right-color: var(--blue); border-radius: 50%; animation: chat-wait-spin .7s linear infinite; }
@keyframes chat-wait-spin { to { transform: rotate(360deg); } }
.chat-input-row { flex: 0 0 auto; display: flex; align-items: flex-end; gap: 10px; margin: 0; padding: 12px 14px; background: #fff; border-top: 1px solid var(--line); }
.chat-input-row .textarea { min-height: 48px; max-height: 140px; flex: 1; padding: 12px 14px; color: var(--text); background: var(--surface-2); border-color: var(--line); resize: none; }
.chat-input-row .textarea::placeholder { color: #8a98aa; }
.chat-input-row .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(61,57,184,.09); }
.chat-input-row .btn { min-width: 112px; }
.send-icon { display: none; width: 21px; height: 21px; }

/* Desktop chat: the document scrolls and the composer stays in view. */
@media (min-width: 681px) {
  html:has(body.ai-chat-body) { scroll-padding-bottom: 118px; }
  .ai-chat-body .main { padding-top: 20px; padding-bottom: 125px; }
  .ai-chat-body .site-footer { display: none; }
  .ai-chat-body .header-inner { min-height: 66px; }
  .ai-chat-body .brand-logo { height: 54px; }
  .ai-chat-body .nav-ai { display: none; }
  .ai-chat-body .chat-only-page { width: 100%; max-width: none; }
  .ai-chat-body .chat-card { height: auto; min-height: calc(100dvh - 190px); max-height: none; overflow: visible; background: transparent !important; border: 0; border-radius: 0; box-shadow: none; }
  .ai-chat-body .chat-reference { width: min(920px, calc(100vw - 40px)); margin: 0 auto 8px; border: 1px solid var(--line); border-radius: 12px; }
  .ai-chat-body .chat-messages { width: min(920px, calc(100vw - 40px)); min-height: calc(100dvh - 250px); flex: 1 0 auto; margin: 0 auto; padding: 18px 10px 108px; overflow: visible; }
  .ai-chat-body .chat-row.greeting { margin: auto 0; }
  .ai-chat-body .chat-input-row { position: fixed; left: 50%; bottom: 14px; z-index: 100; width: min(920px, calc(100vw - 40px)); align-items: center; gap: 8px; padding: 8px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 35px rgba(23,47,89,.2); }
  .ai-chat-body .chat-input-row .textarea { min-height: 48px; padding: 12px 14px; border: 0; background: transparent; box-shadow: none; }
  .ai-chat-body .chat-input-row .chat-send-button { width: 48px; min-width: 48px; height: 48px; min-height: 48px; flex: 0 0 48px; padding: 0; border-radius: 14px; }
  .ai-chat-body .chat-send-button > span { display: none; }
  .ai-chat-body .chat-send-button .send-icon { display: block; }
  .ai-chat-body .message-copy-button { opacity: 0; }
  .ai-chat-body .chat-content:hover .message-copy-button,
  .ai-chat-body .message-copy-button:focus-visible,
  .ai-chat-body .message-copy-button.is-copied { opacity: 1; }
}

/* Admin shell */
.admin-page { display: block; background: var(--bg); }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: 248px; display: flex; flex-direction: column; padding: 22px 16px; background: #fff; border-right: 1px solid var(--line); }
.admin-brand { padding: 0 7px 20px; border-bottom: 1px solid var(--line); }
.admin-brand .brand-logo { width: 185px; height: auto; max-height: 104px; }
.admin-nav { display: grid; gap: 6px; margin-top: 22px; }
.admin-nav a { min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 0 12px; color: var(--muted); border-radius: 11px; text-decoration: none; font-size: .86rem; font-weight: 700; }
.admin-nav a span { width: 22px; color: var(--blue); text-align: center; }
.admin-nav a:hover, .admin-nav a:focus { color: var(--blue); background: #eeedff; }
.admin-logout { margin-top: auto; }
.admin-logout button { width: 100%; min-height: 42px; color: var(--muted); background: var(--surface-2); border: 0; border-radius: 11px; cursor: pointer; font-weight: 700; }
.admin-workspace { min-height: 100vh; display: flex; flex-direction: column; margin-left: 248px; }
.admin-topbar { position: sticky; top: 0; z-index: 40; min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 28px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.admin-topbar > div { display: flex; flex-direction: column; }
.admin-topbar-title { display: none !important; }
.admin-topbar strong { color: var(--navy); }
.admin-topbar span { color: var(--muted); font-size: .75rem; }
.admin-topbar > .admin-topbar-actions { flex-direction: row; align-items: center; gap: 7px; }
.admin-topbar-actions form { margin: 0; }
.admin-topbar-logout { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.admin-main { width: min(1180px, calc(100% - 48px)); flex: 1; margin: 0 auto; padding: 28px 0 42px; }
.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.admin-heading p { max-width: 520px; margin: 0; color: var(--muted); font-size: .86rem; }
.chats-heading-actions { display: flex; align-items: flex-end; flex-direction: column; gap: 9px; }
.chats-heading-actions form { margin: 0; }
.chats-clear-button { min-height: 38px; padding: 7px 12px; font-size: .75rem; white-space: nowrap; }
.chats-clear-button span { font-size: 1rem; line-height: 1; }
.chats-notice { margin: -8px 0 12px; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--blue); font-size: .68rem; font-weight: 900; letter-spacing: .12em; }
.admin-footer { padding: 18px 28px; color: var(--muted); background: #fff; border-top: 1px solid var(--line); font-size: .75rem; }
.admin-panel { padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); scroll-margin-top: 92px; }
.admin-panel + .admin-panel { margin-top: 18px; }
.admin-panel > .section-title:first-child { margin-top: 0; font-size: 1.18rem; }
.settings-form { display: grid; gap: 14px; }
.settings-form > label, .settings-grid > label, .cargo-form label, .tariff-row label { display: grid; gap: 6px; color: var(--muted); font-size: .77rem; font-weight: 700; }
.prompt-editor-panel { display: grid; gap: 18px; margin: 6px 0; padding: 20px; background: #f7f9fc; border: 1px solid #d9e2ee; border-radius: 16px; }
.prompt-editor-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 14px; border-bottom: 1px solid #d9e2ee; }
.prompt-editor-heading h3 { margin: 0; color: var(--navy); font-size: 1.08rem; }
.prompt-editor-heading .eyebrow { margin-bottom: 4px; }
.prompt-editor-heading p { max-width: 430px; margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.prompt-editor-panel > label { display: grid; gap: 6px; color: var(--navy); font-size: .78rem; font-weight: 800; }
.prompt-editor-panel label small { color: var(--muted); font-size: .69rem; font-weight: 500; }
.prompt-editor-panel .textarea { width: 100%; resize: vertical; color: #101d31; background: #fff; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: .82rem; font-weight: 500; line-height: 1.6; tab-size: 2; }
.prompt-topics-editor { min-height: 150px; }
.prompt-system-editor { min-height: 420px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.admin-checkbox { display: inline-flex !important; grid-auto-flow: column; grid-template-columns: auto 1fr; align-items: center; justify-content: start; gap: 8px !important; cursor: pointer; }
.admin-checkbox input { width: 17px; height: 17px; accent-color: var(--blue); }
.calculation-rules { padding: 12px 14px; color: var(--muted); background: var(--surface-2); border-radius: 12px; font-size: .84rem; }
.calculation-rules summary { color: var(--navy); cursor: pointer; font-weight: 800; }
.calculation-rules ol { margin: 10px 0 0; padding-left: 20px; }
.calculation-rules li + li { margin-top: 5px; }
.form-inline, .form-upload, .form-row { display: flex; align-items: center; gap: 9px; }
.form-inline, .form-upload { flex-wrap: wrap; margin-bottom: 14px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.form-inline .input, .form-upload .input, .form-row .input { min-width: 120px; flex: 1; }
.admin-list { list-style: none; margin: 0 0 16px; padding: 0 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.admin-item { display: flex; align-items: center; gap: 9px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.admin-item:last-child { border-bottom: 0; }
.admin-item .form-row { min-width: 0; flex: 1; }
.admin-item.link-hidden { opacity: .58; }
.form-delete { margin-left: auto; }
.file-name-link { color: var(--blue); text-decoration: none; font-size: .82rem; font-weight: 700; }
.tariff-list { display: grid; gap: 8px; }
.tariff-row { display: flex; align-items: flex-end; gap: 9px; padding: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.tariff-row .form-row { flex: 1; }
.section-anchor { position: relative; top: -90px; }
.chat-archive { min-height: 580px; display: grid; grid-template-columns: 320px minmax(0,1fr); overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.chat-archive-search { display: flex; gap: 8px; margin-bottom: 12px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 5px 16px rgba(24,40,72,.06); }
.chat-archive-search .input { min-width: 0; flex: 1; }
.chat-archive-search .btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.analytics-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.analytics-card { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 5px 16px rgba(24,40,72,.05); }
.analytics-card { color: inherit; text-decoration: none; cursor: pointer; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.analytics-card:hover { transform: translateY(-1px); border-color: #bbb9f3; }
.analytics-card.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(61,57,184,.1); }
.analytics-card i { width: 30px; height: 30px; display: grid; flex: 0 0 30px; place-items: center; color: var(--blue); background: #eeedff; border-radius: 9px; font-style: normal; font-size: .8rem; font-weight: 900; }
.analytics-card span { min-width: 0; display: flex; flex: 1; align-items: baseline; justify-content: space-between; gap: 6px; color: var(--muted); font-size: .68rem; white-space: nowrap; }
.analytics-card strong { color: var(--navy); font-size: 1.05rem; }
.analytics-new i { color: #a66a00; background: #fff1c7; }
.analytics-work i { color: #3554b4; background: #e7edff; }
.analytics-done i { color: #17663c; background: #dff6e8; }
.analytics-contact i { color: #087078; background: #dff7f6; }
.status-badge { width: max-content; padding: 3px 7px; border-radius: 999px; font-weight: 700; }
.status-new { color: #855600 !important; background: #fff1c7; }
.status-in_progress { color: #2448a0 !important; background: #e7edff; }
.status-completed { color: #17663c !important; background: #dff6e8; }
.chat-status-form { min-width: 0; display: grid; grid-template-columns: minmax(125px,1fr) auto; align-items: end; gap: 7px; padding: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.chat-status-form label { display: grid; gap: 2px; color: var(--muted); font-size: .62rem; }
.chat-status-form label > span { padding-left: 3px; }
.chat-status-form .input { min-width: 125px; min-height: 38px; padding: 6px 30px 6px 10px; border: 0; background-color: #fff; font-size: .78rem; }
.chat-status-form .btn { min-height: 38px; padding: 7px 12px; }
.chat-archive-list { padding: 8px; overflow-y: auto; border-right: 1px solid var(--line); }
.archive-date-group { margin-bottom: 5px; }
.archive-date-group > summary { position: sticky; top: -8px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 9px; color: var(--navy); background: #fff; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .72rem; font-weight: 850; list-style: none; }
.archive-date-group > summary::-webkit-details-marker { display: none; }
.archive-date-group > summary::before { content: "›"; color: var(--muted); font-size: 1rem; transform: rotate(0); transition: transform .15s ease; }
.archive-date-group[open] > summary::before { transform: rotate(90deg); }
.archive-date-group > summary span { flex: 1; }
.archive-date-group > summary small { min-width: 24px; padding: 2px 7px; color: var(--muted); background: var(--surface-2); border-radius: 99px; text-align: center; font-size: .63rem; }
.archive-date-items { display: grid; gap: 1px; padding: 3px 0 5px; }
.archive-item { display: grid; gap: 4px; padding: 10px; color: var(--text); border-radius: 11px; text-decoration: none; }
.archive-item:hover, .archive-item.active { background: #eeedff; }
.archive-item strong { color: var(--navy); font-size: .8rem; }
.archive-contact { display: grid; gap: 1px; margin: 3px 0; padding: 7px 9px; color: var(--navy); background: var(--mint); border-radius: 8px; }
.archive-contact b { font-size: .65rem; text-transform: uppercase; }
.archive-contact span { color: var(--navy); font-size: .72rem; white-space: normal; }
.archive-item span { overflow: hidden; color: var(--text); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.archive-item small { color: var(--muted); font-size: .66rem; }
.chat-archive-view { min-width: 0; display: flex; flex-direction: column; background: #eef4f9; }
.archive-placeholder { margin: auto; padding: 30px; color: var(--muted); text-align: center; }
.archive-title { display: flex; align-items: stretch; flex-direction: column; gap: 9px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.archive-title-main { min-width: 0; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.archive-ticket { min-width: 0; display: grid; gap: 1px; }
.archive-title span, .archive-title small { color: var(--muted); font-size: .68rem; }
.archive-title strong { color: var(--navy); font-size: .85rem; }
.archive-ticket strong { overflow-wrap: anywhere; }
.archive-title-contact { min-width: 190px; display: grid; padding: 6px 10px; background: var(--mint); border-radius: 9px; }
.archive-title-contact small { color: var(--navy); }
.archive-actions { width: 100%; display: grid; grid-template-columns: minmax(0,370px); align-items: end; justify-content: end; gap: 8px; }
.archive-actions.has-delete { grid-template-columns: minmax(0,370px) 40px; }
.archive-proposal { grid-column: 1 / -1; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 12px; color: var(--navy); background: var(--surface-2); border-color: var(--line); white-space: nowrap; }
.archive-proposal:hover { color: var(--purple); background: var(--lavender); border-color: #c9c5ff; }
.archive-proposal svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.archive-delete { width: 40px; min-width: 40px; height: 40px; min-height: 40px; display: grid; place-items: center; padding: 0; border-radius: 11px; }
.archive-delete svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.archive-back { display: none; color: var(--blue); text-decoration: none; font-size: .75rem; font-weight: 800; }
.chat-summary-panel { display: grid; gap: 9px; margin: 10px 12px 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.chat-summary-panel.is-stale { border-color: #e4bd63; }
.chat-summary-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat-summary-heading > div { display: grid; gap: 1px; }
.chat-summary-heading span { color: var(--blue); font-size: .62rem; font-weight: 900; letter-spacing: .08em; }
.chat-summary-heading strong { color: var(--navy); font-size: .82rem; }
.chat-summary-heading form { margin: 0; }
.chat-summary-form .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.chat-summary-form .btn.is-loading::before { content: ""; width: 12px; height: 12px; flex: 0 0 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: summary-spin .7s linear infinite; }
.chat-summary-form .btn:disabled { cursor: wait; opacity: .72; }
@keyframes summary-spin { to { transform: rotate(360deg); } }
.chat-summary-text { max-height: 310px; margin: 0; padding: 11px; overflow: auto; color: #142239; background: var(--surface-2); border-radius: 9px; font-family: var(--font); font-size: .75rem; line-height: 1.55; white-space: pre-wrap; }
.chat-summary-panel > small { color: var(--muted); font-size: .63rem; text-align: right; }
.summary-stale-note { margin: 0; padding: 7px 9px; color: #7b5200; background: #fff5d9; border-radius: 8px; font-size: .7rem; }
.archive-messages { display: flex; flex-direction: column; gap: 9px; padding: 18px; overflow-y: auto; }
.archive-message { max-width: 78%; align-self: flex-start; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; white-space: pre-wrap; }
.archive-message.user { align-self: flex-end; color: #fff; background: var(--navy-2); border-color: var(--navy-2); border-radius: 14px 14px 4px 14px; }
.archive-message > span { display: block; margin-bottom: 5px; color: var(--blue); font-size: .66rem; font-weight: 800; }
.archive-message.user > span, .archive-message.user small { color: rgba(255,255,255,.7); }
.archive-message > div { font-size: .82rem; }
.archive-message small { display: block; margin-top: 6px; color: var(--muted); font-size: .62rem; text-align: right; }

.chat-access-logout { margin-left: auto; }
.chat-access-logout button { min-height: 34px; padding: 0 11px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-size: .7rem; font-weight: 700; }
@media (max-width: 560px) { .chat-archive-search { flex-wrap: wrap; } .chat-archive-search .input { flex-basis: 100%; } .chat-archive-search .btn { flex: 1; } }
@media (max-width: 760px) { .analytics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
.access-page { min-height: min(650px, calc(100dvh - 190px)); display: grid; place-items: center; }
.access-card { width: min(470px, 100%); padding: 36px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.access-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 18px; color: var(--blue); background: var(--mint); border-radius: 18px; font-size: 1.35rem; }
.access-card .page-title { margin-top: 6px; font-size: 1.75rem; }
.access-card > p { margin: 12px auto 20px; color: var(--muted); }
.access-form { display: grid; gap: 14px; margin-top: 18px; text-align: left; }
.access-form .btn { width: 100%; }
.access-settings { display: grid; gap: 10px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; }
.access-settings > label:not(.admin-checkbox) { display: grid; gap: 6px; color: var(--muted); font-size: .77rem; font-weight: 700; }
.access-settings small { color: var(--muted); font-size: .72rem; }
.telegram-settings-panel { max-width: 760px; }
.telegram-settings-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.telegram-settings-actions .btn { flex: 1 1 220px; }

/* Tablet */
@media (max-width: 980px) {
  .container { width: min(100% - 28px, 900px); }
  .link-list, .file-list { grid-template-columns: 1fr; }
  .admin-sidebar { position: sticky; inset: 0 0 auto; width: 100%; height: auto; display: block; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-brand { display: none; }
  .admin-nav { display: flex; gap: 5px; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav a { flex: 0 0 auto; white-space: nowrap; }
  .admin-logout { display: none; }
  .admin-workspace { margin-left: 0; }
  .admin-topbar { top: 65px; }
  .admin-main { width: min(100% - 28px, 900px); }
  .chat-only-page { max-width: 900px; }
  .header-page-title { max-width: calc(100% - 320px); }
  .header-page-title span { display: none; }
  .chat-archive { grid-template-columns: 290px minmax(0,1fr); }
  .analytics-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .archive-title { align-items: stretch; flex-direction: column; }
  .archive-title-main { justify-content: space-between; }
  .home-hero { grid-template-columns: 1fr; }
  .hero-copy, .hero-card { min-height: 260px; }
}

/* Mobile */
@media (max-width: 680px) {
  html { scroll-behavior: auto; }
  .container { width: calc(100% - 20px); }
  .header-inner { min-height: 62px; }
  .brand-logo { height: 50px; }
  .header-page-title { max-width: calc(100% - 230px); gap: 0; }
  .header-page-title strong { font-size: .76rem; }
  .site-nav { gap: 3px; }
  .site-nav a { min-height: 39px; padding: 0 9px; font-size: .77rem; }
  .site-nav a:first-child { display: none; }
  .site-nav .nav-ai { font-size: 0; }
  .site-nav .nav-ai::after { content: "AI"; font-size: .78rem; }
  .main { padding-top: 18px; padding-bottom: 24px; }
  .page-title { font-size: 1.42rem; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
  .block { padding: 16px; border-radius: 15px; }
  .home-hero { gap: 12px; margin-bottom: 24px; }
  .hero-copy, .hero-card { min-height: auto; padding: 22px 18px; border-radius: 18px; }
  .hero-copy h1 { font-size: 2.15rem; }
  .hero-copy p { margin-top: 14px; font-size: .88rem; }
  .hero-actions { width: 100%; margin-top: 20px; }
  .hero-actions .btn { flex: 1; }
  .hero-card { min-height: 230px; }
  .resource-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .link-card, .file-card { padding: 11px 12px; }
  .btn-copy { width: 44px; height: 44px; }
  .input, textarea, select { font-size: 16px; }
  .btn { min-height: 44px; }
  .auth-section { margin: 3vh auto; }
  .auth-card { padding: 20px; border-radius: 18px; }
  .ai-heading { margin-bottom: 12px; }
  .ai-heading .empty { font-size: .82rem; }
  .chat-card { height: calc(100dvh - 165px); min-height: 430px; max-height: none; border-radius: 16px; }
  .chat-toolbar { min-height: 58px; padding: 8px 11px; }
  .chat-reference { gap: 6px; padding: 6px 8px; }
  .chat-reference-actions { gap: 3px; }
  .chat-reference button { padding: 0 7px; font-size: .62rem; }
  .toolbar-avatar { width: 38px; height: 38px; flex-basis: 38px; }
  .chat-messages { padding: 12px 9px; }
  .chat-content { max-width: 89%; }
  .message-body { font-size: .86rem; }
  .chat-input-row { align-items: center; gap: 8px; padding: 8px 10px; }
  .chat-input-row .textarea { min-height: 46px; max-height: 105px; padding: 11px 12px; line-height: 1.4; overflow-y: auto; }
  .chat-input-row .chat-send-button { width: 46px; min-width: 46px; height: 46px; min-height: 46px; display: grid; flex: 0 0 46px; place-items: center; padding: 0; border-radius: 14px; box-shadow: 0 5px 14px rgba(61,57,184,.22); }
  .chat-send-button > span { display: none; }
  .chat-send-button .send-icon { display: block; }
  .admin-sidebar { padding: 8px 10px; }
  .admin-nav a { min-height: 40px; padding: 0 10px; font-size: .76rem; }
  .admin-nav a span { width: auto; }
  .admin-topbar { top: 57px; min-height: 62px; padding: 8px 12px; }
  .admin-topbar span { display: none; }
  .admin-topbar .btn { min-height: 38px; padding: 7px 10px; font-size: .74rem; }
  .admin-topbar-actions { gap: 5px !important; }
  .admin-topbar-logout { width: auto; padding: 7px 10px !important; }
  .admin-main { width: calc(100% - 20px); padding-top: 16px; }
  .admin-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .chats-heading-actions { width: 100%; align-items: stretch; }
  .chats-clear-button { width: 100%; }
  .admin-panel { padding: 15px; border-radius: 15px; }
  .prompt-editor-panel { gap: 15px; padding: 14px; }
  .prompt-editor-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .prompt-system-editor { min-height: 340px; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-inline, .form-upload { align-items: stretch; flex-direction: column; padding: 11px; }
  .form-inline .input, .form-upload .input { min-width: 100%; }
  .admin-item { align-items: stretch; flex-direction: column; }
  .admin-item .form-row { width: 100%; display: grid; grid-template-columns: 1fr; }
  .admin-item .form-delete, .admin-item .form-delete .btn { width: 100%; margin: 0; }
  .tariff-row { align-items: stretch; flex-direction: column; }
  .tariff-row .form-row { display: grid; grid-template-columns: 1fr 1fr; }
  .tariff-row .form-row .btn { grid-column: 1 / -1; }
  .tariff-row > form:last-child .btn { width: 100%; }
  .copy-toast { width: calc(100% - 24px); bottom: max(12px, env(safe-area-inset-bottom)); text-align: center; }
  .chat-archive { min-height: 520px; display: block; }
  .chat-archive-list { max-height: none; border-right: 0; border-bottom: 0; }
  .chat-archive-view { min-height: 520px; display: none; }
  .chat-archive.has-selection .chat-archive-list { display: none; }
  .chat-archive.has-selection .chat-archive-view { display: flex; }
  .chats-section.has-chat-selection .admin-heading,
  .chats-section.has-chat-selection .analytics-grid,
  .chats-section.has-chat-selection .chat-archive-search { display: none; }
  .archive-back { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; }
  .archive-back span { display: inline !important; color: inherit; font-size: inherit; }
  .chat-summary-panel { margin: 8px 8px 0; padding: 10px; }
  .chat-summary-heading { align-items: stretch; flex-direction: column; }
  .chat-summary-heading .btn { width: 100%; }
  .chat-summary-text { max-height: none; }
  .archive-message { max-width: 90%; }
  .analytics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .analytics-card { padding: 9px; }
  .analytics-card i { width: 27px; height: 27px; flex-basis: 27px; }
  .archive-title-main { align-items: stretch; flex-direction: column; gap: 7px; }
  .archive-ticket, .archive-title-contact { min-width: 0; }
  .archive-actions, .archive-actions.has-delete { grid-template-columns: minmax(0,1fr) 40px; align-items: end; }
  .archive-proposal { grid-column: 1 / -1; width: 100%; }
  .archive-actions:not(.has-delete) .chat-status-form { grid-column: 1 / -1; }
  .chat-status-form { min-width: 0; }
  .chat-status-form label { min-width: 0; }
  .chat-status-form .input { width: 100%; min-width: 0; }
  .access-page { min-height: calc(100dvh - 150px); }
  .access-card { padding: 24px 18px; border-radius: 18px; }
  body.ai-chat-body { height: 100dvh; min-height: 0; overflow: hidden; }
  .ai-chat-body .site-header { position: relative; flex: 0 0 auto; }
  .ai-chat-body .main { width: 100%; min-height: 0; flex: 1; padding: 0; overflow: hidden; }
  .ai-chat-body .chat-only-page { height: 100%; display: flex; flex-direction: column; }
  .ai-chat-body .ai-heading { flex: 0 0 auto; margin: 0; padding: 10px 12px 8px; background: #fff; border-bottom: 1px solid var(--line); }
  .ai-chat-body .ai-heading .page-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ai-chat-body .ai-heading .empty { display: none; }
  .ai-chat-body .chat-card { height: auto; min-height: 0; max-height: none; flex: 1; border-right: 0; border-left: 0; border-radius: 0; box-shadow: none; }
  .ai-chat-body .chat-input-row { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .ai-chat-body .site-footer { display: none; }
}

@media (max-width: 420px) {
  .chat-content { max-width: 93%; }
  .tariff-row .form-row { grid-template-columns: 1fr; }
  .tariff-row .form-row .btn { grid-column: auto; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .chat-card { height: calc(100dvh - 95px); min-height: 320px; }
  .ai-heading { display: none; }
}

/* Automatic color theme */
html[data-theme="dark"] {
  color-scheme: dark;
  --navy: #dce8ff;
  --navy-2: #294a7a;
  --blue: #9692ff;
  --blue-hover: #aaa7ff;
  --mint: #173e35;
  --mint-strong: #62d7a0;
  --bg: #0f1724;
  --surface: #172233;
  --surface-2: #1d2a3d;
  --line: #314159;
  --text: #edf3fb;
  --muted: #a9b7ca;
  --danger: #ff7f8b;
  --shadow: 0 12px 34px rgba(0,0,0,.28);
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .admin-topbar { background: rgba(23,34,51,.94); border-color: var(--line); }
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .admin-footer,
html[data-theme="dark"] .hero-copy,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .chat-toolbar,
html[data-theme="dark"] .chat-reference,
html[data-theme="dark"] .shared-calculation-card,
html[data-theme="dark"] .admin-sidebar,
html[data-theme="dark"] .admin-panel,
html[data-theme="dark"] .form-inline,
html[data-theme="dark"] .form-upload,
html[data-theme="dark"] .admin-list,
html[data-theme="dark"] .chat-archive,
html[data-theme="dark"] .chat-archive-search,
html[data-theme="dark"] .analytics-card,
html[data-theme="dark"] .archive-title,
html[data-theme="dark"] .chat-summary-panel,
html[data-theme="dark"] .archive-message,
html[data-theme="dark"] .access-card { background: var(--surface); border-color: var(--line); }
html[data-theme="dark"] .hero-card { background: #182f56; }
html[data-theme="dark"] .hero-secondary,
html[data-theme="dark"] .chat-card,
html[data-theme="dark"] .chat-archive-view,
html[data-theme="dark"] .access-settings,
html[data-theme="dark"] .calculation-rules,
html[data-theme="dark"] .tariff-row,
html[data-theme="dark"] .method-selector label,
html[data-theme="dark"] .prompt-editor-panel { background: var(--surface-2); border-color: var(--line); }
html[data-theme="dark"] .input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] option,
html[data-theme="dark"] .prompt-editor-panel .textarea,
html[data-theme="dark"] .chat-status-form .input { color: var(--text); background: #111c2b; border-color: var(--line); }
html[data-theme="dark"] .archive-date-group > summary { background: var(--surface); }
html[data-theme="dark"] .chat-input-row { background: var(--surface); border-color: var(--line); }
html[data-theme="dark"] .ai-chat-body .chat-input-row { box-shadow: 0 -12px 26px rgba(0,0,0,.25); }
@media (min-width: 681px) {
  html[data-theme="dark"] .ai-chat-body .chat-input-row .textarea { background: transparent; }
}
html[data-theme="dark"] .chat-message { color: var(--text); background: var(--surface); border-color: var(--line); box-shadow: 0 5px 18px rgba(0,0,0,.2); }
html[data-theme="dark"] .chat-row.assistant:not(.pending) .message-body { color: #f2f6fc; }
html[data-theme="dark"] .chat-row.assistant .message-note { color: #b8c5d6; }
html[data-theme="dark"] .chat-row.assistant .message-time { color: #aebdd0; }
html[data-theme="dark"] .message-copy-button { color: #b6c4d6; background: #27364a; border-color: #41516a; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
html[data-theme="dark"] .message-copy-button:hover,
html[data-theme="dark"] .message-copy-button:focus-visible { color: #fff; background: #34465f; border-color: #7772df; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
html[data-theme="dark"] .message-copy-button.is-copied { color: #79e0b8; background: #1e493c; border-color: #3b8068; }
html[data-theme="dark"] .chat-row.assistant .message-heading { color: #dce8ff; }
html[data-theme="dark"] .chat-row.user .chat-message,
html[data-theme="dark"] .archive-message.user { color: #fff; background: var(--navy-2); border-color: #365b91; }
html[data-theme="dark"] .chat-day { color: var(--muted); background: rgba(23,34,51,.94); border-color: var(--line); }
html[data-theme="dark"] .site-nav .nav-ai,
html[data-theme="dark"] .site-nav a:hover,
html[data-theme="dark"] .admin-nav a:hover,
html[data-theme="dark"] .admin-nav a:focus,
html[data-theme="dark"] .archive-item:hover,
html[data-theme="dark"] .archive-item.active,
html[data-theme="dark"] .btn-copy:hover { background: #292650; }
html[data-theme="dark"] .site-nav .nav-login { color: #fff; background: #294a7a; }
html[data-theme="dark"] .site-nav .nav-login:hover { background: #365b91; }
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .chat-send-button { color: #fff; background: #5c56ca; box-shadow: 0 7px 18px rgba(48,42,145,.38); }
html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .chat-send-button:hover { background: #706ae0; }
html[data-theme="dark"] .chat-reference button { color: #dedcff; background: #343066; }
html[data-theme="dark"] .chat-reference #new-chat { color: #91e4ba; background: #21483b; }
html[data-theme="dark"] .chat-help-button { color: #dedcff; background: #292653; border-color: #5550a0; }
html[data-theme="dark"] .chat-help-button:hover, html[data-theme="dark"] .chat-help-button:focus-visible { background: #343066; border-color: #7770d5; }
html[data-theme="dark"] .link-card:hover,
html[data-theme="dark"] .file-card:hover { background: #223149; }
html[data-theme="dark"] .proposal-download,
html[data-theme="dark"] .share-calculation-button { color: #c6d2ff; background: #1d2942; border-color: #475b91; }
html[data-theme="dark"] .proposal-download:hover,
html[data-theme="dark"] .share-calculation-button:hover { background: #263657; }
html[data-theme="dark"] .error-msg { color: #ffadb5; background: #3a2028; border-color: #743642; }
html[data-theme="dark"] .success-msg { color: #91e6b7; background: #173629; border-color: #2d6747; }
html[data-theme="dark"] .btn-danger { color: #ff9aa4; background: #3a2028; border-color: #743642; }
html[data-theme="dark"] .status-new { color: #ffd783 !important; background: #493a19; }
html[data-theme="dark"] .status-in_progress { color: #aec3ff !important; background: #23345e; }
html[data-theme="dark"] .status-completed { color: #94e6b8 !important; background: #193d2b; }
html[data-theme="dark"] .analytics-new i { color: #ffd783; background: #493a19; }
html[data-theme="dark"] .analytics-work i { color: #aec3ff; background: #23345e; }
html[data-theme="dark"] .analytics-done i { color: #94e6b8; background: #193d2b; }
html[data-theme="dark"] .analytics-contact i { color: #80dfe5; background: #173b42; }
html[data-theme="dark"] .chat-summary-text { color: var(--text); background: #111c2b; }
html[data-theme="dark"] .summary-stale-note { color: #f3cd7a; background: #3f341b; }
html[data-theme="dark"] .ai-chat-body .ai-heading { background: var(--surface); }

/* Desktop admin workspace — aligned with the client application shell. */
@media (min-width: 981px) {
  .admin-page { background: var(--bg); }
  .admin-sidebar { width: 220px; padding: 14px 12px; color: #fff; background: #172f59; border-right: 0; box-shadow: 12px 0 36px rgba(12,31,61,.12); }
  .admin-brand { min-height: 78px; display: flex; align-items: center; justify-content: center; padding: 7px 10px 14px; border-bottom-color: rgba(255,255,255,.12); }
  .admin-brand .brand-logo { width: 142px; max-height: 66px; padding: 0; background: transparent; border-radius: 0; object-fit: contain; }
  .admin-nav { gap: 4px; margin-top: 15px; }
  .admin-nav a { min-height: 42px; gap: 10px; padding: 0 11px; color: #c6d2e2; border: 1px solid transparent; border-radius: 10px; font-size: .8rem; }
  .admin-nav a span { width: 25px; height: 25px; display: grid; place-items: center; color: #a8b9d2; background: rgba(255,255,255,.07); border-radius: 8px; }
  .admin-nav a:hover, .admin-nav a:focus { color: #fff; background: rgba(255,255,255,.08); }
  .admin-nav a.active { color: #fff; background: rgba(130,230,181,.14); border-color: rgba(130,230,181,.24); }
  .admin-nav a.active span { color: #172f59; background: #82e6b5; }
  .admin-logout button { min-height: 40px; color: #c6d2e2; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); }
  .admin-logout button:hover { color: #fff; background: rgba(255,255,255,.12); }
  .admin-workspace { margin-left: 220px; }
  .admin-topbar { min-height: 66px; padding: 8px 24px; background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom-color: var(--line); box-shadow: 0 4px 18px rgba(23,47,89,.035); }
  .admin-topbar > div:first-child { line-height: 1.25; }
  .admin-topbar > div:first-child strong { font-size: .82rem; }
  .admin-topbar > div:first-child span { font-size: .68rem; }
  .admin-topbar-title { position: absolute; left: 50%; display: flex !important; align-items: center; flex-direction: row !important; transform: translateX(-50%); white-space: nowrap; }
  .admin-topbar-title strong { color: var(--navy); font-size: .92rem; }
  .admin-topbar-actions .btn { min-height: 38px; padding: 7px 12px; border-radius: 10px; font-size: .76rem; }
  .admin-main { width: min(1320px, calc(100% - 40px)); padding: 22px 0 34px; }
  .admin-footer { padding: 13px 24px; background: var(--surface); font-size: .68rem; }
  .admin-heading { align-items: center; gap: 20px; margin-bottom: 15px; }
  .admin-heading .page-title { font-size: 1.65rem; }
  .admin-heading .eyebrow { margin-bottom: 4px; font-size: .62rem; }
  .admin-heading p { max-width: 600px; font-size: .78rem; }
  .admin-panel { padding: 18px 20px; border-radius: 16px; box-shadow: 0 8px 24px rgba(23,47,89,.055); }
  .admin-panel + .admin-panel { margin-top: 14px; }
  .admin-panel > .section-title:first-child { font-size: 1.05rem; }
  .settings-form { gap: 11px; }
  .input { min-height: 40px; padding: 8px 11px; border-radius: 10px; }
  .btn { min-height: 39px; padding: 8px 13px; border-radius: 10px; font-size: .8rem; }
  .form-inline, .form-upload { margin-bottom: 11px; padding: 11px; border-radius: 12px; }
  .admin-list { border-radius: 12px; }
  .admin-item { padding: 9px 0; }
  .tariff-list { gap: 6px; }
  .tariff-row { padding: 9px; border-radius: 10px; }
  .distance-tariff-row,
  .destination-tariff-row,
  .region-coefficient-row { display: grid; align-items: end; gap: 9px; }
  .distance-tariff-row { grid-template-columns: minmax(150px,180px) minmax(150px,180px) 92px minmax(20px,1fr) 92px; }
  .destination-tariff-row { grid-template-columns: minmax(250px,2fr) repeat(4,minmax(125px,1fr)) 92px 92px; }
  .region-coefficient-row { grid-template-columns: minmax(180px,1.2fr) minmax(280px,2fr) minmax(125px,.7fr) auto 92px 92px; }
  .distance-tariff-row > .form-row,
  .destination-tariff-row > .form-row,
  .region-coefficient-row > .form-row { display: contents; }
  .distance-tariff-row > form:last-child { grid-column: 5; }
  .destination-tariff-row > form:last-child { grid-column: 7; }
  .region-coefficient-row > form:last-child { grid-column: 6; }
  .distance-tariff-row > form:last-child,
  .destination-tariff-row > form:last-child,
  .region-coefficient-row > form:last-child { margin: 0; }
  .distance-tariff-row > form:last-child .btn,
  .destination-tariff-row > form:last-child .btn,
  .region-coefficient-row > form:last-child .btn,
  .distance-tariff-row > .form-row > .btn,
  .destination-tariff-row > .form-row > .btn,
  .region-coefficient-row > .form-row > .btn { width: 92px; }
  .distance-tariff-row label,
  .destination-tariff-row label,
  .region-coefficient-row label { min-width: 0; }
  .prompt-editor-panel { gap: 14px; padding: 16px; border-radius: 13px; }
  .prompt-editor-heading { padding-bottom: 11px; }
  .analytics-grid { gap: 7px; margin-bottom: 10px; }
  .analytics-card { min-height: 55px; padding: 8px 10px; border-radius: 11px; box-shadow: 0 4px 13px rgba(23,47,89,.045); }
  .analytics-card i { width: 28px; height: 28px; flex-basis: 28px; border-radius: 8px; }
  .chat-archive-search { margin-bottom: 10px; padding: 6px; border-radius: 12px; box-shadow: 0 4px 13px rgba(23,47,89,.045); }
  .chat-archive-search .input { border: 0; background: var(--surface-2); }
  .admin-workspace:has(.chats-section) { height: 100dvh; min-height: 0; overflow: hidden; }
  .admin-workspace:has(.chats-section) .admin-main { min-height: 0; display: flex; flex-direction: column; padding-bottom: 18px; }
  .admin-workspace:has(.chats-section) .admin-footer { display: none; }
  .chats-section { min-height: 0; display: flex; flex: 1 1 auto; flex-direction: column; }
  .chats-section > .admin-heading,
  .chats-section > .chats-notice,
  .chats-section > .analytics-grid,
  .chats-section > .chat-archive-search { flex: 0 0 auto; }
  .chat-archive { height: auto; min-height: 0; flex: 1 1 auto; grid-template-columns: 330px minmax(0,1fr); border-radius: 16px; box-shadow: 0 12px 34px rgba(23,47,89,.075); }
  .chat-archive-list { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .archive-date-group > summary { top: -8px; padding: 7px 9px; }
  .archive-item { padding: 9px 10px; }
  .chat-archive-view { height: 100%; min-height: 0; overflow: hidden; }
  .archive-title { flex: 0 0 auto; gap: 7px; padding: 9px 12px; }
  .archive-title-main { min-height: 40px; }
  .archive-actions { grid-template-columns: minmax(0,390px); }
  .archive-actions.has-delete { grid-template-columns: minmax(0,390px) 40px; }
  .chat-summary-panel { flex: 0 0 auto; margin: 8px 12px 0; padding: 10px 12px; }
  .archive-messages { min-height: 0; flex: 1 1 auto; gap: 8px; padding: 16px 22px 24px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .archive-message { max-width: min(76%, 760px); box-shadow: 0 4px 13px rgba(23,47,89,.045); }
}
