/* ══════════════════════════════════════════════════════════════════════════
   Components.

   Each block is one component and its modifiers. Nothing here positions itself
   in the page — layout is layout.css's job — so a card behaves the same in a
   grid, a modal or a list.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── card ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 52px;
}
.card-head .spacer { flex: 1; }

.card-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
}
.card-sub { font-size: var(--fs-sm); color: var(--text-muted); }

.card-body { padding: var(--s-5); flex: 1; min-width: 0; }
.card-body.is-flush { padding: 0; }
.card-body.is-tight { padding: var(--s-3) var(--s-4); }

.card-foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* A card that is a link to somewhere. */
.card-link {
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.card-link:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.card-link:active { transform: translateY(1px); }


/* ── stat ────────────────────────────────────────────────────────────────── */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.stat-value {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text);
  /* Never break inside a figure. "MAD 72,8 / 72" is not a number any more, and
     a wrapped amount is worse than a smaller one. */
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value.is-small { font-size: var(--fs-md); }

.stat-meta {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: 2px;
}

/* Phone sizing lives here, next to the component, not in layout.css — that file
   loads first, so a rule there would lose the cascade to the one above. */
@media (max-width: 899px) {
  .stat { padding: var(--s-3) var(--s-4); }
  .stat-label { font-size: 10px; letter-spacing: 0.05em; }
  /* Scales with the screen: a long figure stays on one line at 320px and still
     reads as a headline at 430px. */
  .stat-value { font-size: clamp(0.95rem, 4.6vw, var(--fs-md)); }
  .stat-value.is-small { font-size: clamp(0.85rem, 4vw, var(--fs-base)); }
  .stat-meta { font-size: var(--fs-xs); gap: var(--s-1); flex-wrap: wrap; }
}

/* Delta chips: green for a fall in spending, red for a rise. This is the one
   place in the app where green-good / red-bad is inverted relative to finance
   conventions, so the arrow glyph carries the meaning too. */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  font-variant-numeric: tabular-nums;
}
.delta.is-up   { color: var(--danger); }
.delta.is-down { color: var(--ok); }
.delta.is-flat { color: var(--text-subtle); }

/* ── buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 38px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }

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

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-sm svg { width: 14px; height: 14px; }
/* For a control that sits inside a row of content rather than beside it —
   the per-item Sync and Remove in the calendar manager. */
.btn-xs { height: 24px; padding: 0 var(--s-2); font-size: var(--fs-xs); gap: 4px; }
.btn-xs svg { width: 12px; height: 12px; }
.btn-lg { height: 46px; padding: 0 var(--s-6); font-size: var(--fs-base); }
.btn-block { width: 100%; }

/* Square icon-only button. aria-label is mandatory on these in the markup. */
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--r-md);
  color: var(--text-muted);
  flex: none;
}
.btn-icon:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon.is-active { background: var(--accent-soft); color: var(--accent-text); }

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.btn-group .btn { border-radius: 0; border: none; box-shadow: none; height: 34px; }
.btn-group .btn + .btn { border-left: 1px solid var(--border); }

/* ── segmented control ───────────────────────────────────────────────────── */

.segmented {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  background: var(--surface-3);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}

.segmented button {
  /* inline-flex, not inline: some of these carry an icon, and inline layout
     leaves the glyph welded to the first letter. */
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 5px var(--s-3);
  border-radius: calc(var(--r-md) - 3px);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: var(--fw-semi);
  box-shadow: var(--shadow-sm);
}

/* ── forms ───────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-4); }

.label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.label .req { color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  /* iOS zooms the page when a focused input is under 16px. 15px is our base, so
     bump only on touch-primary devices rather than shouting at every desktop. */
}
@media (pointer: coarse) {
  .input, .select, .textarea { font-size: 16px; }
}

.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }

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

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

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

.input.is-error, .select.is-error, .textarea.is-error {
  border-color: var(--danger);
}
.input.is-error:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.textarea { min-height: 84px; resize: vertical; line-height: var(--lh-snug); }

.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23918a83' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 15px;
  cursor: pointer;
}

.field-error { font-size: var(--fs-sm); color: var(--danger); }
.field-hint { font-size: var(--fs-sm); color: var(--text-subtle); line-height: var(--lh-snug); }

/* Amount input with the currency printed inside the box. */
.input-money { position: relative; }
.input-money .input { padding-right: 52px; text-align: right; font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); }
.input-money .cur {
  position: absolute;
  right: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: var(--text-subtle);
  pointer-events: none;
}

.input-search { position: relative; }
.input-search .input { padding-left: 36px; }
.input-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

