/* SM School · Staff Attendance — web portal
   Palette follows the existing admin portal (navy #1f3a5f, indigo #4338ca) and the Android status colours. */
:root {
  --navy: #1f3a5f;
  --navy-2: #2b4c78;
  --ink: #1c2230;
  --ink-2: #4a5468;
  --muted: #6b7486;
  --line: #e3e7ee;
  --bg: #f3f5f9;
  --card: #ffffff;
  --accent: #4338ca;
  --accent-soft: #eef0fd;
  --ok: #15803d;      --ok-soft: #e7f6ec;
  --warn: #b45309;    --warn-soft: #fdf1e3;
  --bad: #b91c1c;     --bad-soft: #fdecec;
  --leave: #4338ca;   --leave-soft: #eceafd;
  --half: #0891b2;    --half-soft: #e3f5f9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --focus: 0 0 0 3px rgba(67, 56, 202, .35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Tamil", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.mt-lg { margin-top: 20px; }
.center { text-align: center; }
.small { font-size: .86rem; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* ---------- top bar ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 18px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: #fff; color: var(--navy); font-weight: 800;
  display: grid; place-items: center; font-size: .92rem; letter-spacing: .02em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1rem; }
.brand-text small { font-size: .74rem; opacity: .78; }
.mainnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a { color: #dbe4f3; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: .92rem; }
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.who { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.who-name { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- layout ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 22px 18px 40px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid #edf0f5; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title h2 { margin: 0; }
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 18px 12px 28px; }

/* ---------- today hero ---------- */
.today { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; border: 0; }
.today .label { color: #fff; font-size: .8rem; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }
.today .status { font-size: 1.9rem; font-weight: 800; letter-spacing: .01em; margin: 4px 0 8px; }
.today .times { display: flex; gap: 22px; flex-wrap: wrap; font-size: .95rem; }
.today .times b { display: block; font-size: 1.25rem; }
.today .note { margin-top: 12px; font-size: .88rem; opacity: .9; }
.today .btn-light { margin-top: 14px; }

/* ---------- chips / badges ---------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.chip-role { background: rgba(255,255,255,.16); color: #fff; }
.st-PRESENT, .st-APPROVED, .st-AUTO_APPROVED, .net-ON { background: var(--ok-soft); color: var(--ok); }
.st-LATE, .st-PENDING, .st-DELAYED, .net-OFF { background: var(--warn-soft); color: var(--warn); }
.st-LEAVE, .dir { background: var(--leave-soft); color: var(--leave); }
.st-HALF { background: var(--half-soft); color: var(--half); }
.st-ABSENT, .st-REJECTED, .flag-late { background: var(--bad-soft); color: var(--bad); }
.today .chip { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- balances ---------- */
.balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.bal { background: var(--accent-soft); border-radius: 12px; padding: 12px; text-align: center; }
.bal .code { font-size: .78rem; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.bal .rem { font-size: 1.6rem; font-weight: 800; color: var(--ink); line-height: 1.15; }
.bal .of { font-size: .76rem; color: var(--muted); }
.bal .name { font-size: .74rem; color: var(--ink-2); margin-top: 2px; }

/* ---------- tables / lists ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.data td { padding: 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 26px 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid #f0f2f6; }
.list li:last-child { border-bottom: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfd6e2; border-radius: 10px;
  padding: 10px 12px; min-height: 44px; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
textarea.input { min-height: 80px; resize: vertical; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700;
  border-radius: 10px; border: 1px solid transparent; padding: 10px 18px; min-height: 44px; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff; transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: 12px; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .85rem; }
.btn-outline { background: #fff; color: var(--accent); border-color: #c9cdf3; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn-light { background: #fff; color: var(--navy); }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }
.btn-bad { background: var(--bad); }

.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: .93rem; border: 1px solid; }
.alert-ok { background: var(--ok-soft); border-color: #bfe5cc; color: #0f5a2b; }
.alert-err { background: var(--bad-soft); border-color: #f3c3c3; color: #8a1414; }
.alert-info { background: var(--accent-soft); border-color: #d4d8fa; color: #2d2591; }
.alert-warn { background: var(--warn-soft); border-color: #f2d3ad; color: #7c3a06; }

/* ---------- login ---------- */
body.anon { background: radial-gradient(1200px 500px at 50% -10%, #2b4c78 0%, var(--navy) 55%, #142843 100%); min-height: 100vh; }
body.anon .topbar { background: transparent; box-shadow: none; position: static; }
body.anon .foot { color: rgba(255,255,255,.6); }
.auth-card { max-width: 400px; margin: 4vh auto 0; }
.auth-card h1 { font-size: 1.3rem; }
.auth-card .card { padding: 26px; }
.public-card { max-width: 560px; margin: 4vh auto 0; text-align: center; }

/* ---------- punch ---------- */
.punch-wrap { max-width: 560px; margin: 0 auto; }
.netline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; color: var(--ink-2); margin-bottom: 14px; }
.camera-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed #c9cdf3; background: var(--accent-soft); border-radius: 16px; min-height: 150px; padding: 16px;
  color: var(--accent); font-weight: 700; cursor: pointer; text-align: center; }
.camera-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.camera-btn .big { font-size: 2rem; line-height: 1; }
.camera-btn.has-photo { border-style: solid; background: #fff; }
.preview { display: none; width: 160px; height: 160px; object-fit: cover; border-radius: 50%; border: 4px solid #fff;
  box-shadow: var(--shadow); margin: 0 auto 4px; }
.preview.show { display: block; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.result { text-align: center; }
.result .msg { font-size: 1.15rem; font-weight: 800; margin-bottom: 6px; }
.scanner { display: none; margin-top: 14px; }
.scanner.open { display: block; }
.scanner video { width: 100%; max-height: 60vh; background: #000; border-radius: 14px; object-fit: cover; }
.scanner .scan-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.done-badge { font-size: 2.4rem; }
.js-only { display: none; }
.has-js .js-only { display: block; }
.has-js .no-js { display: none; }

/* ---------- approvals ---------- */
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: #e9ecf2; border: 1px solid #dfe3ea; display: block; }
.thumb-empty { width: 52px; height: 52px; border-radius: 10px; background: #f0f2f6; color: #9aa3b2; font-size: .62rem;
  display: grid; place-items: center; text-align: center; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.remarks { min-width: 140px; min-height: 36px; padding: 6px 10px; }
.approval-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; }
.selfie-full { max-width: 100%; border-radius: 12px; }

/* ---------- bottom tab bar (mobile) ---------- */
.tabbar { display: none; }
.ti { width: 22px; height: 22px; display: block; margin: 0 auto 2px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.ti-home { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3 2 11h3v9h6v-6h2v6h6v-9h3z'/%3E%3C/svg%3E"); }
.ti-punch { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 4 7.2 6H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-3.2L15 4zm3 4.5a4.5 4.5 0 1 1 0 9 4.5 4.5 0 0 1 0-9z'/%3E%3C/svg%3E"); }
.ti-leave { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 2v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2V2h-2v2H9V2zM5 9h14v11H5z'/%3E%3C/svg%3E"); }
.ti-account { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-5 0-9 2.5-9 5.5V22h18v-2.5C21 16.5 17 14 12 14z'/%3E%3C/svg%3E"); }

@media (max-width: 860px) {
  .grid-main, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  body.signed-in { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .mainnav, .who-name { display: none; }
  .topbar-inner { padding: 10px 14px; }
  .page { padding: 16px 12px 24px; }
  h1 { font-size: 1.25rem; }
  .card { padding: 15px; }
  .two { grid-template-columns: 1fr; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(16,24,40,.06); }
  .tabbar a { text-align: center; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; padding: 4px 0; border-radius: 10px; }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
  .foot { display: none; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 2px; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; }
  table.stack td.num { text-align: right; }
  table.stack td > .cell { text-align: right; }
  table.stack td > .cell .chip { margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .topbar, .tabbar, .foot, .btn { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
