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

:root {
  --ink: #0F3D3E;        /* deep ledger teal: sidebar, headings */
  --ink-2: #1D5557;
  --paper: #F6F7F5;      /* page */
  --sheet: #FFFFFF;      /* tables, forms */
  --rule: #D5DCD8;       /* ledger rules */
  --text: #1C2524;
  --muted: #5F6D6B;
  --marigold: #E0A100;   /* primary action */
  --marigold-d: #B78300;
  --present: #1E7B4F;
  --half: #B26B00;
  --absent: #B42318;
  --leave: #3D5A99;
  --r: 6px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--paper); color: var(--text); line-height: 1.5;
  font-variant-numeric: tabular-nums;
  display: grid; grid-template-columns: 230px 1fr; grid-template-rows: 52px 1fr; min-height: 100vh;
}
a { color: var(--ink-2); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--marigold); outline-offset: 1px;
}

/* ---------- frame ---------- */
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--ink); color: #fff;
}
.brand { font-weight: 700; letter-spacing: .01em; }
.who { margin-left: auto; font-size: .9rem; opacity: .9; }
.who a { color: #fff; margin-left: 10px; }
.burger { display: none; cursor: pointer; font-size: 1.3rem; }
.side { background: var(--sheet); border-right: 1px solid var(--rule); padding: 14px 0; overflow-y: auto; }
.navgroup { padding: 6px 0 10px; }
.navgroup > span { display: block; padding: 0 20px 4px; font-size: .78rem; color: var(--muted); font-weight: 600; }
.side a { display: block; padding: 6px 20px; color: var(--text); text-decoration: none; border-left: 3px solid transparent; }
.side a:hover { background: var(--paper); }
.side a.on { border-left-color: var(--marigold); background: var(--paper); font-weight: 600; color: var(--ink); }
.content { padding: 24px 28px 60px; min-width: 0; }
h1 { font-size: 1.55rem; margin: 0 0 18px; color: var(--ink); font-weight: 700; }
h2 { font-size: 1.1rem; margin: 26px 0 10px; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- messages ---------- */
.flash { padding: 10px 14px; border-radius: var(--r); margin: 0 0 14px; border: 1px solid; }
.flash.ok { background: #EAF5EF; border-color: #B7DEC8; color: #14532D; }
.flash.err { background: #FDEDEC; border-color: #F3C1BC; color: #7A1C12; }

/* ---------- tables: ruled like a register ---------- */
.tablewrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: middle; white-space: nowrap; }
th { background: #EEF2F0; color: var(--ink); font-weight: 600; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 180px; }

/* ---------- attendance marks: the one memorable element ---------- */
.mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid currentColor; font-weight: 700; font-size: .72rem;
}
.m-P { color: var(--present); }
.m-HD { color: var(--half); border-style: dashed; }
.m-A { color: var(--absent); }
.m-L { color: var(--leave); }
.badge { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: .8rem; font-weight: 600; background: #EEF2F0; color: var(--muted); }
.b-approved, .b-active, .b-paid, .b-locked { background: #EAF5EF; color: var(--present); }
.b-pending, .b-draft { background: #FFF4D6; color: #7A5600; }
.b-rejected, .b-blocked, .b-inactive, .b-exited, .b-cancelled { background: #FDEDEC; color: var(--absent); }

/* ---------- stat strip ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; background: var(--sheet);
  border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 22px; }
.stat { padding: 14px 18px; border-right: 1px solid var(--rule); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 1.6rem; color: var(--ink); line-height: 1.2; }
.stat span { color: var(--muted); font-size: .88rem; }

/* ---------- forms ---------- */
form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 18px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 18px; }
form.grid .full { grid-column: 1 / -1; }
form.grid h3 { grid-column: 1 / -1; margin: 8px 0 0; font-size: .95rem; color: var(--ink); border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); padding: 7px 10px; border: 1px solid #B9C4C0; border-radius: var(--r); background: #fff; min-width: 0;
}
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--ink); }
textarea { min-height: 80px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters label { min-width: 140px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 14px; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; padding: 7px 14px; border-radius: var(--r); cursor: pointer;
  border: 1px solid #B9C4C0; background: #fff; color: var(--ink); text-decoration: none; line-height: 1.4;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--marigold); border-color: var(--marigold-d); color: #1F1600; }
.btn.primary:hover { background: #F0B41A; }
.btn.danger { color: var(--absent); border-color: #E6A8A1; }
.btn.sm { padding: 3px 9px; font-size: .84rem; }
form.inline { display: inline; }

/* ---------- feature switches ---------- */
.fgroup { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 14px; }
.fgroup h3 { margin: 0; padding: 10px 16px; font-size: .95rem; color: var(--ink); border-bottom: 1px solid var(--rule); background: #EEF2F0; }
.frow { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--rule); }
.frow:last-child { border-bottom: 0; }
.frow .fl { flex: 1; }
.frow .eff { font-size: .8rem; color: var(--muted); width: 110px; }
.tri { display: inline-flex; border: 1px solid #B9C4C0; border-radius: var(--r); overflow: hidden; }
.tri label { flex-direction: row; cursor: pointer; }
.tri input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tri span { padding: 4px 11px; font-size: .83rem; color: var(--muted); border-left: 1px solid #B9C4C0; }
.tri label:first-child span { border-left: 0; }
.tri input:checked + span { background: var(--ink); color: #fff; }
.tri input:focus-visible + span { outline: 3px solid var(--marigold); }

/* ---------- auth pages ---------- */
body.auth { display: grid; place-items: center; grid-template-columns: 1fr; grid-template-rows: 1fr; background: var(--ink); padding: 16px; }
.auth-card { background: var(--sheet); padding: 30px; border-radius: 10px; width: 100%; max-width: 400px; border-top: 6px solid var(--marigold); }
.auth-card h1 { margin-bottom: 2px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

#map { height: 540px; border: 1px solid var(--rule); border-radius: var(--r); }
.thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 4px; border: 1px solid var(--rule); vertical-align: middle; }
.errors td:first-child { color: var(--absent); font-weight: 600; }

@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .burger { display: block; }
  .side { display: none; position: fixed; top: 52px; left: 0; bottom: 0; width: 250px; z-index: 20; box-shadow: 2px 0 12px rgba(15, 61, 62, .25); }
  #navtoggle:checked ~ .side { display: block; }
  .content { padding: 18px 14px 50px; }
  .who { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- notifications, approvals ---------- */
.bell { color: #fff; text-decoration: none; margin-right: 10px; }
.bell .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--marigold); color: #1F1600; font-size: .78rem; text-align: center; }
.stage { font-size: .8rem; color: var(--muted); display: block; }
.trail { font-size: .8rem; color: var(--muted); margin: 4px 0 0; padding: 0; list-style: none; white-space: normal; }
.decide { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.decide input[name=remarks] { width: 170px; }
.note { background: #FFF8E6; border: 1px solid #F0DDA8; border-radius: var(--r); padding: 10px 14px; margin: 0 0 14px; font-size: .9rem; }
.unread td { font-weight: 600; }
.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; }
.panel h3 { margin: 0 0 6px; font-size: 1rem; color: var(--ink); }
.panel p { margin: 0 0 10px; color: var(--muted); font-size: .88rem; }
.panel form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }

/* ---------- menu icons ---------- */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side a { display: flex; align-items: center; gap: 10px; line-height: 1.3; }
.side a span { min-width: 0; }
.side a .ico { color: var(--muted); }
.side a:hover .ico, .side a.on .ico { color: var(--ink); }
.side a.on .ico { stroke-width: 2.1; }
.who { display: flex; align-items: center; gap: 14px; }
.who a { display: inline-flex; align-items: center; gap: 6px; margin-left: 0; }
.ico-top { width: 18px; height: 18px; color: #fff; }
.bell { margin-right: 0; }
@media (max-width: 600px) { .hide-sm { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
