:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --line: #e4e2dc;
  --line-strong: #cfccc4;
  --text: #1c1b19;
  --text-2: #55534e;
  --muted: #8a8780;
  --brand: #d9286f;
  --teal: #0a8090;
  --brand-ink: #ffffff;
  --brand-soft: #fde8f0;
  --s1: #2a78d6;  /* BL / Meta / received */
  --s2: #eb6834;  /* PT / Google / pending */
  --s3: #1baf7a;  /* RA / other */
  --good: #18794e; --good-bg: #e7f5ee;
  --warn: #9a5b00; --warn-bg: #fdf3e1;
  --bad:  #b42318; --bad-bg: #fdecea;
  --radius: 10px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--s1); }
.boot { padding: 40px; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: 0 8px 30px rgba(0,0,0,.05); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--text-2); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field input, .field select { height: 40px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 12px; background: #fff; }
.field input:focus, .field select:focus { outline: 2px solid var(--s1); outline-offset: -1px; border-color: transparent; }
.err { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 12px; }
.demo-note { margin-top: 16px; font-size: 12px; color: var(--warn); background: var(--warn-bg); padding: 10px; border-radius: 8px; }

/* ---------- buttons ---------- */
.btn { height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.block { width: 100%; height: 42px; justify-content: center; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 18px; height: 56px; }
.logo { font-weight: 800; letter-spacing: -.2px; display: flex; align-items: center; gap: 8px; }
.logo img { height: 38px; width: auto; display: block; }
.login-logo { display: block; width: 230px; max-width: 100%; margin: 0 auto 6px; }
.login-card .tag { text-align: center; color: var(--teal); font-weight: 600; margin: 0 0 22px; }
.nav { display: flex; gap: 2px; overflow-x: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.top .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; }
.who select { height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 8px; background: #fff; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.badge.admin { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.demo-bar { background: var(--warn-bg); color: var(--warn); font-size: 12px; padding: 6px 18px; border-bottom: 1px solid var(--line); }
main { padding: 18px; max-width: 1500px; margin: 0 auto; }
.page-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-h h2 { margin: 0; font-size: 20px; }
.page-h .sub { color: var(--muted); font-size: 13px; }
.page-h .grow { flex: 1; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; background: #fff; }

/* ---------- cards / tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 2px; font-size: 15px; }
.card .hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--text-2); font-weight: 600; }
.tile .v { font-size: 24px; font-weight: 750; margin-top: 4px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile .d.up { color: var(--good); } .tile .d.down { color: var(--bad); }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
@media (max-width: 1000px) { .g2, .g3 { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.t { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.t th { background: var(--surface-2); font-size: 12px; color: var(--text-2); position: sticky; top: 0; z-index: 1; }
table.t td.n, table.t th.n { text-align: right; }
table.t tr.total td { font-weight: 700; background: var(--surface-2); }
table.t tbody tr:hover td { background: #fcfbf9; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad  { background: var(--bad-bg);  color: var(--bad); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* ---------- entry grid (Excel-like) ---------- */
.month-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 10px; }
.month-tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px 8px 0 0; padding: 7px 12px;
  cursor: pointer; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.month-tabs button small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.month-tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.month-tabs button.on small { color: #ffe0ec; }
.sheet-wrap { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
table.sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.sheet th { position: sticky; top: 0; z-index: 2; background: #f0efea; border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong); padding: 6px 6px; font-size: 11.5px; text-align: left; color: var(--text-2); white-space: nowrap; }
table.sheet td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; height: 30px; background: #fff; }
table.sheet td.rn { position: sticky; left: 0; z-index: 1; background: #f6f5f1; color: var(--muted); font-size: 11px; text-align: center;
  min-width: 42px; border-right: 1px solid var(--line-strong); }
table.sheet th.rn { left: 0; z-index: 3; }
table.sheet td.rn .st { display: block; width: 6px; height: 6px; border-radius: 50%; margin: 2px auto 0; background: transparent; }
tr.saving td.rn .st { background: var(--s2); }
tr.saved td.rn .st { background: var(--good); }
tr.error td.rn .st { background: var(--bad); }
tr.error td { background: #fff6f5; }
tr.blank td:not(.rn) { background: #fdfdfb; }
table.sheet input, table.sheet select { width: 100%; height: 30px; border: 0; padding: 0 6px; background: transparent; outline: none; font-size: 13px; }
table.sheet input[type=number] { text-align: right; -moz-appearance: textfield; }
table.sheet input[type=number]::-webkit-inner-spin-button { display: none; }
table.sheet input[type=checkbox] { width: 16px; height: 16px; margin: 0 auto; display: block; }
table.sheet td:focus-within { outline: 2px solid var(--s1); outline-offset: -2px; position: relative; z-index: 1; background: #f5f9ff; }
table.sheet td.calc { text-align: right; padding: 0 8px; font-weight: 600; background: #fafaf7; }
table.sheet td.calc.due { color: var(--bad); background: var(--bad-bg); }
table.sheet td.calc.over { color: var(--warn); }
table.sheet td.del button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 28px; height: 28px; font-size: 16px; }
table.sheet td.del button:hover { color: var(--bad); }
table.sheet tr.hide { display: none; }
.sheet-foot { display: flex; gap: 20px; flex-wrap: wrap; padding: 10px 2px; color: var(--text-2); font-size: 13px; }
.sheet-foot b { color: var(--text); }
.help { font-size: 12px; color: var(--muted); }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: 11px; background: #fff; border: 1px solid var(--line-strong); border-bottom-width: 2px; padding: 0 5px; border-radius: 4px; }
.refresh-bar { background: #eef5ff; color: #1c4f8f; border: 1px solid #cfe1fb; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }

/* ---------- salary ---------- */
.sal-card .big { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.sal-rows { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.sal-rows span:nth-child(even) { text-align: right; font-weight: 600; }
.prog { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.prog i { display: block; height: 100%; background: var(--good); border-radius: 99px; }

/* ---------- upload ---------- */
.drop { display: block; border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-2); background: var(--surface-2); cursor: pointer; }
.drop.over { border-color: var(--s1); background: #eef5ff; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.form-row .field { margin: 0; }
.form-row .field input, .form-row .field select { height: 34px; }
.warnbox { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin: 10px 0; }
.okbox { background: var(--good-bg); color: var(--good); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin: 10px 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c1b19; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }
.section { margin-top: 14px; }
.muted { color: var(--muted); }
@media (max-width: 700px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .nav { order: 3; width: 100%; }
  main { padding: 12px; }
}
@media print { .top, .nav, .filters, .demo-bar { display: none; } }
