/* ==========================================================================
   MKH - Shared components
   Visual language from the Claude Design project "MKH Accounts & Inventory".
   Requires tokens.css and base.css. Load before any screen stylesheet.

   Anything used by more than one screen lives here. Screen stylesheets hold
   layout for that screen only.
   ========================================================================== */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              filter var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.55; }

.btn--block { width: 100%; }
.btn--sm { height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn--lg { height: 46px; padding: 0 20px; font-size: var(--fs-lg); font-family: var(--font-display); font-weight: var(--fw-bold); }

/* Filled buttons are a vertical gradient with a lit top edge - flat fills
   read as unfinished next to the rest of this design. */
.btn--primary {
  background: var(--primary-fill);
  border-color: var(--indigo-700);
  color: #FFFFFF;
  box-shadow: var(--sh-glow), var(--edge);
}
.btn--primary:hover:not(:disabled)  { filter: brightness(1.10); }
.btn--primary:active:not(:disabled) { transform: translateY(1px); }

/* Green fill; the label is white, so this uses the darker end of the ramp. */
.btn--accent {
  background: var(--accent-fill);
  border-color: var(--green-800);
  color: #FFFFFF;
  box-shadow: 0 8px 22px -12px rgba(0, 166, 81, 0.7), var(--edge);
}
.btn--accent:hover:not(:disabled)  { filter: brightness(1.08); }
.btn--accent:active:not(:disabled) { transform: translateY(1px); }

.btn--ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--txt-2);
}
.btn--ghost:hover:not(:disabled) {
  color: var(--txt);
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.btn--subtle { background: var(--primary-soft); color: var(--primary-soft-fg); }
.btn--subtle:hover:not(:disabled) { border-color: var(--primary); }

.btn--danger { background: var(--bad); color: #FFFFFF; }
.btn--danger:hover:not(:disabled) { filter: brightness(1.08); }

.btn__spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: var(--r-full);
  animation: mkh-spin 0.7s linear infinite;
}
.btn.is-loading .btn__spinner { display: block; }

/* Square icon-only button. */
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--txt-2);
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.icon-btn:hover { color: var(--txt); border-color: var(--line-strong); }
.icon-btn svg { width: 17px; height: 17px; }

/* Quiet variant for inside table rows, where a bordered button per row would
   turn the table into a grid of boxes. */
.icon-btn--quiet {
  width: 30px;
  height: 30px;
  background: none;
  border-color: transparent;
  color: var(--txt-3);
}
.icon-btn--quiet:hover { color: var(--txt); background: var(--surface-3); border-color: var(--line); }

.icon-btn__dot {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--accent-graphic);
  box-shadow: 0 0 0 2px var(--surface-2);
}

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

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: var(--sp-4); }

.field__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--txt-2);
  letter-spacing: 0.01em;
}

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

.field__icon {
  position: absolute;
  left: 12px;
  display: grid;
  place-items: center;
  color: var(--txt-3);
  pointer-events: none;
  transition: color var(--dur-fast) var(--ease);
}
.field__icon svg { width: 16px; height: 16px; }

.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--txt);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.input:hover:not(:disabled) { border-color: var(--line-strong); }

/* Focus lifts the field off the page background as well as ringing it. */
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface);
}
.field__control:focus-within .field__icon { color: var(--primary); }

.input:disabled { background: var(--surface-3); color: var(--txt-3); cursor: not-allowed; }

.input--lg { height: 42px; font-size: 14px; }

/* A leading icon reserves room automatically. Uses ~ rather than + because a
   visually-hidden <label> often sits between the icon and the input. */
.field__icon ~ .input { padding-left: 38px; }
.input--password { padding-right: 44px; }

.field.is-invalid .input { border-color: var(--bad); }
.field.is-invalid .input:focus { box-shadow: var(--ring-danger); }
.field.is-invalid .field__icon { color: var(--bad); }

.field__error {
  display: none;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--bad-fg);
}
.field.is-invalid .field__error { display: flex; }

.field__hint { font-size: var(--fs-sm); color: var(--warn-fg); }
.field__hint[hidden] { display: none; }
.field__note { font-size: var(--fs-xs); color: var(--txt-3); line-height: 1.5; }

.reveal {
  position: absolute;
  right: 5px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-xs);
  color: var(--txt-3);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.reveal:hover { color: var(--primary); background: var(--surface-3); }
.reveal svg { width: 16px; height: 16px; }

.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}

.checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 9px;
  font-size: var(--fs-md);
  color: var(--txt-2);
  cursor: pointer;
  user-select: none;
}
.checkbox input { width: 15px; height: 15px; margin-top: 2px; flex: none; cursor: pointer; }

.check { width: 15px; height: 15px; flex: none; cursor: pointer; }
.check:disabled { cursor: not-allowed; opacity: 0.35; }

.link-muted { font-size: var(--fs-md); font-weight: var(--fw-semibold); }

/* ---- Select -------------------------------------------------------------- */

.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap--block { display: flex; width: 100%; }

.select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--txt-2);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.select:hover { border-color: var(--line-strong); }
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface);
}

/* A real element rather than a background image, so it follows the theme. */
.select__chevron {
  position: absolute;
  right: 11px;
  width: 14px;
  height: 14px;
  color: var(--txt-3);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
/* Cards that hold a toolbar or table clip their children to the radius. */
.card--flush { overflow: hidden; }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
}
.card__body { padding: 18px; }
.card__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: var(--sp-4);
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  animation: mkh-rise 0.24s var(--ease);
}
.alert[hidden] { display: none; }
.alert svg { width: 17px; height: 17px; margin-top: 1px; }

.alert--danger  { background: var(--bad-bg);  border-color: var(--bad);  color: var(--bad-fg); }
.alert--success { background: var(--ok-bg);   border-color: var(--ok);   color: var(--ok-fg); }
.alert--warning { background: var(--warn-bg); border-color: var(--warn); color: var(--warn-fg); }
.alert--info    { background: var(--info-bg); border-color: var(--info); color: var(--info-fg); }

/* --------------------------------------------------------------------------
   Build note - scaffolding that should be deleted once real data lands
   -------------------------------------------------------------------------- */

.note {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--txt-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.note svg { width: 17px; height: 17px; margin-top: 2px; color: var(--txt-3); }
.note code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--primary-soft-fg);
  font-size: var(--fs-xs);
}

.cell-muted { color: var(--txt-3); white-space: nowrap; }

/* --------------------------------------------------------------------------
   Bulk action bar
   -------------------------------------------------------------------------- */

.bulkbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 12px 16px;
  background: var(--primary-soft);
  border-bottom: 1px solid var(--line);
  animation: mkh-fade 0.18s var(--ease);
}
.bulkbar[hidden] { display: none; }
.bulkbar__count { font-size: var(--fs-md); color: var(--primary-soft-fg); }
.bulkbar__count strong { font-family: var(--font-display); font-size: var(--fs-lg); }
.bulkbar__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-left: auto; }

/* --------------------------------------------------------------------------
   Badges

   Pills. Status badges carry a dot as well as a word, so the state survives
   both a greyscale print and a reader who cannot separate red from green.
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.badge__dot { width: 6px; height: 6px; flex: none; border-radius: var(--r-full); background: currentColor; }

.badge--paid    { background: var(--ok-bg);   color: var(--ok-fg); }
.badge--overdue { background: var(--bad-bg);  color: var(--bad-fg); }
.badge--low     { background: var(--warn-bg); color: var(--warn-fg); }
.badge--draft   { background: var(--info-bg); color: var(--info-fg); border-color: var(--sky-200); }
.badge--void    { background: var(--mute-bg); color: var(--mute-fg); }

/* Uppercase micro-tag, for "System role" / "Custom" style labels. */
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag--system { background: var(--accent-soft); color: var(--accent-soft-fg); }
.tag--custom { background: var(--primary-soft); color: var(--primary-soft-fg); }

/* --------------------------------------------------------------------------
   Avatar - a rounded square, not a circle, matching the mark's own badge
   -------------------------------------------------------------------------- */

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--grad-badge);
  color: #FFFFFF;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  box-shadow: var(--sh-xs);
  user-select: none;
}
.avatar--sm { width: 30px; height: 30px; border-radius: 9px; font-size: var(--fs-2xs); }
.avatar--round { border-radius: var(--r-full); }

/* --------------------------------------------------------------------------
   Dropdown menu
   -------------------------------------------------------------------------- */

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-menu);
  min-width: 218px;
  /* Bounded, or a menu holding a sentence rather than short items would
     shrink-to-fit the whole viewport width once it is placed. */
  max-width: min(320px, calc(100vw - 24px));
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  animation: mkh-rise 0.16s var(--ease);
}
.menu[hidden] { display: none; }

/* Pinned to the viewport by mkh.placeMenu. The row menus sit inside a card
   that clips to its radius and a table wrapper that scrolls, so an absolutely
   positioned menu on the last row is cut off by both. */
