/* Layout idea: fixed deep-navy command rail + quiet paper workspace; dense, scannable tiles; state carried by stripes and pills. */
:root {
  --bg: #F3F4F7;
  --surface: #FFFFFF;
  --surface-2: #F6F7FA;
  --line: #E1E5EC;
  --line-strong: #CBD2DD;
  --ink: #111A2E;
  --ink-2: #48546A;
  --ink-3: #7A8498;
  --navy: #0D1A35;
  --navy-2: #16274B;
  --navy-ink: #C9D3E6;
  --accent: #23468F;
  --accent-ink: #FFFFFF;
  --accent-soft: #E8EDF8;
  --good: #2F7D5B;   --good-bg: #E5F2EB;
  --warn: #A86A12;   --warn-bg: #FBF0DC;
  --crit: #B8382C;   --crit-bg: #FAE6E3;
  --info: #3657A8;   --info-bg: #E6ECF8;
  --violet: #6A4DA6; --violet-bg: #EEE9F8;
  --muted-bg: #ECEEF2;
  --shadow: 0 1px 2px rgba(13,26,53,.06), 0 4px 16px rgba(13,26,53,.05);
  --shadow-lg: 0 10px 40px rgba(13,26,53,.18);
  --radius: 10px;
  --font-body: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "IBM Plex Sans Condensed", "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1020; --surface: #111A2D; --surface-2: #162036; --line: #222D45; --line-strong: #33405C;
    --ink: #E8ECF4; --ink-2: #AEB7C9; --ink-3: #7E8AA2;
    --navy: #070D1C; --navy-2: #111C36; --navy-ink: #B4C0D8;
    --accent: #8FAEF5; --accent-ink: #0A1020; --accent-soft: #1B2847;
    --good: #5FC296; --good-bg: #13291F; --warn: #E2AE52; --warn-bg: #2E2312;
    --crit: #F07C70; --crit-bg: #331715; --info: #8EA8EE; --info-bg: #17223D;
    --violet: #B49DEA; --violet-bg: #231B38; --muted-bg: #1A2338;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1020; --surface: #111A2D; --surface-2: #162036; --line: #222D45; --line-strong: #33405C;
  --ink: #E8ECF4; --ink-2: #AEB7C9; --ink-3: #7E8AA2;
  --navy: #070D1C; --navy-2: #111C36; --navy-ink: #B4C0D8;
  --accent: #8FAEF5; --accent-ink: #0A1020; --accent-soft: #1B2847;
  --good: #5FC296; --good-bg: #13291F; --warn: #E2AE52; --warn-bg: #2E2312;
  --crit: #F07C70; --crit-bg: #331715; --info: #8EA8EE; --info-bg: #17223D;
  --violet: #B49DEA; --violet-bg: #231B38; --muted-bg: #1A2338;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
[dir="rtl"] body, body[dir="rtl"] { font-family: "IBM Plex Sans Arabic", var(--font-body); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -.005em; text-wrap: balance; }
h1 { font-size: 24px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); }
.num, td, .tile-value { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- app frame ---------- */
#app { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100%; }
#app.collapsed { grid-template-columns: 72px minmax(0, 1fr); }
.sidebar { background: var(--navy); color: var(--navy-ink); display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 18px 12px 14px; gap: 18px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(160deg, #2C4A8C, #142650); display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.brand-text { min-width: 0; }
.brand-name { color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: #8E9BB8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6E7C9C; padding: 0 10px 6px; font-weight: 600; }
[dir="rtl"] .nav-label { letter-spacing: 0; font-size: 11.5px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--navy-ink); text-decoration: none; border: 0; background: none; cursor: pointer; width: 100%; text-align: start; font-size: 13.5px; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(124,155,230,.16); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #8FAEF5; }
[dir="rtl"] .nav-item.active::before { border-radius: 3px 0 0 3px; }
.nav-item svg { flex: none; opacity: .9; }
.nav-count { margin-inline-start: auto; background: #C2453A; color: #fff; font-size: 11px; border-radius: 10px; padding: 0 7px; line-height: 18px; font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.demo-chip { font-size: 11px; color: #F4D58D; border: 1px solid rgba(244,213,141,.35); border-radius: 6px; padding: 6px 8px; line-height: 1.35; }
.store-chip { font-size: 11px; color: #8E9BB8; display: flex; gap: 6px; align-items: center; padding: 0 6px; }
.store-dot { width: 7px; height: 7px; border-radius: 50%; background: #5FC296; flex: none; }
.store-dot.local { background: #E2AE52; } .store-dot.memory { background: #F07C70; } .store-dot.saving { background: #8FAEF5; }
#app.collapsed .brand-text, #app.collapsed .nav-label, #app.collapsed .nav-text, #app.collapsed .demo-chip, #app.collapsed .store-text, #app.collapsed .nav-count { display: none; }
#app.collapsed .nav-item { justify-content: center; }

.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 60px; }
.topbar-title { min-width: 0; flex: 1; }
.crumbs { font-size: 12px; color: var(--ink-3); }
.topbar-title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { text-align: end; font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.clock b { color: var(--ink); font-weight: 600; font-size: 13px; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); position: relative; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .dot { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 600; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.lang-btn { height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.lang-btn:hover { color: var(--ink); background: var(--surface-2); }
#view { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px 28px 48px; min-height: 0; }
.view-inner { max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.bottom-nav { display: none; }

/* ---------- primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; flex-wrap: wrap; }
.card-head h2 { flex: 1; min-width: 0; }
.card-body { padding: 0 18px 18px; }
.card-sub { font-size: 12.5px; color: var(--ink-3); font-weight: 400; font-family: var(--font-body); }
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; font-size: 13.5px; white-space: nowrap; transition: background .12s, border-color .12s; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); }
.btn.danger.solid { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--muted-bg); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); flex-wrap: nowrap; max-width: 100%; overflow-x: auto; }
.btn-group button { border: 0; background: none; padding: 0 12px; height: 34px; cursor: pointer; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.btn-group button + button { border-inline-start: 1px solid var(--line); }
.btn-group button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--muted-bg); color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.plain::before { display: none; }
.pill.present, .pill.approved, .pill.active, .pill.good { background: var(--good-bg); color: var(--good); }
.pill.late, .pill.pending, .pill.probation, .pill.warning { background: var(--warn-bg); color: var(--warn); }
.pill.absent, .pill.rejected, .pill.critical, .pill.terminated { background: var(--crit-bg); color: var(--crit); }
.pill.on_leave, .pill.info { background: var(--info-bg); color: var(--info); }
.pill.permission { background: var(--violet-bg); color: var(--violet); }
.pill.not_recorded { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.pill.not_recorded::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.pill.cancelled, .pill.suspended, .pill.resigned, .pill.archived, .pill.rest_day, .pill.official_holiday { background: var(--muted-bg); color: var(--ink-3); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--muted-bg); color: var(--ink-2); font-weight: 500; }
.demo-tag { background: #FFF3CF; color: #7A5600; font-weight: 600; letter-spacing: .02em; }
:root[data-theme="dark"] .demo-tag { background: #3A2E0E; color: #F4D58D; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; color: #fff; background: var(--navy-2); letter-spacing: .02em; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-text { min-width: 0; }
.who-name { display: block; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-sub { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.who, button.who { text-decoration: none; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: start; }
a.who:hover .who-name, button.who:hover .who-name { color: var(--accent); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, select.input, textarea.input { height: 40px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 11px; background: var(--surface); width: 100%; min-width: 0; }
textarea.input { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.input.sm { height: 34px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; min-width: 0; }
.search svg { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search .input { padding-inline-start: 36px; height: 38px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select.input { width: auto; height: 38px; min-width: 130px; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; text-align: start; }
button.tile { cursor: pointer; font: inherit; color: inherit; }
button.tile:hover { border-color: var(--line-strong); }
.tile::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--tile-c, transparent); }
.tile-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tile-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.1; color: var(--ink); }
.tile-value small { font-size: 14px; color: var(--ink-3); font-weight: 500; font-family: var(--font-body); }
.tile-foot { font-size: 12px; color: var(--ink-3); }
.tile.good { --tile-c: var(--good); } .tile.warn { --tile-c: var(--warn); } .tile.crit { --tile-c: var(--crit); }
.tile.info { --tile-c: var(--info); } .tile.violet { --tile-c: var(--violet); } .tile.navy { --tile-c: var(--accent); }
.meter { height: 6px; background: var(--muted-bg); border-radius: 3px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- dashboard ---------- */
.hello { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.hello h1 { font-size: 26px; }
.hello .sub { color: var(--ink-2); margin-top: 3px; }
.dash-a { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-b { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stackbar { display: flex; height: 16px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface); }
.stackbar > span { display: block; height: 100%; min-width: 3px; cursor: default; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 12px; }
.legend button { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 2px 0; cursor: pointer; color: inherit; font-size: inherit; }
.legend b { color: var(--ink); font-weight: 600; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.c-present { background: var(--good); } .c-late { background: var(--warn); } .c-absent { background: var(--crit); }
.c-on_leave { background: var(--info); } .c-permission { background: var(--violet); }
.c-official_holiday, .c-rest_day { background: var(--line-strong); }
.c-not_recorded { background: repeating-linear-gradient(135deg, var(--ink-3) 0 2px, transparent 2px 5px); box-shadow: inset 0 0 0 1px var(--ink-3); }
.people { display: flex; flex-direction: column; max-height: 360px; overflow-y: auto; margin: 0 -18px; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: start; }
.person-row:hover { background: var(--surface-2); }
.person-row .who { flex: 1; }
.person-row .times { font-size: 12.5px; color: var(--ink-2); text-align: end; }
.attn { display: flex; flex-direction: column; margin: 0 -18px; max-height: 420px; overflow-y: auto; }
.attn-item { display: grid; grid-template-columns: 3px 1fr auto; gap: 12px; align-items: center; padding: 10px 18px 10px 15px; border-top: 1px solid var(--line); }
[dir="rtl"] .attn-item { padding: 10px 15px 10px 18px; }
.attn-item .stripe { align-self: stretch; border-radius: 2px; }
.attn-item.critical .stripe { background: var(--crit); } .attn-item.warning .stripe { background: var(--warn); } .attn-item.info .stripe { background: var(--info); }
.attn-title { font-weight: 500; font-size: 13.5px; }
.attn-sub { font-size: 12px; color: var(--ink-3); }
.attn-group-head { padding: 8px 18px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); background: var(--surface-2); border-top: 1px solid var(--line); text-transform: uppercase; letter-spacing: .06em; display: flex; gap: 8px; align-items: center; }
[dir="rtl"] .attn-group-head { letter-spacing: 0; }
.empty { padding: 28px 18px; text-align: center; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty svg { color: var(--line-strong); }
.empty b { color: var(--ink-2); font-weight: 600; }
.qa { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qa button { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); cursor: pointer; text-align: start; font-size: 13px; font-weight: 500; color: var(--ink); min-height: 52px; }
.qa button:hover { border-color: var(--accent); background: var(--accent-soft); }
.qa .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--accent); flex: none; border: 1px solid var(--line); }
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font-body); }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart-wrap { position: relative; }
.tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 7px; box-shadow: var(--shadow-lg); white-space: nowrap; z-index: 5; transform: translate(-50%, calc(-100% - 10px)); line-height: 1.45; }
.tip b { font-weight: 600; }
.hbar { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 52px; gap: 10px; align-items: center; font-size: 12.5px; padding: 5px 0; }
.hbar .track { height: 10px; background: var(--muted-bg); border-radius: 0 4px 4px 0; overflow: hidden; }
[dir="rtl"] .hbar .track { border-radius: 4px 0 0 4px; }
.hbar .track > i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); }
[dir="rtl"] .hbar .track > i { border-radius: 4px 0 0 4px; margin-inline-start: 0; }
.hbar .v { text-align: end; color: var(--ink-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: start; font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
[dir="rtl"] .t th { letter-spacing: 0; font-size: 12px; }
.t th:first-child, .t td:first-child { padding-inline-start: 18px; }
.t th:last-child, .t td:last-child { padding-inline-end: 18px; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tbody tr:hover { background: var(--surface-2); }
.t tbody tr.sel { background: var(--accent-soft); }
.t tfoot td { font-weight: 600; background: var(--surface-2); border-bottom: 0; }
.t .r { text-align: end; }
.t .acts { text-align: end; white-space: nowrap; }
.t .acts .btn + .btn { margin-inline-start: 4px; }
.sortable { cursor: pointer; user-select: none; }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 18px; font-size: 12.5px; color: var(--ink-3); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 11px 14px; cursor: pointer; color: var(--ink-2); font-weight: 500; position: relative; white-space: nowrap; font-size: 13.5px; }
.tabs button.on { color: var(--ink); font-weight: 600; }
.tabs button.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.tabs .count { font-size: 11px; background: var(--muted-bg); border-radius: 9px; padding: 0 6px; margin-inline-start: 5px; color: var(--ink-2); }

/* employee grid */
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; padding: 16px 18px 18px; }
.emp-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); cursor: pointer; text-align: start; }
.emp-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }

/* profile */
.profile-head { display: flex; gap: 18px; align-items: center; padding: 20px; flex-wrap: wrap; }
.profile-head .id { flex: 1; min-width: 220px; }
.profile-head h1 { font-size: 22px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.profile-meta span { display: inline-flex; align-items: center; gap: 5px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--ink-3); text-align: center; padding-bottom: 4px; font-weight: 600; }
.cal .day { min-height: 56px; border-radius: 7px; border: 1px solid var(--line); padding: 5px 6px; font-size: 11.5px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); cursor: pointer; text-align: start; color: var(--ink); }
.cal .day.out { visibility: hidden; }
.cal .day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal .day .dn { font-weight: 600; font-size: 12px; }
.cal .day.s-present { background: var(--good-bg); } .cal .day.s-late { background: var(--warn-bg); } .cal .day.s-absent { background: var(--crit-bg); }
.cal .day.s-on_leave { background: var(--info-bg); } .cal .day.s-official_holiday, .cal .day.s-rest_day { background: var(--surface-2); color: var(--ink-3); }
.cal .day.s-not_recorded { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--muted-bg) 6px 8px); }
.cal .day.future { opacity: .55; }
.leave-cal .day { min-height: 92px; cursor: default; }
.leave-cal .chip { font-size: 11px; border-radius: 4px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--info-bg); color: var(--info); }
.leave-cal .chip.pending { background: transparent; box-shadow: inset 0 0 0 1px var(--warn); color: var(--warn); }
.leave-cal .day.gap { box-shadow: inset 0 0 0 2px var(--crit); }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 10px 0; position: relative; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: 13px; top: 34px; bottom: -8px; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-2); }
.diff { font-size: 12px; color: var(--ink-2); margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.diff s { color: var(--ink-3); }

/* banners */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 9px; border: 1px solid; font-size: 13px; }
.banner.demo { background: #FFF8E1; border-color: #F1D98F; color: #5C4300; }
:root[data-theme="dark"] .banner.demo { background: #2A220C; border-color: #5C4A16; color: #F4D58D; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner.demo { background: #2A220C; border-color: #5C4A16; color: #F4D58D; } :root:not([data-theme="light"]) .demo-tag { background: #3A2E0E; color: #F4D58D; } }
.banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--ink); }
.banner.crit { background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit) 35%, transparent); color: var(--ink); }
.banner.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--ink); }
.banner svg { flex: none; margin-top: 1px; }
.banner .grow { flex: 1; min-width: 0; }

