/* Ana's Kakanin: design tokens and shared components (values from docs/design/*.dc.html). */
:root {
  --brown: #5C2E0E; --brown-dark: #3F1E07; --yellow: #FFD54A; --yellow-soft: #FFF1C7; --sel: #FFF8E0;
  --ground: #F5F6F2; --card: #FFF; --ink: #17201B; --muted: #56625B; --line: #E3E7E1; --line-soft: #EEF1ED; --input: #CFD6CF;
  --green-bg: #E4F1E9; --green: #155136;
  --blue-bg: #E3ECFB; --blue: #1D4F9E;
  --orange-bg: #FDE8D7; --orange: #9B4307;
  --red-bg: #FBE3E1; --red: #A12A1F;
  --yellow-bg: #FDF1D8; --yellow-ink: #6B4400;
  --gray-bg: #EEF0ED; --gray: #3E4943;
  --rush: #E07A2E; --rush-dark: #C25A12;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font); }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
a { color: var(--brown); }
a:hover { color: var(--brown-dark); }
:focus-visible { outline: 3px solid var(--brown); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Cards and KPIs (.kpi is a card) */
.card, .kpi { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; min-width: 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none; }
a.kpi:hover { color: var(--ink); border-color: var(--input); }
.kpi-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.kpi-sub { font-size: 13px; font-weight: 600; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--input); background: #FFF; color: var(--ink); font: 600 14px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { color: var(--ink); border-color: #B9C1BA; }
.btn-primary, .btn-primary:hover { background: var(--brown); border-color: var(--brown); color: #FFF; }
.btn-primary:hover { background: var(--brown-dark); }
.btn-danger, .btn-danger:hover { color: var(--red); border-color: #E8B4AE; }
.btn-sm { min-height: 36px; padding: 0 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; color: var(--brown); font: 700 14px var(--font); cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Small controls keep a 44px-tall tap area while looking like the design. */
.btn-sm, .chip, .switch { position: relative; }
.btn-sm::before, .chip::before, .switch::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }

/* Pills */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-orange { background: var(--orange-bg); color: var(--orange); }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-yellow { background: var(--yellow-bg); color: var(--yellow-ink); }
.pill-gray { background: var(--gray-bg); color: var(--gray); }

/* Tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }

/* Forms */
.lbl { display: block; font-size: 13px; font-weight: 600; color: #2E3833; margin: 0 0 6px; }
.inp { display: block; width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--input); border-radius: 10px; background: #FFF; color: var(--ink); font: 15px/1.4 var(--font); }
.inp::placeholder { color: #6B756F; }
textarea.inp { resize: vertical; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.err { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--red); }

/* Toggle switch: <button type="button" class="switch" aria-pressed="true" aria-label="..."></button> */
.switch { flex: none; width: 48px; height: 28px; padding: 0; border: 0; border-radius: 999px; background: #B9C1BA; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #FFF; transition: left 0.15s; }
.switch[aria-pressed="true"] { background: var(--brown); }
.switch[aria-pressed="true"]::after { left: 23px; }

/* Segmented control: <div class="seg"><button aria-pressed="true">Week</button>…</div>. The transparent border is the 3px track inset. */
.seg { display: flex; background: #E9ECE7; border-radius: 12px; }
.seg > button { flex: 1; min-height: 44px; padding: 0 14px; border: 3px solid transparent; border-radius: 12px; background: transparent padding-box; color: var(--gray); font: 600 14px var(--font); cursor: pointer; white-space: nowrap; }
.seg > button[aria-pressed="true"] { background: #FFF padding-box; color: var(--ink); font-weight: 700; }

/* Filter chip: aria-pressed (filters) or aria-selected (role=tab) marks the active one. */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--input); background: #FFF; color: var(--ink); font: 700 14px var(--font); cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { border-color: var(--ink); background: var(--ink); color: #FFF; }
.chip span { font-weight: 600; opacity: 0.8; }

/* Page layout */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head h1 { font-size: 30px; font-weight: 800; }
.page-head p { margin-top: 4px; font-size: 15px; color: var(--muted); }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > * { flex: 1 1 380px; min-width: 0; }
.split > :first-child { flex: 999 1 560px; }
.empty { padding: 32px 20px; text-align: center; font-size: 14px; color: var(--muted); }

/* Admin shell */
.admin-layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.admin-side { flex: 1 1 248px; background: var(--card); border-right: 1px solid var(--line); }
.admin-main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 24px; }
.nav, .nav-body { display: flex; flex-direction: column; gap: 18px; }
.nav { padding: 20px 12px; }
.nav-brand { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.nav-brand-name { font-size: 15px; font-weight: 800; line-height: 1.2; }
.nav-brand-sub { font-size: 12px; color: var(--muted); }
.nav-toggle { display: none; margin-left: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { margin: 0 0 4px; padding: 0 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--gray); text-decoration: none; }
.nav-item:hover { background: var(--ground); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--yellow-soft); color: var(--brown); font-weight: 700; }
.nav-item svg { flex: none; }
.nav-item > span:first-of-type { flex: 1; }
.nav-badge { background: var(--rush-dark); color: #FFF; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.nav-user { margin-top: 8px; padding: 12px; border-radius: 12px; background: var(--ground); display: flex; align-items: center; gap: 10px; }
.nav-user > div { flex: 1; min-width: 0; }
.nav-user-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-role { font-size: 12px; color: var(--muted); }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--brown); color: #FFF; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }

/* Login, set-password and not-admin screens */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.auth-card .logo { align-self: center; }
.auth-card h1 { font-size: 22px; font-weight: 800; text-align: center; }
.auth-text { font-size: 14px; line-height: 1.5; color: var(--muted); text-align: center; }
.auth-card .btn-primary { width: 100%; }

/* confirmDialog() */
.dlg { width: min(420px, calc(100% - 32px)); padding: 20px; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 12px 40px rgba(23, 32, 27, 0.25); }
.dlg::backdrop { background: rgba(23, 32, 27, 0.45); }
.dlg-msg { margin-bottom: 18px; font-size: 16px; line-height: 1.5; }
.dlg .actions { justify-content: flex-end; }

/* toast() */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1000; width: min(420px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #FFF; font-size: 14px; font-weight: 600; line-height: 1.4; box-shadow: 0 6px 20px rgba(23, 32, 27, 0.2); }
.toast-error { background: var(--red); }

/* Phones and narrow tablets: the sidebar becomes a top bar with a Menu button (the layout wraps below 809px). */
@media (max-width: 808px) {
  .admin-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-main { padding: 20px 16px 40px; gap: 20px; }
  .nav { padding: 8px 12px; gap: 12px; }
  .nav-toggle { display: inline-flex; }
  .nav:not(.open) .nav-body { display: none; }
  .nav-body { padding-bottom: 8px; }
  .page-head h1 { font-size: 26px; }
  .inp { font-size: 16px; } /* below 16px iOS zooms the page on focus */
}