.menu--fixed { position: fixed; top: auto; right: auto; }

.menu__label {
  padding: 7px 10px 5px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--txt-3);
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-xs);
  font-size: var(--fs-md);
  color: var(--txt);
  text-align: left;
}
.menu__item:hover { background: var(--surface-2); text-decoration: none; }
.menu__item svg { width: 16px; height: 16px; color: var(--txt-3); }
.menu__item--danger { color: var(--bad); }
.menu__item--danger svg { color: currentColor; }
.menu__item--danger:hover { background: var(--bad-bg); }
.menu__item:disabled { color: var(--txt-3); cursor: not-allowed; }
.menu__item:disabled:hover { background: none; }

.menu__sep {
  height: 1px;
  margin: 5px 8px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.menu__note {
  padding: 6px 10px 4px;
  font-size: var(--fs-xs);
  color: var(--txt-3);
}
.menu__note[hidden] { display: none; }

/* Row action menu.

   Fixed, and re-parented to <body> on init. Two things would otherwise break
   it: .table-wrap scrolls horizontally so it would clip the menu, and .content
   declares container-type, which makes it a containing block for fixed
   descendants and would shift the coordinates. */
.menu--row {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: var(--z-drawer);
  min-width: 224px;
  max-width: min(280px, calc(100vw - 16px));
}

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.toolbar__search { position: relative; display: flex; align-items: center; flex: 1; min-width: 190px; }
.toolbar__search .input { height: 36px; font-size: var(--fs-md); }
.toolbar__search .field__icon { left: 11px; }
.toolbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.toolbar__count { font-size: var(--fs-sm); color: var(--txt-3); white-space: nowrap; }

/* --------------------------------------------------------------------------
   Advanced filters
   -------------------------------------------------------------------------- */

.filters {
  padding: 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  animation: mkh-fade 0.18s var(--ease);
}
.filters[hidden] { display: none; }
.filters__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.filters__field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filters__label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--txt-2); }
.filters__field .select { background: var(--surface); }
.filters__foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); margin-top: 14px; }

.filterbtn__count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--primary);
  color: #FFFFFF;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  font-family: var(--font-mono);
}
.filterbtn__count[hidden] { display: none; }

/* Keep applied filters visible once the panel is collapsed - otherwise a
   filtered list looks like an empty one. */
.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.chips[hidden] { display: none; }
.chips__label { font-size: var(--fs-sm); color: var(--txt-3); margin-right: var(--sp-1); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 5px 0 11px;
  border-radius: var(--r-full);
  background: var(--primary-soft);
  color: var(--primary-soft-fg);
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.chip__label { font-weight: var(--fw-semibold); }
.chip__x {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  color: inherit;
  opacity: 0.7;
}
.chip__x:hover { opacity: 1; background: rgba(0, 0, 0, 0.10); }
.chip__x svg { width: 11px; height: 11px; }

/* --------------------------------------------------------------------------
   Table
   -------------------------------------------------------------------------- */

/* Wide tables scroll inside this, never pushing the page sideways.
   position:relative is load-bearing: a .sr-only child is absolutely
   positioned, and without a positioned ancestor it escapes this scroller and
   drags the document's scrollWidth out with it. */
.table-wrap { position: relative; overflow-x: auto; }

.table { width: 100%; font-size: var(--fs-base); }

.table thead tr { background: var(--surface-2); }
.table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--txt-3);
  white-space: nowrap;
}

.table tbody tr {
  border-top: 1px solid var(--line-soft);
  transition: background-color var(--dur-fast) var(--ease);
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--primary-soft); }
.table tbody td { padding: 11px 14px; vertical-align: middle; }

.table .col-check { width: 44px; padding-left: 16px; padding-right: 0; }
.table .col-actions { width: 96px; padding-right: 16px; }
.table__actions { display: flex; align-items: center; gap: 5px; justify-content: flex-end; }

.table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.table__empty td {
  padding: 46px 20px;
  text-align: center;
  color: var(--txt-3);
  font-size: var(--fs-base);
}

