@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0c0f18;
  --bg2: #131825;
  --bg3: #1b2133;
  --bg4: #222b42;
  --border: #263050;
  --border2: #2e3a5c;
  --text: #e6ecf8;
  --text2: #8e9bbf;
  --text3: #65708f;
  --accent: #0ea5c9;
  --accent2: #38bdf8;
  --accent-bg: rgba(14, 165, 201, .13);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, .12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, .12);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, .13);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, .12);
  --sidebar-w: 248px;
  --topbar-h: 62px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 18px 60px rgba(0, 0, 0, .35);
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

.light-mode {
  --bg: #f1f5fb;
  --bg2: #ffffff;
  --bg3: #e9eef8;
  --bg4: #dde5f2;
  --border: #d0daee;
  --border2: #b9c6df;
  --text: #111827;
  --text2: #4b5680;
  --text3: #7a86a4;
  --accent-bg: rgba(14, 165, 201, .09);
  --shadow: 0 16px 50px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
}
a { color: var(--accent2); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
label span {
  display: block;
  margin: 0 0 6px;
  color: var(--text3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
code { font-family: var(--mono); }

/* ===== Login / Install ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(140deg, rgba(14, 165, 201, .12), transparent 36%),
    linear-gradient(320deg, rgba(168, 85, 247, .10), transparent 42%),
    var(--bg);
}
.login-wrap {
  width: min(940px, 96vw);
  min-height: 540px;
  display: grid;
  grid-template-columns: 1.06fr .94fr;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg2);
  box-shadow: var(--shadow);
}
.login-left {
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(150deg, #071830, #0d2448 48%, #0c3060);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #0ea5c9, #0369a1);
  color: #fff;
  font-weight: 800;
  font-size: 21px;
}
.brand-name { font-size: 17px; font-weight: 800; }
.brand-name span { color: var(--accent2); }
.brand-sub { color: rgba(255,255,255,.52); font-size: 12px; margin-top: 2px; }
.login-copy h1 { max-width: 460px; margin: 0; font-size: clamp(31px, 5vw, 46px); line-height: 1.05; letter-spacing: 0; }
.login-copy p { max-width: 520px; margin: 18px 0 0; color: rgba(255,255,255,.68); line-height: 1.7; }
.login-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.login-pills span {
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.06);
  font-size: 12px;
}
.login-right { padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.login-right h2 { margin: 0 0 5px; font-size: 25px; }
.stack { display: grid; gap: 15px; margin-top: 24px; }
.form-message { min-height: 18px; color: var(--amber); font-size: 12px; }
.notice {
  margin: 16px 0 0;
  padding: 12px 13px;
  border: 1px solid var(--accent);
  background: var(--accent-bg);
  border-radius: var(--radius);
  color: var(--accent2);
  line-height: 1.55;
  word-break: break-word;
}
.notice.danger { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.notice.success { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.notice.warn { border-color: var(--amber); background: var(--amber-bg); color: var(--amber); }
.install-card {
  width: min(480px, 96vw);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg2);
  box-shadow: var(--shadow);
}
.install-help { margin-top: 18px; line-height: 1.6; }

/* ===== App shell / Sidebar ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-right: 1px solid var(--border);
}
.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group {
  padding: 10px 18px 4px;
  color: var(--text3);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text2);
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}
.nav-item:hover, .nav-item.active { color: var(--accent2); background: var(--accent-bg); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .85; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid var(--border); }
.user-mini { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5c9, #0369a1);
  color: #fff;
  font-weight: 800;
}
.user-mini strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.user-mini span { display: block; color: var(--text3); font-size: 10px; margin-top: 2px; }
.topbar {
  position: fixed;
  inset: 0 0 auto var(--sidebar-w);
  height: var(--topbar-h);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 16px; flex: 1; }
.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg3);
  color: var(--text2);
}
.icon-btn:hover { color: var(--text); background: var(--bg4); }
.main-content {
  width: 100%;
  min-height: calc(100vh - var(--topbar-h));
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px;
}
.section { display: none; animation: sectionIn .22s ease; }
.section.active { display: block; }
@keyframes sectionIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Cards / Grids / Buttons ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  overflow-wrap: break-word;
}
.card-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-weight: 800; font-size: 14px; }
.card-sub { color: var(--text3); font-size: 12px; margin-top: 3px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 15px; margin-bottom: 20px; }
.kpi {
  position: relative;
  overflow: hidden;
  padding: 18px;
  min-height: 74px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg2);
}
.kpi::after {
  content: '';
  position: absolute;
  inset: auto -30px -35px auto;
  width: 120px;
  height: 5px;
  background: var(--accent);
  opacity: .45;
  transform: rotate(-28deg);
}
.kpi small { display: block; color: var(--text3); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.kpi strong { display: block; margin-top: 9px; font-size: 25px; line-height: 1; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th {
  background: var(--bg3);
  color: var(--text3);
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--text2); font-size: 12px; vertical-align: top; }
tr:hover td { background: rgba(255,255,255,.025); color: var(--text); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ok { color: var(--green); background: var(--green-bg); }
.warn { color: var(--amber); background: var(--amber-bg); }
.danger { color: var(--red); background: var(--red-bg); }
.info { color: var(--accent2); background: var(--accent-bg); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: transform .16s, box-shadow .16s, filter .16s;
}
.btn:hover { transform: translateY(-1px); }
.btn-a { color: #fff; background: linear-gradient(135deg, #0ea5c9, #0369a1); }
.btn-a:hover { filter: brightness(1.08); box-shadow: 0 8px 20px rgba(14,165,201,.22); }
.btn-o { color: var(--text2); background: transparent; border: 1px solid var(--border); }
.btn-s { color: var(--green); background: var(--green-bg); border: 1px solid rgba(34,197,94,.25); }
.btn-d { color: var(--red); background: var(--red-bg); border: 1px solid rgba(239,68,68,.25); }
.btn-full { width: 100%; }
.btn:disabled, button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
a.btn { display: inline-flex; }

/* ===== Utility ===== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.toolbar h2 { margin: 0; font-size: 19px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.muted { color: var(--text3); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.empty { padding: 24px; text-align: center; color: var(--text3); }
form.stack { display: grid; gap: 15px; }
input[type="checkbox"] { width: auto; height: auto; }
label.row { display: flex; align-items: center; gap: 8px; }
label.row span { margin: 0; }

/* ===== Mobile shell ===== */
.mobile-shell {
  min-height: 100vh;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(86px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.mobile-top {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
  background: var(--bg);
}
.mobile-title { font-size: 16px; font-weight: 800; }
.mobile-sub { color: var(--text3); font-size: 12px; margin-top: 2px; }
.mobile-section { display: none; animation: sectionIn .22s ease; }
.mobile-section.active { display: block; }
.attendance-card {
  padding: 22px;
  border-radius: 18px;
  border: 1px solid rgba(14,165,201,.35);
  background: linear-gradient(150deg, rgba(14,165,201,.18), rgba(34,197,94,.08)), var(--bg2);
}
.attendance-time { margin: 12px 0 6px; font-size: 38px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.attendance-state { color: var(--green); font-weight: 800; letter-spacing: .04em; }
.mobile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.mobile-actions .btn { min-height: 48px; }
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(19, 24, 37, .96);
  border-top: 1px solid var(--border);
}
.bottom-nav button {
  min-height: 50px;
  border-radius: 12px;
  color: var(--text3);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
}
.bottom-nav button.active { color: var(--accent2); background: var(--accent-bg); }
.more-sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(75px + env(safe-area-inset-bottom));
  z-index: 25;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg2);
  box-shadow: var(--shadow);
}
.more-sheet.active { display: grid; }
.more-sheet button { min-height: 42px; border-radius: 10px; background: var(--bg3); color: var(--text2); font-weight: 700; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { min-height: 330px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .g2, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .login-page { padding: 0; place-items: stretch; }
  .login-wrap { width: 100%; min-height: 100vh; border: 0; border-radius: 0; }
  .login-left, .login-right { padding: 28px 20px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 14px; }
  .main-content { padding: 16px; }
  .toolbar { align-items: flex-start; }
  .toolbar-actions { width: 100%; }
  .table-wrap table { min-width: 560px; }
}
@media (max-width: 428px) {
  .attendance-time { font-size: 34px; }
  .bottom-nav button { font-size: 10px; }
  .kpi strong { font-size: 21px; }
}
@media (max-width: 360px) {
  .mobile-top { flex-direction: column; align-items: flex-start; }
  .mobile-top .row { width: 100%; justify-content: flex-end; }
  .attendance-time { font-size: 30px; }
}
@supports (padding: max(0px)) {
  .mobile-shell { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .bottom-nav { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .mobile-top, .no-print { display: none !important; }
  .main-content, .mobile-shell { margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; color: #111827 !important; }
}