/*
 * The AMAROV design system, as read from the 22 approved references in
 * docs/design-reference/. That document records the visual language in words;
 * this file is the same statement in CSS, and the two are meant to be checked
 * against each other.
 *
 * Mobile-first: the base rules are the phone, and the two breakpoints add the
 * tablet grid and then the desktop sidebar. The product is used on a phone
 * (docs/PRODUCT_REQUIREMENTS.md section 4), so the phone is not the fallback.
 *
 * No framework, no build step, no remote font (DEC-0037). The Content Security
 * Policy permits no remote origin, so everything here is self-hosted or a
 * system font, and it stays that way.
 */

/* ---------------------------------------------------------------- tokens */
:root {
  /* Surfaces */
  --navy: #0d1b2a;
  --navy-soft: #16293d;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e4e9f2;
  --border-strong: #cfd8e6;

  /* Text */
  --text: #0f172a;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --on-navy: #e2e8f0;
  --on-navy-muted: #94a3b8;

  /* Status. Amber waits on a person, green is healthy, red is danger,
     blue is informational or automatic. */
  --blue: #0b63e5;
  --blue-dark: #0a4fbb;
  --blue-soft: #eaf1fe;
  --green: #16a34a;
  --green-dark: #128040;
  --green-soft: #e8f7ee;
  --red: #d92d20;
  --red-dark: #b42318;
  --red-soft: #fdeceb;
  --amber: #b45309;
  --amber-soft: #fff4e5;

  /* Shape */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .05);
  --shadow-lift: 0 6px 24px rgba(15, 23, 42, .10);

  /* Rhythm */
  --gap: 16px;
  --pad: 20px;

  --sidebar: 260px;
  --topbar: 64px;
  --tabbar: 62px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--blue); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--card);
  padding: 12px 16px;
  border-radius: 0 0 var(--r) 0;
}
.skip-link:focus { left: 0; }

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

/* ---------------------------------------------------------------- boot */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.noscript {
  max-width: 40rem;
  margin: 15vh auto;
  padding: var(--pad);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.noscript h1 { margin-bottom: 8px; }

/* ================================================================ SIGN IN
   AMAROV_Login_Desktop_v1.png / AMAROV_Login_Mobile_v2.png: a photographic
   panel carrying the wordmark, and a form beside it on a desktop, below it on
   a phone. No photograph is shipped — none is invented (design-reference
   README section 3) — so the panel is the brand gradient until an approved
   asset file exists. */
.signin {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.signin__brand {
  background: linear-gradient(155deg, #0d1b2a 0%, #14304a 55%, #1b4568 100%);
  color: #fff;
  padding: 32px var(--pad) 40px;
  display: grid;
  align-content: end;
  gap: 6px;
  min-height: 34vh;
}

.signin__mark {
  background: #fff;
  border-radius: var(--r);
  padding: 14px 18px;
  justify-self: start;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lift);
}

.signin__title { font-size: 1.75rem; }
.signin__tagline { color: #cbd5e1; }

.signin__panel {
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  margin-top: -16px;
  padding: 32px var(--pad) 40px;
  display: grid;
  align-content: start;
  gap: var(--gap);
}

.signin__form { display: grid; gap: var(--gap); max-width: 30rem; width: 100%; }
.signin__heading { font-size: 1.6rem; }
.signin__sub { color: var(--muted); margin-top: 4px; }
.signin__links { display: flex; justify-content: flex-end; }
.signin__password { display: grid; gap: var(--gap); }

/* "or" between the provider button and the password form. A rule with a word
   on it, drawn with borders rather than an image, like everything else here. */
.signin__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted-soft);
  font-size: .9rem;
}
.signin__divider::before,
.signin__divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.signin__note {
  background: var(--blue-soft);
  border-radius: var(--r);
  padding: 16px;
  max-width: 30rem;
}
.signin__note strong { color: var(--blue-dark); display: block; margin-bottom: 4px; }
.signin__note p { color: var(--muted); font-size: .95rem; }
.signin__footer { color: var(--muted-soft); font-size: .85rem; text-align: center; }

/* The wordmark. Typographic and neutral: no company logo is invented, and none
   is embedded (design-reference README section 3). */
.wordmark { display: inline-grid; line-height: 1.05; }
.wordmark__name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--blue-dark);
}
.wordmark__sub {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--green);
}
.wordmark--light .wordmark__name { color: #fff; }
.wordmark--light .wordmark__sub { color: var(--on-navy-muted); }

/* ================================================================ SHELL */
.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: var(--topbar) 1fr auto;
  /* `minmax(0, 1fr)` rather than the implicit `auto` column. A grid item's
     minimum width is its *min-content* by default, so one child that cannot
     shrink — three KPI tiles with long labels, a header with a long page title
     — widens the column, and with it the whole page. The result is a phone
     that scrolls sideways, which is invisible in a screenshot of the top of a
     screen and immediately obvious to somebody holding one.
     `tests/browser/test_navigation.py` measures it at both reference widths. */
  grid-template-columns: minmax(0, 1fr);
}

