/* Bonus System — matches the approved design (Inter, white cards, one blue accent) */
:root {
  --bg: #F6F7F9; --surface: #FFFFFF; --ink: #16191D; --ink2: #3D4652; --muted: #5B6470; --faint: #8A939E;
  --line: #E3E6EA; --line2: #EEF0F3; --input: #D4D9DF;
  --blue: #1E4FD8; --blue-dark: #163BA6; --blue-soft: #E8EEFD; --blue-row: #F8FAFF; --blue-mid: #9DB3F0;
  --warn: #B4540A; --warn-ink: #8A3F06; --warn-soft: #FFF4E8; --warn-line: #F3D5B5; --warn-deep: #5C2A04;
  --ok-soft: #E9F4EC; --ok: #1D6B37;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
       font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
a { color: var(--blue); } a:hover { color: var(--blue-dark); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .s14 { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.right { text-align: right; } .center { text-align: center; }

/* ---------- header ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.wrap { max-width: 1680px; margin: 0 auto; padding: 0 32px; }
.topbar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 32px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--blue); display: inline-flex; align-items: center; justify-content: center; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.nav a { padding: 10px 16px; border-radius: 8px; color: var(--ink2); text-decoration: none; font-size: 14px; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }

main.page { max-width: 1680px; margin: 0 auto; padding: 32px; display: flex; flex-direction: column; gap: 24px; }
main.page.narrow { max-width: 1100px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.card.pad { padding: 24px; } .card.pad-lg { padding: 32px; } .card.pad-md { padding: 20px 24px; }
.card.warn { border-color: var(--warn-line); }
.card.focus { border: 2px solid var(--blue); }
.card .head { padding: 18px 24px; border-bottom: 1px solid var(--line); }
.card .foot { padding: 14px 24px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--input); background: var(--surface);
       color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center;
       justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.outline { border-color: var(--blue); color: var(--blue); }
.btn.warn { background: var(--warn-soft); border-color: var(--warn-soft); color: var(--warn-ink); }
.btn.sm { min-height: 38px; padding: 0 14px; border-radius: 8px; }
.btn.xs { min-height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--blue); padding: 0 6px; }
.btn:disabled, .btn.disabled { background: #C9D3EA; border-color: #C9D3EA; color: var(--ink2); cursor: not-allowed; }
.btn.danger { color: #9B1C1C; }
form.inline { display: inline; margin: 0; }

/* ---------- chips ---------- */
.chip { padding: 4px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip.draft, .chip.neutral { background: var(--line2); color: var(--ink2); }
.chip.approved, .chip.info { background: var(--blue-soft); color: var(--blue); }
.chip.locked { background: var(--ink); color: #fff; }
.chip.missing, .chip.warn { background: var(--warn-soft); color: var(--warn-ink); }
.chip.ready, .chip.optional { border: 1px dashed #C4CAD2; color: var(--muted); background: transparent; }

/* ---------- flash ---------- */
.flash { padding: 14px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; }
.flash.ok { background: var(--blue-soft); color: var(--blue-dark); }
.flash.error { background: var(--warn-soft); color: var(--warn-deep); border: 1px solid var(--warn-line); }

/* ---------- stepper ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.steps.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.steps li { display: flex; flex-direction: column; gap: 10px; }
.steps .bar { height: 6px; border-radius: 3px; background: var(--line); }
.steps .done .bar { background: var(--blue); } .steps .current .bar { background: var(--blue-mid); }
.steps .name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.steps .current .name { color: var(--blue); } .steps .todo .name { color: var(--muted); }
.steps .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.steps .done .dot { background: var(--blue); } .steps .current .dot { border: 2px solid var(--blue); } .steps .todo .dot { border: 2px solid #C4CAD2; }
.steps .sub { color: var(--muted); font-size: 14px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.stat.soft { background: var(--bg); border: none; }
.stat .label { color: var(--muted); font-size: 14px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.stat .value.md { font-size: 19px; line-height: 1.4; }
.stat .note { color: var(--muted); font-size: 14px; } .stat .note.up { color: var(--blue); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ---------- alerts ---------- */
.alert { background: var(--surface); border: 1px solid var(--warn-line); border-radius: 12px; padding: 20px; display: flex; gap: 16px; align-items: flex-start; }
.alert .icon { width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--warn-soft); display: inline-flex; align-items: center; justify-content: center; }
.alert .body { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.alert .body span { color: var(--muted); font-size: 14px; line-height: 1.6; }
.alert.ok { border-color: var(--line); } .alert.ok .icon { background: var(--blue-soft); }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t thead tr { color: var(--muted); font-size: 13px; text-align: left; background: #FAFBFC; }
table.t th { padding: 12px 16px; font-weight: 600; }
table.t td { padding: 13px 16px; }
table.t tbody tr { border-top: 1px solid var(--line2); }
table.t tbody tr.hl { background: var(--blue-row); }
table.t tbody tr:hover { background: #FAFBFC; }
table.t th:first-child, table.t td:first-child { padding-left: 24px; }
table.t th:last-child, table.t td:last-child { padding-right: 24px; }
table.t .num { text-align: right; } table.t .zero { color: var(--faint); }
table.t tbody th { text-align: left; font-weight: 600; padding: 12px 16px; }
table.t tr.total { border-top: 2px solid var(--ink); background: var(--blue-row); }
table.t input.cell { width: 58px; min-height: 34px; text-align: center; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 14px; background: #fff; }
table.t input.cell:focus { border-color: var(--blue); outline: none; }
table.t input.cell.changed { border: 2px solid var(--blue); background: var(--blue-soft); color: var(--blue-dark); font-weight: 700; }
table.t .old { display: block; font-size: 11px; color: var(--muted); text-decoration: line-through; text-align: center; }
table.t select.cell { min-height: 34px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; max-width: 170px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink2); }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=password], input[type=file], select, textarea {
  min-height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--input); background: #fff;
  font: inherit; font-size: 14px; font-weight: 400; color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--blue-mid); outline-offset: 0; border-color: var(--blue); }
.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--input); border-radius: 10px; background: #fff; }
.search input { border: none; outline: none; min-height: 40px; padding: 0; flex: 1 1 auto; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 36px; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
select.title { min-height: 44px; font-weight: 600; border-radius: 10px; }

/* ---------- bars ---------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.barrow { display: grid; grid-template-columns: 320px minmax(0, 1fr) 110px; align-items: center; gap: 16px; font-size: 14px; }
.track { height: 12px; background: var(--line2); border-radius: 6px; }
.fill { height: 12px; background: var(--blue); border-radius: 6px; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 12px 16px; font-size: 14px; font-weight: 600; color: var(--ink2); text-decoration: none; }
.tabs a.active { color: var(--blue); border-bottom: 2px solid var(--blue); margin-bottom: -1px; }

/* ---------- dataset cards ---------- */
.dataset { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.dataset.missing { border-color: var(--warn-line); }
.dataset .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; border-top: 1px solid var(--line2); padding-top: 16px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; font-size: 14px; }
.kv strong { font-size: 20px; display: block; }

/* ---------- employee equation ---------- */
.eq { display: grid; grid-template-columns: 120px minmax(0, 1fr) 90px; align-items: center; gap: 16px; padding: 14px 18px; background: var(--bg); border-radius: 12px; }
.eq .parts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 15px; }
.eq .part { padding: 6px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.eq .part.hi { background: var(--blue-soft); border-color: var(--blue-soft); color: var(--blue-dark); }
.eq .res { font-size: 22px; font-weight: 700; text-align: right; }
.eq.total { background: none; border-top: 2px solid var(--ink); border-radius: 0; }

/* ---------- rule-set cards ---------- */
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.set { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.set.sel { border: 2px solid var(--blue); padding: 15px 17px; }
.set:hover { border-color: var(--blue-mid); color: var(--ink); }
details.newset summary { list-style: none; cursor: pointer; }
details.newset summary::-webkit-details-marker { display: none; }

/* ---------- KPI cards ---------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.tiers { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) 36px; gap: 8px; align-items: center; }
.tiers input { min-height: 36px; width: 100%; }
.example { background: var(--warn-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--warn-deep); }
.hr { border-top: 1px solid var(--line2); padding-top: 14px; }

/* ---------- misc ---------- */
.side { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.side > .main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.side > aside { flex: 1 1 320px; display: flex; flex-direction: column; gap: 20px; }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto; gap: 12px; align-items: center; padding: 10px 20px; border-top: 1px solid var(--bg); }
.pager { display: flex; gap: 8px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.drop { border: 2px dashed var(--input); border-radius: 14px; padding: 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; background: #fff; }
.issue { padding: 12px 16px; border-radius: 10px; font-size: 14px; }
.issue.err { background: var(--warn-soft); color: var(--warn-deep); }
.issue.wrn { background: var(--bg); color: var(--ink2); }
.issue ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink2); }

@media (max-width: 960px) {
  .stats, .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .steps, .steps.three { grid-template-columns: 1fr; }
  .barrow { grid-template-columns: 1fr; gap: 6px; }
  main.page, .wrap { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) { .stats, .grid3, .kv { grid-template-columns: 1fr; } }

/* ---------- sign-in + user menu ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: 72px 20px; display: flex; flex-direction: column; gap: 24px; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; padding: 6px 8px; border-radius: 10px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: var(--bg); }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(22,25,29,.10); min-width: 190px; padding: 6px; z-index: 20; display: flex; flex-direction: column; }
.usermenu .menu a, .usermenu .menu button { display: block; text-align: left; padding: 10px 12px; border-radius: 8px; color: var(--ink);
  text-decoration: none; font: inherit; font-size: 14px; background: none; border: none; cursor: pointer; width: 100%; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--bg); }
.usermenu form { margin: 0; }

/* ---------- icon button (row delete) ---------- */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--warn-soft); border-color: var(--line); outline: none; }

/* ---------- rules grid: add / edit in place ---------- */
table.rules-grid td { vertical-align: middle; }
table.rules-grid select.cell.wide { max-width: 320px; width: 100%; }
table.rules-grid input.cell[type=number] { width: 70px; }
table.rules-grid tr.newrow, table.rules-grid tr.editing { background: var(--blue-row); }
table.rules-grid .row-actions { white-space: nowrap; text-align: right; }
table.rules-grid .row-actions .btn + .btn, table.rules-grid .row-actions form { margin-left: 6px; }
.icon-btn.edit:hover, .icon-btn.edit:focus-visible { background: var(--blue-soft); }

/* ---------- Employees DB + line grid ---------- */
table.t select.cell.changed { border: 2px solid var(--blue); background: var(--blue-soft); }
table.rules-grid input.cell.id { width: 90px; }
table.rules-grid input.cell.name { width: 220px; text-align: left; padding: 0 8px; }
table.lines-grid { min-width: 1330px; }
table.lines-grid input.cell.num { width: 118px; text-align: right; padding: 0 8px; font-variant-numeric: tabular-nums; }
table.lines-grid td, table.lines-grid th { padding-left: 6px; padding-right: 6px; }
table.lines-grid .kpi-first { border-left: 1px solid var(--line); }
table.lines-grid th.kpi-head { border-left: 1px solid var(--line); color: var(--ink); }
table.lines-grid input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--blue); }
table.lines-grid tr.newrow { background: var(--blue-row); }
