/* Base layer — shell, layout primitives and the shared component vocabulary.
   Colours, radii, spacing, type and motion come from tokens.css only.
   The class catalogue is documented in docs/DESIGN.md; app stylesheets build
   on these primitives and never redefine them. */

/* ---------- Utilities and tiny primitives ---------- */

.icon {
  display: block;
  flex: none;
  width: 20px;
  height: 20px;
}

.icon--sm {
  width: 16px;
  height: 16px;
}

.icon--lg {
  width: 28px;
  height: 28px;
}

.icon--xl {
  width: 40px;
  height: 40px;
}

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

.skip-link {
  position: fixed;
  inset-block-start: var(--sp-2);
  inset-inline-start: var(--sp-2);
  z-index: 100;
  padding: var(--sp-2) var(--sp-4);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-sm);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.stack--sm {
  gap: var(--sp-2);
}

.stack--lg {
  gap: var(--sp-6);
}

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

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

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

.text-xs {
  font-size: var(--fs-xs);
}

.strong {
  font-weight: 700;
}

.brand-mark {
  display: inline-block;
  width: 12px;
  height: 26px;
  border-radius: 4px;
  background: var(--grad-brand);
  border-block-end: 4px solid var(--accent);
}

.brand-mark--lg {
  width: 16px;
  height: 36px;
  border-radius: 5px;
  border-block-end-width: 5px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 800;
}

/* ---------- App shell ---------- */

.app {
  min-height: 100dvh;
  background: var(--grad-glow), var(--bg);
  background-repeat: no-repeat;
}

.app__body {
  min-width: 0;
}

/* Mobile top bar: brand and the two always-reachable actions. */
.appbar {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--appbar-h);
  padding: var(--sp-2) var(--sp-4);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-block-end: 1px solid var(--line);
}

.appbar__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

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

.appbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.main {
  padding: var(--sp-5) var(--sp-4) calc(var(--dock-h) + var(--sp-9) + env(safe-area-inset-bottom, 0px));
}

.main:focus {
  outline: none;
}

.page {
  max-width: var(--content);
  margin-inline: auto;
}

/* One <aside class="rail"> serves both layouts. On a phone only its nav list
   shows, as a floating dock; from 960px it becomes the full side rail. */
.rail {
  display: contents;
}

.rail .rail__brand,
.rail .rail__add,
.rail .rail__user {
  display: none;
}

.rail__nav {
  position: fixed;
  inset-inline: var(--sp-3);
  inset-block-end: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-dock);
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: var(--sp-1);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
}

.rail__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 56px;
  padding: var(--sp-1) 2px;
  border-radius: var(--r-lg);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--dur-1) ease;
}

.rail__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 28px;
  border-radius: var(--r-pill);
  transition: background-color var(--dur-2) var(--ease);
}

.rail__icon .icon {
  width: 22px;
  height: 22px;
}

.rail__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.rail__item.is-active {
  color: var(--brand-text);
  font-weight: 800;
}

.rail__item.is-active .rail__icon {
  background: var(--brand-soft);
}

@media (min-width: 960px) {
  .app {
    display: grid;
    grid-template-columns: var(--rail) minmax(0, 1fr);
  }

  .appbar {
    display: none;
  }

  .main {
    padding: var(--sp-7) var(--sp-8) var(--sp-9);
  }

  .rail {
    position: sticky;
    inset-block-start: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    height: 100dvh;
    padding: var(--sp-6) var(--sp-4) var(--sp-4);
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
  }

  .rail .rail__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding-inline: var(--sp-2);
    color: var(--text);
    font-size: var(--fs-lg);
    font-weight: 800;
    line-height: 1.3;
    text-decoration: none;
  }

  .rail .rail__add {
    display: inline-flex;
  }

  .rail__nav {
    position: static;
    flex-direction: column;
    gap: var(--sp-1);
    padding: 0;
    background: transparent;
    backdrop-filter: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .rail__item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--sp-3);
    min-height: var(--touch);
    padding-inline: var(--sp-4);
    border-radius: var(--r-md);
    font-size: var(--fs-md);
    transition:
      background-color var(--dur-1) ease,
      color var(--dur-1) ease;
  }

  .rail__icon,
  .rail__item.is-active .rail__icon {
    width: auto;
    height: auto;
    background: transparent;
  }

  .rail__item:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  .rail__item.is-active {
    background: var(--brand-soft);
  }

  .rail .rail__user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-block-start: auto;
    padding: var(--sp-3);
    background: var(--surface-2);
    border-radius: var(--r-lg);
  }

  .rail__user-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: var(--fs-sm);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ---------- Typography ---------- */