/* -- the phone top bar: logo left, sign out right ---------------------- */
.topbar {
  grid-row: 1;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--pad);
  position: sticky;
  top: 0;
  z-index: 20;
  min-width: 0;
}
/* On a phone the top bar is the logo and *Kilépés*, and the screen's own
   heading carries the title (design-reference/README.md section 2). Showing
   both put a third item in a 390px-wide flex row, which is what pushed the
   header past the viewport. The desktop rule below is the mirror image: there
   the header carries the title and `.page__head` is hidden. */
.topbar__title { display: none; }
.topbar__mark { min-width: 0; }
.topbar__who { display: none; color: var(--muted); font-weight: 600; }
.topbar__right { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* -- the desktop sidebar ---------------------------------------------- */
.sidebar { display: none; }

/* -- the content column ----------------------------------------------- */
.main {
  grid-row: 2;
  padding: var(--pad) var(--pad) calc(var(--tabbar) + 28px);
  display: grid;
  gap: var(--gap);
  align-content: start;
}

.page__head { display: grid; gap: 2px; margin-bottom: 4px; }
.page__title { font-size: 1.9rem; }
.page__sub { color: var(--muted); }

/* -- the phone tab bar ------------------------------------------------- */
.tabbar {
  grid-row: 3;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}
.tabbar__item {
  flex: 1;
  display: grid;
  place-content: center;
  gap: 2px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  position: relative;
}
.tabbar__item:hover { text-decoration: none; }
.tabbar__item[aria-current="page"] { color: var(--blue); }
.tabbar__badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 12px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--amber);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: grid;
  place-content: center;
}

/* -- the "Menü" sheet -------------------------------------------------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, .45);
  display: grid;
  align-items: end;
}
.sheet__panel {
  background: var(--card);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--pad) var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
  display: grid;
  gap: 4px;
  max-height: 80dvh;
  overflow: auto;
}
.sheet__title { color: var(--muted); font-size: .85rem; text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 8px; }
.sheet__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.sheet__item:hover { text-decoration: none; }
.sheet__item[aria-current="page"] { color: var(--blue); }

/* ================================================================ CARDS */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--pad);
  display: grid;
  gap: 12px;
  align-content: start;
}
.card--flush { padding: 0; overflow: hidden; }
/* A last line of defence for every card and panel: a value longer than the
   card breaks rather than widening the page under it. `break-word` rather than
   `anywhere`, because prose should still break between words where it can. */
.card, .panel { overflow-wrap: break-word; }
/* The heading of a flush card, which keeps its own padding while the rows
   below it run to the edge. A class rather than a style attribute: the
   Content Security Policy is `style-src 'self'`, and a browser blocks an
   inline one outright. */