/* Checkbox / radio / switch */
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  cursor: pointer;
  padding: var(--s-2) 0;
  min-width: 0;
}
.check input { flex: none; width: 17px; height: 17px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; }
.check-text { font-size: var(--fs-sm); line-height: var(--lh-snug); min-width: 0; }
.check-title { font-weight: var(--fw-medium); color: var(--text); }
.check-hint { color: var(--text-subtle); font-size: var(--fs-xs); }

.switch {
  --w: 40px; --h: 23px;
  position: relative;
  width: var(--w); height: var(--h);
  flex: none;
  border-radius: var(--r-full);
  background: var(--border-strong);
  transition: background var(--t-base) var(--ease);
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: calc(var(--h) - 4px);
  height: calc(var(--h) - 4px);
  border-radius: var(--r-full);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base) var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(calc(var(--w) - var(--h))); }

/* ── chips & badges ──────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 28px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
button.chip { cursor: pointer; }
button.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: var(--fw-semi);
}
.chip-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--dot, currentColor); flex: none; }
.chip-x { margin-right: -4px; opacity: 0.6; }
.chip-x:hover { opacity: 1; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.01em;
  background: var(--surface-3);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-ok     { background: var(--ok-soft);     color: var(--ok);     }
.badge-warn   { background: var(--warn-soft);   color: var(--warn);   }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info   { background: var(--info-soft);   color: var(--info);   }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }

.dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  flex: none;
  background: var(--dot, var(--text-subtle));
}
.dot-lg { width: 10px; height: 10px; }

/* A live status dot that pulses only while something is genuinely live. */
.dot-live { position: relative; background: var(--ok); }
.dot-live::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: var(--r-full);
  border: 2px solid var(--ok);
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse {
  0%   { opacity: 0.7; transform: scale(0.7); }
  70%  { opacity: 0;   transform: scale(1.3); }
  100% { opacity: 0;   transform: scale(1.3); }
}

/* ── tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
  /* Wide tables scroll inside their own box; the page never scrolls sideways. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table th.right, .table td.right { text-align: right; }

.table td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.is-selected { background: var(--accent-soft); }

.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-arrow { opacity: 0.4; margin-left: 3px; }
.table th.is-sorted .sort-arrow { opacity: 1; }

/* ── list rows ───────────────────────────────────────────────────────────── */

.list { display: flex; flex-direction: column; }

.list-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  min-width: 0;
  transition: background var(--t-fast) var(--ease);
  text-align: left;
  width: 100%;
}
.list-row:last-child { border-bottom: none; }
a.list-row:hover, button.list-row:hover { background: var(--surface-hover); text-decoration: none; }

.list-row-main { flex: 1; min-width: 0; }
.list-row-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: 1px;
}
.list-row-amount {
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: none;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  flex: none;
  background: var(--tint-soft, var(--surface-3));
  color: var(--tint, var(--text-muted));
  font-weight: var(--fw-semi);
  font-size: var(--fs-sm);
}
.avatar svg { width: 18px; height: 18px; }
.avatar-sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
.avatar-sm svg { width: 15px; height: 15px; }

/* ── progress ────────────────────────────────────────────────────────────── */

.progress {
  height: 7px;
  border-radius: var(--r-sm);
  background: var(--chart-track);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--r-sm);
  background: var(--tint, var(--accent));
  transition: width var(--t-slow) var(--ease);
}
.progress.is-over .progress-bar { background: var(--danger); }
.progress-lg { height: 10px; }

.progress-stack { display: flex; height: 8px; border-radius: var(--r-sm); overflow: hidden; background: var(--chart-track); }
.progress-stack span { height: 100%; }

/* ── modal & sheet ───────────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: var(--s-4);
  animation: fade var(--t-base) var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: min(560px, 100%);
  max-height: min(86vh, 780px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise var(--t-base) var(--ease);
}
.modal-lg { width: min(820px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.985); } }

.modal-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
  flex: none;
}
.modal-title { font-size: var(--fs-md); font-weight: var(--fw-semi); letter-spacing: -0.015em; }
.modal-head .spacer { flex: 1; }

.modal-body {
  min-height: 0;
  padding: var(--s-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  flex: 1;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  flex: none;
}
.modal-foot .spacer { flex: 1; }
.modal-foot > .row { flex-wrap: wrap; }

/* On a phone a centred dialog fights the keyboard; slide up from the bottom. */
@media (max-width: 640px) {
  .scrim { place-items: end center; padding: 0; }
  .modal {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: none;
    padding-bottom: var(--safe-bottom);
    animation: slide-up var(--t-base) var(--ease);
  }
  @keyframes slide-up { from { transform: translateY(100%); } }

  /* A grab handle, so it reads as a sheet you can dismiss. */
  .modal-head::before {
    content: "";
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    border-radius: var(--r-sm);
    background: var(--border-strong);
  }
  .modal-head { position: relative; padding-top: var(--s-5); }
}

