:root {
  --bg: #f4f6fa; --panel: #fff; --text: #1d2433; --muted: #6b7385; --border: #e3e7ef;
  --primary: #2f5bea; --primary-d: #2348c4; --focus: #c5d3fb;
  --side: #141b2d; --side-t: #b9c1d6; --side-hover: #1d2640; --side-active: #1f2a47; --side-muted: #6c7590;
  --green: #14804a; --green-bg: #e3f6ec; --red: #c4321f; --red-bg: #fdecea;
  --amber: #a15c07; --amber-bg: #fdf3e1; --blue: #2348c4; --blue-bg: #e7edfd; --gray-bg: #eef0f4; --gray-t: #4a5266;
  --purple: #6b35c4; --purple-bg: #f1e9fd;
  --input-bg: #fff; --input-border: #cfd5e1; --btn-bg: #fff; --btn-hover: #f3f5f9; --th-bg: #fafbfd; --off-bg: #f6f7fa;
}

/* Tema warna (Pengaturan → Tema Tampilan) */
[data-theme="hijau"]  { --primary: #15803d; --primary-d: #116632; --focus: #bbe5c8; --side: #0f2419; --side-hover: #173323; --side-active: #1b3d2a; }
[data-theme="merah"]  { --primary: #c8102e; --primary-d: #a30d25; --focus: #f6c3cb; --side: #2a1014; --side-hover: #3a171c; --side-active: #451b21; }
[data-theme="ungu"]   { --primary: #7c3aed; --primary-d: #6528d4; --focus: #ddd0fb; --side: #1e1433; --side-hover: #2a1d47; --side-active: #312253; }
[data-theme="oranye"] { --primary: #ea580c; --primary-d: #c2410c; --focus: #fbd5bf; --side: #2a170b; --side-hover: #3a2210; --side-active: #452814; }
[data-theme="tosca"]  { --primary: #0d9488; --primary-d: #0b7a70; --focus: #bde8e3; --side: #0d2624; --side-hover: #133431; --side-active: #173d39; }
[data-theme="abu"]    { --primary: #475569; --primary-d: #334155; --focus: #d3d9e2; --side: #0f172a; --side-hover: #1e293b; --side-active: #26334a; }
[data-theme="java"]   { --primary: #1d4f9c; --primary-d: #173f7d; --focus: #c4d4ee; --side: #dbe4f0; --side-t: #24406d; --side-hover: #ccd8ea; --side-active: #c1d0e7; --side-muted: #637899;
                        --brand-bg: transparent; --brand-line: 1px solid #c3cfe2; --brand-t: #163160; }
[data-theme="java"]:not([data-mode="gelap"]) { --side-title: #163160; --side-hover-t: #12284f; }
[data-theme="biru-terang"] { --side: #ffffff; --side-t: #3b4356; --side-hover: #eef2fd; --side-active: #e7edfd; --side-muted: #8a92a5; }

@media screen {
  [data-mode="gelap"] {
    color-scheme: dark;
    --bg: #0e131d; --panel: #161d2b; --text: #e5e9f2; --muted: #95a0b5; --border: #273148;
    --green: #4ade80; --green-bg: #12352a; --red: #f87171; --red-bg: #3b1a1a; --amber: #fbbf24; --amber-bg: #3a2a10;
    --blue: #93b4ff; --blue-bg: #1a2547; --gray-bg: #2a3346; --gray-t: #c3c9d6; --purple: #c4a5ff; --purple-bg: #2d1f4a;
    --input-bg: #111827; --input-border: #334155; --btn-bg: #1c2435; --btn-hover: #232d42; --th-bg: #1a2232; --off-bg: #121927;
    --side: #0a0e16; --side-hover: #161d2b; --side-active: #1c2435; --side-t: #b9c1d6; --side-muted: #6c7590;
    --brand-bg: #fff; --brand-line: 3px solid var(--primary); --brand-t: #1e2a3b;
  }
  [data-mode="gelap"] a:not(.btn) { color: color-mix(in srgb, var(--primary) 55%, #fff); }
  [data-mode="gelap"] .sidebar a { color: var(--side-t); }
  [data-mode="gelap"] .btn-success { background: #15803d; border-color: #15803d; }
  [data-mode="gelap"] .sidebar a:hover, [data-mode="gelap"] .sidebar a.active { color: #fff; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--side); color: var(--side-t); flex-shrink: 0; padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: var(--side-title, #fff); font-weight: 700; font-size: 17px; padding: 0 20px 4px; }
.brand-sub { font-size: 12px; padding: 0 20px 16px; color: var(--side-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--side-muted); padding: 14px 20px 4px; }
.sidebar a { display: block; color: var(--side-t); padding: 7px 20px; border-left: 3px solid transparent; }
.sidebar a:hover { background: var(--side-hover); text-decoration: none; color: var(--side-hover-t, #fff); }
.sidebar a.active { background: var(--side-active); color: var(--side-hover-t, #fff); border-left-color: var(--primary); }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 28px; background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar form { display: inline; }
.content { padding: 24px 28px 48px; max-width: 1280px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.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)); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--th-bg); }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.table-wrap { overflow-x: auto; }
.btn { display: inline-block; border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); padding: 7px 14px; border-radius: 7px; cursor: pointer; font: inherit; }
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--green); }
.btn-danger { color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-link { background: none; border: none; color: var(--red); cursor: pointer; padding: 0; font: inherit; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: 7px; font: inherit; background: var(--input-bg); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--primary); }
input[type=checkbox] { width: auto; }
.field { margin-bottom: 14px; }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 180px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge-gray { background: var(--gray-bg); color: var(--gray-t); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-error { background: var(--red-bg); color: var(--red); }
.muted { color: var(--muted); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 28px; }
dl.info { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }
.items td input, .items td select { min-width: 80px; }
.totals { margin-left: auto; width: 320px; }
.totals td { padding: 5px 10px; border: none; }
.totals tr.grand td { font-size: 16px; font-weight: 700; border-top: 2px solid var(--border); }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar div { width: 100%; max-width: 46px; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 2px; }
.bar span { font-size: 12px; color: var(--muted); margin-top: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; }
.pl td { padding: 7px 10px; }
.pl .section td { font-weight: 700; background: var(--th-bg); }
.pl .indent td:first-child { padding-left: 28px; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; display: flex; flex-wrap: wrap; padding: 10px; }
  .sidebar .nav-group, .brand-sub { display: none; }
  .brand { width: 100%; padding: 4px 10px 8px; }
  .sidebar a { border-left: none; padding: 6px 10px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .totals { width: 100%; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .card { border: none; }
}
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.sidebar .nav-sub { padding-left: 32px; font-size: 13px; }
.clock { text-align: center; }
.clock .time { font-size: 40px; font-weight: 700; letter-spacing: .02em; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .d { border: 1px solid var(--border); border-radius: 8px; padding: 6px; min-height: 64px; font-size: 12px; background: var(--panel); }
.cal .d.off { background: var(--off-bg); color: var(--muted); }
.cal .d .n { font-weight: 700; }
.cal .h { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.progress { height: 8px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; background: var(--primary); }
td input, td select { padding: 5px 7px; }
.compact td, .compact th { padding: 6px 8px; font-size: 13px; }
.slip { max-width: 800px; margin: 0 auto 30px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 28px; page-break-after: always; }
.slip h1 { font-size: 20px; }
.slip table td { padding: 5px 8px; }
details summary { cursor: pointer; color: var(--primary); }
.hstack { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
td.r, th.r { white-space: nowrap; }

[data-theme="biru-terang"]:not([data-mode="gelap"]) { --side-title: #1d2433; --side-hover-t: #1d2433; }
[data-theme="biru-terang"]:not([data-mode="gelap"]) .sidebar { border-right: 1px solid var(--border); }
.brand-logo { display: inline-flex; align-items: center; background: #fff; border-radius: 8px; padding: 6px 10px; max-width: 190px; }
.brand-logo img { max-height: 40px; max-width: 170px; display: block; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.theme-opt { border: 2px solid var(--border); border-radius: 10px; padding: 10px; cursor: pointer; display: block; font-weight: 400; }
.theme-opt:has(input:checked) { border-color: var(--primary); }
.theme-opt input { width: auto; margin-right: 6px; }
.theme-sw { display: flex; height: 46px; border-radius: 7px; overflow: hidden; margin-bottom: 8px; border: 1px solid var(--border); }
.theme-sw span:first-child { width: 34%; }
.theme-sw span:last-child { flex: 1; display: flex; align-items: center; justify-content: center; }
.theme-sw i { display: block; width: 60%; height: 12px; border-radius: 99px; }

/* Kepala sidebar saat logo dipasang: latar putih penuh agar menyatu dengan logo */
.brand-head { background: var(--brand-bg, #fff); margin: -18px 0 10px; padding: 20px 16px 14px; text-align: center; border-bottom: var(--brand-line, 3px solid var(--primary)); }
.brand-head img { display: block; margin: 0 auto; max-width: 100%; max-height: 64px; }
.brand-name { margin-top: 8px; color: var(--brand-t, #1e2a3b); font-size: 11.5px; font-weight: 700; line-height: 1.35; letter-spacing: .3px; text-transform: uppercase; }
@media (max-width: 900px) {
  .brand-head { width: 100%; margin: -10px -10px 8px; padding: 10px; display: flex; align-items: center; gap: 10px; text-align: left; }
  .brand-head img { margin: 0; max-height: 36px; max-width: 120px; }
  .brand-name { margin-top: 0; }
}

/* Rekap absensi bulanan */
.print-only { display: none; }
.recap-sum th { white-space: normal; vertical-align: bottom; font-size: 12px; }
.recap-grid-wrap { overflow-x: auto; }
.recap-grid { border-collapse: collapse; font-size: 11px; width: max-content; min-width: 100%; }
.recap-grid th, .recap-grid td { border: 1px solid var(--border); padding: 3px 4px; text-align: center; line-height: 1.3; white-space: nowrap; }
.recap-grid th { background: var(--th-bg); font-weight: 600; }
.recap-grid th span { font-weight: 400; color: var(--muted); font-size: 10px; }
.recap-grid .sticky { position: sticky; left: 0; z-index: 1; background: var(--panel); text-align: left; min-width: 150px; max-width: 190px; white-space: normal; }
.recap-grid th.sticky { background: var(--th-bg); }
.recap-grid .sticky .muted { font-size: 10px; }
.recap-grid .off { background: var(--off-bg); color: var(--muted); }
.recap-grid .late { color: var(--red); font-weight: 600; }
.recap-grid .tot { background: var(--th-bg); min-width: 30px; }
.code { display: inline-block; min-width: 18px; padding: 1px 4px; border-radius: 4px; font-weight: 700; font-size: 11px; }
.code-izin { background: var(--blue-bg); color: var(--blue); }
.code-sakit { background: var(--purple-bg); color: var(--purple); }
.code-cuti { background: var(--green-bg); color: var(--green); }
.code-alpha { background: var(--red-bg); color: var(--red); }
.code-libur { background: var(--gray-bg); color: var(--gray-t); }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  .print-only { display: block; }
  .print-head { margin-bottom: 8px; font-size: 13px; }
  .tabs, .filters { display: none !important; }
  .main, .content { padding: 0 !important; max-width: none !important; }
  .recap-grid { font-size: 7.5px; width: 100%; }
  .recap-grid th, .recap-grid td { padding: 1px 2px; }
  .recap-grid .sticky { position: static; min-width: 0; }
  .recap-sum { font-size: 9px; }
  .recap-grid-wrap, .table-wrap { overflow: visible !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Shift */
.shift-tag { display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: 5px; font-weight: 700; font-size: 12px; text-align: center;
  color: var(--c, #475569); background: color-mix(in srgb, var(--c, #94a3b8) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c, #94a3b8) 40%, transparent); }
.shift-off { --c: #64748b; }
.shift-mini { display: inline-block; font-size: 9px; font-weight: 700; color: var(--c, var(--muted)); }
.sched-grid td { padding: 2px; }
.sched-grid select.sch { width: 46px; min-width: 0; padding: 3px 0; font-size: 11px; text-align: center; border-radius: 4px; height: auto;
  border: 1px solid var(--border); appearance: none; -webkit-appearance: none; cursor: pointer; font-weight: 600;
  background: color-mix(in srgb, var(--c, transparent) 18%, var(--input-bg)); color: var(--text); }
.sched-grid select.sch[data-v=""] { color: var(--muted); font-weight: 400; }
.sched-grid select.sch.changed { outline: 2px solid var(--primary); outline-offset: -1px; }
@media print { .sched-grid select.sch { border: none; width: auto; font-size: 8px; background: none; } }

/* Diagram bulat kehadiran & peringatan disiplin */
.pie { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.pie-svg { flex: none; transform: none; }
.pie-num { font-size: 7px; font-weight: 700; fill: var(--text); }
.pie-cap { font-size: 3.6px; fill: var(--muted); }
.pie-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 170px; }
.pie-legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.pie-legend li.zero { opacity: .45; }
.pie-legend i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.pie-legend span { flex: 1; }
.disc { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; border-left: 4px solid; }
.disc strong { display: flex; align-items: center; gap: 8px; }
.disc p { margin: 6px 0 0; }
.disc-i { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 12px; flex: none; }
.disc-0 { background: var(--green-bg); border-color: var(--green); }
.disc-0 .disc-i { background: var(--green); }
.disc-1 { background: var(--amber-bg); border-color: #f59e0b; }
.disc-1 .disc-i { background: #f59e0b; }
.disc-2 { background: var(--red-bg); border-color: var(--red); }
.disc-2 .disc-i { background: var(--red); }
.disc-list td { vertical-align: top; }
.nav-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.filters-inline input, .filters-inline select { width: auto; }
