/* ==========================================================================
   App shell — header (mobile), sidebar (mobile drawer + desktop permanent)
   ========================================================================== */

.shell {
  display: grid;
  grid-template-columns: 0 1fr;
  min-height: 100dvh;
  transition: grid-template-columns var(--t-mid) var(--ease);
}

@media (min-width: 900px) {
  .shell { grid-template-columns: var(--sidebar-w) 1fr; }
}

.shell__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
  /* Explicit column 2 placement: sidebar is position:fixed and removed from
     grid flow, so without this main would auto-place into column 1 (behind
     the sidebar). */
  grid-column: 2;
}

.shell__content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-5) var(--s-4) var(--s-8);
  padding-left: max(var(--s-4), var(--safe-left));
  padding-right: max(var(--s-4), var(--safe-right));
  padding-bottom: max(var(--s-8), calc(var(--safe-bottom) + var(--s-5)));
}

@media (min-width: 700px) {
  .shell__content {
    padding-top: var(--s-6);
    padding-left: max(var(--s-6), var(--safe-left));
    padding-right: max(var(--s-6), var(--safe-right));
  }
}

/* ---------- Header (mobile only) ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--s-3) 0;
  gap: var(--s-2);
}

@media (min-width: 900px) {
  .header { display: none; }
}

.header__logo {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  margin-right: auto;
}

.header__logo-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--color-accent), var(--color-pink));
  display: grid;
  place-items: center;
  color: var(--color-text-inverse);
  font-weight: var(--fw-bold);
  font-size: 0.875rem;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(var(--sidebar-w), 86vw);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-drawer);
  transform: translateX(-100%);
  transition: transform var(--t-mid) var(--ease);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.sidebar[data-open="true"] { transform: translateX(0); }

@media (min-width: 900px) {
  .sidebar { transform: translateX(0); width: var(--sidebar-w); }
}

.sidebar__header {
  padding: var(--s-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: calc(var(--header-h) + 1px);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  color: var(--color-text);
}

.sidebar__brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--color-accent), var(--color-pink));
  display: grid;
  place-items: center;
  color: var(--color-text-inverse);
  font-weight: var(--fw-bold);
}

.sidebar__nav {
  flex: 1;
  padding: var(--s-3);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar__group { margin-bottom: var(--s-5); }
.sidebar__group:last-child { margin-bottom: 0; }

.sidebar__group-title {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.6875rem;
  font-weight: var(--fw-semibold);
  color: var(--color-text-faint);
  padding: 0 var(--s-2) var(--s-2);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  min-height: 38px;
  text-decoration: none;
}
.sidebar__link:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  text-decoration: none;
}
.sidebar__link[data-active="true"] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.sidebar__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar__footer {
  padding: var(--s-3);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.sidebar__user {
  flex: 1;
  min-width: 0;
}
.sidebar__user-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__user-email {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--color-surface-2);
  flex-shrink: 0;
  object-fit: cover;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid) var(--ease);
  z-index: calc(var(--z-drawer) - 1);
}
.sidebar-backdrop[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 900px) {
  .sidebar-backdrop { display: none; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  min-height: 38px;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--color-surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-color: transparent;
}
.btn--primary:hover { background: var(--color-accent-strong); }

.btn--pink {
  background: var(--color-pink);
  color: var(--color-text-inverse);
  border-color: transparent;
}
.btn--pink:hover { background: var(--color-pink-strong); }

.btn--ghost {
  background: transparent;
  border-color: transparent;
}
.btn--ghost:hover { background: var(--color-surface-2); }

.btn--danger {
  background: var(--color-danger);
  color: white;
  border-color: transparent;
}
.btn--danger:hover { background: var(--color-danger-strong); }

.btn--icon {
  padding: var(--s-2);
  width: 38px;
  min-height: 38px;
  border-radius: var(--r-md);
}
.btn--icon svg {
  width: 18px;
  height: 18px;
}

.btn--lg {
  padding: var(--s-3) var(--s-5);
  font-size: var(--fs-md);
  min-height: 44px;
}
.btn--sm {
  padding: var(--s-1) var(--s-3);
  font-size: var(--fs-xs);
  min-height: 30px;
}

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

.btn-group {
  display: inline-flex;
  align-items: stretch;
}
.btn-group .btn {
  border-radius: 0;
  border-right-width: 0;
}
.btn-group .btn:first-child {
  border-top-left-radius: var(--r-md);
  border-bottom-left-radius: var(--r-md);
}
.btn-group .btn:last-child {
  border-top-right-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
  border-right-width: 1px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.field { margin-bottom: var(--s-4); }
.field--inline {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.field__label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  margin-bottom: var(--s-2);
}
.field__hint {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: var(--s-1);
}
.field__error {
  font-size: var(--fs-xs);
  color: var(--color-danger);
  margin-top: var(--s-1);
}
.field__warn {
  font-size: var(--fs-xs);
  color: var(--color-warning);
  margin-top: var(--s-1);
}

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-sm);
  color: var(--color-text);
  transition: border-color var(--t-fast), background var(--t-fast);
  min-height: 38px;
  font-family: inherit;
}
.input::placeholder,
.textarea::placeholder { color: var(--color-text-faint); }

.input:focus,
.textarea:focus,
.select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 0;
  border-color: var(--color-accent);
}

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

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

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--s-7);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
    linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 12px) 17px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.input-row {
  display: grid;
  gap: var(--s-3);
}
@media (min-width: 700px) {
  .input-row--2 { grid-template-columns: 1fr 1fr; }
  .input-row--3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ==========================================================================
   Card
   ========================================================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.card--pad-sm { padding: var(--s-4); }
.card--flat {
  background: transparent;
  border: 1px solid var(--color-border);
}
.card__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--s-3);
}

/* ==========================================================================
   Toast — w/ undo action
   ========================================================================== */