/* ── toasts ──────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  z-index: 200;
  bottom: var(--s-5);
  right: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
  max-width: min(400px, calc(100vw - var(--s-8)));
}

@media (max-width: 899px) {
  .toasts {
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-3));
    left: var(--s-3);
    right: var(--s-3);
    max-width: none;
  }
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: toast-in var(--t-base) var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast.is-leaving { animation: toast-out var(--t-base) var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

.toast-ok     { border-left-color: var(--ok); }
.toast-error  { border-left-color: var(--danger); }
.toast-warn   { border-left-color: var(--warn); }

.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast-ok svg    { color: var(--ok); }
.toast-error svg { color: var(--danger); }
.toast-warn svg  { color: var(--warn); }
.toast-body { flex: 1; min-width: 0; line-height: var(--lh-snug); }
.toast-title { font-weight: var(--fw-semi); }
.toast-text { color: var(--text-muted); overflow-wrap: anywhere; }

/* ── empty & loading ─────────────────────────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-3);
  padding: var(--s-10) var(--s-5);
  color: var(--text-muted);
}
.empty-icon {
  width: 46px; height: 46px;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-subtle);
}
.empty-icon svg { width: 22px; height: 22px; }
.empty-title { font-size: var(--fs-base); font-weight: var(--fw-semi); color: var(--text); }
.empty-text { font-size: var(--fs-sm); max-width: 42ch; line-height: var(--lh-snug); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-hover) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.skeleton-line { height: 12px; margin-bottom: var(--s-2); }
.skeleton-card { height: 120px; border-radius: var(--r-lg); }

.spinner {
  width: 17px; height: 17px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--r-full);
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-lg { width: 26px; height: 26px; border-width: 2.5px; }

.loading-page {
  display: grid;
  place-items: center;
  padding: var(--s-16);
  color: var(--text-subtle);
  gap: var(--s-3);
}

/* ── callout ─────────────────────────────────────────────────────────────── */

.callout {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--info-border);
  background: var(--info-soft);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}
.callout svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--info); }
.callout-warn   { background: var(--warn-soft);   border-color: var(--warn-border); }
.callout-warn svg { color: var(--warn); }
.callout-danger { background: var(--danger-soft); border-color: var(--danger-border); }
.callout-danger svg { color: var(--danger); }
.callout-ok     { background: var(--ok-soft);     border-color: var(--ok-border); }
.callout-ok svg { color: var(--ok); }
.callout-title { font-weight: var(--fw-semi); display: block; margin-bottom: 2px; }

/* ── tabs ────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button.is-active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
  font-weight: var(--fw-semi);
}

/* ── menu ────────────────────────────────────────────────────────────────── */

.menu {
  position: absolute;
  z-index: 120;
  min-width: 190px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: var(--s-1);
  animation: rise var(--t-fast) var(--ease);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text);
  text-align: left;
  transition: background var(--t-fast) var(--ease);
}
.menu-item:hover { background: var(--surface-hover); text-decoration: none; }
.menu-item svg { width: 16px; height: 16px; color: var(--text-subtle); flex: none; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger svg { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border-subtle); margin: var(--s-1) 0; }

/* ── filter bar ──────────────────────────────────────────────────────────── */

.filters {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-4);
}
.filters .input, .filters .select { height: 34px; min-height: 34px; }
.filters .input-search { flex: 1 1 200px; min-width: 160px; }
.filters .spacer { flex: 1; }

/* ── pagination ──────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}


/* ── a grid of cards that are all the same height ────────────────────────── */

/*
 * `.grid` is `align-items: start` on purpose — a dashboard of unrelated panels
 * looks wrong when a short one is stretched to match a tall neighbour. But a
 * row of *peers*, like the fun tools, wants the opposite: ragged card bottoms
 * read as a skyline rather than as a set.
 *
 * So this is opt-in per grid, and it does the whole job from the container:
 * stretch the row, make each card fill it, and let the body absorb the slack so
 * anything below it lands on the same line across the row.
 */
.grid-even { align-items: stretch; }
.grid-even > * { height: 100%; }
.grid-even > .card { display: flex; flex-direction: column; }
.grid-even > .card > .card-body { flex: 1 1 auto; }
.grid-even > .card > .card-foot { margin-top: auto; }

/* ── a date heading inside a flush list ──────────────────────────────────── */

/*
 * Used where a list is grouped by day — the home screen's "Coming up", the
 * calendar agenda. Sticky, so the day you are looking at stays named while you
 * scroll past a busy one.
 */
.day-label {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4) var(--s-2);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.day-label:first-child { border-top: none; }

/* A plain divider inside a dialog or a card. */
.rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s-4) 0 0;
}
