:root {
  --bg: #f1f4f0;
  --surface: #fbfcf9;
  --fg: #17231e;
  --muted: #596961;
  --border: #d2dbd4;
  --accent: #2451c6;
  --accent-on: #f9fbff;
  --font-display: "Golos Text", sans-serif;
  --font-body: "Golos Text", sans-serif;
  --radius: 8px;
  --space-section: 32px;
  --sidebar: #17231e;
  --sidebar-muted: #aebbb4;
  --success: #247148;
  --warning: #9a5b12;
  --danger: #a63131;
  --info-bg: #e8eefc;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.safe-text { min-width: 0; overflow-wrap: anywhere; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); background: var(--surface); }
.auth-context { min-width: 0; padding: 48px clamp(32px, 6vw, 88px); background: var(--sidebar); color: #eef4ef; display: grid; grid-template-rows: auto 1fr auto; }
.auth-brand { display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; }
.auth-brand span { font-size: 24px; font-weight: 700; letter-spacing: -.04em; }
.auth-brand small { color: #9fac9f; font-size: 12px; letter-spacing: .16em; }
.auth-copy { align-self: center; max-width: 680px; }
.section-label { margin: 0 0 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.auth-context .section-label { color: #9eada5; }
.auth-copy h1 { margin: 0; max-width: 760px; font-family: var(--font-display); font-size: clamp(42px, 6vw, 78px); line-height: .98; letter-spacing: -.055em; text-wrap: balance; }
.auth-copy > p:last-child { margin: 24px 0 0; max-width: 580px; color: #bdc8c2; font-size: 17px; }
.source-chain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; border-top: 1px solid #34443d; }
.source-chain div { min-width: 0; padding: 18px 16px 0 0; }
.source-chain strong, .source-chain span { display: block; }
.source-chain strong { font-size: 13px; letter-spacing: .08em; }
.source-chain span { margin-top: 2px; color: #98a69f; font-size: 12px; overflow-wrap: anywhere; }
.source-chain b { padding-top: 18px; color: #dfe8e2; font-size: 13px; white-space: nowrap; }
.auth-panel { display: grid; place-items: center; padding: 32px; }
.auth-form { width: min(100%, 420px); }
.auth-form h2 { margin: 0; font-size: 30px; letter-spacing: -.035em; }
.form-intro { margin: 8px 0 26px; color: var(--muted); }
label { display: grid; gap: 7px; color: var(--fg); font-size: 14px; font-weight: 500; }
.auth-form label + label { margin-top: 18px; }
input, select { width: 100%; height: 44px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg); padding: 0 12px; outline: none; transition: border-color 160ms ease, box-shadow 160ms ease; }
select[multiple] { height: auto; min-height: 112px; padding: 8px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36,81,198,.13); }
input:disabled, select:disabled { background: #e8ece8; color: var(--muted); cursor: not-allowed; }
.password-field { position: relative; }
.password-field input { padding-right: 92px; }
.password-toggle { position: absolute; inset: 0 4px 0 auto; min-width: 82px; border: 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 600; }
.form-error { min-height: 22px; margin: 10px 0; color: var(--danger); font-size: 14px; }

.btn { min-height: 44px; border: 1px solid transparent; border-radius: var(--radius); padding: 0 16px; background: transparent; color: var(--fg); font-weight: 600; transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease, opacity 160ms ease; }
.btn.primary { background: var(--accent); color: var(--accent-on); }
.btn.secondary { border-color: var(--border); background: var(--surface); }
.btn.ghost { color: var(--muted); }
.btn.danger { border-color: #e4c0c0; color: var(--danger); background: #fff8f7; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(36,81,198,.35); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px 16px; background: var(--sidebar); color: #eef4ef; display: flex; flex-direction: column; z-index: 20; }
.logo { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.logo > span { display: grid; place-items: center; width: 42px; height: 32px; border: 1px solid #415149; border-radius: 6px; font-weight: 700; letter-spacing: -.03em; }
.logo strong, .logo small { display: block; }
.logo strong { font-size: 14px; }
.logo small { color: var(--sidebar-muted); font-size: 12px; }
.sidebar nav { display: grid; gap: 4px; margin-top: 26px; }
.sidebar nav button { height: 44px; border: 0; border-radius: 7px; padding: 0 12px; background: transparent; color: var(--sidebar-muted); display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 8px; text-align: left; transition: background-color 160ms ease, color 160ms ease; }
.sidebar nav button b { font-size: 11px; font-variant-numeric: tabular-nums; color: #77867f; }
.sidebar nav button.active { background: var(--accent); color: var(--accent-on); }
.sidebar nav button.active b { color: #cfdafd; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #34443d; padding-top: 14px; }
.profile-button { width: 100%; min-height: 48px; border: 0; background: transparent; color: #eef4ef; display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 10px; text-align: left; }
.profile-button > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #2c3c34; font-weight: 700; }
.profile-button strong, .profile-button small { display: block; overflow-wrap: anywhere; }
.profile-button strong { font-size: 13px; }
.profile-button small { color: var(--sidebar-muted); font-size: 12px; }
.logout-button { width: 100%; min-height: 40px; border: 0; background: transparent; color: #96a59d; text-align: left; padding-left: 46px; font-size: 13px; }

.workspace { min-width: 0; }
.topbar { height: 88px; padding: 18px 32px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: rgba(241,244,240,.92); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
.topbar p { margin: 0 0 2px; color: var(--muted); font-size: 12px; }
.topbar h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.035em; }
.notification-button { min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg); padding: 0 8px 0 14px; display: flex; align-items: center; gap: 10px; }
.notification-button b { min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: #e5eae6; font-size: 12px; font-variant-numeric: tabular-nums; }
.content { padding: 28px 32px 48px; min-width: 0; }
.content:focus { outline: none; }

.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-actions p { margin: 0; color: var(--muted); }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.coverage-rail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.coverage-item { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--border); }
.coverage-item:last-child { border-right: 0; }
.coverage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coverage-head strong { font-size: 16px; }
.coverage-code { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.coverage-state { display: inline-flex; align-items: center; min-height: 24px; border-radius: 5px; padding: 0 8px; background: #e5eae6; color: var(--muted); font-size: 12px; font-weight: 600; }
.coverage-state.success { background: #e1f0e7; color: var(--success); }
.coverage-state.warning { background: #f7ead7; color: var(--warning); }
.coverage-state.error { background: #f6e2e0; color: var(--danger); }
.coverage-item p { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.coverage-track { height: 3px; margin-top: 12px; background: #e4e9e5; }
.coverage-track span { display: block; width: 100%; height: 100%; background: var(--fg); }
.coverage-item.attention .coverage-track span { width: 62%; background: var(--warning); }
.coverage-item.empty .coverage-track span { width: 0; }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 18px; border-block: 1px solid var(--border); }
.metric { min-width: 0; padding: 18px 18px 18px 0; }
.metric + .metric { border-left: 1px solid var(--border); padding-left: 18px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 3px; font-size: 27px; line-height: 1.2; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-head h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: #edf1ed; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 160ms ease; }
td.wrap { white-space: normal; min-width: 180px; max-width: 300px; }
.mono { font-family: "Golos Text", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.kiz-cell { display: flex; align-items: center; gap: 8px; }
.copy-button { min-width: 56px; min-height: 32px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--accent); font-size: 12px; font-weight: 600; }
.status { display: inline-flex; min-height: 24px; align-items: center; border-radius: 5px; padding: 0 8px; background: #e5eae6; color: var(--muted); font-size: 12px; font-weight: 600; }
.status.sold, .status.success { background: #e1f0e7; color: var(--success); }
.status.returned, .status.partial, .status.warning { background: #f7ead7; color: var(--warning); }
.status.failed, .status.error, .status.cancelled { background: #f6e2e0; color: var(--danger); }
.status.running, .status.queued, .status.info { background: var(--info-bg); color: var(--accent); }
.empty-state { padding: 38px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--fg); font-size: 16px; }

.filters { display: grid; grid-template-columns: minmax(150px, 180px) minmax(150px, 180px) minmax(180px, 1fr) minmax(180px, 1fr) minmax(220px, 1.4fr) auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.filters label { min-width: 0; }
.filters .btn { white-space: nowrap; }
.filters-secondary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: -2px 0 16px; }
.check-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.check-label input { width: 18px; height: 18px; margin: 0; }
.result-meta { color: var(--muted); font-size: 13px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.pagination span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.form-panel { max-width: 900px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .short { max-width: 240px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.form-note { margin: 0; padding: 12px 14px; background: #eef2ee; color: var(--muted); border-radius: 6px; font-size: 13px; }

.account-list { border-top: 1px solid var(--border); }
.account-row { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(180px, .8fr) minmax(170px, .7fr) auto; gap: 20px; align-items: center; padding: 17px 0; border-bottom: 1px solid var(--border); }
.account-row h3 { margin: 0; font-size: 16px; }
.account-row p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.account-row .action-row { justify-content: flex-end; }

.notice-list { display: grid; gap: 1px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); }
.notice { padding: 14px 16px; background: var(--surface); }
.notice header { display: flex; justify-content: space-between; gap: 12px; }
.notice h3 { margin: 0; font-size: 15px; }
.notice p { margin: 5px 0 0; color: var(--muted); }
.notice time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.notice.unread { background: #f6f8ff; }

.modal { width: min(680px, calc(100vw - 32px)); max-height: min(88vh, 760px); border: 0; border-radius: 10px; padding: 0; background: var(--surface); color: var(--fg); box-shadow: 0 24px 70px rgba(18,31,25,.25); overflow: auto; }
.modal::backdrop { background: rgba(17,29,24,.58); }
.modal-body { padding: 24px; }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.modal-head h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.modal-head p { margin: 4px 0 0; color: var(--muted); }
.modal-close { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--muted); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border-radius: var(--radius); background: var(--fg); color: #f6faf7; box-shadow: 0 12px 32px rgba(18,31,25,.22); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.mobile-nav { display: none; }
.mobile-more-list { display: grid; gap: 8px; }
.mobile-more-list .btn { width: 100%; text-align: left; }

@media (hover: hover) {
  .btn.primary:hover { background: #1b43ab; }
  .btn.secondary:hover, .notification-button:hover, .copy-button:hover { border-color: #aebbb2; background: #f5f7f4; }
  .sidebar nav button:hover { background: #22322b; color: #eef4ef; }
  .sidebar nav button.active:hover { background: var(--accent); }
  tbody tr:hover { background: #f6f8f5; }
  .logout-button:hover { color: #eef4ef; }
}

@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(4) { border-left: 0; padding-left: 0; }
  .account-row { grid-template-columns: minmax(220px, 1fr) minmax(180px, .8fr) auto; }
  .account-row > :nth-child(3) { display: none; }
}

@media (max-width: 900px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-context { min-height: 42vh; padding: 28px 20px; grid-template-rows: auto 1fr; }
  .auth-copy { align-self: end; margin-top: 40px; }
  .auth-copy h1 { font-size: clamp(38px, 12vw, 58px); }
  .auth-copy > p:last-child { margin-top: 16px; font-size: 15px; }
  .source-chain { display: none; }
  .auth-panel { padding: 30px 20px 48px; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { height: 76px; padding: 13px 16px; }
  .topbar h1 { font-size: 24px; }
  .topbar p { display: none; }
  .notification-button { width: 44px; padding: 0; justify-content: center; }
  .notification-button span { display: none; }
  .content { padding: 20px 16px 34px; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 50; display: grid; grid-template-columns: repeat(5, 1fr); min-height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: rgba(251,252,249,.97); backdrop-filter: blur(12px); }
  .mobile-nav button { min-height: 64px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 2px; }
  .mobile-nav b { font-size: 10px; }
  .mobile-nav span { font-size: 11px; }
  .mobile-nav button.active { color: var(--accent); }
  .coverage-rail { grid-template-columns: 1fr; }
  .coverage-item { border-right: 0; border-bottom: 1px solid var(--border); }
  .coverage-item:last-child { border-bottom: 0; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric, .metric + .metric { padding: 14px 12px 14px 0; border-left: 0; }
  .metric:nth-child(even) { padding-left: 14px; border-left: 1px solid var(--border); }
  .metric strong { font-size: 24px; }
  .page-actions, .section-head { align-items: stretch; flex-direction: column; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > :nth-child(n+5) { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .form-grid .short { max-width: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .account-row { grid-template-columns: 1fr; gap: 10px; }
  .account-row > :nth-child(3) { display: block; }
  .account-row .action-row { justify-content: flex-start; }
  .modal-body { padding: 20px 16px; }
  .toast { right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .filters { grid-template-columns: 1fr; }
  .filters > * { grid-column: auto !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
