/* ==========================================================================
   SolveTech Attendance — stylesheet
   Light by default, dark via prefers-color-scheme. All colour lives in the
   token block below: change it once and the whole app follows.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Brand */
  --brand:          #0a6f63;   /* SolveTech teal — buttons, active states */
  --brand-strong:   #085a50;
  --brand-soft:     #e4f2ef;
  --brand-ink:      #ffffff;   /* text on brand fills */

  /* Planes */
  --plane:          #f4f5f3;   /* page background */
  --surface:        #fcfcfb;   /* cards */
  --surface-sunk:   #f0f1ee;   /* inset areas, table heads */
  --rail:           #0f1a1d;   /* top navigation rail */
  --rail-ink:       #eef2f1;
  --rail-muted:     #8ea3a0;

  /* Ink */
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --ink-muted:      #898781;

  /* Lines */
  --line:           rgba(11, 11, 11, 0.10);
  --line-soft:      #e1e0d9;
  --baseline:       #c3c2b7;

  /* Data (validated for both themes) */
  --series-1:       #2a78d6;
  --series-1-soft:  #cde2fb;

  /* Status */
  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;
  --good-wash:      rgba(12, 163, 12, 0.10);
  --warning-wash:   rgba(250, 178, 25, 0.14);
  --critical-wash:  rgba(208, 59, 59, 0.10);

  --radius:         14px;
  --radius-sm:      9px;
  --shadow:         0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px -16px rgba(11, 11, 11, 0.28);
  --sans:           system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand:        #14b8a6;
    --brand-strong: #2dd4bf;
    --brand-soft:   #12312e;
    --brand-ink:    #05201c;

    --plane:        #0d0d0d;
    --surface:      #1a1a19;
    --surface-sunk: #232322;
    --rail:         #111413;
    --rail-ink:     #eef2f1;
    --rail-muted:   #7f918e;

    --ink:          #ffffff;
    --ink-2:        #c3c2b7;
    --ink-muted:    #898781;

    --line:         rgba(255, 255, 255, 0.10);
    --line-soft:    #2c2c2a;
    --baseline:     #383835;

    --series-1:     #3987e5;
    --series-1-soft:#184f95;

    --good-wash:    rgba(12, 163, 12, 0.16);
    --warning-wash: rgba(250, 178, 25, 0.16);
    --critical-wash:rgba(208, 59, 59, 0.16);
    --shadow:       0 1px 2px rgba(0, 0, 0, 0.6), 0 8px 24px -16px rgba(0, 0, 0, 0.9);
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--plane);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem; }

.muted { color: var(--ink-muted); }
.small { font-size: 0.8rem; }
.nums  { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.right { text-align: right; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 22px 48px;
}
.wrap-narrow { max-width: 620px; }

/* --------------------------------------------------------------------------
   Brand mark
   -------------------------------------------------------------------------- */

.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand svg { display: block; flex: none; }
.brand-name {
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  text-transform: uppercase;
  color: var(--rail-ink);
}
.brand-name span { color: var(--brand-strong); }

/* --------------------------------------------------------------------------
   Top rail
   -------------------------------------------------------------------------- */

.rail { background: var(--rail); color: var(--rail-ink); }
.rail-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 12px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.rail-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-inline-start: auto; }
.rail-nav a {
  color: var(--rail-muted);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 550;
  white-space: nowrap;
}
.rail-nav a:hover { color: var(--rail-ink); background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.rail-nav a.is-active { color: var(--brand-ink); background: var(--brand); }
.rail-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.8rem; color: var(--rail-muted);
  border-inline-start: 1px solid rgba(255, 255, 255, 0.12);
  padding-inline-start: 14px;
}
.rail-user strong { color: var(--rail-ink); font-weight: 560; }
.rail-user a { color: var(--rail-muted); }
.rail-user a:hover { color: var(--rail-ink); }

@media (max-width: 640px) {
  .rail-nav { margin-inline-start: 0; order: 3; width: 100%; }
  .rail-user { margin-inline-start: auto; border: 0; padding-inline-start: 0; }
}

/* --------------------------------------------------------------------------
   Cards, sections
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.card-head p { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }

.page-head {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head p { margin: 2px 0 0; color: var(--ink-muted); font-size: 0.86rem; }

/* --------------------------------------------------------------------------
   Stat tiles
   -------------------------------------------------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label { font-size: 0.76rem; color: var(--ink-muted); margin-bottom: 5px; }
.stat-value { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.stat-value small { font-size: 0.9rem; font-weight: 500; color: var(--ink-2); margin-inline-start: 3px; }
.stat-note { font-size: 0.76rem; color: var(--ink-muted); margin-top: 4px; }

/* --------------------------------------------------------------------------
   Buttons & forms
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 580;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease, opacity .12s ease;
}
.btn:hover { background: var(--brand-strong); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-sunk); color: var(--ink); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-danger:hover { background: #b83232; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 0.8rem; font-weight: 560;
  color: var(--ink-2); margin-bottom: 5px;
}
.field .hint { font-size: 0.76rem; color: var(--ink-muted); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"], input[type="tel"],
select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
select { appearance: none; background-image: none; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1 1 150px; margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Flash messages
   -------------------------------------------------------------------------- */

