/* ===========================================================================
   BQT Presence — design system (light, brand-matched to barquecontech.com)
   Tokens first, then a lean component kit. No external resources (CSP self).
   Fonts: Poppins (vendored, latin subset) with system-ui fallback.
   Chart/status palette validated for CVD + contrast (see /styleguide):
     productive #118a5e · neutral #df8a00 · unproductive #a01f5a ·
     unknown/idle #6b7280 (deliberate neutral) · on-leave/offline #2563eb.
   =========================================================================== */

@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('/vendor/poppins/poppins-400.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('/vendor/poppins/poppins-500.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('/vendor/poppins/poppins-600.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('/vendor/poppins/poppins-700.woff2') format('woff2'); }

:root {
  /* --- color roles ------------------------------------------------------- */
  --bg: #f5f7fa;            /* app background */
  --surface: #ffffff;       /* cards, panels */
  --surface-2: #f9fafc;     /* wells, table heads, hover rows */
  --ink: #0d1b2a;           /* primary text = brand navy */
  --ink-2: #5f6b7a;         /* secondary text */
  --ink-3: #687482;         /* muted (AA on white/surface-2) */
  --placeholder: #97a1ad;
  --line: #e7ebf0;          /* hairline borders */
  --line-2: #d5dce4;        /* input borders */
  --brand: #0d1b2a;         /* navy — sidebar, headings */
  --brand-2: #16283c;       /* navy hover / raised */
  --brand-ink: #ffffff;
  --accent: #f1b621;        /* gold — primary actions only */
  --accent-hover: #e4a400;
  --accent-ink: #0d1b2a;    /* always dark navy on gold */

  /* --- status + dataviz (validated) -------------------------------------- */
  --good: #118a5e;    --good-soft: #e6f4ee;
  --warn: #df8a00;    --warn-soft: #fdf3e1;
  --bad:  #a01f5a;    --bad-soft:  #f9e7ef;
  --info: #2563eb;    --info-soft: #e8effd;
  --neutral: #6b7280; --neutral-soft: #eef0f3;
  --cat-productive: var(--good);
  --cat-neutral: var(--warn);
  --cat-unproductive: var(--bad);
  --cat-unknown: var(--neutral);
  --cat-leave: var(--info);
  --cat-offline: var(--info);

  /* --- type scale -------------------------------------------------------- */
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 11px; --fs-s: 12.5px; --fs-m: 14px; --fs-l: 16px; --fs-xl: 20px; --fs-xxl: 27px;

  /* --- geometry ---------------------------------------------------------- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --radius: 10px; --radius-s: 6px; --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(13,27,42,.06), 0 4px 16px rgba(13,27,42,.05);
  --sidebar-w: 224px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: var(--fs-m); line-height: 1.5;
}
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 var(--sp-3); }
h1 { font-size: var(--fs-xxl); font-weight: 700; }
h2 { font-size: var(--fs-xl); font-weight: 600; }
h3 { font-size: var(--fs-l); font-weight: 600; }
p  { margin: 0 0 var(--sp-3); }
a  { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--ink-2); font-size: var(--fs-s); }
.subtle { color: var(--ink-3); }
.hidden { display: none !important; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-s); }
.sidebar :focus-visible { outline-color: var(--accent); }

/* --- app shell ----------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand); color: var(--brand-ink);
  padding: var(--sp-4) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo { display: flex; align-items: baseline; gap: 6px; padding: 2px var(--sp-2) var(--sp-4); font-size: var(--fs-l); font-weight: 700; color: #fff; }
.sidebar .logo .gold { color: var(--accent); }
.sidebar .logo small { color: #9fb0c3; font-weight: 500; font-size: var(--fs-xs); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-s);
  color: #c8d2dd; font-size: var(--fs-m); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--brand-2); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-pill); padding: 0 7px; font-size: var(--fs-xs); font-weight: 600; }
.sidebar .foot { margin-top: auto; padding: var(--sp-3) var(--sp-2) 0; color: #7d8ea1; font-size: var(--fs-xs); }
.sidebar .foot a { color: #c8d2dd; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5); background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: var(--fs-l); font-weight: 600; margin-right: auto; }
.topbar .who { color: var(--ink-2); font-size: var(--fs-s); }
.content { padding: var(--sp-5); max-width: 1240px; width: 100%; margin: 0 auto; }

/* period switcher (Day / Week / Month) */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-s); padding: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 5px; cursor: pointer;
  font: inherit; font-size: var(--fs-s); font-weight: 500; color: var(--ink-2);
}
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; font-weight: 600; }

/* date stepper */
.datenav { display: inline-flex; align-items: center; gap: 6px; }
.datenav input[type="date"] { width: auto; }

