/* DWHRD design system: modern, mobile first. Tokens on :root, dark mode follows the device. */

:root {
  --bg:        #edf1f5;
  --surface:   #ffffff;
  --surface-2: #eef1f8;
  --line:      #e2e7f1;
  --ink:       #111827;
  --ink-2:     #4b5563;
  --ink-3:     #8590a3;

  --brand:     #1a3a5c;
  --brand-2:   #2c5f8a;
  --brand-ink: #ffffff;
  --brand-soft:#e3edf7;
  --navy:      #1a3a5c;
  --gold:      #f0a500;

  --ok:        #059669;  --ok-soft:   #d9f5ea;
  --bad:       #dc2626;  --bad-soft:  #fde4e4;
  --warn:      #d97706;  --warn-soft: #fdefd3;

  --radius:    10px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(17,24,39,.05), 0 8px 24px rgba(17,24,39,.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tab-h: 64px;
  --side-w: 236px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1017; --surface: #161b26; --surface-2: #1d2433; --line: #283044;
    --ink: #eef1f7; --ink-2: #aab3c5; --ink-3: #7a8499;
    --brand: #8b83ff; --brand-2: #b18cff; --brand-ink: #0d1017; --brand-soft: #23334f; --navy: #12294a; --gold: #f0a500;
    --ok: #34d399; --ok-soft: #10302a; --bad: #f87171; --bad-soft: #3a1a1c;
    --warn: #fbbf24; --warn-soft: #3a2b0e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1017; --surface: #161b26; --surface-2: #1d2433; --line: #283044;
  --ink: #eef1f7; --ink-2: #aab3c5; --ink-3: #7a8499;
  --brand: #8b83ff; --brand-2: #b18cff; --brand-ink: #0d1017; --brand-soft: #23334f; --navy: #12294a; --gold: #f0a500;
  --ok: #34d399; --ok-soft: #10302a; --bad: #f87171; --bad-soft: #3a1a1c;
  --warn: #fbbf24; --warn-soft: #3a2b0e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); font-size: .875rem; }
.hidden { display: none !important; }

/* ---------- App shell: navy header with a scrolling tab strip (the old HR Dashboard look) ---------- */
.shell { min-height: 100dvh; }
.head { position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.logo { font-size: 1.6rem; line-height: 1; }
.topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .faint { color: rgba(255,255,255,.75); font-size: .78rem; }
.topbar .btn { min-height: 34px !important; padding: 0 12px !important; font-size: .78rem; background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.main { padding: 16px; max-width: 980px; margin: 0 auto; display: grid; gap: 16px; }

.tabbar { display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; border-top: 1px solid rgba(255,255,255,.12); -webkit-overflow-scrolling: touch; }
.tabbar a {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 12px 16px 10px; font-size: .84rem; font-weight: 600;
  color: rgba(255,255,255,.68); border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0; white-space: nowrap;
}
.tabbar a:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabbar a.active { color: #fff; background: rgba(255,255,255,.12); border-bottom-color: var(--gold); }
.tabbar a .ico { font-size: 1.05rem; }
@media (max-width: 480px) { .topbar .faint { display: none; } }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 0; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 0 20px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 650; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s; }

/* Setup checklist */
.step { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-top: 1px solid var(--line); }
.step:first-of-type { border-top: 0; }
.step .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); color: var(--ink-2); flex: none; }
.step.done .num { background: var(--ok-soft); color: var(--ok); }
.step .txt { flex: 1; min-width: 0; }
.step .txt b { display: block; }
.step .txt span { color: var(--ink-2); font-size: .875rem; }

/* Toast + auth screen */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 99;
  padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; transition: .25s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); color: #fff; }

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #1a3a5c 0%, #2c5f8a 100%); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }

/* Form rows: fields never squeeze below a readable width, they wrap instead. */
.row > label.grow { min-width: 150px; }

/* List rows wrap: text takes a full line on a phone, buttons drop underneath. */
.step { flex-wrap: wrap; }
.step .txt { flex: 1 1 220px; }
.step .num + .txt { flex-basis: 140px; }
.step .txt span b { display: inline; }

/* ---------- Stepper number fields, tables, data-entry cards ---------- */
.num { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; min-width: 128px; }
.num button { width: 44px; border: 0; background: var(--surface-2); color: var(--ink); font-size: 1.3rem; font-weight: 700; cursor: pointer; flex: none; }
.num button:active { background: var(--brand-soft); }
.num input { border: 0; border-radius: 0; text-align: center; min-height: 48px; padding: 0 4px; font-weight: 700; font-size: 1.05rem; width: 100%; min-width: 48px; }
.num input:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.num.sm { min-width: 104px; } .num.sm button { width: 36px; } .num.sm input { min-height: 40px; font-size: .95rem; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.data th, table.data td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); position: sticky; top: 0; }
table.data tfoot td { font-weight: 800; background: var(--surface-2); }
table.data td.neg, .neg { color: var(--bad); font-weight: 700; } table.data td.pos, .pos { color: var(--ok); font-weight: 700; } table.data td.warn { color: var(--warn); font-weight: 700; }

.taskgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.task { display: grid; gap: 4px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); }
.task b { font-size: 1.05rem; } .task span { color: var(--ink-2); font-size: .875rem; }
.task:active { transform: scale(.99); }
.entryline { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.entryline:first-of-type { border-top: 0; }
.entryline .lab { flex: 1 1 140px; font-weight: 650; } .entryline .lab small { display: block; color: var(--ink-2); font-weight: 500; }
.stickybar { position: sticky; bottom: calc(var(--tab-h) + 8px + env(safe-area-inset-bottom)); z-index: 15; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg, var(--shadow)); }
@media (min-width: 900px) { .stickybar { bottom: 16px; } }
.stickybar .grow { font-weight: 700; }
.attgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.attgrid label { font-size: .78rem; }
@media (min-width: 700px) { .attgrid { grid-template-columns: repeat(4, 1fr); } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.kpi b { display: block; font-size: 1.35rem; } .kpi span { color: var(--ink-2); font-size: .82rem; }

.card-title { font-size: .88rem; font-weight: 700; color: var(--navy); border-bottom: 2px solid var(--line); padding-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }

/* Old HR Dashboard flavour: navy uppercase card headings, navy table headers, emoji shortcut tiles */
.card > h2, .card > .stack > h2:first-child { font-size: .9rem; color: var(--navy); text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
table.data thead th { background: var(--navy); color: #fff; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.shortcuts a { display: grid; gap: 4px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); color: var(--ink); box-shadow: var(--shadow); }
.shortcuts a b { font-size: 1rem; } .shortcuts a span { color: var(--ink-2); font-size: .85rem; }
.task { border-left: 4px solid var(--gold); }
