/* WTP (Work Time Planner) — base styles
   Palette: cool paper, slate ink, one safety-orange brand color.
   Shift and day-code colors come from the database (configurable per company). */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("../fonts/archivo-latin-ext-wdth-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("../fonts/archivo-latin-wdth-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f1f2f4;
  --sheet: #ffffff;
  --sheet-2: #f7f8f9;
  --ink: #1b2430;
  --ink-2: #4b5664;
  --ink-3: #7a8492;
  --line: #d9dde3;
  --line-2: #e8ebee;
  --brand: #e0532a;
  --brand-ink: #b23d1a;
  --brand-wash: #fdebe4;
  --danger: #c0262d;
  --danger-wash: #fdeaea;
  --warn: #9a5b00;
  --warn-wash: #fff3dc;
  --ok: #2e7a3b;
  --ok-wash: #e6f4e8;
  --sunday: #c0262d;
  --focus: #e0532a;

  --radius: 6px;
  --radius-sm: 4px;
  --bar-h: 52px;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 24px;

  color-scheme: light;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--fs-md);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

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

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-xl); font-weight: 620; }
h3 { font-size: var(--fs-lg); font-weight: 620; }

.muted { color: var(--ink-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: stretch; gap: 24px;
  height: var(--bar-h);
  padding: 0 20px;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); font-weight: 700; font-size: 17px; letter-spacing: -0.01em;
  font-stretch: 110%;
}
.brand:hover { text-decoration: none; }
.brand-name { display: grid; line-height: 1; letter-spacing: 0.02em; }
.brand-name small { font-size: 10px; font-weight: 560; letter-spacing: 0.04em; color: var(--ink-3); font-stretch: 100%; margin-top: 2px; text-transform: uppercase; }
.brand svg { width: 26px; height: 26px; flex: none; }

