/* ==========================================================================
   Alpon dashboard - design system
   One hand-written stylesheet: no framework, no web fonts, no external assets.
   The Content-Security-Policy forbids inline styles, so everything visual is a
   class from this file (page-specific additions go into static/css/<page>.css).
   The Jinja macros in templates/_macros.html produce the markup for these classes.

    1. Tokens            8. Filter bar           15. Definition list
    2. Base              9. Forms                16. Disclosure, confirm, menu
    3. Layout           10. Buttons              17. Tabs, progress
    4. Page header      11. Badges               18. Log-in and error pages
    5. Card             12. Flash, callout       19. Utilities
    6. Stat tiles       13. Pagination           20. Print, reduced motion
    7. Table            14. Empty state
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */

:root {
  /* surfaces and text (contrast against the surface it sits on is at least 4.5:1) */
  --c-bg: #f4f6f9;
  --c-surface: #ffffff;
  --c-surface-alt: #f3f5f8;
  --c-zebra: #fafbfc;
  --c-border: #d8dee8;
  --c-border-strong: #b6c0cf;
  --c-border-input: #6f7c91;
  --c-text: #17202c;
  --c-text-muted: #4f5d6f;
  --c-topbar: #0f2742;
  --c-topbar-text: #ffffff;
  --c-topbar-muted: #c6d3e4;

  /* brand / interactive */
  --c-primary: #1257a6;
  --c-primary-hover: #0d4585;
  --c-primary-soft: #e7f0fb;
  --c-focus: #1257a6;

  /* status tones: text, soft background, border */
  --c-neutral: #3f4a5a;
  --c-neutral-soft: #eceff3;
  --c-neutral-border: #cfd6e0;
  --c-info: #0f4f96;
  --c-info-soft: #e7f0fb;
  --c-info-border: #b3cff0;
  --c-success: #14633a;
  --c-success-soft: #e3f4ea;
  --c-success-border: #a7d7ba;
  --c-warning: #7a4a00;
  --c-warning-soft: #fdf0d5;
  --c-warning-border: #eccb85;
  --c-danger: #a11d1d;
  --c-danger-soft: #fdeaea;
  --c-danger-border: #efb1b1;
  --c-danger-strong: #b42323;
  --c-danger-strong-hover: #931b1b;
  --c-accent: #5433a3;
  --c-accent-soft: #efe9fb;
  --c-accent-border: #cdbff0;

  /* spacing */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;

  /* radius and shadow */
  --r-sm: 6px;
  --r-md: 10px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(15, 39, 66, 0.06), 0 1px 3px rgba(15, 39, 66, 0.08);
  --shadow-2: 0 8px 24px rgba(15, 39, 66, 0.16);

  /* type */
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Bengali", "Kohinoor Bangla", "Bangla Sangam MN",
    "Nirmala UI", "Vrinda", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;
  --lh: 1.5;
  --lh-tight: 1.3;

  /* layout */
  --topbar-h: 3.5rem;
  --sidenav-w: 14.5rem;
  --content-max: 86rem;
}

/* Bangla script has taller glyphs with marks above and below the line. */
html[lang="bn"] {
  --lh: 1.7;
  --lh-tight: 1.5;
}

/* 2. Base ------------------------------------------------------------------ */

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

html {
  font-family: var(--font);
  font-size: 100%;
  line-height: var(--lh);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

h1,
h2,
h3 {
  line-height: var(--lh-tight);
  font-weight: 700;
}

a {
  color: var(--c-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--c-primary-hover);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: var(--s-3);
  top: -4rem;
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  background: var(--c-surface);
  color: var(--c-primary);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-2);
  font-weight: 600;
}

.skip-link:focus {
  top: var(--s-3);
}