/* --- cards & grids -------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-4) var(--sp-4); margin-bottom: var(--sp-4); }
.card > h3 { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.grid { display: grid; gap: var(--sp-4); }
.kpis { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); margin-bottom: var(--sp-4); }

/* KPI stat tile */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: 2px; min-height: 86px; }
.kpi .l { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.kpi .n { font-size: var(--fs-xxl); font-weight: 700; line-height: 1.15; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .n .unit { font-size: var(--fs-s); font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.kpi .sub { font-size: var(--fs-xs); color: var(--ink-3); }
.kpi svg { margin-top: auto; }

/* --- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-s); cursor: pointer;
  font: inherit; font-size: var(--fs-m); font-weight: 600; background: var(--accent); color: var(--accent-ink);
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: var(--fs-s); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* --- forms ---------------------------------------------------------------- */
label { display: block; font-size: var(--fs-s); font-weight: 500; color: var(--ink-2); margin: var(--sp-3) 0 var(--sp-1); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-m);
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 56px; }
.field { min-width: 130px; }
.row { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; }
.row .grow { flex: 1; }

/* --- tables ---------------------------------------------------------------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.wrap { white-space: normal; }
th { color: var(--ink-2); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
td .num, .num { font-variant-numeric: tabular-nums; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
tr.clickable { cursor: pointer; }

/* --- tabs (status filters with counts) ------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font: inherit;
  font-size: var(--fs-s); font-weight: 500; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

/* --- chips / badges --------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.good { background: var(--good-soft); color: #0d6b47; }
.chip.warn { background: var(--warn-soft); color: #9a6100; }
.chip.bad  { background: var(--bad-soft);  color: var(--bad); }
.chip.info { background: var(--info-soft); color: #1d4ed8; }
.chip.neutral { background: var(--neutral-soft); color: #4b5563; }

/* --- banners / notes -------------------------------------------------------- */
.banner { border: 1px solid var(--line); border-left: 4px solid var(--info); background: var(--info-soft); border-radius: var(--radius-s); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); font-size: var(--fs-s); }
.banner.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.banner.good { border-left-color: var(--good); background: var(--good-soft); }
.note { font-size: var(--fs-xs); color: var(--ink-3); }
.warn-text { color: #9a6100; font-weight: 600; }

/* --- toast ------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 18px; border-radius: var(--radius-s);
  box-shadow: var(--shadow); font-size: var(--fs-s); max-width: 90vw;
}
.toast.bad { background: var(--bad); }

/* --- empty / loading states --------------------------------------------------- */
.empty { text-align: center; color: var(--ink-3); padding: var(--sp-6) var(--sp-4); font-size: var(--fs-s); }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-s); min-height: 16px; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(13,27,42,.05), transparent); animation: shimmer 1.4s infinite; }
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* --- legends (charts) ---------------------------------------------------------- */
.legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-2); margin-top: var(--sp-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* chart tooltip */
.tip { position: fixed; z-index: 90; pointer-events: none; background: var(--brand); color: #fff; font-size: var(--fs-xs); padding: 6px 10px; border-radius: var(--radius-s); box-shadow: var(--shadow); max-width: 260px; }
.tip b { color: var(--accent); }

/* --- auth (sign-in) card --------------------------------------------------------- */
.authwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); background: linear-gradient(180deg, var(--brand) 0 260px, var(--bg) 260px); }
.authcard { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(13,27,42,.18); padding: var(--sp-6); }
.authcard .logo { font-size: var(--fs-xl); font-weight: 700; margin-bottom: 2px; }
.authcard .logo .gold { color: #c98f00; }
.err { color: var(--bad); font-size: var(--fs-s); min-height: 1.4em; margin-top: var(--sp-2); }

/* --- calendar grid ------------------------------------------------------------------ */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); text-align: center; padding: 4px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal .day { min-height: 68px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 4px 6px; font-size: var(--fs-xs); background: var(--surface); }
.cal .day.out { background: var(--surface-2); color: var(--ink-3); }
.cal .day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal .day .d { font-weight: 600; color: var(--ink-2); }
.cal .day.wknd .d { color: var(--ink-3); }
.cal .ev { display: block; margin-top: 3px; padding: 1px 6px; border-radius: 4px; background: var(--info-soft); color: var(--info); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.half { background: repeating-linear-gradient(45deg, var(--info-soft) 0 6px, #fff 6px 9px); }
.cal .day.hol { background: var(--warn-soft); border-color: #f0dcb0; }
.cal .ev.holname { background: transparent; color: #9a6100; font-weight: 600; padding-left: 0; }

/* --- responsive -------------------------------------------------------------------- */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
  .sidebar { position: sticky; height: auto; flex-direction: row; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); overflow-x: auto; z-index: 30; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent); }
  .sidebar .logo { padding: 0 var(--sp-2) 0 0; white-space: nowrap; }
  .sidebar .logo small { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .nav a .ico { display: none; }
  .sidebar .foot { display: none; }
  .content { padding: var(--sp-3); }
  .topbar { padding: var(--sp-2) var(--sp-3); position: static; }
  .kpis { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .cal .day { min-height: 46px; }
}

@media print {
  .sidebar, .topbar .seg, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
