:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e7ef;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --sidebar: #111827;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1f2937;
  --green: #059669; --green-bg: #d1fae5;
  --red: #dc2626; --red-bg: #fee2e2;
  --amber: #d97706; --amber-bg: #fef3c7;
  --blue: #2563eb; --blue-bg: #dbeafe;
  --purple: #7c3aed; --purple-bg: #ede9fe;
  --gray: #475569; --gray-bg: #e2e8f0;
  --teal: #0d9488; --teal-bg: #ccfbf1;
  --orange: #ea580c; --orange-bg: #ffedd5;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #818cf8;
  --primary-600: #6366f1;
  --primary-50: #1e1b4b;
  --sidebar: #030712;
  --sidebar-active: #111827;
  --green-bg: #064e3b; --green: #6ee7b7;
  --red-bg: #7f1d1d; --red: #fca5a5;
  --amber-bg: #78350f; --amber: #fcd34d;
  --blue-bg: #1e3a8a; --blue: #93c5fd;
  --purple-bg: #4c1d95; --purple: #c4b5fd;
  --gray-bg: #334155; --gray: #cbd5e1;
  --teal-bg: #134e4a; --teal: #5eead4;
  --orange-bg: #7c2d12; --orange: #fdba74;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", Inter, system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
@media (max-width: 1100px) { .g4, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .g2, .g3, .g4, .g6 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; } }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #6366f1, #06b6d4); display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand b { display: block; font-size: 15px; }
.brand small { color: #94a3b8; font-size: 11px; }
.nav { padding: 6px 10px 24px; }
.nav-group { margin-top: 14px; }
.nav-group > span { display: block; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #64748b; padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text);
  font-size: 13.5px; text-decoration: none; position: relative;
}
.nav a:hover { background: var(--sidebar-active); color: #fff; }
.nav a.active { background: rgba(99, 102, 241, .18); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #818cf8; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-version { margin-top: auto; padding: 12px 20px 16px; font-size: 11.5px; color: #64748b; text-decoration: none; display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid rgba(255,255,255,.06); }
.nav-version span { color: #818cf8; }
.nav-version:hover { color: #cbd5e1; text-decoration: none; }
.nav .badge-count { margin-left: auto; background: #ef4444; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 17px; font-weight: 600; }
.topbar .crumb { color: var(--muted); font-size: 12px; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 30px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); position: relative; }
.user-chip .who { line-height: 1.1; }
.user-chip .who b { font-size: 13px; display: block; }
.user-chip .who small { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 200px; padding: 6px; z-index: 50; }
.dropdown button { display: flex; width: 100%; gap: 8px; align-items: center; background: none; border: 0; padding: 9px 10px; border-radius: 6px; cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.dropdown button:hover { background: var(--surface-2); }

.content { padding: 22px 24px 40px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; transition: left .2s; }
  .app.nav-open .sidebar { left: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .menu-toggle { display: grid; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .user-chip .who { display: none; }
  .topbar .crumb, #clock { display: none; }
}

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }

.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: center; position: relative; overflow: hidden; cursor: default; }
.kpi[data-link] { cursor: pointer; }
.kpi[data-link]:hover { border-color: var(--primary); }
.kpi .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.kpi .ic svg { width: 22px; height: 22px; }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi .sub { font-size: 11.5px; color: var(--muted); }
.tone-green .ic { background: var(--green-bg); color: var(--green); }
.tone-red .ic { background: var(--red-bg); color: var(--red); }
.tone-amber .ic { background: var(--amber-bg); color: var(--amber); }
.tone-blue .ic { background: var(--blue-bg); color: var(--blue); }
.tone-purple .ic { background: var(--purple-bg); color: var(--purple); }
.tone-gray .ic { background: var(--gray-bg); color: var(--gray); }
.tone-teal .ic { background: var(--teal-bg); color: var(--teal); }
.tone-indigo .ic { background: var(--primary-50); color: var(--primary); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.danger { color: var(--red); border-color: var(--red-bg); }
.btn.danger:hover { background: var(--red-bg); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn.on { background: var(--primary-50); color: var(--primary); border-color: var(--primary); position: relative; z-index: 1; }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label.field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; height: 36px; padding: 0 10px; width: 100%;
}
textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
input[type="color"] { padding: 2px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-50); border-color: var(--primary); }
.input-sm { height: 32px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid, .form-grid.cols3 { grid-template-columns: 1fr; } }
.field .req { color: var(--red); }
.field .hint { font-weight: 400; font-size: 11.5px; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 32px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .empty { text-align: center; padding: 36px; color: var(--muted); }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; color: var(--muted); font-size: 12.5px; gap: 10px; flex-wrap: wrap; }
.tbl-tools { display: flex; gap: 10px; padding: 12px 14px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tbl-tools .search { width: 260px; max-width: 100%; }

/* register grid */
.register { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.register th, .register td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; text-align: center; min-width: 34px; height: 34px; }
.register th { background: var(--surface-2); position: sticky; top: 0; z-index: 2; font-weight: 600; color: var(--muted); }
.register th.we { color: var(--red); }
.register .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; padding: 4px 10px; min-width: 200px; }
.register th.sticky { z-index: 3; background: var(--surface-2); }
.register td.cell { cursor: pointer; font-weight: 600; }
.register td.cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.register td.tot { background: var(--surface-2); font-weight: 600; min-width: 46px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 18px; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.b-gray { background: var(--gray-bg); color: var(--gray); }
.b-teal { background: var(--teal-bg); color: var(--teal); }
.b-orange { background: var(--orange-bg); color: var(--orange); }
.b-indigo { background: var(--primary-50); color: var(--primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); }
.dot.off { background: #94a3b8; }
.st-P, .st-MIS { }

/* ---------- avatar ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 12.5px; color: #fff; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 84px; height: 84px; font-size: 28px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.person { display: flex; gap: 10px; align-items: center; min-width: 0; }
.person b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { color: var(--muted); font-size: 12px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.card .tabs { padding: 0 12px; margin-bottom: 0; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; width: 560px; max-width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: pop .15s; }
.modal.lg { width: 860px; }
.modal.xl { width: 1100px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; display: flex; gap: 10px; align-items: flex-start; animation: pop .15s; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.empty-state svg, .list-item > svg { flex-shrink: 0; }
.list-item > svg { width: 18px; height: 18px; color: var(--muted); }
a.list-item { color: inherit; text-decoration: none; }
a.list-item:hover { background: var(--surface-2); }
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }

.alert { padding: 12px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.alert.info { background: var(--blue-bg); color: var(--blue); }
.alert.warn { background: var(--amber-bg); color: var(--amber); }
.alert.ok { background: var(--green-bg); color: var(--green); }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 240px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--border); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; font-size: 12.5px; padding: 5px 0; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #06b6d4); border-radius: 6px; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }
.empty-state svg { width: 36px; height: 36px; opacity: .5; margin-bottom: 6px; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at 10% 10%, #4f46e5 0%, #1e1b4b 55%, #0b1120 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h2 { font-size: 34px; line-height: 1.15; margin-top: 30px; max-width: 460px; }
.auth-hero ul { padding: 0; list-style: none; display: grid; gap: 12px; margin-top: 24px; color: #c7d2fe; }
.auth-hero li::before { content: "✓"; color: #34d399; margin-right: 10px; font-weight: 700; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-form h1 { font-size: 24px; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: minmax(0, 1fr); } .auth-hero { display: none; } }

/* ---------- live monitor ---------- */
.live-feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.punch-card { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.punch-card.fresh { animation: flash 2.5s; }
@keyframes flash { 0% { background: var(--green-bg); } 100% { background: var(--surface); } }
.punch-card .t { font-size: 20px; font-weight: 700; margin-left: auto; font-variant-numeric: tabular-nums; }

.timeline { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline span { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-variant-numeric: tabular-nums; font-weight: 600; }

/* mobile punch */
.mp-wrap { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.mp-card { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.mp-clock { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.mp-cam { position: relative; display: grid; place-items: center; gap: 10px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 16px; min-height: 120px; overflow: hidden; }
.mp-video { width: 100%; max-height: 300px; object-fit: cover; border-radius: 16px; }
video.mp-video { transform: scaleX(-1); }
.mp-chip { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; }
.mp-chip svg { width: 16px; height: 16px; flex-shrink: 0; }
.mp-btn { height: 64px; border: 0; border-radius: 16px; font: inherit; font-size: 20px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 8px 24px rgba(16, 185, 129, .35); }
.mp-btn.out { background: linear-gradient(135deg, #f97316, #dc2626); box-shadow: 0 8px 24px rgba(220, 38, 38, .3); }
.mp-btn:disabled { background: var(--gray-bg); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.mp-big-ic { width: 48px; height: 48px; margin: 0 auto; color: var(--muted); }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.cal .day { border: 1px solid var(--border); border-radius: 10px; min-height: 74px; padding: 6px 8px; background: var(--surface); font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.cal .day.blank { background: transparent; border-style: dashed; opacity: .4; }
.cal .day.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.cal .day .n { font-weight: 600; }

/* payslip */
.payslip { background: #fff; color: #111; padding: 28px; border: 1px solid #e5e7eb; border-radius: 10px; }
.payslip h2 { font-size: 20px; }
.payslip table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.payslip td, .payslip th { border: 1px solid #e5e7eb; padding: 7px 10px; font-size: 13px; }
.payslip th { background: #f3f4f6; text-align: left; }
.payslip .net { font-size: 18px; font-weight: 700; background: #eef2ff; }

.code-box { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 12px 14px; font-family: Consolas, monospace; font-size: 13px; }
.steps { counter-reset: s; display: grid; gap: 10px; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: 12px; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--primary-50); color: var(--primary); font-weight: 700; display: grid; place-items: center; flex-shrink: 0; font-size: 12px; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; display: grid; place-items: center; color: var(--muted); }

@media print {
  .sidebar, .topbar, .no-print, .tbl-tools, .tbl-foot, .page-head .row { display: none !important; }
  body { background: #fff; color: #000; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .overlay { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; width: 100% !important; }
  .modal-head, .modal-foot { display: none; }
  .modal-body { max-height: none; overflow: visible; }
  body.printing-modal .app { display: none; }
  .register th, .register td { min-width: 0; height: auto; padding: 2px; }
}

/* All punches of the day + current in/out state */
.punch-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }
.punch-chip { font: 600 12px/18px ui-monospace, Consolas, monospace; padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.punch-chip.in { background: rgba(16, 185, 129, .12); color: #047857; }
.punch-chip.out { background: rgba(100, 116, 139, .14); color: #475569; }
.now-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.now-badge.in { background: rgba(16, 185, 129, .12); color: #047857; }
.now-badge.out { background: rgba(100, 116, 139, .14); color: #475569; }
[data-theme="dark"] .punch-chip.in, [data-theme="dark"] .now-badge.in { color: #6ee7b7; }
[data-theme="dark"] .punch-chip.out, [data-theme="dark"] .now-badge.out { color: #cbd5e1; }
.presence-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .presence-cols { grid-template-columns: 1fr; } }
.presence-cols h4 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dir-badge { display: inline-block; font: 700 10.5px/16px system-ui, sans-serif; letter-spacing: .05em; padding: 1px 7px; border-radius: 5px; margin-top: 4px; }
.dir-badge.in { background: #10b981; color: #fff; }
.dir-badge.out { background: #64748b; color: #fff; }
.dir-badge.rep { background: rgba(245, 158, 11, .15); color: #b45309; }
.punch-card .t .dir-badge { display: block; text-align: center; }

/* Multi-select employee picker (manager team) */
.pick { border: 1px solid var(--line, #e2e8f0); border-radius: 10px; padding: 10px; }
.pick-search { flex: 1 1 200px; min-width: 160px; padding: 7px 10px; border: 1px solid var(--line, #e2e8f0); border-radius: 8px; font: inherit; background: transparent; color: inherit; }
.pick-list { margin-top: 8px; max-height: 240px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 10px; }
.pick-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.pick-item:hover { background: rgba(79, 70, 229, .06); }
.pick-item input { width: 16px; height: 16px; flex: none; }

/* ---------- quick actions (employee home) ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .12s, border-color .12s; }
.qa:hover { border-color: var(--primary); }
.qa:active { transform: scale(.96); }
.qa .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.qa .ic svg { width: 22px; height: 22px; }
@media (max-width: 900px) { .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- phone layout: bottom tab bar ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(62px + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgba(15, 23, 42, .06); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none;
    font-size: 11px; font-weight: 600; position: relative; -webkit-tap-highlight-color: transparent; }
  .tabbar a svg { width: 22px; height: 22px; padding: 3px 14px; box-sizing: content-box; border-radius: 14px; transition: background .15s; }
  .tabbar a.active { color: var(--primary); }
  .tabbar a.active svg { background: var(--primary-50); }
  .tabbar .badge-count { position: absolute; top: 6px; left: calc(50% + 8px); background: #ef4444; color: #fff; border-radius: 10px; font-size: 10px; font-style: normal; padding: 0 5px; line-height: 16px; }
  .content { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { height: 56px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .topbar .menu-toggle { display: none; }
  .page-head h1 { font-size: 20px; }
  .card { border-radius: 16px; }
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g4 > .kpi:first-child, .grid.g4 > .kpi:first-child:nth-last-child(4) ~ .kpi:last-child { grid-column: 1 / -1; }
  .page-head:has(+ .quick-actions) .btn { display: none; }
  .kpi { padding: 14px; gap: 10px; }
  .kpi .v { font-size: 22px; }
  .kpi .ic { width: 38px; height: 38px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
/* inside the Android app the browser-style hints are not needed */
.in-app .auth-form .alert.info { display: none; }

/* Android app download card on the sign-in page */
.app-get { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.app-get .grow { flex: 1; min-width: 0; }
.app-get b { display: block; font-size: 13.5px; }
.app-get small { display: block; color: var(--muted); font-size: 12px; }
.app-get-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; color: #fff; background: linear-gradient(135deg, #4f46e5, #0ea5e9); }
.app-get-ic svg { width: 20px; height: 20px; }
.app-get .btn { flex-shrink: 0; }
@media (max-width: 380px) { .app-get { flex-wrap: wrap; } .app-get .btn { width: 100%; justify-content: center; } }

/* ---------- 1.4.0 polish ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
/* menu icons: fixed small size */
.dropdown { min-width: 230px; border-radius: 14px; box-shadow: 0 12px 32px rgba(15, 23, 42, .14); }
.dropdown button { font-size: 14px; font-weight: 500; padding: 10px 12px; gap: 10px; }
.dropdown button svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--muted); }
.dropdown button:hover svg { color: var(--primary); }

/* sign-in page: brand header when the side panel is hidden (phones and the app) */
.auth-brand { display: none; }
@media (max-width: 900px) {
  .auth-form { align-items: stretch; flex-direction: column; justify-content: flex-start; padding: 0; min-height: 100vh; background: var(--bg); }
  .auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 52px 24px 72px; color: #fff; text-align: center;
    background: radial-gradient(600px 300px at 20% 0%, #6366f1 0%, #3730a3 55%, #1e1b4b 100%); }
  .auth-brand .logo { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-weight: 800; font-size: 24px; color: #fff;
    background: linear-gradient(135deg, #818cf8, #0ea5e9); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); margin-bottom: 6px; overflow: hidden; }
  .auth-brand .logo img { width: 100%; height: 100%; object-fit: cover; }
  .auth-brand b { font-size: 20px; }
  .auth-brand small { color: #c7d2fe; font-size: 13px; }
  .auth-form form { margin: -40px auto 24px; width: calc(100% - 32px); max-width: 420px; background: var(--surface); border-radius: 20px; padding: 24px 20px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .10); border: 1px solid var(--border); }
  .auth-form form h1 { font-size: 22px; }
  .auth-form input { height: 46px; font-size: 16px; }
}

/* attendance calendar */
.cal .day { font: inherit; text-align: left; color: inherit; cursor: pointer; min-width: 0; overflow: hidden; }
.cal .day:hover { border-color: var(--primary); }
.cal .day.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.cal .day.future { opacity: .55; }
.cal .cal-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; }
.cal .cal-full { min-width: 0; }
.cal .cal-full .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.cal .cal-short { display: none; }
.cal-detail { margin-top: 14px; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--surface-2); }
.cd-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.cd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px 16px; }
.cd-item { display: flex; flex-direction: column; font-size: 13px; }
.cd-item .muted { font-size: 11.5px; }
.cal-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.cal .day.t-green { background: color-mix(in srgb, var(--green-bg) 45%, var(--surface)); }
.cal .day.t-red { background: color-mix(in srgb, var(--red-bg) 45%, var(--surface)); }
.cal .day.t-blue { background: color-mix(in srgb, var(--blue-bg) 45%, var(--surface)); }
.cal .day.t-amber { background: color-mix(in srgb, var(--amber-bg) 45%, var(--surface)); }
.cal .day.t-purple { background: color-mix(in srgb, var(--purple-bg) 45%, var(--surface)); }
@media (max-width: 760px) {
  .cal { gap: 4px; }
  .cal .dow { font-size: 10px; }
  .cal .day { min-height: 0; aspect-ratio: 1 / 1.05; padding: 4px; border-radius: 10px; align-items: center; justify-content: center; gap: 3px; text-align: center; }
  .cal .day.blank { border: 0; }
  .cal .cal-top { justify-content: center; }
  .cal .cal-full, .cal .cal-info { display: none; }
  .cal .day .n { font-size: 13px; }
  .cal .cal-short { display: block; font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 5px; border-radius: 6px; background: var(--gray-bg); color: var(--gray); }
  .cal .t-green .cal-short { background: var(--green-bg); color: var(--green); }
  .cal .t-red .cal-short { background: var(--red-bg); color: var(--red); }
  .cal .t-blue .cal-short { background: var(--blue-bg); color: var(--blue); }
  .cal .t-amber .cal-short { background: var(--amber-bg); color: var(--amber); }
  .cal .t-purple .cal-short { background: var(--purple-bg); color: var(--purple); }
  .cal .t-teal .cal-short { background: var(--teal-bg); color: var(--teal); }
  .cal-tools { flex-direction: column; align-items: stretch; gap: 10px; }
  .cal-tools .grow { display: none; }
  .card-body:has(> .cal) { padding: 12px 10px; }
}

/* mobile punch: selfie + location view */
.punch-chip.mobile { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; border: 1px dashed currentColor; font: inherit; }
.punch-chip.mobile svg { width: 12px; height: 12px; }
.punch-card.mobile { cursor: pointer; }
.punch-card.mobile:hover { border-color: var(--primary); }
.punch-selfie { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: var(--surface-2); }
.punch-where { display: flex; align-items: center; gap: 4px; color: var(--teal); }
.punch-where svg { width: 13px; height: 13px; }
.pi-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
.pi-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pi-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.pi-label svg { width: 15px; height: 15px; }
.pi-photo { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.pi-map { width: 100%; height: 300px; border: 1px solid var(--border); border-radius: 14px; }
.pi-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.pi-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 160px; border: 1px dashed var(--border); border-radius: 14px; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.pi-empty svg { width: 26px; height: 26px; }
@media (max-width: 640px) { .pi-grid { grid-template-columns: 1fr; } .pi-photo { aspect-ratio: 1; } .pi-map { height: 240px; } }
.mp-cam { position: relative; }
.mp-cam-retry { position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; }

/* attendance mode dialog */
.am-list { display: flex; flex-direction: column; max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.am-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.am-row:last-child { border-bottom: 0; }
.am-ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 7px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