.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.calc div { display: flex; flex-direction: column; gap: 1px; }
.calc span { font-size: 11.5px; color: var(--ink-3); }
.calc b { font-size: 15px; font-variant-numeric: tabular-nums; }
.bulkbar { position: sticky; top: 0; z-index: 3; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); }
.bulkbar .btn { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); }
.bulkbar .btn:hover { background: rgba(255,255,255,.18); }
.datenav { display: flex; align-items: center; gap: 6px; }
.datenav .input { width: 160px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.chips button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chips button b { color: var(--ink); font-weight: 600; }

/* ---------- modal / toast / sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8,14,30,.48); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(620px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; animation: pop .18s ease-out; }
.modal.wide { width: min(820px, 100%); }
.modal.narrow { width: min(440px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: .5; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; }
.modal-head h2 { flex: 1; font-size: 18px; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.err { color: var(--crit); font-size: 13px; background: var(--crit-bg); border-radius: 8px; padding: 9px 12px; }
#toasts { position: fixed; bottom: 22px; inset-inline-end: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100% - 32px); }
.toast { background: var(--navy); color: #fff; padding: 11px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; display: flex; gap: 10px; align-items: center; animation: pop .2s; max-width: 420px; }
.toast.err { background: #7F1D17; color: #fff; }
.sheet { position: fixed; inset: auto 0 0 0; background: var(--surface); border-radius: 16px 16px 0 0; z-index: 55; padding: 10px 14px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 10px; }
.sheet .nav-item { color: var(--ink); padding: 13px 12px; font-size: 15px; }
.sheet .nav-item:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--surface); }
.login-art { background: var(--navy); color: #C9D3E6; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; }
.login-art > * { position: relative; }
.login-art h1 { color: #fff; font-size: 34px; max-width: 14ch; line-height: 1.12; }
.login-art p { max-width: 46ch; margin-top: 14px; color: #A9B6D2; }
.login-form { display: grid; place-items: center; padding: 32px 24px; }
.login-box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-box h2 { font-size: 22px; }
.pin { font-size: 20px; letter-spacing: .3em; text-align: center; height: 50px; }
.fineprint { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.splash { height: 100%; display: grid; place-items: center; background: var(--navy); color: #C9D3E6; text-align: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: #8FAEF5; animation: spin .8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .dash-a, .dash-b { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  #app, #app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); min-height: 56px; position: sticky; top: 0; z-index: 4; }
  .clock { display: none; }
  #view { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; box-shadow: 0 -4px 20px rgba(13,26,53,.06); }
  .bottom-nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-3); padding: 6px 2px; cursor: pointer; position: relative; min-height: 50px; }
  .bottom-nav button.on { color: var(--accent); font-weight: 600; }
  .bottom-nav .dot { position: absolute; top: 2px; inset-inline-end: calc(50% - 20px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--crit); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px 13px; }
  .tiles > .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tile-value { font-size: 24px; }
  .hello h1 { font-size: 21px; }
  .hello > .row { width: 100%; min-width: 0; }
  .hello .btn-group { flex: 1 1 100%; min-width: 0; }
  .hello .btn-group button { flex: 1 0 auto; padding: 0 10px; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar select.input { flex: 1 1 140px; min-width: 0; }
  .overlay { padding: 0; place-items: end stretch; }
  .modal, .modal.wide, .modal.narrow { width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .input, select.input { height: 44px; font-size: 16px; }
  .btn { height: 42px; }
  .btn.sm { height: 36px; }
  #toasts { inset-inline: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { padding: 28px 22px; padding-top: calc(28px + env(safe-area-inset-top)); min-height: 220px; }
  .login-art h1 { font-size: 26px; }
  .login-art .art-foot { display: none; }
  .hide-m { display: none !important; }
  .cal .day { min-height: 44px; padding: 3px 4px; }
  .cal .day .lbl { display: none; }
  .leave-cal .day { min-height: 54px; }
  .leave-cal .chip { display: none; }
  .leave-cal .chip-count { display: block !important; }
  .hbar { grid-template-columns: minmax(70px, 110px) 1fr 44px; }

  /* tables become cards */
  table.t.cards, .t.cards thead, .t.cards tbody, .t.cards tr, .t.cards td, .t.cards tfoot { display: block; width: 100%; }
  .t.cards thead { display: none; }
  .t.cards tr { border-bottom: 1px solid var(--line); padding: 12px 16px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; }
  .t.cards td { border: 0; padding: 0 !important; display: flex; flex-direction: column; gap: 1px; min-width: 0; text-align: start !important; }
  .t.cards td::before { content: attr(data-label); font-size: 11px; color: var(--ink-3); font-weight: 600; }
  .t.cards td.lead, .t.cards td.acts, .t.cards td.wide { grid-column: 1 / -1; }
  .t.cards td.lead::before, .t.cards td.acts::before, .t.cards td.nolabel::before { display: none; }
  .t.cards td.acts { flex-direction: row; flex-wrap: wrap; gap: 6px; justify-content: flex-start; margin-top: 4px; }
  .t.cards td.acts .btn { flex: 1 1 auto; height: 38px; }
  .t.cards td.acts .btn + .btn { margin: 0; }
  .t.cards td.sel-cell { position: absolute; }
  .t.cards tr.has-sel { position: relative; padding-inline-start: 48px; }
  .t.cards tr.has-sel td.sel-cell { inset-inline-start: 14px; top: 14px; }
  .t.cards tr.has-sel td.sel-cell::before { display: none; }
  .t.cards tfoot tr { background: var(--surface-2); }
}
@media (max-width: 400px) {
  .tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tile-value { font-size: 21px; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print { display: none !important; }
  #app { display: block; }
  #view { overflow: visible; padding: 0; }
}

/* ---------- v2: work & performance ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.board-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 4px; }
.board-card { display: flex; flex-direction: column; gap: 6px; text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; color: var(--ink); box-shadow: var(--shadow); }
.board-card:hover { border-color: var(--accent); }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.proj-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
a.proj-card:hover { border-color: var(--accent); }
.proj-card .meter { flex: 1; }
.row > .meter { flex: 1; }
table.roster td { vertical-align: top; min-width: 96px; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.sheet-grid .nav-item { padding: 11px 10px; font-size: 14px; }
.nav-group + .nav-group { margin-top: -4px; }
.sidebar .nav-item { padding: 8px 10px; }
input[type="range"] { accent-color: var(--accent); }
@media (max-width: 1180px) { .board { grid-template-columns: repeat(5, minmax(220px, 1fr)); } }
@media (max-width: 860px) {
  .board { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .board-col { min-height: 0; }
  .proj-grid { grid-template-columns: minmax(0, 1fr); }
  table.roster { min-width: 760px; }
}

.tiles.t8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .tiles.t8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sheet-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sheet-grid .nav-item { min-width: 0; }
.sheet-grid .nav-item span:not(.nav-count) { min-width: 0; overflow-wrap: anywhere; }
