/* No external fonts/CDN — CSP is script/style/img/font-src 'self' with zero exceptions
   (see section 8.6 of the plan), so we use the system font stack instead of Google Fonts. */
:root {
  --brand-800: #0F2C59;
  --brand-900: #0A1F40;
  --accent: #1D4ED8;
  --accent-soft: #E8EEFC;
  --gold: #E0A82E;
  --gold-soft: #FBEEC9;
  --present: #16A34A; --present-soft: #DCFCE7;
  --absent: #DC2626;  --absent-soft: #FEE2E2;
  --late: #F59E0B;    --late-soft: #FEF3C7;
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --border: #E6EAF2;
  --text: #0F172A;
  --text-2: #64748B;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(15, 23, 42, .06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .09);
  --shadow-lg: 0 14px 36px rgba(15, 44, 89, .14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); overflow-x: hidden; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
.icon { display: inline-block; vertical-align: middle; }
h1 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; } .card h2 { font-size: 15.5px; font-weight: 800; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-side { flex: 1; background: radial-gradient(130% 160% at 10% -10%, #1c3f78 0%, var(--brand-800) 50%, var(--brand-900) 100%); display: none; align-items: center; justify-content: center; color: #fff; padding: 40px; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(224,168,46,.14); }
@media (min-width: 860px) { .auth-side { display: flex; } }
.auth-side .mark { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; position: relative; z-index: 1; }
.auth-side .mark .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); }
.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; animation: rise .4s ease both; }
.auth-card h1 { margin: 0 0 4px; }
.auth-card p.sub { color: var(--text-2); margin: 0 0 24px; font-size: 14px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 11px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29,78,216,.14); }
.field .error { color: var(--absent); font-size: 12px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--brand-800), var(--brand-900)); color: #fff; border: none; min-height: 44px;
  padding: 11px 18px; border-radius: 11px; font-size: 14.5px; font-weight: 700; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(15,44,89,.25); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; }