/* 3. Layout ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: var(--topbar-h);
  padding: 0 var(--s-5);
  background: var(--c-topbar);
  color: var(--c-topbar-text);
}

.topbar :focus-visible {
  outline-color: #ffffff;
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: inherit;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.topbar__brand:hover {
  color: inherit;
}

.topbar__mark {
  display: inline-grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: var(--r-sm);
  background: var(--c-topbar-text);
  color: var(--c-topbar);
  font-size: var(--fs-md);
  font-weight: 800;
  line-height: 1;
}

.topbar__tools {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-width: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.lang-switch__item {
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  color: var(--c-topbar-muted);
  text-decoration: none;
}

a.lang-switch__item:hover {
  color: var(--c-topbar-text);
  text-decoration: underline;
}

.lang-switch__item.is-active {
  color: var(--c-topbar-text);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--c-topbar-text);
  border-radius: 0;
}

.lang-switch__sep {
  color: var(--c-topbar-muted);
}

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidenav-w) minmax(0, 1fr);
  align-items: start;
}

.shell--plain {
  display: block;
}

.sidenav {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--s-4) var(--s-3);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
}

.sidenav__section + .sidenav__section {
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--c-border);
}

.sidenav__title {
  padding: 0 var(--s-3) var(--s-2);
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sidenav__list {
  display: grid;
  gap: 2px;
}

.sidenav__link {
  display: block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  border-left: 3px solid transparent;
  color: var(--c-text);
  text-decoration: none;
}

.sidenav__link:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
}

.sidenav__link[aria-current="page"] {
  background: var(--c-primary-soft);
  border-left-color: var(--c-primary);
  color: var(--c-primary-hover);
  font-weight: 700;
}

.main {
  width: 100%;
  max-width: var(--content-max);
  min-width: 0;
  padding: var(--s-5) var(--s-5) var(--s-7);
}

.main:focus {
  outline: none;
}

.main > * + * {
  margin-top: var(--s-5);
}

.shell--plain .main {
  margin: 0 auto;
}

.footer {
  padding-top: var(--s-4);
  border-top: 1px solid var(--c-border);
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
}

@media (max-width: 55.99rem) {
  .topbar {
    padding: 0 var(--s-3);
    gap: var(--s-2);
  }

  .topbar__tools {
    gap: var(--s-2);
  }

  .shell {
    display: block;
  }

  /* the side navigation becomes a strip that scrolls sideways */
  .sidenav {
    position: static;
    height: auto;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    overflow-x: auto;
    padding: var(--s-2) var(--s-3);
    border-right: 0;
    border-bottom: 1px solid var(--c-border);
  }

  .sidenav__section {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex: none;
  }

  .sidenav__section + .sidenav__section {
    margin-top: 0;
    padding-top: 0;
    padding-left: var(--s-3);
    border-top: 0;
    border-left: 1px solid var(--c-border-strong);
  }

  .sidenav__title {
    padding: 0;
  }

  .sidenav__list {
    display: flex;
    gap: var(--s-1);
  }

  .sidenav__link {
    border-left: 0;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .sidenav__link[aria-current="page"] {
    border-bottom-color: var(--c-primary);
  }

  .main {
    padding: var(--s-4) var(--s-3) var(--s-6);
  }
}

/* 4. Page header ----------------------------------------------------------- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3) var(--s-4);
}

.page-header__text {
  min-width: 0;
}

.page-header__back {
  display: inline-block;
  margin-bottom: var(--s-1);
  font-size: var(--fs-sm);
}

.page-header__title {
  font-size: var(--fs-xl);
  overflow-wrap: anywhere;
}

.page-header__subtitle {
  margin-top: var(--s-1);
  color: var(--c-text-muted);
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* 5. Card ------------------------------------------------------------------ */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.card__header {
  padding: var(--s-4) var(--s-5) 0;
}

.card__title {
  font-size: var(--fs-lg);
}

.card__subtitle {
  margin-top: var(--s-1);
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
}

.card__body {
  padding: var(--s-4) var(--s-5) var(--s-5);
}

.card__body > * + * {
  margin-top: var(--s-4);
}

.card--flush > .card__body {
  padding: var(--s-4) 0 0;
}

.card--flush .table-wrap {
  border-width: 1px 0 0;
  border-radius: 0 0 var(--r-md) var(--r-md);
}

.card--flush .card__note,
.card--flush .empty {
  margin: 0;
  padding: var(--s-3) var(--s-5) var(--s-4);
}

.card--flush .table-wrap + .card__note {
  border-top: 1px solid var(--c-border);
}

.card--flush .table-wrap:not(:last-child) {
  border-radius: 0;
}

@media (max-width: 40rem) {
  .card__header {
    padding: var(--s-4) var(--s-4) 0;
  }

  .card__body {
    padding: var(--s-4);
  }

  .card--flush .card__note,
  .card--flush .empty {
    padding: var(--s-3) var(--s-4) var(--s-4);
  }
}