h1 {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: var(--lh-tight);
}

h3 {
  font-size: var(--fs-md);
  font-weight: 700;
}

p {
  max-width: 68ch;
}

@media (min-width: 960px) {
  h1 {
    font-size: var(--fs-2xl);
  }
}

/* ---------- Focus ---------- */

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

/* ---------- Page header and sections ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3) var(--sp-4);
  margin-block-end: var(--sp-6);
}

.page-head__main {
  flex: 1 1 260px;
  min-width: 0;
}

.page-head__sub,
.page-head__hint {
  margin-block-start: var(--sp-1);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 44px;
  margin-block-end: var(--sp-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  color: var(--brand-text);
}

.section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.section__title {
  font-size: var(--fs-lg);
  font-weight: 800;
}

.section__link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 44px;
  font-size: var(--fs-sm);
  font-weight: 700;
  text-decoration: none;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--touch);
  padding-inline: var(--sp-5);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--sh-1);
  transition:
    background-color var(--dur-1) ease,
    border-color var(--dur-1) ease,
    color var(--dur-1) ease,
    box-shadow var(--dur-2) var(--ease),
    transform var(--dur-1) ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--grad-brand);
  border-color: transparent;
  color: var(--on-brand);
  box-shadow: var(--sh-brand);
}

.btn--primary:hover {
  background: var(--grad-brand);
  filter: brightness(1.06);
}

.btn--soft {
  background: var(--brand-soft);
  border-color: transparent;
  box-shadow: none;
  color: var(--brand-text);
}

.btn--soft:hover {
  background: var(--brand-soft);
  filter: brightness(0.97);
}

.btn--ghost,
.btn--quiet {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-2);
}

.btn--ghost:hover,
.btn--quiet:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  background: var(--bad);
  border-color: transparent;
  box-shadow: none;
  color: var(--surface);
}

.btn--danger:hover {
  background: var(--bad);
  filter: brightness(0.92);
}

.btn--sm {
  min-height: 44px;
  padding-inline: var(--sp-4);
}

.btn--icon {
  width: 44px;
  padding-inline: 0;
}

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

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Form controls ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-block-end: var(--sp-5);
}

.field > label,
.field__label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
}

.field__required {
  margin-inline-start: var(--sp-1);
  color: var(--bad);
}

/* Text-like controls are styled wherever they appear, so a plain login form
   needs no extra classes; checkboxes, radios and file inputs keep native looks. */
input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="submit"], [type="button"], [type="reset"], [type="hidden"]),
select,
textarea,
.input {
  width: 100%;
  min-height: var(--touch);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-md); /* never below 16px: avoids iOS zoom on focus */
  transition:
    border-color var(--dur-1) ease,
    box-shadow var(--dur-1) ease;
}

textarea,
textarea.input {
  min-height: 112px;
  resize: vertical;
}

select {
  appearance: none;
  padding-inline-end: var(--sp-8);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position:
    calc(var(--sp-4) + 5px) 50%,
    var(--sp-4) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

input[type="checkbox"],
input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}

input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]):hover,
select:hover,
textarea:hover {
  border-color: var(--text-3);
}

input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]):focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--brand);
  outline: 0;
  box-shadow: 0 0 0 4px var(--brand-soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
  opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}

.field--error input,
.field--error select,
.field--error textarea {
  border-color: var(--bad);
}

