/* IMB Accounts: Ideal Marriage Bureau brand theme.
   Brand red lives in the header band, primary buttons and key figures.
   Everything else stays calm so salaries and flags are easy to read. */

@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --red: #C6121F;          /* exact logo red */
  --red-deep: #A00E19;
  --red-wash: #FCEDEE;
  --page: #F6F4F5;
  --surface: #FFFFFF;
  --ink: #241A1C;
  --muted: #6F6266;
  --line: #E7DEE0;
  --line-strong: #D6CACD;
  --accent: var(--red);     /* buttons, links on light surfaces */
  --accent-ink: #FFFFFF;
  --link: #A00E19;
  --focus: #1F6FD6;
  --ok: #1D7A4E;     --ok-bg: #E2F3EA;
  --warn: #8F5B00;   --warn-bg: #FFF1D6;
  --bad: #B3121D;    --bad-bg: #FCE8E9;
  --info: #3D4F7A;   --info-bg: #ECEFF7;
  --row-hover: #FBF8F9;
  --current: #FFF7F7;
  --header: var(--red);
  --r-s: 8px;
  --r-m: 14px;
  --shadow: 0 1px 2px rgba(60, 20, 25, .05), 0 8px 24px -12px rgba(60, 20, 25, .12);
  --font: "Figtree", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --red-wash: #3A1A1D;
    --page: #141112;
    --surface: #1E1A1B;
    --ink: #F3EBEC;
    --muted: #B3A5A8;
    --line: #342C2E;
    --line-strong: #463C3F;
    --accent: #E5414C;
    --accent-ink: #FFFFFF;
    --link: #FF8C93;
    --focus: #7FB0F5;
    --ok: #6FD3A0;     --ok-bg: #16352A;
    --warn: #F3C46A;   --warn-bg: #3B2E12;
    --bad: #FF8C93;    --bad-bg: #3D1B1E;
    --info: #A9B8E0;   --info-bg: #1F2434;
    --row-hover: #242021;
    --current: #2A2022;
    --header: #8F0D17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 400 15.5px/1.55 var(--font); font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.85rem; line-height: 1.15; margin: 0; font-weight: 750; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 .5rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 1.8rem 0 .25rem; font-weight: 700; }