/* 6. Stat tiles ------------------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: var(--s-3);
}

/* six tiles: always complete rows (2 x 3, 3 x 2 or 6 x 1) */
.stat-grid--six {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 40rem) {
  .stat-grid--six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 75rem) {
  .stat-grid--six {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-top: 4px solid var(--c-neutral-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  color: var(--c-text);
  text-decoration: none;
}

.card .stat {
  box-shadow: none;
}

.stat__label {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.stat__value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat__hint {
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
}

.stat--success {
  border-top-color: var(--c-success);
}

.stat--info {
  border-top-color: var(--c-info);
}

.stat--warning {
  border-top-color: #b97a00;
}

.stat--danger {
  border-top-color: var(--c-danger-strong);
}

.stat--accent {
  border-top-color: var(--c-accent);
}

a.stat:hover {
  border-color: var(--c-primary);
  color: var(--c-text);
}

a.stat .stat__label {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* 7. Table ----------------------------------------------------------------- */

/* The wrapper scrolls in both directions: wide tables stay usable on a phone and
   the header row stays visible while a long table is scrolled. */
.table-wrap {
  max-height: 75vh;
  overflow: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}

.table-wrap--free {
  max-height: none;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.table th,
.table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--c-border);
  text-align: start;
  vertical-align: top;
}

.table th:first-child,
.table td:first-child {
  padding-left: var(--s-5);
}

.table th:last-child,
.table td:last-child {
  padding-right: var(--s-5);
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--c-surface-alt);
  border-bottom: 1px solid var(--c-border-strong);
  color: var(--c-text-muted);
  font-weight: 700;
  white-space: nowrap;
  vertical-align: bottom;
}

.table tbody th {
  font-weight: 600;
}

.table tbody tr:nth-child(even) {
  background: var(--c-zebra);
}

.table tbody tr:hover {
  background: var(--c-primary-soft);
}

.table tbody tr:last-child > * {
  border-bottom: 0;
}

.table tfoot th,
.table tfoot td {
  background: var(--c-surface-alt);
  border-top: 1px solid var(--c-border-strong);
  border-bottom: 0;
  font-weight: 700;
}

.table .num {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table .nowrap {
  white-space: nowrap;
}

.table__actions {
  text-align: end;
  white-space: nowrap;
}

.table__sub {
  display: block;
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
  font-weight: 400;
}

.table tbody tr.is-selected {
  background: var(--c-primary-soft);
  box-shadow: inset 3px 0 0 var(--c-primary);
}

.table--compact th,
.table--compact td {
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}

@media (max-width: 40rem) {
  .table th:first-child,
  .table td:first-child {
    padding-left: var(--s-4);
  }

  .table th:last-child,
  .table td:last-child {
    padding-right: var(--s-4);
  }
}

/* 8. Filter bar ------------------------------------------------------------ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-3) var(--s-4);
  padding: var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}

.filter-bar .field {
  flex: 1 1 11rem;
  max-width: 20rem;
}

.filter-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* 9. Forms ----------------------------------------------------------------- */

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--s-4) var(--s-5);
  align-items: start;
}

.field {
  display: grid;
  gap: var(--s-1);
  align-content: start;
  min-width: 0;
}

.field__label {
  font-weight: 600;
}

.field__optional {
  color: var(--c-text-muted);
  font-weight: 400;
}

.field__hint {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
}

.field__error {
  color: var(--c-danger);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.375rem 0.625rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border-input);
  border-radius: var(--r-sm);
  line-height: var(--lh);
}

.textarea {
  resize: vertical;
}

.input--file {
  padding: 0.3125rem;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--c-text);
}

.input:disabled,
.select:disabled,
.textarea:disabled,
.input[readonly] {
  background: var(--c-surface-alt);
  color: var(--c-text-muted);
  border-color: var(--c-border-strong);
}

.field--invalid .input,
.field--invalid .select,
.field--invalid .textarea {
  border-color: var(--c-danger);
  box-shadow: inset 3px 0 0 var(--c-danger);
}

.field--checkbox {
  align-self: center;
}

.checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--s-2);
  font-weight: 600;
  cursor: pointer;
}

