/* K50 Attendance - dashboard styles. No external fonts or libraries. */
:root {
  --bg: #f3f5fa; --card: #ffffff; --text: #18213a; --muted: #6a7590; --line: #e5e9f2;
  --brand: #4f46e5; --brand-soft: #eef0ff; --side: #121a30; --side-text: #aeb8d4;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --info: #1d4ed8; --info-bg: #dbeafe; --mute: #5b6578; --mute-bg: #eceff5; --pur: #6d28d9; --pur-bg: #ede9fe;
  --ora: #c2410c; --ora-bg: #ffedd5; --bar-ok: #22c55e; --bar-late: #f59e0b; --bar-abs: #ef4444;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 10px 28px rgba(16,24,40,.06); --r: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #0d1325; --card: #161e36; --text: #e8ecf8; --muted: #8e9ab8; --line: #263050;
  --brand: #818cf8; --brand-soft: #1f2750; --side: #0a0f1f; --side-text: #8e9ab8;
  --ok: #4ade80; --ok-bg: #123524; --warn: #fbbf24; --warn-bg: #3a2c0d; --bad: #f87171; --bad-bg: #3d1717;
  --info: #93c5fd; --info-bg: #14264d; --mute: #9aa6c2; --mute-bg: #212b48; --pur: #c4b5fd; --pur-bg: #2a2150;
  --ora: #fdba74; --ora-bg: #3b230f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.side { width: 244px; background: var(--side); color: var(--side-text); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 18px 14px; z-index: 30; transition: transform .2s; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 22px; color: #fff; }
.side-brand b { display: block; font-size: 15px; line-height: 1.2; }
.side-brand small { color: var(--side-text); font-size: 12px; }
.logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #6366f1, #8b5cf6); display: grid; place-items: center; }
.logo .ic { width: 20px; height: 20px; }
.side nav { display: flex; flex-direction: column; gap: 3px; }
.side a, .linkbtn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-text); font-weight: 500; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; width: 100%; }
.side a:hover, .linkbtn:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.side a.on { background: rgba(129,140,248,.18); color: #fff; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; display: flex; flex-direction: column; gap: 3px; }
.main { margin-left: 244px; flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 28px; position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); z-index: 10; border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.burger { display: none; background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 10px; width: 38px; height: 38px; place-items: center; cursor: pointer; }
.content { padding: 24px 28px 48px; max-width: 1400px; min-width: 0; }
.scrim { display: none; }

/* ---------- status pill ---------- */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600; border: 1px solid transparent; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.ok i { animation: pulse 2s infinite; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- cards & stats ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 20px; }
.card > h2, .card-head h2 { margin: 0 0 14px; font-size: 15.5px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; border-top: 3px solid var(--line); }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-num { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: 12.5px; }
.stat.ok { border-top-color: var(--bar-ok); } .stat.warn { border-top-color: var(--bar-late); }
.stat.bad { border-top-color: var(--bar-abs); } .stat.info { border-top-color: #3b82f6; } .stat.brand { border-top-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.banner { background: var(--info-bg); color: var(--info); border-radius: 12px; padding: 11px 16px; margin-bottom: 18px; font-weight: 600; }
.flash { border-radius: 12px; padding: 11px 16px; margin-bottom: 18px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); } .flash.err { background: var(--bad-bg); color: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.tbl td.wrap { white-space: normal; min-width: 200px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--brand) 5%, transparent); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .muted, .muted { color: var(--muted); }
.tbl .name { font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.b-p { background: var(--ok-bg); color: var(--ok); } .b-l { background: var(--warn-bg); color: var(--warn); }
.b-hd { background: var(--ora-bg); color: var(--ora); } .b-a { background: var(--bad-bg); color: var(--bad); }
.b-o { background: var(--mute-bg); color: var(--mute); } .b-h { background: var(--pur-bg); color: var(--pur); }
.b-n { background: var(--info-bg); color: var(--info); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 11.5px; font-weight: 600; background: var(--mute-bg); color: var(--mute); white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- forms & buttons ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar form { display: contents; }
input[type=text], input[type=date], input[type=month], input[type=time], input[type=number], input[type=password], select {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn .ic { width: 16px; height: 16px; }
.seg { display: inline-flex; background: var(--mute-bg); border-radius: 10px; padding: 3px; }
.seg a { padding: 6px 14px; border-radius: 8px; color: var(--mute); font-weight: 600; text-decoration: none; }
.seg a.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 24px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); margin-top: 4px; }
.field input[type=text], .field input[type=number], .field input[type=time], .field input[type=date], .field input[type=password] { width: 100%; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { font-weight: 500; display: inline-flex; gap: 6px; align-items: center; background: var(--mute-bg); border-radius: 8px; padding: 5px 10px; cursor: pointer; }

/* ---------- monthly grid ---------- */
.gridtbl { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.gridtbl th { font-size: 11px; color: var(--muted); font-weight: 600; text-align: center; padding: 2px 0; }
.gridtbl th.wk { color: var(--bar-abs); }
.gridtbl td.who { font-weight: 600; font-size: 13px; padding-right: 12px; white-space: nowrap; position: sticky; left: 0; background: var(--card); }
.gridtbl td.c { width: 26px; min-width: 26px; height: 26px; text-align: center; border-radius: 6px; font-weight: 700; font-size: 11px; }
.c-P { background: var(--ok-bg); color: var(--ok); } .c-L { background: var(--warn-bg); color: var(--warn); }
.c-HD { background: var(--ora-bg); color: var(--ora); } .c-A { background: var(--bad-bg); color: var(--bad); }
.c-O, .c-H { background: var(--mute-bg); color: var(--mute); } .c-N { background: var(--info-bg); color: var(--info); }
.c-F, .c- { background: transparent; color: transparent; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* ---------- chart ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10.5px; }
.chart .axis.sm { font-size: 9px; }
.bar-ok { fill: var(--bar-ok); } .bar-late { fill: var(--bar-late); } .bar-abs { fill: var(--bar-abs); }
.chart-legend { display: flex; gap: 16px; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rank li:last-child { border-bottom: 0; }

/* ---------- login ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 32px 30px; }
.login-card .logo { margin: 0 auto 14px; width: 52px; height: 52px; color: #fff; }
.login-card h1 { text-align: center; margin: 0 0 4px; font-size: 21px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .side { transform: translateX(-100%); } .side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.5); }
  .main { margin-left: 0; } .burger { display: grid; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
  .top { padding: 12px 16px; } .content { padding: 16px 14px 40px; }
  .top h1 { font-size: 17px; } .stat-num { font-size: 26px; }
}
@media (max-width: 700px) { .hide-sm { display: none; } }
@media (max-width: 520px) { .top-right { width: 100%; justify-content: flex-start; margin-left: 0; } .top { flex-wrap: wrap; } }
@media print { .side, .top, .toolbar, .scrim { display: none !important; } .main { margin: 0; } .card, .stat { box-shadow: none; } }

/* ---------- v3 additions: roles, reasons, leave, forms ---------- */
:root { --tea: #0f766e; --tea-bg: #ccfbf1; }
[data-theme="dark"] { --tea: #5eead4; --tea-bg: #0f3330; }
.b-lv { background: var(--tea-bg); color: var(--tea); }
.c-LV { background: var(--tea-bg); color: var(--tea); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.reason { background: var(--info-bg); color: var(--info); }
.chip.remark { font-weight: 500; font-style: italic; }
.who-me { align-items: flex-start !important; }
.who-me span { display: flex; flex-direction: column; line-height: 1.25; color: #fff; }
.who-me small { color: var(--side-text); font-size: 11.5px; font-weight: 500; }
textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 100%; min-height: 70px; resize: vertical; }
textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline form { margin: 0; }
.tbl a.row-link { font-weight: 600; font-size: 12.5px; }
.lock-note { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; font-weight: 600; }
.voided td { opacity: .5; text-decoration: line-through; }
.voided td:last-child, .voided td.keep { text-decoration: none; opacity: 1; }
.help { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0 0 6px; }
.kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; }
.gridtbl td.c a { color: inherit; display: block; text-decoration: none; }

.chip.bad { background: var(--bad-bg); color: var(--bad); }
