:root {
  --bg: #f4f6f8; --surface: #fff; --ink: #18212b; --muted: #667281; --line: #dfe4ea; --soft: #eef2f5;
  --accent: #0f766e; --accent-ink: #fff; --accent-soft: #e2f3f1; --good: #15803d; --bad: #c2410c; --warn-bg: #fff7e6; --warn-line: #f2c36b;
  --input: #fffdf2; --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.good { color: var(--good); } .bad { color: var(--bad); }

/* ---- top bar */
.top { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 8px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand i { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 14px; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 550; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }
.top .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.page { max-width: 1500px; margin: 0 auto; padding: 16px; }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 14px; }
.card > h2 { margin-bottom: 10px; }

/* ---- controls */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
select, input[type=text], input[type=password], input[type=month], input[type=date], input:not([type]), textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--surface); min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.f input, label.f select { font-size: 14px; color: var(--ink); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.submitted { background: #dcfce7; color: var(--good); } .badge.draft { background: #fef3c7; color: #92400e; } .badge.none { background: #f1f5f9; color: #94a3b8; }
.save { font-size: 12px; color: var(--muted); min-width: 90px; }

/* ---- tabs */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 14px; scrollbar-width: thin; }
.tabs a { padding: 9px 13px; text-decoration: none; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .l { font-size: 12px; color: var(--muted); } .kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; } .kpi .s { font-size: 12px; margin-top: 2px; color: var(--muted); }

/* ---- tables */
.scroll { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.scroll.tall { max-height: calc(100vh - 210px); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--soft); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #f8fafb; position: sticky; top: 0; z-index: 2; white-space: nowrap; }
th.sort { cursor: pointer; } th.sort:hover { color: var(--ink); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--accent-soft); }
tr.sub td { font-weight: 650; background: #f8fafb; }
tr.total td { font-weight: 700; background: var(--accent-soft); }
tfoot td { font-weight: 700; background: #f8fafb; position: sticky; bottom: 0; border-top: 1px solid var(--line); }
td.hint { color: var(--muted); font-size: 12px; }
.stick { position: sticky; left: 0; z-index: 1; background: var(--surface); }
th.stick { z-index: 3; background: #f8fafb; }
tr.total td.stick { background: var(--accent-soft); } tr.sub td.stick, tfoot td.stick { background: #f8fafb; }
.bar { height: 6px; border-radius: 3px; background: var(--soft); min-width: 60px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); }

/* ---- data entry grids */
table.grid th, table.grid td { padding: 0; border-right: 1px solid var(--soft); }
table.grid th { padding: 6px 8px; white-space: normal; min-width: 84px; max-width: 110px; line-height: 1.2; vertical-align: bottom; }
table.grid th.c { background: #eef1f4; }
table.grid td.c { padding: 5px 8px; background: #f6f8fa; text-align: right; font-variant-numeric: tabular-nums; color: #3d4957; white-space: nowrap; }
table.grid td.d { padding: 5px 8px; white-space: nowrap; font-weight: 600; }
table.grid tr.we td.d { color: var(--bad); }
table.grid input { width: 100%; border: 0; border-radius: 0; background: var(--input); padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; }
table.grid tfoot td { padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list td { padding: 3px 4px; }
table.list input { width: 100%; background: var(--input); padding: 6px 8px; }
table.list input[type=text] { min-width: 150px; }
table.list input.num { min-width: 110px; }
table.list input[type=date] { min-width: 140px; }
table.list input.num, input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.err { outline: 2px solid var(--bad); }
input[readonly], input:disabled { background: #f3f5f7 !important; color: #4b5563; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.form input { background: var(--input); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.two > .card { margin: 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center; }
.kv b { font-variant-numeric: tabular-nums; text-align: right; }
.kv input { width: 150px; background: var(--input); }
.checks { border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.checks ul { margin: 4px 0 0; padding-left: 18px; } .checks.ok { border-color: #bbf7d0; background: #f0fdf4; color: var(--good); }

/* ---- login / modal / toast */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 24px; display: grid; gap: 12px; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 720px; max-height: 90vh; display: flex; flex-direction: column; }
.modal > header { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 16px; }
.modal > .body { padding: 16px; overflow: auto; }
.modal > footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast { background: #18212b; color: #fff; padding: 9px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 90vw; } .toast.err { background: #9a3412; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chips label { border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: 13px; } .chips input { margin-right: 4px; }
pre.creds { background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; user-select: all; }

@media (max-width: 640px) { .form { grid-template-columns: 1fr 1fr; } .page { padding: 10px; } .top { padding: 8px 10px; gap: 8px; } .kpi .v { font-size: 18px; } }
@media print {
  .top, .tabs, .noprint, #toasts { display: none !important; }
  body { background: #fff; } .page { padding: 0; max-width: none; } .scroll { border: 0; overflow: visible; max-height: none; } th, td { padding: 3px 8px; font-size: 11px; }
}

.upcard { display: flex; align-items: center; gap: 14px; justify-content: space-between; flex-wrap: wrap; border-color: #9fd3cd; background: var(--accent-soft); margin-bottom: 14px; }
.upcard h2 { margin-bottom: 2px; } .upcard > div { flex: 1; min-width: 220px; }
.steps { display: grid; gap: 8px; }
.step { display: grid; grid-template-columns: 22px 1fr 150px; gap: 10px; align-items: center; }
.step .sign { font-size: 18px; font-weight: 700; color: var(--muted); text-align: center; }
.step input { background: var(--input); width: 100%; }
.step.res { border-top: 2px solid var(--ink); padding-top: 10px; margin-top: 4px; font-size: 16px; } .step.res > b { text-align: right; font-variant-numeric: tabular-nums; }
details.help { margin-top: 12px; } details.help summary { cursor: pointer; color: var(--accent); font-weight: 550; } details.help ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
@media (max-width: 640px) { .step { grid-template-columns: 18px 1fr 110px; } }

.badge.sev-high { background: #fee2e2; color: #b91c1c; } .badge.sev-medium { background: #fef3c7; color: #92400e; } .badge.sev-low { background: #e0f2fe; color: #075985; }
.issue { border-left: 4px solid var(--line); } .issue.sev-high { border-left-color: #dc2626; } .issue.sev-medium { border-left-color: #f59e0b; } .issue.sev-low { border-left-color: #38bdf8; }
.issue h3 { margin: 12px 0 6px; } .issue ul, .card > ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; } .issue td { white-space: normal; }

.card.ai { max-width: 620px; } .badge.big { font-size: 15px; padding: 5px 14px; }
.ai-sum { font-size: 18px; font-weight: 650; margin: 8px 0 14px; line-height: 1.35; }
.ai-prob { border-left: 4px solid #f59e0b; background: #fffaf0; border-radius: 0 8px 8px 0; padding: 10px 14px; margin-bottom: 10px; }
.ai-prob h3 { font-size: 16px; margin: 0 0 2px; } .ai-prob p { margin: 0 0 6px; }
.ai-prob ul.todo { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; } .ai-prob ul.todo li { font-weight: 600; } .ai-prob ul.todo li::before { content: "→ "; color: var(--accent); }
.ai-sec { margin-top: 12px; } .ai-sec h3 { margin: 0 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; } .ai-sec ul { margin: 0; padding-left: 18px; }

tr.click td.stick { white-space: nowrap; }

.ai-imp { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; padding: 10px 14px; margin-bottom: 10px; }
.ai-imp h3 { font-size: 15px; margin: 0 0 6px; } .ai-imp ul.todo { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; } .ai-imp ul.todo li::before { content: "→ "; color: var(--accent); font-weight: 700; }

.mbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; } .mbox .form input { background: var(--input); }

tbody.be tr.be-head td { background: #1f2a37; color: #fff; font-weight: 700; padding-top: 8px; } tbody.be td.hint { white-space: normal; }

/* Monthly report (area manager KPI sheet) */
.kpiT { border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.kpiT th, .kpiT td { border: 1px solid var(--line, #e2e8f0); padding: 4px 6px; }
.kpiT thead th { background: #f1f5f9; text-align: center; white-space: normal; min-width: 62px; vertical-align: bottom; }
.kpiT thead th.auto { background: #e2e8f0; }
.kpiT thead th.g0 { background: #dbeafe; } .kpiT thead th.g1 { background: #fef3c7; } .kpiT thead th.g2 { background: #dcfce7; } .kpiT thead th.g3 { background: #fce7f3; } .kpiT thead th.g4 { background: #ede9fe; }
.kpiT td.ok { background: #dcfce7; } .kpiT td.no { background: #fee2e2; }
.kpiT td.ok input, .kpiT td.no input { background: transparent; }
.kpiT input.kin { width: 58px; min-width: 0; padding: 3px 4px; text-align: right; border: 1px solid #cbd5e1; border-radius: 4px; font: inherit; }
.kpiT input.kin.rm { width: 220px; text-align: left; }
.kpiT tfoot td { font-weight: 600; background: #f8fafc; } .kpiT tr.sub td { background: #f1f5f9; font-weight: 600; }
.kpiT td.stick, .kpiT th.stick { position: sticky; left: 0; background: #fff; z-index: 1; }
@media print { .kpiT { font-size: 9px; } .kpiT input.kin { border: 0; width: 40px; } .kpiT input.kin.rm { width: 110px; } }

/* Sales tab summary */
.sx-kpis { margin-top: 14px; }
.sx-bar { display: flex; height: 30px; border-radius: 8px; overflow: hidden; margin: 4px 0 14px; background: var(--soft); }
.sx-bar > div { color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; white-space: nowrap; overflow: hidden; min-width: 2px; }
.sx-tbl { width: 100%; }
.sx-tbl td, .sx-tbl th { padding: 7px 8px; }
.sx-tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.sx-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }

/* ===== Polish pass (all pages) ===== */
:root { --bg: #f3f5f7; --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06); --radius: 12px; }
.top { box-shadow: 0 1px 0 var(--line), 0 2px 8px rgba(16, 24, 40, .04); border-bottom: 0; }
.card { border-color: #e4e8ed; box-shadow: var(--shadow); padding: 16px 18px; }
.card > h2 { margin-bottom: 12px; font-size: 15px; letter-spacing: .1px; }
/* even spacing between every block on a page */
.card + .card, .card + .two, .two + .card, .two + .two, .card + .scroll, .scroll + .card, .kpis + .card, .kpis + .two, .kpis + .scroll,
.card + details, .scroll + details { margin-top: 14px; }
.upcard { margin-bottom: 0; } .upcard + * { margin-top: 14px; }
/* tabs */
.tabs { gap: 4px; margin-bottom: 16px; }
.tabs a { padding: 10px 14px; border-radius: 8px 8px 0 0; }
.tabs a:hover { color: var(--ink); background: #e9eef2; }
.tabs a.on { background: transparent; font-weight: 650; }
/* KPI cards */
.kpis { gap: 12px; }
.kpi { box-shadow: var(--shadow); border-color: #e4e8ed; border-top: 3px solid var(--accent); padding: 12px 16px 14px; }
.kpi .l { text-transform: uppercase; letter-spacing: .04em; font-size: 11px; font-weight: 600; }
.kpi .v { font-size: 24px; margin-top: 4px; }
/* tables */
.scroll { box-shadow: var(--shadow); border-color: #e4e8ed; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: #f6f8fa; border-bottom: 1px solid var(--line); }
th, td { padding: 8px 10px; }
tbody tr:hover td { background: #f9fbfc; }
tr.total td { background: var(--accent-soft); border-top: 1px solid #b9ded9; }
tr.sub td { background: #f4f6f8; }
table.list { border: 1px solid #edf0f3; border-radius: 10px; overflow: hidden; }
table.list td { padding: 4px 6px; }
table.list tfoot td { padding: 8px 10px; }
/* forms: labels on top, inputs lined up along the bottom even when a label wraps */
.form { gap: 12px 14px; }
label.f { justify-content: space-between; font-weight: 550; }
label.f input, label.f select { height: 36px; }
.form input, .kv input, .step input, table.list input { border-color: #d9e0e7; }
.form input:hover, .step input:hover, table.list input:hover { border-color: #b8c4cf; }
/* label / value lists */
.kv { gap: 0 16px; }
.kv > span, .kv > b { padding: 7px 0; border-bottom: 1px solid #eef1f4; }
.kv > span:nth-last-child(2), .kv > b:last-child { border-bottom: 0; }
/* upload / info strips */
.upcard { border-color: #b7dfd9; background: linear-gradient(90deg, #e6f4f2, #f1f9f8); box-shadow: none; }
.step { padding: 4px 0; }
/* buttons */
.btn { border-radius: 9px; transition: background .12s, border-color .12s; }
.btn.primary { box-shadow: 0 1px 2px rgba(15, 118, 110, .25); }
@media (max-width: 640px) { .card { padding: 14px; } .kpi .v { font-size: 20px; } }
.two > .card + .card, .two > .card { margin-top: 0; }