.checkbox input {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0.25em 0 0;
  accent-color: var(--c-primary);
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.fieldset {
  min-width: 0;
  margin: 0;
  padding: var(--s-4);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
}

.fieldset > legend {
  padding: 0 var(--s-2);
  font-weight: 700;
}

.inline-form {
  display: inline-block;
}

/* 10. Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 2.5rem;
  padding: 0.375rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: var(--lh-tight);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn--primary {
  background: var(--c-primary);
  color: #ffffff;
}

.btn--primary:hover {
  background: var(--c-primary-hover);
  color: #ffffff;
}

.btn--secondary {
  background: var(--c-surface);
  border-color: var(--c-border-input);
  color: var(--c-text);
}

.btn--secondary:hover {
  background: var(--c-surface-alt);
  border-color: var(--c-text);
  color: var(--c-text);
}

.btn--danger {
  background: var(--c-danger-strong);
  color: #ffffff;
}

.btn--danger:hover {
  background: var(--c-danger-strong-hover);
  color: #ffffff;
}

.btn--link {
  min-height: 0;
  padding: var(--s-1);
  background: none;
  color: var(--c-primary);
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.btn--small {
  min-height: 2rem;
  padding: 0.1875rem 0.625rem;
  font-size: var(--fs-sm);
}

.btn--block {
  width: 100%;
}

.btn:disabled,
.btn.is-disabled,
.btn[aria-disabled="true"] {
  background: var(--c-neutral-soft);
  border-color: var(--c-neutral-border);
  color: var(--c-text-muted);
  cursor: not-allowed;
}

/* 11. Badges --------------------------------------------------------------- */

/* A badge always carries its meaning as text; the colour and the dot only support it. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.0625rem 0.5rem;
  background: var(--c-neutral-soft);
  border: 1px solid var(--c-neutral-border);
  border-radius: var(--r-pill);
  color: var(--c-neutral);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: var(--lh);
  white-space: nowrap;
  vertical-align: baseline;
}

.badge::before {
  content: "";
  flex: none;
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: currentColor;
}

.badge--info {
  background: var(--c-info-soft);
  border-color: var(--c-info-border);
  color: var(--c-info);
}

.badge--success {
  background: var(--c-success-soft);
  border-color: var(--c-success-border);
  color: var(--c-success);
}

.badge--warning {
  background: var(--c-warning-soft);
  border-color: var(--c-warning-border);
  color: var(--c-warning);
}

.badge--danger {
  background: var(--c-danger-soft);
  border-color: var(--c-danger-border);
  color: var(--c-danger);
}

.badge--accent {
  background: var(--c-accent-soft);
  border-color: var(--c-accent-border);
  color: var(--c-accent);
}

/* 12. Flash messages and callouts ------------------------------------------ */

.flashes {
  display: grid;
  gap: var(--s-2);
}

.flash,
.callout {
  padding: var(--s-3) var(--s-4);
  background: var(--c-info-soft);
  border: 1px solid var(--c-info-border);
  border-left: 4px solid var(--c-info);
  border-radius: var(--r-sm);
  color: var(--c-text);
}

.flash {
  font-weight: 600;
}

.flash--info,
.callout--info {
  background: var(--c-info-soft);
  border-color: var(--c-info-border);
  border-left-color: var(--c-info);
}

.flash--success,
.callout--success {
  background: var(--c-success-soft);
  border-color: var(--c-success-border);
  border-left-color: var(--c-success);
}

.flash--error,
.callout--danger {
  background: var(--c-danger-soft);
  border-color: var(--c-danger-border);
  border-left-color: var(--c-danger-strong);
}

.callout--warning {
  background: var(--c-warning-soft);
  border-color: var(--c-warning-border);
  border-left-color: #b97a00;
}

.callout__title {
  font-weight: 700;
}

.callout__title + .callout__text {
  margin-top: var(--s-1);
}

.callout__list {
  margin-top: var(--s-1);
  padding-left: 1.25rem;
  list-style: disc;
}

/* 13. Pagination ----------------------------------------------------------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
}

.pagination__status {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* 14. Empty state ---------------------------------------------------------- */

.empty {
  padding: var(--s-6) var(--s-5);
  background: var(--c-surface);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-md);
  text-align: center;
}

.card .empty {
  border: 0;
  background: none;
}

.empty__title {
  font-size: var(--fs-lg);
  font-weight: 700;
}

.empty__text {
  max-width: 34rem;
  margin: var(--s-1) auto 0;
  color: var(--c-text-muted);
}

.empty__action {
  margin-top: var(--s-4);
}

/* 15. Definition list ------------------------------------------------------ */

.dl {
  display: grid;
}

.dl__row {
  display: grid;
  grid-template-columns: minmax(9rem, 16rem) minmax(0, 1fr);
  gap: var(--s-1) var(--s-4);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--c-border);
}

.dl__row:last-child {
  border-bottom: 0;
}

.dl dt {
  color: var(--c-text-muted);
  font-weight: 600;
}