p { margin: 0 0 .8rem; text-wrap: pretty; }
h1, h2, .auth__brand p { text-wrap: balance; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
strong { font-weight: 650; }

/* ---------- Header band: the one bold brand moment ---------- */
.topbar { background: var(--header); color: #fff; }
.topbar__inner {
  max-width: 1160px; margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 2rem;
}
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand img { display: block; height: 40px; width: auto; }
.brand__app {
  font-weight: 600; font-size: .95rem; padding-left: .75rem;
  border-left: 1px solid rgba(255, 255, 255, .35); opacity: .95;
}
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a {
  color: rgba(255, 255, 255, .82); text-decoration: none; font-weight: 600;
  padding: .45rem .85rem; border-radius: 999px; white-space: nowrap; flex: none;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.nav a[aria-current="page"] { color: var(--red-deep); background: #fff; }
.who { display: flex; align-items: center; gap: .9rem; }
.who__text { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.who__name { font-weight: 650; font-size: .92rem; }
.who__role { font-size: .78rem; opacity: .8; }
.who form { margin: 0; }
.topbar :focus-visible { outline-color: #fff; }

.page { max-width: 1160px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page-head { margin: 0 0 1.5rem; }
.page-head p { margin: .35rem 0 0; }

/* ---------- Notices ---------- */
.notice { padding: .75rem 1rem; border-radius: var(--r-s); margin: 0 0 1.1rem; font-weight: 500; }
.notice--success { background: var(--ok-bg); color: var(--ok); }
.notice--error   { background: var(--bad-bg); color: var(--bad); }
.notice--info    { background: var(--info-bg); color: var(--info); }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 1.35rem 1.5rem; margin: 0 0 1.25rem; box-shadow: var(--shadow);
}
.panel > h2 + .muted { margin-top: -.25rem; }
.crumbs { margin: 0 0 .35rem; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r-m);
  overflow: hidden; margin: 0 0 2.2rem; box-shadow: var(--shadow);
}
.summary__item { background: var(--surface); padding: 1.3rem 1.5rem; display: flex; flex-direction: column; gap: .2rem; }
.summary__value { font-size: 2.3rem; font-weight: 750; line-height: 1.05; letter-spacing: -.02em; }
.summary__item:first-child .summary__value { color: var(--accent); }
.summary__label { color: var(--muted); font-size: .92rem; max-width: 30ch; }

.checklist {
  list-style: none; padding: 0; margin: 0 0 1.5rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden;
}
.checklist__item { display: flex; gap: 1rem; align-items: center; padding: .9rem 1.2rem; border-top: 1px solid var(--line); }
.checklist__item:first-child { border-top: 0; }
.checklist__state {
  flex: 0 0 2.1rem; height: 2.1rem; border-radius: 50%; display: inline-grid; place-items: center;
  font-weight: 700; background: var(--red-wash); color: var(--accent);
}
.checklist__item.is-done .checklist__state { background: var(--ok-bg); color: var(--ok); }
.checklist__item.is-done .checklist__text { color: var(--muted); }
.checklist__text a { font-weight: 650; margin-right: .5rem; color: var(--ink); }
.checklist__text a:hover { color: var(--link); }

/* ---------- Add-staff picker ---------- */
.picker {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  margin: 0 0 1.5rem; box-shadow: var(--shadow); overflow: hidden;
}
.picker > summary {
  list-style: none; cursor: pointer; padding: 1rem 1.3rem; display: flex; flex-wrap: wrap;
  align-items: baseline; gap: .3rem 1rem; border-left: 4px solid var(--accent);
}
.picker > summary::-webkit-details-marker { display: none; }
.picker > summary::after { content: "Show"; margin-left: auto; color: var(--link); font-weight: 600; font-size: .9rem; }
.picker[open] > summary::after { content: "Hide"; }
.picker[open] > summary { border-bottom: 1px solid var(--line); }
.picker__title { font-weight: 700; font-size: 1.05rem; }
.picker__meta { color: var(--muted); }
.picker__body { padding: 1rem 1.3rem 1.3rem; }
.picker .table-wrap { box-shadow: none; max-height: 460px; overflow: auto; }
.picker__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem 1rem; margin-top: 1rem; }
.table--pick tr.is-dim td { color: var(--muted); }
.table--pick tr.is-dim strong { font-weight: 500; }
.pick { width: 2.5rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.tabs a {
  padding: .35rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); font-size: .9rem; font-weight: 550;
}
.tabs a:hover { border-color: var(--line-strong); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.tabs .count { opacity: .7; margin-left: .25rem; font-weight: 500; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-m); box-shadow: var(--shadow);
}
.panel .table-wrap { box-shadow: none; border-radius: var(--r-s); }
.table { width: 100%; border-collapse: collapse; min-width: 680px; }
.table th, .table td { padding: .75rem .95rem; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.table thead th {
  border-top: 0; font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap;
  background: var(--surface); position: sticky; top: 0; z-index: 1;
}
.table tbody tr:hover td { background: var(--row-hover); }
.table tr.is-current td { background: var(--current); }
.name-link { font-weight: 650; color: var(--ink); text-decoration: none; }
.name-link:hover { color: var(--link); text-decoration: underline; }
.num { text-align: right !important; white-space: nowrap; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Badges and flags ---------- */
.badge {
  display: inline-block; white-space: nowrap; font-size: .76rem; padding: .12rem .55rem;
  border-radius: 999px; font-weight: 650; margin-right: .25rem;
}
.badge--active { background: var(--ok-bg); color: var(--ok); }
.badge--left, .badge--none { background: var(--page); color: var(--muted); border: 1px solid var(--line); }
.badge--suspended { background: var(--bad-bg); color: var(--bad); }
.flag {
  display: inline-block; font-size: .8rem; padding: .14rem .55rem; margin: 0 .3rem .3rem 0;
  border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-weight: 550;
}
.flags { margin: .8rem 0 1.2rem; }

/* ---------- Facts ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem 1.5rem; margin: .8rem 0 0; }
.facts dt { font-size: .8rem; color: var(--muted); margin-bottom: .1rem; }
.facts dd { margin: 0; font-weight: 600; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1rem; }
.form fieldset { border: 0; padding: 0; margin: 0; display: contents; }
.form--grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); align-items: start; }
.field { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.field > span { font-weight: 600; }
.field--wide { grid-column: 1 / -1; }
.field--check { flex-direction: row; align-items: center; gap: .55rem; align-self: end; padding-bottom: .65rem; }
.field--check > span { font-weight: 500; }
.field--inline { flex-direction: row; align-items: center; gap: .7rem; }
.field__error { color: var(--bad); font-size: .83rem; font-weight: 550; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-s);
  padding: .55rem .7rem; width: 100%; min-height: 2.65rem;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--red-wash); }
.field--inline input { width: auto; }
input[type="checkbox"] { width: 1.15rem; min-height: 1.15rem; accent-color: var(--accent); box-shadow: none; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: var(--page); color: var(--muted); }
.inline-form { display: flex; flex-wrap: wrap; gap: .7rem 1rem; align-items: center; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 650; border-radius: 999px; padding: .6rem 1.25rem;
  border: 1px solid transparent; cursor: pointer; min-height: 2.65rem;
  transition: background-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--red-deep); }
.btn--primary:disabled { background: var(--line-strong); color: var(--muted); cursor: not-allowed; }
.btn--danger { background: var(--bad); color: #fff; padding: .45rem 1rem; min-height: 0; }
.btn--on-brand { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); padding: .35rem .95rem; min-height: 0; }
.btn--on-brand:hover { background: rgba(255, 255, 255, .24); }
.btn--block { width: 100%; }
.btn[aria-busy="true"] { opacity: .65; cursor: progress; }

/* Remove-salary mini form */
.mini summary { cursor: pointer; color: var(--bad); font-size: .88rem; font-weight: 600; }
.mini__form { display: flex; gap: .45rem; margin-top: .45rem; min-width: 290px; }

/* ---------- Login ---------- */
.bare { min-height: 100vh; display: grid; }
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth__brand {
  background: var(--header); color: #fff; display: flex; flex-direction: column;
  justify-content: center; align-items: flex-start; padding: 3rem clamp(2rem, 6vw, 5.5rem);
}
.auth__brand img { width: min(340px, 80%); height: auto; }
.auth__brand p { margin: 1.6rem 0 0; font-size: 1.15rem; max-width: 30ch; opacity: .92; line-height: 1.45; }
.auth__panel { display: flex; flex-direction: column; justify-content: center; padding: 3rem clamp(1.5rem, 6vw, 5rem); max-width: 520px; width: 100%; }
.auth__panel h1 { margin-bottom: .4rem; }
.auth__panel .form { margin-top: 1.2rem; }

.empty { padding: 1.5rem; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-m); color: var(--muted); }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .bare { display: block; }
  .auth { grid-template-columns: 1fr; grid-auto-rows: max-content; min-height: 100vh; }
  .auth__brand { padding: 2.4rem 1.5rem 2rem; align-items: center; text-align: center; }
  .auth__brand img { width: 210px; }
  .auth__brand p { margin-top: .9rem; font-size: 1rem; }
  .auth__panel { padding: 2rem 1.5rem 2.5rem; max-width: none; justify-content: flex-start; }
}
@media (max-width: 680px) {
  .topbar__inner { gap: .6rem 1rem; padding: .6rem 1rem; }
  .brand img { height: 32px; }
  .brand__app { display: none; }
  .who__role { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  .page { padding: 1.4rem 1rem 3rem; }
  h1 { font-size: 1.5rem; }
  .summary__value { font-size: 1.9rem; }
  .panel { padding: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ================= Stage 4: attendance, settings, users, audit ================= */
.page-head--split { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.page-head--split p { max-width: 70ch; }
.month-nav { display: flex; align-items: center; gap: .6rem; }
.month-nav strong { min-width: 9.5rem; text-align: center; font-size: 1.05rem; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); padding: .4rem .9rem; min-height: 0; text-decoration: none; display: inline-block; }
.btn--ghost:hover { border-color: var(--muted); }
.btn--small { padding: .3rem .8rem; font-size: .88rem; min-height: 0; }
.btn--danger-text { color: var(--bad); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem 1rem; margin-bottom: .6rem; }
.panel-head h2 { margin: 0; }
.day-nav { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.day-pick { margin: 0; }
.day-pick input { width: auto; min-height: 2.3rem; padding: .3rem .6rem; }
.off-note { background: var(--page); border-radius: var(--r-s); padding: .9rem 1rem; color: var(--muted); margin: 0; }
.form-actions { margin-top: 1rem; display: flex; justify-content: flex-end; }
.table--mark { min-width: 560px; }
.table--mark td { vertical-align: middle; }
.table--mark select { max-width: 15rem; }
.table--mark tr.is-marked td { background: var(--current); }
.count-pill { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: .8rem; padding: .05rem .55rem; margin-left: .3rem; vertical-align: middle; }
.badge--warn { background: var(--warn-bg); color: var(--warn); }

/* Review queue */
.review-list { display: grid; gap: .6rem; }
.review-item { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; justify-content: space-between; align-items: center; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--page); }
.review-item__what { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: baseline; }
.review-item__form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
.review-item__form select { width: auto; }
.review-item__form input { width: 16rem; }

/* Month register grid */
.register-section { margin: 0 0 2rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: 0 0 .8rem; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.register-wrap { max-height: 70vh; }
.register { border-collapse: separate; border-spacing: 0; font-size: .82rem; min-width: 100%; }
.register th, .register td { border-bottom: 1px solid var(--line); text-align: center; padding: 0; height: 2.3rem; min-width: 1.8rem; }
.register thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-weight: 650; color: var(--ink); padding: .3rem 0; line-height: 1.1; }
.register__dow { display: block; font-size: .68rem; color: var(--muted); font-weight: 500; }
.register .register__name { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; padding: 0 .8rem; white-space: nowrap; font-weight: 600; min-width: 8.5rem; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--line); }
.register thead .register__name { z-index: 3; }
.register td a { display: grid; place-items: center; width: 100%; height: 100%; text-decoration: none; }
.register td a:hover { background: var(--row-hover); }
.register .is-off { background: repeating-linear-gradient(135deg, var(--page) 0 4px, transparent 4px 8px); color: var(--muted); }
.register .is-na { color: var(--line-strong); }
.register .is-selected { box-shadow: inset 0 0 0 2px var(--accent); }
.cell-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }
.cell-code { display: inline-grid; place-items: center; min-width: 1.55rem; height: 1.45rem; padding: 0 .25rem; border-radius: 5px; font-size: .74rem; font-weight: 700; font-style: normal; }
.code--half_day      { background: var(--warn-bg); color: var(--warn); }
.code--leave         { background: var(--info-bg); color: var(--info); }
.code--paid_leave    { background: var(--ok-bg); color: var(--ok); }
.code--absent        { background: var(--bad-bg); color: var(--bad); }
.code--official_duty { background: var(--ok-bg); color: var(--ok); }
.code--late, .code--early_leave { background: var(--page); color: var(--muted); border: 1px solid var(--line-strong); }
.code--off { background: repeating-linear-gradient(135deg, var(--line) 0 3px, transparent 3px 6px); border: 1px solid var(--line); }
.cell-code.is-flagged { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--bad); }
.amount--minus { color: var(--bad); }

/* Settings */
.choice-list { display: grid; gap: .7rem; }
.choice { display: flex; gap: .8rem; align-items: flex-start; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--current); }
.choice input[type="radio"] { width: 1.1rem; min-height: 1.1rem; margin-top: .2rem; accent-color: var(--accent); }
.choice > span { display: flex; flex-direction: column; gap: .2rem; }
.inline-input { display: inline-flex; align-items: center; gap: .5rem; margin-top: .3rem; }
.inline-input input { width: 4.5rem; min-height: 2.2rem; padding: .3rem .5rem; }

/* Users */
.role-help { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem 1.4rem; margin: 1.2rem 0 0; font-size: .88rem; }
.role-help dt { font-weight: 650; }
.role-help dd { margin: 0; color: var(--muted); }
.table tr.is-dim td { color: var(--muted); }
.inline-form select { width: auto; }

/* Audit log */
.table--audit td { font-size: .9rem; }
.changes { min-width: 18rem; }
.chg { display: block; margin-bottom: .15rem; }
.chg b { font-weight: 600; text-transform: capitalize; }
.chg__arrow { color: var(--muted); }
.nowrap { white-space: nowrap; }
.pager { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 680px) {
  .review-item__form input { width: 100%; }
  .month-nav strong { min-width: 0; }
}

@media (max-width: 680px) {
  .nav { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin: 0 -1rem; padding: 0 1rem .2rem; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: .4rem .8rem; }
  /* attendance marking: one card per person instead of a wide table */
  .table--mark { min-width: 0; }
  .table--mark thead { display: none; }
  .table--mark tr { display: grid; grid-template-columns: 1fr; gap: .45rem; padding: .85rem 1rem; border-top: 1px solid var(--line); }
  .table--mark tr:first-child { border-top: 0; }
  .table--mark td { border: 0; padding: 0; }
  .table--mark select { max-width: none; }
  .day-nav { width: 100%; }
}