.toasts {
  position: fixed;
  bottom: max(var(--s-4), var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: var(--z-toast);
  pointer-events: none;
  max-width: calc(100vw - var(--s-4) * 2);
  width: max-content;
}
.toast {
  background: var(--color-surface-3);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  pointer-events: auto;
  font-size: var(--fs-sm);
  min-width: 280px;
  max-width: 480px;
  animation: toast-in 200ms var(--ease);
}
.toast[data-leaving="true"] {
  animation: toast-out 200ms var(--ease) forwards;
}
.toast__body { flex: 1; }
.toast__title { font-weight: var(--fw-medium); }
.toast__desc {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  margin-top: 2px;
}
.toast__action {
  background: transparent;
  border: none;
  color: var(--color-accent);
  font-weight: var(--fw-medium);
  cursor: pointer;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: inherit;
}
.toast__action:hover { background: var(--color-accent-soft); }
.toast__dismiss {
  color: var(--color-text-muted);
  padding: var(--s-1);
  border-radius: var(--r-sm);
}
.toast__dismiss:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.toast--danger { border-color: var(--color-danger); }
.toast--danger .toast__action { color: var(--color-danger); }
.toast--success { border-color: var(--color-accent); }
.toast--warning { border-color: var(--color-warning); }
.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width 100ms linear;
}
.toast {
  position: relative;
  overflow: hidden;
}

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(20px); opacity: 0; }
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: grid;
  place-items: center;
  z-index: var(--z-modal);
  padding: var(--s-4);
  animation: modal-fade-in 160ms var(--ease);
}
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: min(500px, 100%);
  width: 100%;
  max-height: calc(100dvh - var(--s-6) * 2);
  overflow: auto;
  animation: modal-slide-in 200ms var(--ease);
  display: flex;
  flex-direction: column;
}
.modal--lg { max-width: min(720px, 100%); }
.modal__header {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.modal__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin-right: auto;
}
.modal__close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--s-1);
  border-radius: var(--r-sm);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}
.modal__close:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.modal__body {
  padding: var(--s-5);
  overflow-y: auto;
}
.modal__footer {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-slide-in {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ==========================================================================
   Page heading
   ========================================================================== */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  flex-wrap: wrap;
}
.page-head__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}
.page-head__subtitle {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--s-1);
}
.page-head__actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: stretch;
}
.page-head__actions > .btn:not(.btn--icon) {
  min-width: 140px;
}
.page-head__actions > input[type="search"] {
  min-width: 0;
}
@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head__actions { width: 100%; flex-direction: column; }
  .page-head__actions > input[type="search"],
  .page-head__actions > .btn,
  .page-head__actions > a.btn {
    max-width: none !important;
    width: 100%;
    min-width: 0;
  }
}

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty {
  text-align: center;
  padding: var(--s-8) var(--s-4);
  color: var(--color-text-muted);
}
.empty__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  background: var(--color-surface-2);
  display: grid;
  place-items: center;
  margin: 0 auto var(--s-4);
  color: var(--color-text-faint);
}
.empty__icon svg { width: 28px; height: 28px; }
.empty__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  margin-bottom: var(--s-2);
}
.empty__desc {
  max-width: 360px;
  margin: 0 auto var(--s-5);
}

