:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f0f3f9;
  --text: #172033;
  --muted: #5d6880;
  --line: #e2e7f0;
  --brand: #3b5bdb;
  --brand-2: #0ca678;
  --brand-soft: #e8edff;
  --good: #0f9d6b;
  --good-soft: #dcf5ea;
  --warn: #c77700;
  --warn-soft: #fff1d6;
  --bad: #d6336c;
  --bad-soft: #fde4ec;
  --q-sales: #7048e8;
  --q-support: #1c7ed6;
  --c-actual: #1c7ed6;
  --c-forecast: #e8590c;
  --c-req: #e8590c;
  --c-sched: #3b5bdb;
  --c-raw: #94a3b8;
  --shade: rgba(59, 91, 219, .05);
  --shadow: 0 1px 2px rgba(23, 32, 51, .05), 0 4px 16px rgba(23, 32, 51, .05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --panel: #171e2e; --panel-2: #1e2638; --text: #e6eaf2; --muted: #98a2b8; --line: #2a3349;
    --brand: #7c94ff; --brand-soft: #243058; --good: #3ccf91; --good-soft: #153a2c; --warn: #ffb547; --warn-soft: #3d2f13;
    --bad: #ff6b9a; --bad-soft: #3e1a28; --q-sales: #a58bff; --q-support: #4dabf7; --c-actual: #4dabf7; --c-forecast: #ff922b;
    --c-req: #ff922b; --c-sched: #7c94ff; --c-raw: #6b7895; --shade: rgba(124, 148, 255, .07); --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420; --panel: #171e2e; --panel-2: #1e2638; --text: #e6eaf2; --muted: #98a2b8; --line: #2a3349;
  --brand: #7c94ff; --brand-soft: #243058; --good: #3ccf91; --good-soft: #153a2c; --warn: #ffb547; --warn-soft: #3d2f13;
  --bad: #ff6b9a; --bad-soft: #3e1a28; --q-sales: #a58bff; --q-support: #4dabf7; --c-actual: #4dabf7; --c-forecast: #ff922b;
  --c-req: #ff922b; --c-sched: #7c94ff; --c-raw: #6b7895; --shade: rgba(124, 148, 255, .07); --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }
[hidden] { display: none !important; }

.demo-banner { position: sticky; top: 0; z-index: 50; background: linear-gradient(90deg, #3b5bdb, #0ca678); color: #fff; text-align: center; font-size: 12.5px; font-weight: 600; padding: 6px 12px; letter-spacing: .01em; }
.demo-banner span { opacity: .85; font-weight: 500; }

/* ---------- login */
.login { min-height: calc(100vh - 30px); display: grid; grid-template-columns: 1.1fr 1fr; background: radial-gradient(1200px 700px at -10% -20%, rgba(59, 91, 219, .16), transparent 60%), radial-gradient(900px 600px at 100% 110%, rgba(12, 166, 120, .14), transparent 60%); }
.login-hero { padding: 56px 56px 40px; display: flex; flex-direction: column; gap: 22px; }
.login-hero h1 { font-size: 34px; line-height: 1.15; margin: 18px 0 0; letter-spacing: -.02em; max-width: 560px; }
.login-hero p { color: var(--muted); font-size: 16px; max-width: 540px; margin: 0; }
.feat { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 600px; }
.feat div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.feat b { display: block; margin-bottom: 2px; }
.feat span { color: var(--muted); font-size: 13px; }
.login-side { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--muted); margin: 0 0 18px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select { min-width: 0; width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px 11px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.roles { display: grid; gap: 10px; margin: 16px 0 6px; }
.role { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; background: var(--panel-2); }
.role .rl { flex: 1; min-width: 0; }
.role b { display: block; }
.role code { display: block; font-size: 12px; color: var(--muted); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- buttons */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 13px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 30px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 30px; height: calc(100vh - 30px); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; padding: 0 6px; }
.logo small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.who { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none; }
.who small { display: block; color: var(--muted); }
main { min-width: 0; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 28px 6px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.top .sub { color: var(--muted); font-size: 13px; }
.top .tools { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page { padding: 12px 28px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- cards */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 2px; }
.card .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head > div:first-child { flex: 1; min-width: 180px; }
.kpi { padding: 14px 16px; }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi .delta { font-size: 12.5px; margin-top: 2px; color: var(--muted); }
.up { color: var(--good) !important; } .down { color: var(--bad) !important; } .amber { color: var(--warn) !important; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.brand { background: var(--brand-soft); color: var(--brand); }
.note { background: var(--panel-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 12.5px; }

/* ---------- tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel-2); }
.tbl tr.sel td { background: var(--brand-soft); }
.tbl select { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 3px 6px; }
.tbl-scroll { max-height: 520px; overflow: auto; }

/* ---------- chart */
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line); stroke-width: 1.2; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .guide { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .now { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 4 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--c); vertical-align: middle; margin-right: 5px; }
.lg-sw.bar { height: 10px; width: 10px; border-radius: 3px; }
.lg-sw.dash { background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 8px); }
.tip { position: fixed; z-index: 100; display: none; pointer-events: none; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); min-width: 150px; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 4px; }
.tip div span { margin-left: auto; padding-left: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- schedule */
.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.day { flex: 1; min-width: 118px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 11px; cursor: pointer; text-align: left; }
.day:hover { border-color: var(--brand); }
.day.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.day .dn { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; }
.day .dd { font-size: 12px; color: var(--muted); margin-top: 3px; }
.bar-mini { height: 5px; border-radius: 3px; background: var(--panel-2); margin-top: 7px; overflow: hidden; }
.bar-mini i { display: block; height: 100%; border-radius: 3px; }
.gantt { position: relative; font-size: 12.5px; }
.g-scale, .g-row { display: grid; grid-template-columns: 210px 1fr 100px; align-items: center; }
.g-scale { position: sticky; top: 0; background: var(--panel); z-index: 2; border-bottom: 1px solid var(--line); height: 26px; }
.g-ticks { position: relative; height: 100%; }
.g-ticks span { position: absolute; top: 5px; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
.g-row { height: 32px; border-bottom: 1px solid var(--line); }
.g-row:hover { background: var(--panel-2); }
.g-row.click { cursor: pointer; }
.g-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 8px; }
.g-name small { color: var(--muted); margin-left: 4px; }
.g-track { position: relative; height: 100%; background-image: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px calc(100% / 14)); }
.g-shift { position: absolute; top: 7px; height: 18px; border-radius: 5px; background: var(--c-sched); opacity: .9; }
.g-shift.part { background: var(--brand-2); }
.g-shift.fixed { outline: 2px solid var(--warn); outline-offset: 1px; }
.g-brk { position: absolute; top: 7px; height: 18px; background: repeating-linear-gradient(45deg, #fff 0 3px, #ffd8a8 3px 6px); border-radius: 3px; }
:root[data-theme="dark"] .g-brk { background: repeating-linear-gradient(45deg, #171e2e 0 3px, #b06d1f 3px 6px); }
.g-time { white-space: nowrap; font-size: 12px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.heat { border-collapse: separate; border-spacing: 2px; font-size: 11px; width: 100%; table-layout: fixed; }
.heat td { height: 24px; text-align: center; border-radius: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.heat th { font-weight: 600; color: var(--muted); font-size: 10.5px; padding: 0 0 3px; }
.heat th.rowh { text-align: left; width: 74px; font-size: 12px; }
.ot { display: flex; flex-direction: column; gap: 8px; }
.ot-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.ot-item .t { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.ot-item ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.inputs .field { margin: 0; }
.lock { font-size: 12px; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.calc-out { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.calc-out div { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.calc-out b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.calc-out span { font-size: 12px; color: var(--muted); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #172033; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; opacity: 0; transition: .25s; z-index: 200; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.search { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 11px; min-width: 200px; }
.muted { color: var(--muted); }
.mt0 { margin-top: 0; }

@media (max-width: 1100px) {
  .g3 { grid-template-columns: 1fr 1fr; }
  .g-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 16px 8px; }
  .login-hero h1 { font-size: 26px; }
  .feat { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .logo small, .side-foot .who { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 7px 9px; }
  .nav a span { display: none; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
  .top, .page { padding-left: 16px; padding-right: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g-scale, .g-row { grid-template-columns: 120px 1fr 0; }
  .g-time { display: none; }
}
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 32, .45); display: grid; place-items: center; z-index: 150; padding: 16px; }
.modal { width: 100%; max-width: 420px; }
.page > * { min-width: 0; }
.seg { max-width: 100%; overflow-x: auto; }
.seg button { flex: none; }
a.btn { text-decoration: none; color: var(--text); }