.flash {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 0.88rem;
  border: 1px solid var(--line);
}
.flash-success { background: var(--good-wash); border-color: rgba(12, 163, 12, .35); }
.flash-error   { background: var(--critical-wash); border-color: rgba(208, 59, 59, .35); }
.flash-info    { background: var(--brand-soft); border-color: var(--line); }
.flash strong { font-weight: 620; }

/* --------------------------------------------------------------------------
   Pills / status
   -------------------------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.74rem; font-weight: 580;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-sunk); color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex: none;
}
.pill-in       { color: var(--good); background: var(--good-wash); border-color: rgba(12, 163, 12, .3); }
.pill-done     { color: var(--ink-2); }
.pill-absent   { color: var(--ink-muted); }
.pill-late     { color: #8a5a00; background: var(--warning-wash); border-color: rgba(250, 178, 25, .45); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill-late { color: var(--warning); }
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-scroll { overflow-x: auto; margin-inline: -18px; padding-inline: 18px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 640px;
}
table.data th {
  text-align: start;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 620;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
table.data td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-sunk); }
table.data .nums { font-variant-numeric: tabular-nums; }
.table-empty { padding: 34px 10px; text-align: center; color: var(--ink-muted); font-size: 0.88rem; }

.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
  font-size: 0.74rem; font-weight: 680; flex: none;
  border: 1px solid var(--line);
}
.who-name { font-weight: 560; }
.who-sub { font-size: 0.76rem; color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   Check-in screen
   -------------------------------------------------------------------------- */

.punch {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.punch::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0;
  width: 4px; background: var(--baseline);
}
.punch.is-in::before   { background: var(--good); }
.punch.is-done::before { background: var(--series-1); }
.punch-body { padding: 26px 22px; }

.clock {
  font-size: clamp(3rem, 16vw, 4.6rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock .sec { font-size: 0.42em; color: var(--ink-muted); font-weight: 400; margin-inline-start: 4px; }
.clock-date { color: var(--ink-muted); font-size: 0.88rem; margin-top: 6px; }

.punch-state {
  display: flex; align-items: center; gap: 10px;
  margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.punch-action { margin-top: 18px; }
.punch-action .btn { font-size: 1.02rem; padding: 15px 20px; }
.btn-out { background: var(--rail); color: #fff; }
.btn-out:hover { background: #000; }

.timeline { list-style: none; margin: 18px 0 0; padding: 0; }
.timeline li {
  display: flex; gap: 12px; align-items: baseline;
  padding: 9px 0; border-top: 1px solid var(--line-soft);
  font-size: 0.86rem;
}
.timeline .t { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; }
.timeline .what { color: var(--ink-2); }
.timeline .where { margin-inline-start: auto; font-size: 0.78rem; }

.geo-note {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 0.78rem; color: var(--ink-muted);
  margin-top: 14px;
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.auth-panel {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
}
.auth-panel h1 { font-size: 1.9rem; max-width: 15ch; margin-top: 30px; }
.auth-panel p { color: var(--rail-muted); max-width: 40ch; font-size: 0.9rem; }
.auth-points { list-style: none; padding: 0; margin: 22px 0 0; }
.auth-points li {
  display: flex; gap: 10px; align-items: flex-start;
  color: var(--rail-muted); font-size: 0.86rem; padding: 5px 0;
}
.auth-points svg { flex: none; margin-top: 3px; color: var(--brand-strong); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--plane); }
.auth-form-inner { width: 100%; max-width: 360px; }

@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; min-height: 0; }
  .auth-panel { padding: 28px 22px; }
  .auth-panel h1 { font-size: 1.5rem; margin-top: 18px; }
  .auth-points, .auth-panel > .small { display: none; }
  .auth-form { padding: 30px 22px 48px; }
}

/* --------------------------------------------------------------------------
   Chart
   -------------------------------------------------------------------------- */

.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .bar-empty { fill: var(--line-soft); }
.chart text { fill: var(--ink-muted); font-size: 10px; font-family: var(--sans); }
.chart .tick-y { font-variant-numeric: tabular-nums; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit:hover + .bar, .chart-hit:focus-visible + .bar { fill: var(--brand); }
.chart-legend { font-size: 0.78rem; color: var(--ink-muted); margin-top: 6px; }

.bar-tip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--rail);
  color: var(--rail-ink);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .6);
  white-space: nowrap;
}
.bar-tip b { font-weight: 620; }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.divider { height: 1px; background: var(--line-soft); margin: 18px 0; border: 0; }
.stack > * + * { margin-top: 10px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.footer-note {
  text-align: center; color: var(--ink-muted);
  font-size: 0.76rem; padding: 26px 16px 10px;
}
.tag {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 650; color: var(--ink-muted);
}
.inactive-row td { opacity: .55; }

@media print {
  .rail, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
}