/* ==========================================================================
   Login page
   ========================================================================== */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s-5);
  position: relative;
  overflow: hidden;
}
.login::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, var(--color-accent-soft), transparent 50%),
    radial-gradient(circle at 80% 80%, var(--color-pink-soft), transparent 50%);
  z-index: 0;
  pointer-events: none;
}
.login__card {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-xl);
  padding: var(--s-7) var(--s-6);
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login__logo {
  width: 64px;
  height: 64px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--color-accent), var(--color-pink));
  margin: 0 auto var(--s-5);
  display: grid;
  place-items: center;
  color: var(--color-text-inverse);
  font-size: 1.875rem;
  font-weight: var(--fw-bold);
}
.login__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--s-2);
}
.login__subtitle {
  color: var(--color-text-muted);
  margin-bottom: var(--s-6);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
}
.login__google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  background: white;
  color: #1f1f1f;
  font-weight: var(--fw-medium);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid #dadce0;
  font-size: var(--fs-md);
  width: 100%;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast);
  min-height: 44px;
  font-family: inherit;
}
.login__google:hover {
  background: #f8f9fa;
  box-shadow: var(--shadow-sm);
}
.login__google svg { width: 18px; height: 18px; }
.login__footnote {
  color: var(--color-text-faint);
  font-size: var(--fs-xs);
  margin-top: var(--s-5);
  line-height: var(--lh-loose);
}

/* ==========================================================================
   Setup screen (shown when Firebase config not configured yet)
   ========================================================================== */

.setup {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s-5);
}
.setup__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  max-width: 620px;
  width: 100%;
}
.setup__kicker {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-pink);
  margin-bottom: var(--s-2);
}
.setup__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--s-3);
}
.setup__desc {
  color: var(--color-text-muted);
  margin-bottom: var(--s-5);
  line-height: var(--lh-loose);
}
.setup__steps {
  margin: 0;
  padding-left: var(--s-5);
}
.setup__steps li {
  margin-bottom: var(--s-3);
  list-style: decimal;
  color: var(--color-text-muted);
  line-height: var(--lh-loose);
}
.setup__steps li::marker {
  color: var(--color-accent);
  font-weight: var(--fw-semibold);
}
.setup__steps strong { color: var(--color-text); font-weight: var(--fw-medium); }
.setup__steps code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-surface-2);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  color: var(--color-text);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--color-surface);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th,
.table td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.table th {
  background: var(--color-surface-2);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--t-fast);
}
.table tbody tr:hover { background: var(--color-surface-2); }
.table td.num,
.table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Badge / chip
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}
.badge--accent { background: var(--color-accent-soft); color: var(--color-accent); }
.badge--pink { background: var(--color-pink-soft); color: var(--color-pink); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--danger { background: var(--color-danger-soft); color: var(--color-danger); }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
}
.tab {
  flex: 1;
  min-width: max-content;
  background: transparent;
  border: none;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  font-family: inherit;
  white-space: nowrap;
}
.tab:hover { color: var(--color-text); }
.tab[aria-selected="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Onboarding card
   ========================================================================== */

.onboarding-card {
  background: linear-gradient(135deg, var(--color-accent-soft), var(--color-pink-soft));
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-5);
}
.onboarding-card__kicker {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-pink);
  margin-bottom: var(--s-2);
}
.onboarding-card__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--s-2);
}
.onboarding-card__desc {
  color: var(--color-text-muted);
  line-height: var(--lh-loose);
  margin-bottom: var(--s-4);
}
.onboarding-card__steps {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.onboarding-card__steps li {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  padding-left: var(--s-5);
  position: relative;
}
.onboarding-card__steps li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  border: 2px solid var(--color-border-strong);
  background: var(--color-surface);
}
.onboarding-card__steps li.done {
  color: var(--color-text);
}
.onboarding-card__steps li.done::before {
  border-color: var(--color-accent);
  background: var(--color-accent);
  box-shadow: inset 0 0 0 3px var(--color-surface);
}