/* Identity cell - avatar plus name and secondary line. */
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
/* The children are spans, so the stack has to be declared. */
.person__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.person__name {
  font-weight: var(--fw-semibold);
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--txt-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.pagination__info { font-size: var(--fs-sm); color: var(--txt-3); }
.pagination__info strong { color: var(--txt-2); }
.pagination__pages { display: flex; align-items: center; gap: 6px; }

.page-btn {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--txt-3);
  font-size: var(--fs-sm);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.page-btn svg { width: 14px; height: 14px; }
.page-btn:hover:not(:disabled) { color: var(--txt); border-color: var(--line-strong); }
.page-btn[aria-current="page"] {
  background: var(--primary-fill);
  border-color: var(--indigo-700);
  color: #FFFFFF;
  font-weight: var(--fw-bold);
}
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Slide-over panel
   Its own scrim, independent of the nav drawer in layout.css - that one only
   exists below 900px, whereas this must work at every width.
   -------------------------------------------------------------------------- */

.panel-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: rgba(9, 10, 26, 0.55);
  backdrop-filter: blur(2px);
  animation: mkh-fade 0.2s var(--ease);
}
body[data-panel="open"] .panel-scrim { display: block; }
body[data-panel="open"] { overflow: hidden; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--sh-lg);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease);
}
/* Which drawer is showing is per-drawer, not per-page: a screen can hold more
   than one. The body attribute only drives the shared scrim and scroll lock. */
.drawer.is-open { transform: translateX(0); }

.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.drawer__title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}
.drawer__sub { margin-top: 4px; font-size: var(--fs-sm); color: var(--txt-3); }

.drawer__body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; }

.drawer__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex: none;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.drawer__foot .btn { height: 38px; }

/* --------------------------------------------------------------------------
   Switch
   -------------------------------------------------------------------------- */

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch__track {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--surface-3);
  transition: background-color var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: left var(--dur-base) var(--ease);
}
.switch input:checked + .switch__track { background: var(--accent-fill); border-color: var(--green-800); }
.switch input:checked + .switch__track::after { left: 20px; }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--primary-ring); }
.switch__label { font-size: var(--fs-md); color: var(--txt-2); }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--txt-2);
  white-space: nowrap;
}
.tab:hover { color: var(--txt); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

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

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 46px 20px; }
.empty__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--primary-soft);
  color: var(--primary-soft-fg);
}
.empty__icon svg { width: 24px; height: 24px; }
.empty__title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: var(--fw-bold); margin-bottom: var(--sp-2); }
.empty__text { max-width: 46ch; font-size: var(--fs-md); color: var(--txt-2); margin-bottom: var(--sp-4); }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--ok);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-lg);
  font-size: var(--fs-md);
  color: var(--txt);
  animation: mkh-slide-r 0.24s var(--ease);
}
.toast[hidden] { display: none; }
.toast__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.toast__icon svg { width: 13px; height: 13px; }

/* --------------------------------------------------------------------------
   Touch and forced colours
   -------------------------------------------------------------------------- */

/* 16px stops iOS Safari zooming the page when a field takes focus. */
@media (max-width: 860px) {
  .input { font-size: 16px; }
  .select { font-size: 16px; }
}

@media (pointer: coarse) {
  .input { height: 42px; }
  .select { height: 42px; }
  .btn { height: 42px; }
  .btn--sm { height: 38px; }
  .reveal { width: 38px; height: 38px; }
  .icon-btn { width: 42px; height: 42px; }
  .icon-btn--quiet { width: 38px; height: 38px; }
  /* Row and permission checkboxes are hit directly, with no label wrapping
     them to widen the target. */
  .check, .checkbox input { width: 20px; height: 20px; }
  .link-muted { padding-block: var(--sp-2); }
}

@media (forced-colors: active) {
  .input, .btn, .alert, .card, .menu, .badge { border: 1px solid currentColor; }
}

/* When the filters or chips close out a card, the divider has nothing below
   it to separate from. */
.filters:last-child,
.chips:last-child { border-bottom: 0; }

/* Invisible catcher that dismisses an open row menu on the next click, without
   a global JS listener fighting Blazor over the DOM. */
.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-menu) - 1);
}

/* ==========================================================================
   Reconnect modal

   Shown when the Blazor circuit drops. Blazor owns the state: it puts
   .components-reconnect-show / -retrying / -failed / -paused / -resume-failed
   on the dialog and fills #components-seconds-to-next-attempt with the
   countdown. Every state is present in the markup at once, so the rules below
   are what decide which one reaches the screen.
   ========================================================================== */

/* Everything is hidden until a state asks for it. No element carries its own
   `display` outside these rules, or it would leak into the wrong state. */
.reconnect__state,
.reconnect__icon,
.reconnect__actions,
.components-rejoining-animation,
#components-reconnect-button,
#components-resume-button,
#components-reload-button { display: none; }

/* Copy blocks.

   `retrying` is added ON TOP of `show`, not instead of it - Blazor only ever
   clears the whole set at once - so the first-attempt copy has to opt out of
   it explicitly or both messages appear together. Every other state is
   exclusive already. */
