/* Balaji HR */
:root {
  --ground: #F6F5F1; --surface: #FFFFFF; --ink: #1C1B19; --muted: #5E5B55; --muted2: #4A4740;
  --line: #E3E0D8; --line2: #EEECE6; --field: #CFCAC0;
  --accent: #A84B08; --accent-ink: #8F3F06; --accent-soft: #FBEFE3;
  --side: #1F2420; --side-on: #343B36; --side-ink: #C9C6BE; --side-muted: #B3B0A8;
  --good-bg: #E3F1E8; --good: #1E5E3D; --warn-bg: #FBEFD5; --warn: #7A4E00;
  --bad-bg: #FBE5E2; --bad: #9A2419; --info-bg: #E4ECF7; --info: #24497A; --neutral-bg: #EDEBE5;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.45; }
a { color: var(--accent-ink); }
a:hover { color: #6E3005; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.muted { color: var(--muted); }
.muted-light { color: var(--side-muted); }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* layout */
.app { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.side { flex: 1 1 220px; max-width: 100%; background: var(--side); color: #E9E6DF; padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--side-muted); }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
.nav-item:hover { background: #2A302C; color: #fff; }
.nav-item.on { background: var(--side-on); color: #fff; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex: none; }
.nav-item.on .dot { background: #E39A5B; }
.device-card { margin-top: auto; border: 1px solid #39413B; border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.device-status { display: flex; align-items: center; gap: 8px; color: #D9D6CE; }
.led { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.led-on { background: #5BC48A; } .led-off { background: #C9655B; }
.me { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.me-actions { display: flex; gap: 14px; margin-top: 6px; align-items: center; }
.me-actions a, .me .linkish { color: #E9C9A8; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 32px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar h1 { font-size: 20px; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.content { padding: 24px 32px 64px; display: flex; flex-direction: column; gap: 20px; max-width: 1240px; width: 100%; }
@media (max-width: 640px) { .topbar { padding: 14px 16px; } .content { padding: 16px 16px 48px; } .side { padding: 16px; } }

/* cards, grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.row > .grow { flex: 2 1 420px; min-width: 0; }
.row > .side-col { flex: 1 1 280px; min-width: 0; }
.list-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line2); }
.list-item:first-child { border-top: 0; }
dl.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 24px; margin: 0; }
dl.fields dt { font-size: 12px; color: var(--muted); font-weight: 500; }
dl.fields dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.empty-state { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table-wrap.flat { border: 0; border-radius: 0; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; padding: 12px 14px; white-space: nowrap; }
table.t td { padding: 11px 14px; border-top: 1px solid var(--line2); vertical-align: middle; }
table.t td.tight, table.t th.tight { padding: 6px 8px; }
table.t .r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.who { display: flex; flex-direction: column; gap: 1px; }
.who .id { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--muted); }

/* chips */
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-good { background: var(--good-bg); color: var(--good); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-neutral { background: var(--neutral-bg); color: var(--muted2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid var(--field); border-radius: 8px; background: var(--surface); color: var(--ink); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #F2F0EB; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-danger { color: var(--bad); border-color: #D9A39C; font-weight: 600; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions.end { justify-content: flex-end; }
form.inline { display: inline; }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 13px; font-weight: 500; color: var(--muted2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 8px; background: var(--surface); }
textarea.input { padding: 10px 12px; min-height: 80px; resize: vertical; }
.input-sm { min-height: 38px; padding: 0 8px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
fieldset.section { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
fieldset.section legend { font-size: 17px; font-weight: 600; padding: 0; margin-bottom: 4px; }
.section + .section { padding-top: 22px; border-top: 1px solid var(--line2); }
.error-text { color: var(--bad); font-size: 13px; }

/* flash */
.flash { padding: 12px 16px; border-radius: 10px; font-weight: 500; }
.flash-success { background: var(--good-bg); color: var(--good); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-info { background: var(--info-bg); color: var(--info); }
.note { padding: 14px 16px; border-radius: 10px; background: var(--ground); border: 1px solid var(--line); color: var(--muted2); }
.note-warn { background: var(--warn-bg); border-color: #EBD3A0; color: var(--warn); }

/* profile */
.profile-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.timeline li { display: flex; gap: 12px; }
.timeline .tdot { width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--field); flex: none; }

/* roster */
.roster td.cell { padding: 5px; vertical-align: top; min-width: 132px; }
.roster td.changed { background: var(--accent-soft); }
.roster td.off { background: #F2F0EB; }
.roster th.today { color: var(--accent-ink); }
.roster .custom-times { display: flex; gap: 4px; margin-top: 5px; }
.roster .custom-times input { min-width: 0; flex: 1; }
.roster .custom-times[hidden] { display: none; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; border: 1px solid #E8CBAE; background: var(--accent-soft); }

/* plain pages (sign-in) */
body.plain { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px 16px; }
.plain-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.plain-brand { text-align: center; }
.plain-card { padding: 28px; gap: 16px; }
.qr { display: flex; justify-content: center; padding: 8px; background: #fff; }
.secret { font-family: 'IBM Plex Mono', monospace; font-size: 15px; letter-spacing: .08em; word-break: break-all; background: var(--ground); padding: 10px 12px; border-radius: 8px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: 'IBM Plex Mono', monospace; }

/* payslip print */
.payslip { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; max-width: 760px; page-break-after: always; break-after: page; }
.payslip h2 { font-size: 20px; }
.payslip table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.payslip td { padding: 6px 0; border-bottom: 1px solid var(--line2); }
.payslip td.r { text-align: right; font-variant-numeric: tabular-nums; }
.payslip .total td { font-weight: 700; border-bottom: 2px solid var(--ink); }
.payslip-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
@media print {
  .side, .topbar, .no-print, .flash { display: none !important; }
  body, .main, .content { background: #fff; padding: 0; margin: 0; }
  .payslip { border: 0; padding: 0; max-width: none; }
  .content { gap: 0; }
}

/* expandable fix forms */
details.fix > summary { list-style: none; display: inline-flex; }
details.fix > summary::-webkit-details-marker { display: none; }
details.fix[open] > summary { background: var(--accent-soft); }
details.fix > form { position: relative; z-index: 2; }

/* fixes after visual check */
.table-wrap, .card, .roster td { position: relative; }
.content > * { min-width: 0; }
.date-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.date-nav .input { width: auto; min-width: 0; }
.date-nav input[type=date] { width: 160px; }
.date-nav select { width: 170px; }
.me-actions { flex-wrap: wrap; gap: 6px 14px; }
.row > * { min-width: 0; max-width: 100%; }
.roster td.cell { min-width: 158px; width: 158px; }
.roster .custom-times { flex-direction: column; }
.roster select { font-size: 13px; }
.after-table { margin-top: 16px; }
.shift-name { min-width: 180px; }
.actions > .input { width: auto; }