/* ==========================================================================
   Business type radio options
   ========================================================================== */

.biz-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}
@media (min-width: 700px) {
  .biz-options { grid-template-columns: 1fr 1fr; }
}
.biz-option {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.biz-option:hover {
  border-color: var(--color-border-strong);
}
.biz-option.is-active {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}
.biz-option input { accent-color: var(--color-accent); margin-top: 2px; }
.biz-option__name {
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-1);
}
.biz-option__desc {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  line-height: var(--lh-normal);
}

/* ==========================================================================
   Theme picker
   ========================================================================== */

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3);
  max-width: 480px;
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--t-fast);
}
.theme-option.is-active { border-color: var(--color-accent); background: var(--color-accent-soft); }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option__preview {
  width: 64px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--color-border);
}
.theme-option__preview--dark { background: linear-gradient(135deg, #14181d 50%, #2a3038 50%); }
.theme-option__preview--light { background: linear-gradient(135deg, #ffffff 50%, #e7e9ec 50%); }
.theme-option__preview--system { background: linear-gradient(135deg, #ffffff 50%, #14181d 50%); }
.theme-option__name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

/* ==========================================================================
   Signature block
   ========================================================================== */

.signature-block {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--color-surface-2);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--r-md);
}
@media (min-width: 700px) {
  .signature-block { flex-direction: row; align-items: center; justify-content: space-between; }
}
.signature-block__preview {
  max-width: 240px;
  max-height: 80px;
  background: white;
  padding: var(--s-2);
  border-radius: var(--r-sm);
}
.signature-block__placeholder {
  color: var(--color-text-faint);
  font-size: var(--fs-sm);
}
.signature-block__actions {
  display: flex;
  gap: var(--s-2);
}

/* ==========================================================================
   Numbering preview
   ========================================================================== */

.numbering-preview {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--color-surface-2);
  border-radius: var(--r-md);
}
.numbering-preview li {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

/* ==========================================================================
   Rich text editor
   ========================================================================== */

.rich-text {
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--color-surface);
  overflow: hidden;
}
.rich-text__toolbar {
  display: flex;
  gap: 2px;
  padding: var(--s-1);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.rich-text__btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-weight: bold;
  font-size: 0.875rem;
  display: grid;
  place-items: center;
  font-family: inherit;
}
.rich-text__btn:hover {
  background: var(--color-surface-3);
  color: var(--color-text);
}
.rich-text__btn.rt-italic { font-style: italic; font-weight: normal; }
.rich-text__btn.rt-underline { text-decoration: underline; font-weight: normal; }
.rich-text__editor {
  padding: var(--s-3);
  outline: none;
  color: var(--color-text);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
}
.rich-text__editor:focus { outline: none; }
.rich-text__editor[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-faint);
  pointer-events: none;
}
.rich-text__editor p { margin: 0 0 var(--s-2); }
.rich-text__editor p:last-child { margin-bottom: 0; }
/* base.css resets `list-style: none` globally (sidebar nav etc.). Re-enable
   markers inside the rich-text editor so numbered/bulleted lists render. */
.rich-text__editor ol {
  list-style: decimal outside;
  padding-left: var(--s-5);
  margin: 0 0 var(--s-2);
  color: var(--color-text);
}
.rich-text__editor ul {
  list-style: disc outside;
  padding-left: var(--s-5);
  margin: 0 0 var(--s-2);
  color: var(--color-text);
}
.rich-text__editor li {
  margin-bottom: var(--s-1);
  color: var(--color-text);
}
.rich-text__editor li::marker {
  color: var(--color-text);
}

/* ==========================================================================
   Autocomplete
   ========================================================================== */

.autocomplete {
  position: relative;
  width: 100%;
}
.autocomplete__input { width: 100%; }
.autocomplete__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
}
.autocomplete__option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.autocomplete__option:hover,
.autocomplete__option[aria-selected="true"] {
  background: var(--color-surface-2);
}
.autocomplete__hint {
  margin-left: auto;
  color: var(--color-text-faint);
  font-size: var(--fs-xs);
}
.autocomplete__empty {
  padding: var(--s-3);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

/* ==========================================================================
   Material chip input
   ========================================================================== */

.material-chips {
  position: relative;
  width: 100%;
}
.material-chips__box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  min-height: 38px;
  cursor: text;
  transition: border-color var(--t-fast);
}
.material-chips__box:focus-within {
  outline: 2px solid var(--color-accent);
  outline-offset: 0;
  border-color: var(--color-accent);
}
.material-chips__input {
  flex: 1 1 120px;
  min-width: 100px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: var(--fs-sm);
  padding: var(--s-1);
  font-family: inherit;
}
.material-chips__input::placeholder { color: var(--color-text-faint); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--color-surface-3);
  color: var(--color-text);
  padding: 2px 2px 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  border: 1px solid var(--color-border-strong);
  line-height: 1.4;
}
.chip__label { padding-right: 2px; }
.chip__remove {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  width: 18px;
  height: 18px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  font-family: inherit;
  padding: 0;
}
.chip__remove:hover {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.material-chips__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
}