#components-reconnect-modal.components-reconnect-show:not(.components-reconnect-retrying) .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible {
  display: block;
}

/* The activity bars belong to the two "still trying" states only. */
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation {
  display: flex;
}

/* A static icon replaces the animation once Blazor has stopped trying. */
#components-reconnect-modal.components-reconnect-failed .reconnect__icon--warn,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect__icon--warn,
#components-reconnect-modal.components-reconnect-paused .reconnect__icon--pause {
  display: grid;
}

#components-reconnect-modal.components-reconnect-failed #components-reconnect-button,
#components-reconnect-modal.components-reconnect-failed #components-reload-button,
#components-reconnect-modal.components-reconnect-paused #components-resume-button,
#components-reconnect-modal.components-reconnect-resume-failed #components-resume-button,
#components-reconnect-modal.components-reconnect-resume-failed #components-reload-button {
  display: inline-flex;
}

/* The two "still trying" states offer no buttons, so the row itself goes too -
   an empty flex row would still contribute the card gap above it. */
#components-reconnect-modal.components-reconnect-failed .reconnect__actions,
#components-reconnect-modal.components-reconnect-paused .reconnect__actions,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect__actions {
  display: flex;
}

/* ---- Dialog -------------------------------------------------------------- */

#components-reconnect-modal {
  margin: auto;
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
  color: var(--txt);
}
#components-reconnect-modal::backdrop {
  background: rgba(9, 10, 26, 0.62);
  backdrop-filter: blur(3px);
  animation: mkh-fade 0.2s var(--ease);
}

.reconnect__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
  width: min(420px, calc(100vw - 32px));
  padding: 28px 26px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  animation: mkh-rise 0.26s var(--ease-out);
}

/* ---- Activity indicator -------------------------------------------------- */

/* Three bars rising and falling out of phase. A determinate progress bar would
   be a lie here: nobody knows how long the server will take to come back. */
.reconnect__pulse { align-items: flex-end; gap: 5px; height: 34px; }
.reconnect__pulse div {
  width: 6px;
  height: 12px;
  border-radius: var(--r-full);
  background: var(--primary-fill);
  animation: mkh-reconnect-pulse 1.05s ease-in-out infinite;
}
.reconnect__pulse div:nth-child(2) { animation-delay: 0.16s; }
.reconnect__pulse div:nth-child(3) { animation-delay: 0.32s; }

@keyframes mkh-reconnect-pulse {
  0%, 100% { height: 12px; opacity: 0.45; }
  50%      { height: 30px; opacity: 1; }
}

.reconnect__icon {
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--r-full);
}
.reconnect__icon svg { width: 24px; height: 24px; }
.reconnect__icon--warn  { background: var(--bad-bg);  color: var(--bad-fg); }
.reconnect__icon--pause { background: var(--warn-bg); color: var(--warn-fg); }

/* ---- Copy ---------------------------------------------------------------- */

.reconnect__title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}
.reconnect__text {
  margin-top: 6px;
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--txt-2);
  max-width: 34ch;
  margin-inline: auto;
}

/* ---- Countdown ----------------------------------------------------------- */

.reconnect__countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

/* Tabular figures and a fixed minimum width, so the number does not jiggle the
   label sideways as it counts 10, 9, 8. */
.reconnect__seconds {
  min-width: 2ch;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: var(--fw-bold);
  line-height: 1;
  color: var(--primary);
}
.reconnect__seconds-label { font-size: var(--fs-sm); color: var(--txt-3); text-align: left; }

/* Blazor holds the countdown at 0 for the two seconds an attempt takes. A
   frozen "0 seconds to the next attempt" reads as a stuck timer, so the JS
   flags that window and the box says what is actually happening. */
.reconnect__now { display: none; font-size: var(--fs-md); color: var(--txt-2); }
#components-reconnect-modal.is-attempting .reconnect__seconds,
#components-reconnect-modal.is-attempting .reconnect__seconds-label { display: none; }
#components-reconnect-modal.is-attempting .reconnect__now { display: inline; }

/* Attempt N of M. Says the retrying will not go on forever, which the bare
   countdown does not. */
.reconnect__attempt {
  margin-top: 8px;
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--txt-3);
}
.reconnect__attempt span { font-variant-numeric: tabular-nums; color: var(--txt-2); }

.reconnect__actions {
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .reconnect__pulse div { animation: none; height: 20px; opacity: 0.8; }
}