.card__flush-head { padding: 20px 20px 0; }
.card__title { font-size: 1.15rem; }
.card__sub { color: var(--muted); font-size: .95rem; }
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card__foot { border-top: 1px solid var(--border); padding-top: 12px; }

/* Tinted panels carry meaning, not decoration. */
.panel { border-radius: var(--r); padding: 16px; display: grid; gap: 6px; }
.panel--info { background: var(--blue-soft); }
.panel--info strong { color: var(--blue-dark); }
.panel--ok { background: var(--green-soft); }
.panel--ok strong { color: var(--green-dark); }
.panel--warn { background: var(--amber-soft); }
.panel--warn strong { color: var(--amber); }
.panel--danger { background: var(--red-soft); }
.panel--danger strong { color: var(--red-dark); }
.panel p { color: var(--muted); }
.panel--danger p, .panel--warn p { color: #52525b; }

/* ================================================================ KPI */
/* Mobile-first, and `auto-fit` rather than a fixed three: `repeat(3, 1fr)` on a
   phone means each column is at least its own min-content, so a label like
   *Elfogadott megrendelés (30 nap)* makes the row — and the page under it —
   wider than the screen. Two tiles fit a phone; the tablet and desktop rules
   below ask for more. */
.kpis {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.kpi {
  min-width: 0;
  /* A tile is 152px wide on a phone and its note carries a document name and a
     section reference. `anywhere` is the only value that lets a token longer
     than the tile break rather than push the page sideways. */
  overflow-wrap: anywhere;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.kpi__label { color: var(--muted); font-size: .85rem; }
.kpi__value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi__value--amber { color: var(--amber); }
.kpi__value--green { color: var(--green); }
.kpi__value--red { color: var(--red); }
.kpi__value--blue { color: var(--blue-dark); }
.kpi__value--unknown { color: var(--muted-soft); font-size: 1.15rem; font-weight: 600; }
.kpi__note { color: var(--muted); font-size: .8rem; }

/* The hero spend card from AMAROV_Marketing_Director_Mobile_v2.png. */
.hero__value { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; }
.hero__of { color: var(--muted); }

.meter {
  height: 12px;
  border-radius: var(--r-pill);
  background: #e6e9ef;
  overflow: hidden;
}
.meter__fill { height: 100%; background: var(--green); border-radius: var(--r-pill); }
.meter__fill--warn { background: var(--amber); }
.meter__fill--over { background: var(--red); }
.meter-row { display: flex; align-items: center; gap: 12px; }
.meter-row .meter { flex: 1; }
.meter-row__pct { font-weight: 700; color: var(--green-dark); font-size: .95rem; }

/* ================================================================ PILLS */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
}
.pill--amber { background: var(--amber-soft); color: var(--amber); }
.pill--green { background: var(--green-soft); color: var(--green-dark); }
.pill--red { background: var(--red-soft); color: var(--red-dark); }
.pill--blue { background: var(--blue-soft); color: var(--blue-dark); }
.pill--grey { background: #eef1f6; color: var(--muted); }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot--amber { background: var(--amber); }
.dot--green { background: var(--green); }
.dot--red { background: var(--red); }
.dot--blue { background: var(--blue); }
.dot--grey { background: var(--muted-soft); }

/* ================================================================ BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: #f1f4f9; }
.btn--outline { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn--outline:hover { background: var(--blue-soft); }
.btn--approve { background: var(--green); }
.btn--approve:hover { background: var(--green-dark); }
.btn--reject { background: transparent; color: var(--red); border-color: var(--red); }
.btn--reject:hover { background: var(--red-soft); }
.btn--danger { background: var(--red); }
.btn--danger:hover { background: var(--red-dark); }
.btn--signout {
  background: transparent;
  color: var(--red);
  border-color: transparent;
  font-weight: 700;
  min-height: 40px;
  padding: 0 6px;
}
.btn--signout:hover { background: var(--red-soft); }
.btn--small { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn--link {
  background: none;
  border: none;
  color: var(--blue);
  padding: 0;
  min-height: 0;
  font-weight: 700;
}
.btn--link:hover { background: none; text-decoration: underline; }

.actions { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.actions--single { grid-template-columns: 1fr; }
.actions--end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ================================================================ FORMS */
.field { display: grid; gap: 6px; }
.field__label { font-weight: 700; font-size: .95rem; }
.field__hint { color: var(--muted); font-size: .85rem; }
.field__error { color: var(--red-dark); font-size: .85rem; font-weight: 600; }

.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--card);
  color: var(--text);
}
.input:focus { border-color: var(--blue); }
.input[aria-invalid="true"] { border-color: var(--red); }
textarea.input { min-height: 90px; resize: vertical; }

.form-grid { display: grid; gap: var(--gap); }

/* Segmented control — the autonomy chooser in AMAROV_Settings_*.png. */
.segments { display: grid; gap: 10px; }
.segment {
  min-height: 48px;
  border: 1px solid var(--blue);
  border-radius: var(--r);
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}
.segment[aria-pressed="true"] { background: var(--blue); color: #fff; }
.segment:disabled { opacity: .5; cursor: not-allowed; }

/* Sub-navigation chips — the Settings sections on a phone. */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  flex: none;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.chip[aria-current="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ================================================================ LISTS */
.rows { display: grid; }
.row {
  display: grid;
  gap: 8px;
  padding: 16px var(--pad);
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}
/* `anywhere`, because the strings that land in a row title are not prose: a
   browser's user-agent string, an identifier, a URL. One of them is enough to
   make a phone scroll sideways, and it is the row nobody thought about. */
.row__title { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.row__meta { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.row__value { font-weight: 700; white-space: nowrap; }

.pairs { display: grid; gap: 10px; }
.pair { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.pair__key { color: var(--muted); }
.pair__value { font-weight: 600; text-align: right; }
.pair__value--mono { font-family: var(--mono); font-size: .85rem; word-break: break-all; }

.stack { display: grid; gap: var(--gap); }
.stack--tight { gap: 10px; }

.bullets { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 8px; }

/* What an Owner actually wrote, quoted back to them, and what the system made
   of it. Two visually distinct things on purpose: the quote is evidence and
   must never be mistaken for the reading, which is a machine's opinion. */
.quote {
  margin: 0;
  padding: 12px 16px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.reading { margin: 0; color: var(--muted); }

/* A disclosure whose contents cost a request, so it is closed until asked. */
.disclosure > summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
  padding: 8px 0;
}
.disclosure[open] > summary { margin-bottom: 8px; }

/* ================================================================ STATES
   Explicit loading, error, empty, and unknown states. A blank card and a card
   that is still loading must never look the same, and "no data" must never
   look like "zero". */
.state {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
}
.state__title { font-weight: 700; color: var(--text); }
.state--error { color: var(--red-dark); }
.state--error .state__title { color: var(--red-dark); }

.unknown { color: var(--muted-soft); font-style: italic; }

.skeleton {
  background: linear-gradient(90deg, #eef1f6 25%, #e4e9f2 37%, #eef1f6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
  height: 1em;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.offline-banner {
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
  text-align: center;
  padding: 10px var(--pad);
}

/* ================================================================ TOASTS */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(30rem, calc(100vw - 32px));
}
.toast {
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow-lift);
  font-weight: 600;
  background: var(--navy);
  color: #fff;
}
.toast--ok { background: var(--green-dark); }
.toast--error { background: var(--red-dark); }

/* ================================================================ DIALOG */
.confirm {
  border: none;
  border-radius: var(--r-lg);
  padding: 0;
  width: min(32rem, calc(100vw - 32px));
  box-shadow: var(--shadow-lift);
}
.confirm::backdrop { background: rgba(15, 23, 42, .5); }
.confirm__form { padding: var(--pad); display: grid; gap: var(--gap); }
.confirm__title { font-size: 1.25rem; }
.confirm__body { color: var(--muted); }
.confirm__state { border-radius: var(--r); padding: 12px 14px; font-weight: 600; }
.confirm__actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ================================================================ TABLES
   A table on a desktop; the same data as stacked rows on a phone, because a
   horizontally scrolling table on a phone is a table nobody reads. */
.table { width: 100%; border-collapse: collapse; display: none; }
.table th, .table td { padding: 14px var(--pad); text-align: left; }
.table th {
  font-size: .85rem;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.table td { border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; }

/* ================================================================ TABLET */
@media (min-width: 640px) {
  .main { padding: 24px 28px calc(var(--tabbar) + 32px); }
  .kpis--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { display: grid; gap: var(--gap); grid-template-columns: 1fr 1fr; }
  .signin {
    grid-template-rows: none;
    grid-template-columns: 1fr 1fr;
    min-height: 100dvh;
  }
  .signin__brand { min-height: auto; padding: 40px; }
  .signin__panel {
    margin: 0;
    border-radius: 0;
    padding: 40px;
    align-content: center;
    justify-items: center;
  }
  .actions--wide { grid-template-columns: auto auto; justify-content: end; }
}

/* ================================================================ DESKTOP
   AMAROV_Marketing_Director_UI_v2.png: a fixed dark sidebar with the logo card
   at the top, and a white header bar carrying the page title, the signed-in
   Owner, and the sign-out button. */
@media (min-width: 1024px) {
  .shell {
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    grid-template-rows: var(--topbar) 1fr;
  }

  .sidebar {
    display: grid;
    grid-row: 1 / -1;
    grid-column: 1;
    background: var(--navy);
    padding: 20px 16px;
    gap: 6px;
    align-content: start;
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
  }
  .sidebar__mark {
    background: #fff;
    border-radius: var(--r);
    padding: 14px 16px;
    margin-bottom: 18px;
    text-align: center;
  }
  .sidebar__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r);
    color: var(--on-navy);
    font-weight: 600;
    text-decoration: none;
  }
  .sidebar__link:hover { background: var(--navy-soft); text-decoration: none; }
  .sidebar__link[aria-current="page"] { background: var(--blue); color: #fff; }
  .sidebar__badge {
    min-width: 22px;
    padding: 1px 7px;
    border-radius: var(--r-pill);
    background: var(--amber);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    text-align: center;
  }
  .sidebar__link[aria-current="page"] .sidebar__badge { background: #fff; color: var(--blue-dark); }

  .topbar { grid-column: 2; }
  .topbar__mark { display: none; }
  .topbar__title {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar__who { display: block; }

  .main {
    grid-column: 2;
    padding: 24px 32px 48px;
    max-width: 1400px;
  }
  .page__head { display: none; }

  .tabbar { display: none; }
  .toasts { bottom: 24px; left: auto; right: 24px; transform: none; }

  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpis--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-side { display: grid; gap: var(--gap); grid-template-columns: 2fr 1fr; }
  .grid-settings { display: grid; gap: var(--gap); grid-template-columns: 240px 1fr; align-items: start; }

  .chips { display: none; }
  .sidenav { display: grid; gap: 4px; }
  .sidenav__item {
    text-align: left;
    padding: 12px 16px;
    border-radius: var(--r);
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
  }
  .sidenav__item[aria-current="true"] { background: var(--blue-soft); color: var(--blue-dark); }

  .table { display: table; }
  .table + .rows { display: none; }

  .row--wide {
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 20px;
  }
  .actions { grid-template-columns: auto auto; justify-content: end; }
  .actions--single { grid-template-columns: auto; }
}

/* ================================================================ MOTION */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ================================================================ PRINT
   The audit trail and the weekly brief are the two things anybody prints. */
@media print {
  .sidebar, .tabbar, .topbar, .toasts, .actions { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