.btn.secondary { background: #fff; color: var(--text); border: 1.5px solid var(--border); box-shadow: none; }
.btn.secondary:hover { box-shadow: 0 4px 12px rgba(15,23,42,.08); border-color: #d6dce6; }
.btn.danger { background: linear-gradient(135deg, var(--absent), #b91c1c); }
.btn.gold { background: linear-gradient(135deg, var(--gold), #c98f1d); color: var(--brand-900); }
.btn.small { padding: 7px 12px; font-size: 13px; min-height: 34px; border-radius: 9px; }
.msg { padding: 11px 15px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.msg.error { background: var(--absent-soft); color: var(--absent); }
.msg.ok { background: var(--present-soft); color: var(--present); }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; background: linear-gradient(185deg, var(--brand-800), var(--brand-900)); color: #fff; padding: 22px 14px; display: none; flex-direction: column; position: fixed; top: 0; bottom: 0; }
@media (min-width: 960px) { .sidebar { display: flex; } .main { margin-left: 248px; } }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 24px; font-weight: 800; font-size: 16px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(224,168,46,.18); }
.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; color: rgba(255,255,255,.65); font-weight: 600; font-size: 13.5px; transition: background .15s ease, color .15s ease; }
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.active { background: linear-gradient(135deg, var(--gold), #c98f1d); color: var(--brand-900); box-shadow: 0 4px 14px rgba(224,168,46,.3); }
.side-nav-label { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.35); padding: 14px 12px 4px; }
.side-nav-label:first-child { padding-top: 2px; }
.side-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; font-size: 13px; color: rgba(255,255,255,.8); }

.topbar { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 16px; position: sticky; top: 0; z-index: 5; }
@media (min-width: 960px) { .topbar.mobile-only { display: none; } }
.topbar-pill { display: flex; gap: 2px; background: var(--bg); border-radius: 999px; padding: 3px; overflow-x: auto; -ms-overflow-style: none; scrollbar-width: none; }
.topbar-pill::-webkit-scrollbar { display: none; }
.topbar-pill a { padding: 8px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.topbar-pill a.active { background: var(--brand-800); color: #fff; }

.main { padding: 18px; max-width: 1180px; min-width: 0; flex: 1; }
@media (min-width: 640px) { .main { padding: 26px; } }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr 1fr; gap: 10px; } }

.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); animation: rise .35s ease both; border: 1px solid rgba(15,23,42,.03); }
@media (max-width: 560px) { .card { padding: 14px; border-radius: 14px; } }
.stat-card { display: flex; align-items: center; gap: 12px; }
@media (max-width: 560px) { .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; } }
.stat-card-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card-icon.blue { background: var(--accent-soft); color: var(--accent); }
.stat-card-icon.present { background: var(--present-soft); color: var(--present); }
.stat-card-icon.absent { background: var(--absent-soft); color: var(--absent); }
.stat-card-icon.late { background: var(--late-soft); color: var(--late); }
.stat-card .num { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
@media (min-width: 560px) { .stat-card .num { font-size: 24px; } }
.stat-card .lbl { font-size: 12.5px; color: var(--text-2); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-2); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.table-wrap { overflow-x: auto; margin: 0 -2px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800; }
.badge.present { background: var(--present-soft); color: var(--present); }
.badge.absent { background: var(--absent-soft); color: var(--absent); }
.badge.late { background: var(--late-soft); color: var(--late); }
.badge.gray { background: var(--bg); color: var(--text-2); }

.badge-select {
  border: none; border-radius: 999px; padding: 4px 24px 4px 10px; font-size: 11.5px; font-weight: 800;
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center;
}
.badge-select.present { background-color: var(--present-soft); color: var(--present); }
.badge-select.absent { background-color: var(--absent-soft); color: var(--absent); }
.badge-select.gray { background-color: var(--bg); color: var(--text-2); }
.badge.gold { background: var(--gold-soft); color: #7A5B0A; }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-800), var(--brand-900)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.person { display: flex; align-items: center; gap: 10px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; width: 100%; }
.toolbar .field { margin-bottom: 0; min-width: 150px; flex: 1 1 150px; }
@media (max-width: 480px) { .toolbar form { flex-direction: column; align-items: stretch; } .toolbar .field { width: 100%; } }

.empty { text-align: center; padding: 44px 20px; color: var(--text-2); }
.empty .icon { color: #CBD5E1; margin-bottom: 10px; }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,15,30,.52); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; backdrop-filter: blur(1px); }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 18px; padding: 24px; max-width: 440px; width: 100%; max-height: 85vh; overflow-y: auto; animation: rise .25s ease both; box-shadow: var(--shadow-lg); }
@media (max-width: 480px) { .modal { padding: 20px; border-radius: 16px; } }
.modal h2 { margin: 0 0 16px; font-size: 17px; font-weight: 800; }

.bell-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--bg); color: var(--text-2); transition: background .15s ease; }
.bell-btn:hover { background: #e9edf5; }
.bell-btn .dot { position: absolute; top: 6px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--absent); border: 2px solid var(--surface); }

.hero {
  background: radial-gradient(130% 180% at 12% -20%, #1c3f78 0%, var(--brand-800) 50%, var(--brand-900) 100%);
  color: #fff; border-radius: var(--radius); padding: 22px 22px 26px; margin-bottom: 18px; position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; right: -36px; top: -36px; width: 160px; height: 160px; border-radius: 50%; background: rgba(224,168,46,.14); }
.hero-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.hero-person { display: flex; align-items: center; gap: 12px; }
.hero-avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #c98f1d); color: var(--brand-900); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; flex-shrink: 0; }
.hero-greet { color: var(--gold); font-size: 12px; font-weight: 700; }
.hero-name { font-weight: 800; font-size: 17px; }
.hero-ring-row { display: flex; align-items: center; gap: 18px; margin-top: 22px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-ring { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
.hero-ring .ring-svg circle { transition: stroke-dashoffset .6s ease; }
.hero-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hero-ring-label strong { font-size: 20px; font-weight: 800; line-height: 1; }
.hero-ring-label span { font-size: 9.5px; color: rgba(255,255,255,.65); margin-top: 3px; font-weight: 600; }
.hero-ring-side { flex: 1; min-width: 180px; }
.hero-headline { font-weight: 800; font-size: 15px; }
.hero-sub { color: rgba(255,255,255,.65); font-size: 12.5px; margin-top: 2px; }
.hero-chips { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.hero-chips span { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); border-radius: 99px; padding: 5px 11px; font-size: 11.5px; color: rgba(255,255,255,.85); }
.hero-chips strong { color: #fff; }

.progress-track { height: 6px; border-radius: 99px; background: var(--border); margin-top: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .4s ease; }

.chart-wrap { position: relative; height: 260px; }
@media (min-width: 640px) { .chart-wrap { height: 280px; } }
.leaderboard-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row .rank { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); color: var(--text-2); font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

@media print {
  .sidebar, .topbar.mobile-only, .toolbar, .btn, .page-head a, .bell-btn { display: none !important; }
  .main { margin-left: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-md); min-width: 190px; z-index: 50; padding: 6px;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu form { margin: 0; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  border: none; background: none; text-align: left; font-size: 13.5px; font-weight: 500;
  border-radius: 8px; cursor: pointer; color: var(--text); font-family: inherit;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--absent); }
.dropdown-item:disabled { opacity: .45; cursor: not-allowed; }

.mini-cal-head, .mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.mini-cal-head span { font-size: 11px; font-weight: 700; color: var(--text-2); padding-bottom: 6px; }
.mini-cal-grid span { position: relative; padding: 7px 0; font-size: 13px; font-weight: 600; color: var(--text); border-radius: 8px; }
.mini-cal-grid span.today { background: var(--gold); color: var(--brand-900); font-weight: 800; }
.mini-cal-grid span.has-incident::after {
  content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--absent);
}
.mini-cal-grid span.today.has-incident::after { background: var(--brand-900); }
.dot-legend { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 4px 4px; flex-wrap: wrap; }
.pager-info { font-size: 12.5px; color: var(--text-2); }
.pager-pages { display: flex; gap: 6px; flex-wrap: wrap; }
.pager-pages .btn.disabled { opacity: .4; pointer-events: none; }
@media (max-width: 560px) { .pager { justify-content: center; } .pager-info { display: none; } }