.field__error,
.errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--bad-text);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.field__help,
.helptext {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.form-hint {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* Two columns from tablet up; one column on a phone. */
.form-grid {
  display: grid;
  gap: 0 var(--sp-4);
}

.form-grid__wide {
  grid-column: 1 / -1;
}

@media (min-width: 720px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- Cards and bento ---------- */

.card {
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}

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

.card--sunken {
  background: var(--surface-2);
  border-color: transparent;
  box-shadow: none;
}

.card--hover {
  transition:
    box-shadow var(--dur-2) var(--ease),
    transform var(--dur-2) var(--ease),
    border-color var(--dur-1) ease;
}

.card--hover:hover {
  border-color: var(--line-strong);
  box-shadow: var(--sh-2);
  transform: translateY(-2px);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-end: var(--sp-4);
}

.card__title {
  font-size: var(--fs-md);
  font-weight: 800;
}

.bento {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.bento__wide {
  grid-column: span 2;
}

.bento__full {
  grid-column: 1 / -1;
}

@media (min-width: 960px) {
  .bento {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-4);
  }
}

/* ---------- Badges, chips, segmented control ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.7;
  white-space: nowrap;
}

.badge--brand {
  background: var(--brand-soft);
  color: var(--brand-text);
}

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

.badge--ok {
  background: var(--ok-soft);
  color: var(--ok-text);
}

.badge--bad {
  background: var(--bad-soft);
  color: var(--bad-text);
}

.badge--warn {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* A coloured dot keeps status readable without relying on colour alone. */
.badge--dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: currentColor;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 44px;
  padding-inline: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-1) ease,
    border-color var(--dur-1) ease,
    color var(--dur-1) ease;
}

.chip:hover {
  border-color: var(--text-3);
  color: var(--text);
}

.chip--on {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.chip--on:hover {
  color: var(--on-brand);
  border-color: var(--brand);
}

/* One row that scrolls sideways on a phone; only this strip overflows. */
.chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--sp-2);
  padding-block: var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip-row .chip {
  flex: none;
}

.segmented {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-1);
  background: var(--surface-2);
  border-radius: var(--r-pill);
}

.segmented__item {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: var(--sp-4);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-decoration: none;
  transition:
    background-color var(--dur-2) var(--ease),
    color var(--dur-1) ease;
}

.segmented__item:hover {
  color: var(--text);
}

.segmented__item.is-active {
  background: var(--surface);
  box-shadow: var(--sh-1);
  color: var(--brand-text);
}

/* ---------- Search bar ---------- */

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar__icon {
  position: absolute;
  inset-inline-start: var(--sp-4);
  display: inline-flex;
  color: var(--text-3);
  pointer-events: none;
}

.search-bar input,
.search-bar .search-bar__input {
  min-height: 52px;
  padding-inline-start: calc(var(--sp-4) + 20px + var(--sp-3));
  padding-inline-end: var(--sp-8);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  text-overflow: ellipsis;
}

.search-bar__spinner {
  position: absolute;
  inset-inline-end: var(--sp-4);
}

/* ---------- Data display: stat tile, list row, facts ---------- */

.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  color: var(--text);
  text-decoration: none;
}

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

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

.stat--brand {
  background: var(--grad-hero);
  border-color: transparent;
  color: var(--on-hero);
}

.stat--brand .stat__label {
  color: rgb(255 255 255 / 82%);
}

.stat--ok .stat__value {
  color: var(--ok-text);
}

.stat--bad .stat__value {
  color: var(--bad-text);
}

.stat--warn .stat__value {
  color: var(--accent-text);
}

.list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  text-decoration: none;
}

.list-row__main {
  flex: 1 1 200px;
  min-width: 0;
}

.list-row__title {
  font-weight: 700;
}

.list-row__meta {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.facts {
  display: grid;
  gap: var(--sp-3);
  margin: 0;
}

.facts__row {
  display: grid;
  grid-template-columns: minmax(96px, 36%) minmax(0, 1fr);
  gap: var(--sp-3);
  align-items: baseline;
  padding-block-end: var(--sp-3);
  border-block-end: 1px solid var(--line);
}

.facts__row:last-child {
  padding-block-end: 0;
  border-block-end: 0;
}

.facts dt {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-5);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--text-2);
  text-align: center;
}

.empty-state > .icon {
  color: var(--text-3);
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-start: var(--sp-5);
}

.pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding-inline: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-decoration: none;
}

.pagination__link:hover {
  background: var(--surface-2);
}

