:root {
  --navy: #0E1A2B; --navy-2: #1D3A66; --navy-line: #22324A;
  --bg: #F3F6FA; --surface: #FFFFFF; --soft: #F6F8FB; --line: #E3E8EF; --line-2: #EEF2F6; --field: #D5DCE6;
  --ink: #0F172A; --ink-2: #1E293B; --muted: #475569; --muted-2: #5B6475;
  --blue: #2563EB; --blue-ink: #1D4ED8; --blue-soft: #EFF6FF; --blue-line: #BFDBFE;
  --red-soft: #FEF2F2; --red-line: #FECACA; --red-ink: #991B1B; --red: #DC2626;
  --amber-soft: #FFF7ED; --amber-line: #FED7AA; --amber-ink: #9A3412;
  --green-soft: #DCFCE7; --green-ink: #14532D; --green: #15803D;
  --yellow-soft: #FEF9C3;
  --radius: 14px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--blue-ink); }
a:hover { color: #1E3A8A; }
button { font: inherit; }
:focus-visible { outline: 3px solid #93C5FD; outline-offset: 2px; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; background: var(--navy); color: #C7D0DD; padding: 22px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.content { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.view { padding: 26px 34px 48px; max-width: 1320px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.brand-text { display: flex; flex-direction: column; }
.brand-text b { color: #fff; letter-spacing: 0.02em; }
.brand-text small { color: #93A1B5; font-size: 12px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #7D8BA0; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #C7D0DD; text-decoration: none; min-height: 40px; }
.nav-link:hover { color: #fff; background: #16263D; }
.nav-link.active { background: var(--navy-2); color: #fff; font-weight: 600; }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: #F59E0B; color: #1F1300; font-size: 12px; font-weight: 700; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--navy-line); font-size: 13px; color: #93A1B5; display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot b { color: #fff; }
.link-btn { background: none; border: 0; padding: 0; color: #C7D0DD; cursor: pointer; text-align: left; text-decoration: underline; }
.tabbar { display: none; }

/* Headings & generic blocks */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); }
h1 { margin: 4px 0 0; font-size: 28px; line-height: 1.2; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
h3 { margin: 0; font-size: 15px; font-weight: 600; }
.lead { margin: 6px 0 0; color: var(--muted); max-width: 760px; }
.muted { color: var(--muted-2); font-size: 13px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel.tint-amber { background: var(--amber-soft); border-color: var(--amber-line); }
.panel.tint-blue { background: var(--blue-soft); border-color: var(--blue-line); }
.grid { display: grid; gap: 16px; align-items: start; }
.cols-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart { width: 100%; height: auto; display: block; }
.chart rect[tabindex]:focus { outline: none; fill: rgba(37, 99, 235, 0.06); }
.chart-readout { min-height: 20px; font-size: 13px; }
.rank-row { gap: 4px; }
.cols-4-8 { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.kpi .k { font-size: 13px; color: var(--muted-2); }
.kpi .v { font-size: 30px; font-weight: 700; line-height: 1.1; }
.kpi .n { font-size: 13px; color: var(--muted); }
.kpi.red { background: var(--red-soft); border-color: var(--red-line); }
.kpi.red .v, .kpi.red .k { color: var(--red-ink); }
.kpi.amber { background: var(--amber-soft); border-color: var(--amber-line); }
.kpi.amber .v, .kpi.amber .k { color: var(--amber-ink); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fact { background: var(--soft); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fact .k { font-size: 12px; color: var(--muted-2); }
.fact .v { font-weight: 600; overflow-wrap: anywhere; }
.empty { padding: 18px; text-align: center; color: var(--muted-2); background: var(--soft); border-radius: 10px; }
.error-box { padding: 14px 16px; border-radius: 10px; background: var(--red-soft); color: var(--red-ink); }

/* Controls */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.btn-primary { min-height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn { min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 600; }
.btn.on { background: var(--green); border-color: var(--green); color: #fff; }
input[type=search], input[type=text], select, textarea { font: inherit; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); color: var(--ink); min-height: 44px; padding: 0 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar input[type=search] { flex-grow: 1; min-width: 200px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.hot { background: #FEE2E2; color: var(--red-ink); }
.badge.warm { background: #FFEDD5; color: var(--amber-ink); }
.badge.cold { background: #F1F5F9; color: #334155; }
.badge.busy { background: var(--green-soft); color: var(--green-ink); }
.badge.normal { background: #DBEAFE; color: #1E3A8A; }
.badge.light { background: #FEF3C7; color: #78350F; }
.badge.cat { background: #DBEAFE; color: #1E3A8A; }
.tag { display: inline-flex; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.tag.high { background: #FEE2E2; color: var(--red-ink); }
.tag.medium { background: #FFEDD5; color: var(--amber-ink); }
.tag.soft, .tag.neutral { background: #F1F5F9; color: #334155; }
.tag.info { background: #E0E7FF; color: #3730A3; }
.tag.ok { background: var(--green-soft); color: var(--green-ink); }

/* Lists */
.card-link { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.card-link:hover { border-color: #93C5FD; }
.row-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.row-title { font-size: 16px; font-weight: 600; }
.row-meta { font-size: 13px; color: var(--muted-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.blocker { font-size: 14px; color: var(--ink-2); }
.blocker b { color: #B45309; margin-right: 6px; }
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); color: var(--ink); text-decoration: none; background: var(--surface); border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item.selected { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; background: #94A3B8; }
.dot.high { background: var(--red); }
.dot.medium { background: #F59E0B; }
.stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; border-top: 1px solid var(--line-2); }
.history-item { display: grid; grid-template-columns: 112px 26px minmax(0, 1fr); gap: 10px; padding: 12px 4px; color: var(--ink); text-decoration: none; }
.history-row > .player { grid-column: 1 / -1; margin-bottom: 12px; }
.play-btn { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 999px; background: var(--navy); color: #fff; font-size: 15px; cursor: pointer; }
.play-btn:hover { filter: brightness(1.15); }
.play-btn.on { background: var(--blue); }
.play-btn:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 2px; }
.listen { display: flex; align-items: center; gap: 10px; }
.player.inline { padding: 6px 8px; }
.correction summary { cursor: pointer; font-weight: 600; color: var(--blue-ink); }
.correction[open] summary { margin-bottom: 8px; }
.correction .toolbar { flex-wrap: wrap; }
.correction select { min-height: 44px; max-width: 100%; }
.dir { font-weight: 700; }
.dir.in { color: #B45309; } .dir.out { color: var(--blue-ink); } .dir.miss { color: var(--red); }

/* Bars & timelines */
.bar { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--blue); }
.bar.slate > span { background: #64748B; }
.funnel { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.funnel-step { display: flex; flex-direction: column; gap: 6px; }
.funnel-step .v { font-size: 26px; font-weight: 700; }
.funnel-step .drop { font-size: 12px; color: #B91C1C; font-weight: 600; min-height: 16px; }
.timeline { position: relative; height: 40px; border-radius: 8px; background: #F1F5F9; }
.timeline.mini { height: 10px; border-radius: 4px; }
.timeline .noon { position: absolute; top: 0; bottom: 0; border-left: 2px dashed #94A3B8; }
.timeline .blk { position: absolute; top: 6px; bottom: 6px; min-width: 3px; border-radius: 3px; background: #93C5FD; }
.timeline.mini .blk { top: 0; bottom: 0; border-radius: 2px; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: #334155; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.c-equipment_sales { background: #2563EB !important; } .c-parts { background: #7C3AED !important; }
.c-service_support { background: #0F766E !important; } .c-presale_preparation { background: #C2410C !important; }
.c-biosim { background: #4D7C0F !important; } .c-grain_procurement { background: #B45309 !important; }
.c-logistics { background: #0369A1 !important; } .c-finance_documents { background: #BE185D !important; }
.c-internal_coordination, .c-vendor_partner, .c-personal_other, .c-unclear, .c-unknown { background: #94A3B8 !important; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted-2); font-weight: 600; padding: 8px 6px; }
td { padding: 10px 6px; border-top: 1px solid var(--line-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.flag { color: #B91C1C; font-weight: 700; }

/* Call card */
.player { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--navy); color: #fff; }
.player audio { width: 100%; }
.segment { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; color: var(--ink); width: 100%; line-height: 1.45; }
.segment:hover { background: var(--soft); }
.segment.evidence { background: var(--yellow-soft); }
.segment.current { background: #E0ECFF; }
.segment .t { width: 48px; flex-shrink: 0; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.summary { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.review-card { display: flex; flex-direction: column; gap: 12px; }
.review-card.done { background: #F0FDF4; border-color: #BBF7D0; }
.quote { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--soft); color: #334155; }
.back { font-weight: 600; text-decoration: none; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #EEF2F6, #F8FAFC, #EEF2F6); }

/* Login */
.login-body { background: var(--navy); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; padding: 30px; display: flex; flex-direction: column; gap: 10px; }
.login-card .brand { padding: 0; margin-bottom: 6px; }
.login-card .brand-text b { color: var(--ink); }
.login-card .brand-text small { color: var(--muted-2); }
.login-card label { font-size: 14px; font-weight: 600; margin-top: 6px; }
.login-card .check { display: flex; gap: 8px; align-items: center; font-weight: 400; color: #334155; }
.login-card .check input { width: 18px; height: 18px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red-ink); font-size: 14px; }

/* Phone */
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.2s ease; height: 100%; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.45); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--navy); color: #fff; }
  .menu-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: var(--navy-2); color: #fff; display: flex; align-items: center; justify-content: center; }
  .topbar-title { font-weight: 700; }
  .view { padding: 16px 16px 96px; gap: 14px; }
  h1 { font-size: 23px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .v { font-size: 26px; }
  .cols-7-5, .cols-4-8, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .history-item { grid-template-columns: 20px minmax(0, 1fr); row-gap: 4px; }
  .history-item > .muted:first-child { grid-column: 1 / -1; }
  .panel { padding: 14px; }
  .tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; padding: 6px 6px max(10px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border-radius: 10px; font-size: 12px; color: var(--muted); text-decoration: none; }
  .tab.active { color: var(--blue-ink); background: var(--blue-soft); font-weight: 700; }
  table.responsive thead { display: none; }
  table.responsive tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
  table.responsive td { border: 0; padding: 2px 0; text-align: left; }
  table.responsive td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted-2); }
  table.responsive td:first-child { grid-column: 1 / -1; font-weight: 600; }
  table.responsive td:first-child::before { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
