:root {
  --navy: #1f3a5f; --navy-2: #2b4c77; --bg: #f3f5f8; --card: #fff; --line: #dfe4ea; --text: #1d2733;
  --muted: #6b7785; --green: #1e9e62; --green-bg: #dcf5e8; --red: #d64545; --red-bg: #fde3e3;
  --amber: #b7791f; --amber-bg: #fff3d6; --blue: #2f6fd6; --blue-bg: #e1ecfd; --grey-bg: #eceff3;
  --purple: #7048c8; --purple-bg: #eee6fd; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--red); min-height: 18px; font-size: 13px; margin: 4px 0; }
h1, h2, h3 { margin: 0 0 10px; }
h1 { font-size: 21px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--blue); }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: #fff; border-color: #f1b7b7; color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.warn { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 8px; padding: 10px; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 6px; }
.btn.lunch { background: var(--amber-bg); border-color: #f0d59a; color: #7a5210; }
.btn.lunch.on { background: var(--amber); color: #fff; border-color: var(--amber); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(183,121,31,.2); } }
.icon-btn { border: 0; background: none; font-size: 20px; cursor: pointer; }
label { display: block; font-weight: 600; font-size: 12.5px; color: #3c4855; margin-bottom: 10px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #cfd6de; border-radius: 7px; font: inherit; background: #fff; color: var(--text); }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9ab8e6; border-color: #9ab8e6; }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 6px 0 0; vertical-align: middle; }
.check { font-weight: 500; display: inline-flex; align-items: center; margin-right: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

/* auth */
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(135deg, #1f3a5f, #2b6a8f); }
.auth-card { background: #fff; width: 100%; max-width: 380px; padding: 28px; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.brand-lg { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.brand-lg img { width: 48px; height: 48px; }
.brand-lg b { font-size: 20px; display: block; }
.brand-lg span { color: var(--muted); }

/* layout */
.app { display: flex; min-height: 100%; }
.sidebar { width: 220px; background: var(--navy); color: #d9e3ef; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand img { width: 36px; height: 36px; }
.brand b { color: #fff; display: block; font-size: 15px; }
.brand span { font-size: 12px; opacity: .8; }
nav { flex: 1; overflow-y: auto; padding: 8px; }
nav a { display: flex; align-items: center; justify-content: space-between; color: #d9e3ef; text-decoration: none; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
nav a:hover { background: rgba(255,255,255,.08); }
nav a.active { background: #fff; color: var(--navy); font-weight: 700; }
nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 12px 12px 4px; }
.badge { background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.side-foot { padding: 10px 16px; color: #9fb2c8; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.menu-btn { display: none; }
.att-chip { flex: 1; display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.att-chip b { color: var(--text); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.user-menu { position: relative; }
.dropdown { position: absolute; right: 0; top: 110%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 180px; z-index: 30; overflow: hidden; }
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 14px; cursor: pointer; font: inherit; }
.dropdown button:hover { background: var(--bg); }
main { padding: 20px; max-width: 1500px; width: 100%; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.clickable { cursor: pointer; } .stat.clickable:hover { border-color: var(--navy-2); }
.stat.red .v { color: var(--red); } .stat.amber .v { color: var(--amber); } .stat.green .v { color: var(--green); }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.banner.amber { background: var(--amber-bg); border: 1px solid #f0d59a; }
.banner.red { background: var(--red-bg); border: 1px solid #f3b9b9; }
.banner.blue { background: var(--blue-bg); border: 1px solid #b9cff5; }
.running-card { background: linear-gradient(135deg, #1f3a5f, #2b6a8f); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.running-card .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.running-card .btn { border-color: transparent; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid #edf0f3; text-align: left; vertical-align: top; }
th { background: #f7f9fb; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #56626f; position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
tr.running { background: #f0f7ff !important; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.task-title { font-weight: 600; }
.task-sub { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 5px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
tfoot td { font-weight: 700; background: #f7f9fb; }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: #13724a; }
.pill.red { background: var(--red-bg); color: #b02f2f; }
.pill.amber { background: var(--amber-bg); color: #8a5b12; }
.pill.blue { background: var(--blue-bg); color: #1f55ad; }
.pill.grey { background: var(--grey-bg); color: #56626f; }
.pill.purple { background: var(--purple-bg); color: #5733a6; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filters label { margin: 0; min-width: 140px; }
.filters input, .filters select { padding: 6px 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--navy); }

/* attendance grid */
.att-grid td, .att-grid th { padding: 5px 4px; text-align: center; font-size: 12px; }
.att-grid td:first-child, .att-grid th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 150px; padding-left: 10px; }
.code { display: inline-block; min-width: 26px; border-radius: 4px; padding: 2px 3px; font-weight: 700; font-size: 11px; cursor: default; }
.code.P { background: var(--green-bg); color: #13724a; } .code.HD { background: var(--amber-bg); color: #8a5b12; }
.code.A { background: var(--red-bg); color: #b02f2f; } .code.WO { background: var(--grey-bg); color: #6b7785; }
.code.H { background: var(--blue-bg); color: #1f55ad; } .code.late { outline: 2px solid #e8a33d; }
th.wo { color: #b0b8c2; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(17,28,43,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 16px 18px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.partner-pick { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.partner-pick label { border: 1px solid #cfd6de; border-radius: 8px; padding: 9px 12px; cursor: pointer; margin: 0; font-weight: 600; display: flex; align-items: center; }
.partner-pick label:has(input:checked) { border-color: var(--navy); background: var(--blue-bg); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--line); padding: 4px 0 10px 12px; }
.timeline li b { display: block; }
pre.report { white-space: pre-wrap; background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: 13px/1.5 Consolas, monospace; max-height: 420px; overflow: auto; }
.bday { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f2f5; }
.bday:last-child { border-bottom: 0; }
.bday .cake { font-size: 26px; }
.bday.today { background: #fff8e6; border-radius: 8px; padding: 8px; }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: #1d2733; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 420px; animation: slide .2s; }
.toast.error { background: var(--red); } .toast.ok { background: var(--green); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; padding: 6px; z-index: 300; font-weight: 600; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -240px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .menu-btn { display: block; }
  .cols, .grid2, .grid3 { grid-template-columns: 1fr; }
  main { padding: 12px; }
  .top-actions { width: 100%; justify-content: flex-end; }
}
@media print {
  .sidebar, .topbar, .filters, .btn, .tabs { display: none !important; }
  main { padding: 0; }
}