.pagination__link.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pagination__status {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* ---------- Toasts, loading ---------- */

.toasts {
  position: fixed;
  inset-block-start: calc(var(--appbar-h) + var(--sp-3));
  inset-inline: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
}

.toasts > * {
  pointer-events: auto;
}

.toast {
  width: min(100%, 460px);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 5px solid var(--info);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.toast--success {
  border-inline-start-color: var(--ok);
}

.toast--error {
  border-inline-start-color: var(--bad);
}

.toast--warning {
  border-inline-start-color: var(--accent);
}

@media (min-width: 960px) {
  .toasts {
    inset-block-start: var(--sp-5);
  }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-strong);
  border-block-start-color: var(--brand);
  border-radius: var(--r-pill);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* HTMX swaps the indicator in while a request is in flight. */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

.global-spinner {
  position: fixed;
  inset-block-start: var(--sp-3);
  inset-inline-start: var(--sp-3);
  z-index: 90;
  padding: var(--sp-2);
  background: var(--surface);
  box-shadow: var(--sh-2);
  border-radius: var(--r-pill);
}

/* ---------- Overlay and sheet ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-sheet) - 1);
  background: var(--overlay);
}

.sheet {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: var(--z-sheet);
  max-height: 88dvh;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-start-start-radius: var(--r-xl);
  border-start-end-radius: var(--r-xl);
  box-shadow: var(--sh-sheet);
}

.sheet__grip {
  width: 44px;
  height: 5px;
  margin: 0 auto var(--sp-3);
  background: var(--line-strong);
  border-radius: var(--r-pill);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-end: var(--sp-4);
}

.sheet__title {
  font-size: var(--fs-xl);
  font-weight: 800;
}

.sheet__body {
  margin-block-end: var(--sp-4);
}

.sheet__actions {
  display: flex;
  gap: var(--sp-2);
}

.sheet__actions .btn {
  flex: 1 1 0;
}

.sheet--enter {
  transition:
    transform var(--dur-3) var(--ease),
    opacity var(--dur-2) ease;
}

.sheet--from {
  opacity: 0;
  transform: translateY(32px);
}

.sheet--to {
  opacity: 1;
  transform: none;
}

/* Dialog on desktop: centred and narrower, never full width. */
@media (min-width: 960px) {
  .sheet {
    inset: 0;
    width: min(560px, calc(100% - var(--sp-8)));
    height: fit-content;
    margin: auto;
    padding-block-end: var(--sp-6);
    border-radius: var(--r-xl);
  }

  .sheet__grip {
    display: none;
  }
}

/* Global quick-add content. */
.quick-add__group {
  margin-block: var(--sp-4) var(--sp-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.quick-add__grid {
  display: grid;
  gap: var(--sp-3);
}

.quick-add__grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 104px;
  padding: var(--sp-3);
  background: var(--brand-soft);
  border-radius: var(--r-lg);
  color: var(--brand-text);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition:
    transform var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.quick-tile:hover {
  box-shadow: var(--sh-2);
  transform: translateY(-2px);
}

.quick-tile--soft {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- The plate (پلاک): the one signature element ---------- */

.plate {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  min-height: 2.75rem;
  padding: var(--sp-1) var(--sp-3) calc(var(--sp-1) + 3px);
  background: var(--grad-brand);
  border-radius: var(--r-xs);
  color: var(--on-brand);
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--sh-brand);
}

/* Thin inner border and amber underline, like a street-number enamel plate. */
.plate::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid var(--on-brand);
  border-radius: 5px;
  opacity: 0.5;
  pointer-events: none;
}

.plate::after {
  content: "";
  position: absolute;
  inset-block-end: 5px;
  inset-inline: 9px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.plate--file {
  min-width: auto;
  padding-inline: var(--sp-3);
  font-size: var(--fs-xs);
  letter-spacing: 0;
}

.plate--lg {
  min-width: 4.5rem;
  min-height: 3.5rem;
  font-size: var(--fs-2xl);
}

/* ---------- Login ---------- */

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--sp-4);
  background: var(--grad-glow), var(--bg);
  background-repeat: no-repeat;
}

.login__sheet {
  width: 100%;
  max-width: 420px;
  padding: var(--sp-8) var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
}

.login__mark {
  margin-block-end: var(--sp-4);
}

.login__brand {
  margin-block-end: var(--sp-1);
  color: var(--brand-text);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.login__title {
  margin-block-end: var(--sp-6);
  font-size: var(--fs-2xl);
}

.login__error {
  margin-block-end: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bad-soft);
  border-radius: var(--r-md);
}