/* ==========================================================================
   Locked navigation (onboarding mode)
   ========================================================================== */

body[data-onboarding="true"] .sidebar__link:not([data-route="/settings"]) {
  opacity: 0.5;
  pointer-events: none;
}

/* ==========================================================================
   List card + rows (used by clients / projects / masters / quotations list)
   ========================================================================== */

.list-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--t-fast);
  min-height: 56px;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--color-surface-2); }

@media (min-width: 700px) {
  .list-row {
    grid-template-columns: 2fr 1.5fr auto;
  }
  .list-row__primary { min-width: 0; }
}

.list-row__primary { min-width: 0; }
.list-row__title {
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.list-row__sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row__meta {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}
.list-row__actions {
  display: flex;
  gap: var(--s-1);
  flex-shrink: 0;
}

@media (max-width: 699px) {
  .list-row__meta { display: none; }
}

/* Masters control bar above tab list */
.masters-bar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-4) 0 var(--s-4);
  flex-wrap: wrap;
}
.masters-bar input { flex: 1 1 200px; }

/* ==========================================================================
   Quotations list + filters
   ========================================================================== */

.quote-filters {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.quote-filters__row {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
@media (min-width: 900px) {
  .quote-filters__row { flex-direction: row; align-items: center; }
  .quote-filters__row input[type="search"] { max-width: 280px; flex: 1 1 200px; }
}

.period-nav {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: 4px;
}
.period-nav__btn {
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--color-text-muted);
  display: grid;
  place-items: center;
  font-family: inherit;
  padding: 0;
}
.period-nav__btn:hover:not(:disabled) {
  background: var(--color-surface-3);
  color: var(--color-text);
}
.period-nav__btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.period-nav__label {
  min-width: 150px;
  text-align: center;
  padding: 0 var(--s-2);
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  color: var(--color-text);
  white-space: nowrap;
}
.period-nav__custom {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-2);
}
.period-nav__custom input[type="date"] {
  min-height: 30px;
  padding: 4px var(--s-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-sm);
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-family: inherit;
  color-scheme: dark light;
  min-width: 0;
}

/* On phones, let period-nav fill the row and shrink internal elements
   instead of overflowing. */
@media (max-width: 899px) {
  .period-nav {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
  .period-nav__label {
    flex: 1;
    min-width: 0;
    text-align: center;
  }
  .period-nav__custom {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }
  .period-nav__custom input[type="date"] {
    flex: 1 1 auto;
    min-width: 0;
  }
}

/* Slightly tighter tab padding on phones so chips fit better when wrapped. */
@media (max-width: 600px) {
  .tab {
    padding: var(--s-2) var(--s-3);
  }
}

.tabs--inline {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0;
}
.tabs--inline .tab {
  flex: 0 0 auto;
}
.tabs--inline .tab[aria-selected="true"] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  box-shadow: none;
}

.quote-row {
  text-decoration: none;
  color: inherit;
}
.quote-row:hover { text-decoration: none; }

/* ==========================================================================
   Quotation form
   ========================================================================== */

.quote-form__breadcrumb {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--s-1);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.quote-form__breadcrumb a { color: var(--color-text-muted); }
.quote-form__breadcrumb a:hover { color: var(--color-text); }

.quote-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.quote-form__row {
  display: grid;
  gap: var(--s-3);
}
.quote-form__row--header {
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .quote-form__row--header {
    grid-template-columns: 1.4fr 1fr 1fr;
    /* `start` so labels + inputs sit at the same baseline regardless of
       hint text below. `end` made the no-hint Date field drop lower. */
    align-items: start;
  }
}
.quote-form__row--parties {
  grid-template-columns: 1fr;
}
@media (min-width: 800px) {
  .quote-form__row--parties { grid-template-columns: 1fr 1fr; }
}