.dl dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 40rem) {
  .dl__row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 16. Disclosure, confirm, menu -------------------------------------------- */

.disclosure > summary,
.confirm > summary,
.menu > summary {
  list-style: none;
  cursor: pointer;
}

.disclosure > summary::-webkit-details-marker,
.confirm > summary::-webkit-details-marker,
.menu > summary::-webkit-details-marker {
  display: none;
}

.disclosure__panel,
.confirm__panel {
  margin-top: var(--s-2);
  padding: var(--s-4);
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
}

.disclosure__panel > * + *,
.confirm__panel > * + * {
  margin-top: var(--s-3);
}

/* Confirm pattern: the visible button only opens the question; the real submit
   button is inside. Works without JavaScript. */
.confirm {
  display: inline-block;
  max-width: 100%;
}

.confirm[open] > summary {
  background: var(--c-neutral-soft);
  border-color: var(--c-neutral-border);
  color: var(--c-text);
}

.confirm__panel {
  display: block;
  max-width: 30rem;
  border-left: 4px solid #b97a00;
  text-align: start;
  white-space: normal;
}

.confirm__text {
  font-weight: 600;
}

.menu {
  position: relative;
}

.menu__button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 14rem;
  min-height: 2.25rem;
  padding: var(--s-1) var(--s-3);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.menu__button::after {
  content: "";
  flex: none;
  width: 0.4375rem;
  height: 0.4375rem;
  margin-top: -0.25rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.menu[open] > .menu__button::after {
  margin-top: 0.125rem;
  transform: rotate(225deg);
}

.menu__button:hover {
  border-color: #ffffff;
}

.user-menu__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu__panel {
  position: absolute;
  top: calc(100% + var(--s-2));
  right: 0;
  z-index: 40;
  width: max-content;
  min-width: 13rem;
  max-width: min(20rem, 90vw);
  padding: var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  color: var(--c-text);
}

.menu__panel :focus-visible {
  outline-color: var(--c-focus);
}

.menu__title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.menu__meta {
  margin-bottom: var(--s-3);
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

@media (max-width: 30rem) {
  .menu__button {
    max-width: 8.5rem;
  }
}

/* 17. Tabs, progress ------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--s-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--c-border-strong);
}

.tabs__item {
  flex: none;
  padding: var(--s-2) var(--s-4);
  border-bottom: 3px solid transparent;
  color: var(--c-text);
  text-decoration: none;
  white-space: nowrap;
}

.tabs__item:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
}

.tabs__item.is-active {
  border-bottom-color: var(--c-primary);
  color: var(--c-primary-hover);
  font-weight: 700;
}

.progress {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.progress__bar {
  flex: 1 1 8rem;
  min-width: 4rem;
  max-width: 16rem;
  height: 0.625rem;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  background: var(--c-neutral-soft);
  border: 1px solid var(--c-neutral-border);
  border-radius: var(--r-pill);
}

.progress__bar::-webkit-progress-bar {
  background: var(--c-neutral-soft);
}

.progress__bar::-webkit-progress-value {
  background: var(--c-primary);
}

.progress__bar::-moz-progress-bar {
  background: var(--c-primary);
}

.progress__text {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 18. Log-in and error pages ----------------------------------------------- */

.auth {
  max-width: 25rem;
  margin: 8vh auto 0;
}

.auth__title {
  font-size: var(--fs-xl);
}

.auth .btn {
  width: 100%;
}

.error-page {
  max-width: 36rem;
  margin: 8vh auto 0;
  padding: var(--s-6) var(--s-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  text-align: center;
}

.error-page > * + * {
  margin-top: var(--s-3);
}

.error-page__code {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.error-page__title {
  font-size: var(--fs-xl);
}

.error-page__text {
  color: var(--c-text-muted);
}

.error-page__reference {
  display: inline-block;
  padding: var(--s-1) var(--s-3);
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.error-page__actions {
  margin-top: var(--s-5);
}

/* 19. Utilities ------------------------------------------------------------ */

.stack > * + * {
  margin-top: var(--s-4);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
}

.split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
}

.grid-2,
.grid-3 {
  display: grid;
  gap: var(--s-5);
  align-items: start;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.muted {
  color: var(--c-text-muted);
}

.small {
  font-size: var(--fs-sm);
}

.strong {
  font-weight: 700;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9375em;
}

.nowrap {
  white-space: nowrap;
}

.break {
  overflow-wrap: anywhere;
}

.text-end {
  text-align: end;
}

.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;
}

/* Progressive enhancement: app.js adds the class "js" to <html>. */
.js-only {
  display: none;
}

.js .js-only {
  display: inline-flex;
}

.js .js-hide {
  display: none;
}

/* 20. Print, reduced motion ------------------------------------------------ */

@media print {
  .topbar,
  .sidenav,
  .skip-link,
  .filter-bar,
  .pagination,
  .footer,
  .btn {
    display: none;
  }

  html {
    background: #ffffff;
  }

  .shell {
    display: block;
  }

  .main {
    max-width: none;
    padding: 0;
  }

  .card,
  .stat {
    box-shadow: none;
    break-inside: avoid;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  .table thead th {
    position: static;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .sidenav__link,
  .input,
  .select,
  .textarea {
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  }
}
