/* SJ Attendance — admin panel */
:root {
  --ink: #1d3f8f;
  --ink-2: #2c55b3;
  --ink-soft: #e4eaf7;
  --paper: #f6f8fc;
  --card: #ffffff;
  --rule: #dbe2ee;
  --rule-2: #bfcae0;
  --text: #18233a;
  --muted: #5b6577;
  --p: #19734a;   --p-soft: #e2f2e9;
  --a: #b42318;   --a-soft: #fdecea;
  --hd: #9a5a06;  --hd-soft: #fcefdb;
  --l: #6b45b8;   --l-soft: #eee8fa;
  --h: #5d6b82;   --h-soft: #eaeef4;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Hind", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side: 232px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--body); color: var(--text); background: var(--paper); }
[hidden] { display: none !important; }
a { color: var(--ink); }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); }
:focus-visible { outline: 3px solid var(--ink-2); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); line-height: 1.1; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.small { font-size: 13px; }

/* ---------- buttons, fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 8px; padding: 8px 14px; min-height: 40px; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-2); }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--rule-2); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn.danger { background: #fff; color: var(--a); box-shadow: inset 0 0 0 1.5px #efc2bd; }
.btn.good { background: var(--p); color: #fff; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; border-radius: 7px; }
.btn.wide { width: 100%; min-height: 46px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 40px; height: 40px; border: 0; background: transparent; border-radius: 50%; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: var(--ink-soft); }
.link-btn { border: 0; background: none; color: var(--ink); text-decoration: underline; cursor: pointer; padding: 0; font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--rule-2); border-radius: 8px; background: #fff; padding: 8px 10px; min-height: 42px;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }
.field small { color: var(--muted); font-size: 12.5px; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.span2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-error { color: var(--a); margin: 0; }
.form-error:empty { display: none; }
.days-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.days-pick label { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 99px; box-shadow: inset 0 0 0 1.5px var(--rule-2); cursor: pointer; background: #fff; }
.days-pick input { accent-color: var(--ink); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login-box img { border-radius: 14px; }
.login-box h1 { font-size: 36px; margin: 6px 0 0; }
.login-box p { margin: 0; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.topbar { display: none; }
.side {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--side); z-index: 30;
  background: #fff; border-right: 1px solid var(--rule); display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-family: var(--display); font-size: 21px; font-weight: 700; color: var(--ink); }
.brand img { border-radius: 8px; }
.co-pick { display: flex; flex-direction: column; gap: 4px; padding: 0 16px 14px; font-size: 12.5px; color: var(--muted); }
.co-pick select { border: 1.5px solid var(--rule-2); border-radius: 8px; padding: 7px 8px; background: #fff; font-weight: 600; color: var(--text); }
.co-fixed { padding: 0 18px 14px; font-weight: 600; }
.nav { display: flex; flex-direction: column; padding: 6px 0; border-top: 1px solid var(--rule); }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 18px; color: var(--text); text-decoration: none; font-weight: 500; border-left: 3px solid transparent;
}
.nav a:hover { background: var(--paper); }
.nav a.on { border-left-color: var(--ink); color: var(--ink); font-weight: 600; background: var(--ink-soft); }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--a); color: #fff; font-size: 12.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.side-foot { margin: auto 0 0; padding: 14px 18px; font-size: 12px; color: var(--muted); }
.side-back { display: none; }
.view { margin-left: var(--side); padding: 26px 32px 60px; max-width: 1400px; outline: none; }

@media (max-width: 960px) {
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
    background: #fff; border-bottom: 1px solid var(--rule); padding: 6px 10px;
  }
  .topbar-co { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--ink); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-badge { background: var(--a); color: #fff; text-decoration: none; border-radius: 99px; font-size: 13px; font-weight: 700; padding: 3px 10px; }
  .side { transform: translateX(-102%); transition: transform .2s ease; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  .shell.nav-open .side-back { display: block; position: fixed; inset: 0; background: rgba(13, 20, 36, .4); z-index: 25; }
  .view { margin-left: 0; padding: 16px 16px 60px; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 34px; margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.month-nav { display: inline-flex; align-items: center; gap: 2px; }
.month-nav b { font-family: var(--display); font-size: 22px; min-width: 104px; text-align: center; color: var(--text); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--h-soft); color: var(--h); }
.tag.lock { background: var(--text); color: #fff; }
.tag.open { background: var(--p-soft); color: var(--p); }
.tag.warn { background: var(--hd-soft); color: var(--hd); }
.note-box { padding: 10px 14px; border-radius: 8px; background: var(--hd-soft); color: #6b3f05; margin: 0 0 14px; }
.note-box.bad { background: var(--a-soft); color: var(--a); }
.note-box.info { background: var(--ink-soft); color: var(--ink); }
.note-box a { color: inherit; font-weight: 600; }
.section { margin-top: 30px; }
.section > h2 { font-size: 24px; margin: 0 0 10px; }
.empty { color: var(--muted); padding: 24px 0; }

/* stat strip (today) */
.strip { display: flex; flex-wrap: wrap; border-top: 2px solid var(--text); border-bottom: 1px solid var(--rule-2); margin-bottom: 20px; }
.strip > div { padding: 10px 22px 12px 0; margin-right: 22px; }
.strip > div + div { padding-left: 22px; border-left: 1px solid var(--rule); }
.strip b { display: block; font-family: var(--display); font-size: 34px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.strip span { color: var(--muted); font-size: 13px; }
@media (max-width: 600px) {
  .strip > div { padding: 8px 12px 10px 0; margin-right: 12px; }
  .strip > div + div { padding-left: 12px; }
  .strip b { font-size: 26px; }
}

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; background: transparent; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-top: 2px solid var(--text); border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
.tbl td { padding: 10px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: #fff; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
.tbl .name { font-weight: 600; }
.tbl .sub { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.tbl .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tbl tr.off td { color: var(--muted); }

.st { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.st-P { background: var(--p-soft); color: var(--p); }
.st-HD { background: var(--hd-soft); color: var(--hd); }
.st-A { background: var(--a-soft); color: var(--a); }
.st-L { background: var(--l-soft); color: var(--l); }
.st-H { background: var(--h-soft); color: var(--h); }
.st-MP { background: var(--hd-soft); color: var(--hd); }
.st-IN { background: var(--ink-soft); color: var(--ink); }
.st-NA, .st- { background: #f0f2f6; color: var(--muted); }
.thumb { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--h-soft); border: 0; padding: 0; cursor: zoom-in; vertical-align: middle; display: inline-block; }
.photo-big { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; background: #0d1424; display: block; }
.punch-cell { display: flex; align-items: center; gap: 8px; }
.punch-cell .t { font-variant-numeric: tabular-nums; font-weight: 600; }
.far { color: var(--a); font-weight: 600; }

/* ---------- register ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.legend b { font-family: var(--display); font-size: 16px; margin-right: 3px; }
.reg-wrap { overflow: auto; max-height: calc(100vh - 210px); border-top: 2px solid var(--text); background: #fff; }
.reg { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.reg th, .reg td { border-bottom: 1px solid var(--rule); border-right: 1px solid #edf1f7; padding: 0; text-align: center; }
.reg thead th { position: sticky; top: 0; z-index: 2; background: #fff; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 4px 0; border-bottom: 1px solid var(--rule-2); }
.reg thead th b { display: block; font-family: var(--display); font-size: 15px; color: var(--text); }
.reg .who { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left; padding: 6px 12px; min-width: 170px; max-width: 220px; border-right: 1px solid var(--rule-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg thead .who { z-index: 3; }
.reg .who .sub { color: var(--muted); font-size: 12px; }
.reg td.c { width: 32px; min-width: 32px; height: 40px; cursor: pointer; position: relative; font-family: var(--display); font-size: 17px; font-weight: 700; }
.reg td.c:hover { background: var(--ink-soft); }
.reg .offcol { background: #f3f5f9; }
.reg thead .offcol { background: #eef1f6; }
.reg .todaycol { box-shadow: inset 2px 0 0 var(--ink), inset -2px 0 0 var(--ink); }
.reg td.c .ot { position: absolute; right: 2px; top: 2px; font-size: 10px; font-family: var(--body); font-weight: 600; color: var(--ink); line-height: 1; }
.reg td.c.sw { font-style: italic; opacity: .7; }
.reg td.c.pre { opacity: .45; }
.reg td.c.late::before { content: ""; position: absolute; left: 7px; right: 7px; bottom: 5px; height: 2px; background: var(--a); border-radius: 2px; }
.reg td.c.ovr::after { content: ""; position: absolute; top: 0; left: 0; border-style: solid; border-width: 7px 7px 0 0; border-color: var(--ink) transparent transparent transparent; }
.reg td.tot { padding: 0 8px; min-width: 40px; font-weight: 600; font-size: 14px; }
.reg thead th.tot { padding: 4px 8px; }
.c-P { color: var(--p); } .c-HD { color: var(--hd); } .c-A { color: var(--a); } .c-L { color: var(--l); }
.c-H { color: var(--h); } .c-MP { color: var(--hd); } .c-IN { color: var(--ink); } .c-NA { color: var(--rule-2); }

/* ---------- salary ---------- */
.sal td, .sal th { font-size: 14px; }
.sal .net { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--ink); }
.sal .warn-dot { color: var(--hd); font-weight: 700; }

/* ---------- cards (approvals) ---------- */
.req { border-top: 2px solid var(--text); padding: 14px 0 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px 28px; }
.req + .req { border-top: 1px solid var(--rule-2); }
.req h3 { font-size: 22px; margin: 0; color: var(--text); }
.req .ask { font-family: var(--display); font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.1; margin-top: 4px; }
.req .why { margin-top: 8px; padding-left: 10px; border-left: 3px solid var(--rule-2); }
.req .meta { color: var(--muted); font-size: 13.5px; }
.req .bill { margin-top: 10px; max-width: 160px; max-height: 160px; border-radius: 8px; cursor: zoom-in; display: block; border: 1px solid var(--rule); }
.req form .row { margin-top: 4px; }
@media (max-width: 760px) { .req { grid-template-columns: 1fr; } }

/* ---------- settings ---------- */
.settings fieldset { border: 0; border-top: 2px solid var(--text); margin: 0 0 26px; padding: 14px 0 0; }
.settings legend { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--ink); padding: 0 10px 0 0; }
.settings .help { color: var(--muted); font-size: 13.5px; margin: -2px 0 10px; max-width: 70ch; }
.qr-box { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.qr-box #qr { background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--rule); }
.copy-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copy-line code { background: #fff; border: 1px solid var(--rule); border-radius: 6px; padding: 6px 10px; font-size: 14px; word-break: break-all; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(to top, var(--paper) 70%, rgba(246, 248, 252, 0)); padding: 16px 0 10px; display: flex; gap: 12px; align-items: center; }

@media (max-width: 760px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .page-head h1 { font-size: 28px; }
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-back { position: absolute; inset: 0; background: rgba(13, 20, 36, .45); }
.modal-box { position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: 14px; box-shadow: 0 24px 60px rgba(13, 20, 36, .3); }
.modal-box.wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 14px 8px 22px; position: sticky; top: 0; background: var(--paper); z-index: 1; border-bottom: 1px solid var(--rule); }
.modal-head h2 { margin: 0; font-size: 26px; }
.modal-body { padding: 16px 22px 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.modal-actions .left { margin-right: auto; }
@media (max-width: 600px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { max-height: 94vh; border-radius: 16px 16px 0 0; }
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.punch-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.punch-pair > div { background: #fff; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--rule); padding: 10px 12px; }
.punch-pair h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.punch-pair .big { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1; }
.punch-pair img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; margin-top: 8px; background: var(--h-soft); cursor: zoom-in; display: block; }

/* ---------- toast ---------- */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 70; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; max-width: min(420px, calc(100% - 40px)); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.toast.good { background: var(--p); }
.toast.bad { background: var(--a); }

/* ---------- print ---------- */
.print-area { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .side, .topbar, .side-back, .no-print, .toast, .modal { display: none !important; }
  .view { margin: 0; padding: 0; max-width: none; }
  .reg-wrap { max-height: none; overflow: visible; }
  .reg td.c { height: 24px; width: 22px; min-width: 22px; font-size: 13px; }
  .reg .who { min-width: 120px; }
  body.print-slips .shell { display: none !important; }
  body.print-slips .print-area { display: block; }
}
.slip { page-break-inside: avoid; border: 1.5px solid #18233a; padding: 14px 16px; margin-bottom: 14px; font-size: 12.5px; }
.slip-head { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1.5px solid #18233a; padding-bottom: 8px; margin-bottom: 8px; }
.slip-head h3 { margin: 0; font-size: 20px; color: #18233a; }
.slip-head .r { text-align: right; }
.slip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.slip table { width: 100%; border-collapse: collapse; }
.slip td { padding: 3px 0; border-bottom: 1px dotted #c3cbd9; }
.slip td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.slip .net-line { margin-top: 10px; display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; border-top: 1.5px solid #18233a; padding-top: 6px; }
.slip .words { font-size: 11.5px; color: #444; margin-top: 2px; }
.slip .sign { display: flex; justify-content: space-between; margin-top: 26px; font-size: 11.5px; color: #444; }
.strip b small { font-size: 18px; color: var(--muted); font-weight: 500; }
.thumb.sq { border-radius: 6px; }
@media (max-width: 600px) {
  .tbl.stack-sm thead { display: none; }
  .tbl.stack-sm tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .tbl.stack-sm tbody td { border: 0; padding: 0; text-align: left; }
  .tbl.stack-sm tbody td:first-child { grid-column: 1 / -1; }
  .tbl.stack-sm tbody td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
  .tbl.stack-sm tbody td.num { text-align: left; }
}