.quote-form__section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.quote-form__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  gap: var(--s-3);
  flex-wrap: wrap;
}
.quote-form__section-head h2 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}
.quote-form__section-meta {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.quote-form__add-row {
  margin-top: var(--s-3);
}

.quote-form__totals {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  align-items: flex-end;
}
.totals__row {
  display: flex;
  gap: var(--s-5);
  font-size: var(--fs-sm);
  align-items: baseline;
}
.totals__row > span:first-child {
  color: var(--color-text-muted);
  min-width: 80px;
  text-align: right;
}
.totals__row > span:last-child {
  min-width: 120px;
  text-align: right;
  font-size: var(--fs-md);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.totals__row--grand {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}
.totals__row--grand > span:last-child {
  font-size: var(--fs-xl);
  color: var(--color-accent);
}

.quote-form__footer {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  flex-wrap: wrap;
  padding-top: var(--s-3);
}

.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

/* ==========================================================================
   Party cards (Client / Project)
   ========================================================================== */

.party-card { padding: var(--s-4); }
.party-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
  gap: var(--s-2);
}
.party-card__head h3 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.party-card__actions { display: flex; gap: var(--s-1); }
.party-card__name {
  font-weight: var(--fw-medium);
  font-size: var(--fs-md);
  color: var(--color-text);
}
.party-card__sub {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.party-card__addr {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--s-2);
  line-height: var(--lh-normal);
}
.party-card__placeholder {
  color: var(--color-text-faint);
  font-size: var(--fs-sm);
  font-style: italic;
}

/* ==========================================================================
   Line item rows
   ========================================================================== */

.line-items {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.line-item {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: var(--s-3);
}
.line-item[data-readonly="true"] { background: var(--color-surface); }

.line-item__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-2);
}
@media (min-width: 900px) {
  .line-item__row {
    grid-template-columns: 3fr 1.2fr 1fr 1fr auto;
    align-items: end;
  }
}

.line-item__row--materials {
  margin-top: var(--s-2);
}

.line-item__cell { display: flex; flex-direction: column; gap: var(--s-1); }
.line-item__cell--actions { align-self: end; }

.line-item__label {
  font-size: 0.6875rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
}
@media (min-width: 900px) {
  .line-item__row:not(:first-child) .line-item__label { display: none; }
}

.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

/* ==========================================================================
   Picker modal list
   ========================================================================== */

.picker-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  max-height: 50vh;
  overflow-y: auto;
}
.picker-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-3);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--color-text);
}
.picker-item:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
}
.picker-item__name {
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
}
.picker-item__sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* ==========================================================================
   Signatory preview block
   ========================================================================== */

.signatory-preview {
  display: flex;
  gap: var(--s-4);
  align-items: center;
}
.signatory-preview img {
  background: white;
  padding: var(--s-2);
  border-radius: var(--r-sm);
}

/* ==========================================================================
   Dashboard KPI cards + charts
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
@media (min-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

.kpi {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
}
.kpi--accent::before { background: var(--color-accent); }
.kpi--pink::before { background: var(--color-pink); }
.kpi--warning::before { background: var(--color-warning); }
.kpi--muted::before { background: var(--color-text-faint); }

.kpi__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--s-2);
}
.kpi__value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  line-height: 1.1;
  margin-bottom: var(--s-1);
}
.kpi__sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
}
@media (min-width: 1000px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
}

.chart-card {
  padding: var(--s-4);
}
.chart-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--s-3);
  flex-wrap: wrap;
  gap: var(--s-2);
}
.chart-card__head h3 {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}
.chart-card canvas {
  width: 100% !important;
  height: 240px !important;
}

/* ==========================================================================
   Install prompt + update banner
   ========================================================================== */

.install-banner {
  background: linear-gradient(135deg, var(--color-accent-soft), var(--color-pink-soft));
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.install-banner__text {
  flex: 1;
  font-size: var(--fs-sm);
}
.install-banner__title {
  font-weight: var(--fw-medium);
  color: var(--color-text);
}
.install-banner__sub {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  margin-top: 2px;
}