.nav { display: flex; align-items: stretch; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a {
  display: flex; align-items: center;
  padding: 0 12px;
  color: var(--ink-2); font-weight: 520; white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav a:hover { color: var(--ink); text-decoration: none; background: var(--sheet-2); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 620; }

.userbox { margin-left: auto; display: flex; align-items: center; gap: 14px; white-space: nowrap; font-size: var(--fs-sm); }
.userbox .who { text-align: right; line-height: 1.25; }
.userbox .who strong { display: block; font-weight: 600; font-size: var(--fs-sm); }
.userbox form { margin: 0; }

/* ---------- operator acting inside a company ---------- */

.acting-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 20px; background: var(--ink); color: #e9ecf0; font-size: var(--fs-sm);
  border-bottom: 3px solid var(--brand);
}
.acting-bar strong { color: #fff; }
.acting-bar a { color: #ffd2c2; margin-left: auto; }
.acting-bar form { margin: 0; }
.acting-bar button {
  height: 28px; padding: 0 12px; border-radius: var(--radius); border: 0; cursor: pointer;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600;
}
.acting-bar button:hover { background: var(--brand-ink); }
body:has(.acting-bar) .topbar { top: 0; }

/* ---------- page ---------- */

.page { padding: 20px 24px 48px; max-width: 1480px; margin: 0 auto; }
.page.wide { max-width: none; }
.site-footer { padding: 0 24px 20px; text-align: center; font-size: var(--fs-xs); color: var(--ink-3); }
.login .site-footer { padding: 0; }

.page-head {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head .titles { min-width: 0; }
.page-head .sub { margin-top: 4px; color: var(--ink-2); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.sheet-pad { padding: 18px 20px; }
.sheet + .sheet { margin-top: 16px; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.sheet-head .actions { margin-left: auto; display: flex; gap: 8px; }

.subnav { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.subnav a {
  padding: 6px 12px; border-radius: var(--radius); color: var(--ink-2); font-weight: 520;
}
.subnav a:hover { background: var(--sheet); text-decoration: none; }
.subnav a[aria-current="page"] { background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

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

.messages { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.messages li {
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--sheet); border: 1px solid var(--line); border-left: 3px solid var(--ink-3);
}
.messages .success { border-left-color: var(--ok); }
.messages .error { border-left-color: var(--danger); background: var(--danger-wash); }
.messages .warning { border-left-color: var(--warn); background: var(--warn-wash); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink);
  font: inherit; font-weight: 560; white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: var(--sheet-2); border-color: #c9ced6; text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-wash); border-color: #efc2c2; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--line-2); border-color: transparent; }

.steps { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 18px; padding: 0; counter-reset: step; font-size: var(--fs-sm); color: var(--ink-3); }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 8px; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; font-weight: 650; }
.steps li + li { padding-left: 14px; border-left: 1px solid var(--line); }
.steps li.current { color: var(--ink); font-weight: 620; }
.steps li.current::before { background: var(--brand); border-color: var(--brand); color: #fff; }
.steps li.done { color: #2e7d4f; }
.steps li.done::before { content: "✓"; background: #e4f3ea; border-color: #b9dfc8; }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand-ink); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

/* ---------- forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.field { display: grid; gap: 5px; align-content: start; }
.field label, .field .label { font-size: var(--fs-sm); font-weight: 580; color: var(--ink-2); }
.field .help { font-size: var(--fs-xs); color: var(--ink-3); }
.field .errorlist { list-style: none; margin: 0; padding: 0; color: var(--danger); font-size: var(--fs-sm); }
.field.has-error input, .field.has-error select { border-color: var(--danger); }

input[type=text], input[type=email], input[type=number], input[type=date], input[type=time],
input[type=password], input[type=search], select, textarea {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink);
  font: inherit;
}
textarea { height: auto; padding: 8px 10px; min-height: 80px; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
input[type=color] {
  width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); cursor: pointer;
}
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.check input { margin-top: 2px; }
.check label { font-weight: 560; color: var(--ink); }
.check .help { display: block; font-weight: 400; color: var(--ink-3); font-size: var(--fs-sm); }

.form-actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
.form-actions .spacer { flex: 1; }

fieldset { border: 0; margin: 0 0 22px; padding: 0; }
fieldset legend { font-weight: 640; font-size: var(--fs-lg); margin-bottom: 12px; padding: 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.filters .field { min-width: 150px; flex: 1 1 150px; max-width: 260px; }
.filters .field.grow { flex: 2 1 240px; max-width: 360px; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th, .table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table th {
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); font-stretch: 92%;
  background: var(--sheet-2); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
.table tbody tr:hover td { background: #fafbfc; }
.table td a:not(.btn) { color: var(--ink); font-weight: 560; }
.table td a:not(.btn):hover { color: var(--brand-ink); }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn + .btn { margin-left: 4px; }
.table tfoot td { font-weight: 640; background: var(--sheet-2); border-top: 1px solid var(--line); }
.table .num { text-align: right; }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-2); }
.empty p { margin: 0 0 14px; }

.pager { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--ink-2); font-size: var(--fs-sm); }
.pager .links { margin-left: auto; display: flex; gap: 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 11px;
  background: var(--line-2); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 560; white-space: nowrap;
}
.swatch {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 24px; padding: 0 6px; border-radius: var(--radius-sm);
  font-weight: 650; font-stretch: 85%; font-size: var(--fs-sm); color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(27, 36, 48, .08);
}

.badge-placeholder {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--radius-sm);
  background: var(--warn-wash); color: var(--warn); font-size: var(--fs-xs); font-weight: 600;
}

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 560; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.cols > .sheet + .sheet { margin-top: 0; }
.cols-side { grid-template-columns: minmax(0, 2fr) minmax(var(--side, 280px), 1fr); }
.cols-split { grid-template-columns: minmax(0, 3fr) minmax(var(--side, 300px), 2fr); }
@media (max-width: 900px) { .cols-side, .cols-split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- cockpit ---------- */

.stat-strip { display: flex; gap: 40px; flex-wrap: wrap; padding: 14px 20px; margin-bottom: 16px; }
.stat-strip > div { display: grid; }
.stat-num { font-size: 28px; font-weight: 700; font-stretch: 90%; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { font-size: var(--fs-sm); color: var(--ink-2); }
.chip-off { background: var(--danger-wash); color: var(--danger); }
.table tr.row-off td { color: var(--ink-3); }

/* ---------- login ---------- */

.login {
  min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 16px; padding: 24px;
  background:
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(27,36,48,.035) 39px 40px),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(27,36,48,.035) 31px 32px),
    var(--paper);
}
.login .card { width: 100%; max-width: 380px; padding: 28px; background: var(--sheet); border: 1px solid var(--line); border-radius: 10px; }
.login .brand { margin-bottom: 22px; font-size: 22px; }
.login .brand-name small { font-size: 11px; }
.login .brand svg { width: 32px; height: 32px; }
.login form { display: grid; gap: 14px; }
.login .btn { height: 38px; }

/* ---------- print ---------- */

@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .no-print, .messages, .page-head .actions, .filters { display: none !important; }
  .page { padding: 0; max-width: none; }
  .sheet { border: 0; }
  .table th { position: static; background: #fff; }
  .table th, .table td { padding: 3px 5px; border-bottom-color: #bbb; }
  a { color: inherit; }
}

@media (max-width: 760px) {
  .userbox .who { display: none; }
  .page { padding: 16px 16px 40px; }
  .form-grid .span-2 { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- meeting 17 Oct additions ------------------------------------------- */
.nav .count, .ask-btn .count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}
.ask-dialog textarea { width: 100%; margin: 10px 0; }
dialog.modal { width: min(640px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; box-shadow: 0 24px 64px rgba(27, 36, 48, .25); }
dialog.modal::backdrop { background: rgba(27, 36, 48, .35); }
dialog.modal > form { padding: 16px 20px 18px; display: grid; gap: 10px; }
dialog.modal .modal-head { display: flex; justify-content: space-between; align-items: center; }
dialog.modal .modal-head h2 { margin: 0; font-size: var(--fs-xl); }
dialog.modal .modal-actions { display: flex; gap: 8px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 560; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.matrix-wrap { overflow: auto; max-height: calc(100vh - 260px); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); padding: 4px 8px; background: var(--sheet); }
table.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--sheet-2); vertical-align: bottom; }
table.matrix thead th.comp { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; height: 130px; padding: 8px 4px; text-align: left; font-weight: 600; }
table.matrix th.emp, table.matrix td.emp { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 220px; }
table.matrix thead th.emp { z-index: 3; }
table.matrix td.lvl { text-align: center; padding: 2px; min-width: 44px; }
table.matrix td.lvl select { height: 28px; padding: 0 4px; font-size: var(--fs-sm); width: 48px; }
table.matrix td.lvl.has { background: #eaf5ec; }
table.matrix td.lvl input[type=checkbox] { width: 18px; height: 18px; }
table.matrix tfoot td { background: var(--sheet-2); font-weight: 600; text-align: center; }
.meter { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; margin: 4px 0; min-width: 80px; }
.meter span { display: block; height: 100%; background: var(--ok); }
.meter.over span { background: var(--danger); }
.meter.near span { background: #e09a1a; }
.calendar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: 11px; color: var(--ink-3); font-weight: 600; padding: 4px 0; }
.cal td { height: 54px; vertical-align: top; border: 1px solid var(--line-2); padding: 3px; font-size: 12px; overflow: hidden; }
@media (max-width: 520px) {
  .cal td { height: 58px; padding: 2px; }
  .cal .code { min-width: 0; display: block; padding: 1px 2px; font-size: 11px; }
  .cal .time { font-size: 9px; line-height: 1.15; word-break: break-all; }
  .cal .before { font-size: 9px; }
}
.cal td.empty-day { background: var(--sheet-2); border-color: transparent; }
.cal td.weekend .dnum { color: var(--sunday); }
.cal td.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal td.changed { box-shadow: inset 0 0 0 2px #2f5fa8; background: #eef4fd; }
.cal .dnum { font-size: 11px; color: var(--ink-3); }
.cal .code { display: inline-block; min-width: 26px; padding: 1px 4px; border-radius: 3px; font-weight: 700; text-align: center; }
.cal .time { display: block; font-size: 10px; color: var(--ink-2); }
.cal .ot { display: inline-block; font-size: 10px; color: #b23d1a; font-weight: 700; }
.cal .before { display: block; font-size: 10px; color: #2f5fa8; }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.qlist li { padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--sheet); }
.qlist .q { white-space: pre-wrap; }
.qlist .a { margin-top: 8px; padding: 8px 10px; background: #eef7ef; border-radius: var(--radius-sm); white-space: pre-wrap; }
.group-row td { background: var(--sheet-2) !important; font-weight: 700; }
.subtotal-row td { background: #f7f8f9 !important; font-weight: 650; border-top: 1px solid var(--line); }
.help-box { padding: 10px 14px; border-radius: var(--radius); background: var(--sheet-2); font-size: var(--fs-sm); color: var(--ink-2); }
.radio-list { display: grid; gap: 6px; }
.radio-list label { display: flex; gap: 8px; align-items: center; font-weight: 450; }
@media print {
  .ask-btn, dialog { display: none !important; }
}
.error-page { max-width: 560px; margin: 40px auto; }
.error-page .error-code { margin: 0; font-size: 44px; font-weight: 800; color: var(--brand); letter-spacing: -0.02em; }
.error-page h1 { margin: 4px 0 8px; }
.sheet-head { flex-wrap: wrap; }
@media (max-width: 760px) {
  /* Wide tables scroll inside their card instead of pushing the whole page sideways. */
  .sheet { overflow-x: auto; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  /* Phones and small tablets: brand and account on the first row, the menu on its own scrollable row. */
  .topbar { position: static; flex-wrap: wrap; height: auto; padding: 0 12px; gap: 0 12px; }
  .brand { height: 48px; }
  .userbox { height: 48px; gap: 8px; }
  .userbox .who { display: none; }
  .nav { order: 3; flex: 0 0 calc(100% + 24px); height: 42px; margin: 0 -12px; padding: 0 6px; border-top: 1px solid var(--line-2);
         scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .ask-btn { padding: 0 8px; }
}
@media (max-width: 760px) {
  .brand-name small { display: none; }
  .brand span.brand-name { display: grid; }
}
