/* ================================================================
   Kaison Design System — CSS Custom Properties & Components
   Premium financial tool aesthetic. Dark (default) + Light theme.
   ================================================================ */

/* Hide Alpine.js-controlled elements until Alpine initializes */
[x-cloak] { display: none !important; }

/* --- Design Tokens --- */
:root {
  /* Palette — dark to light */
  --ink: #121214;
  --graphite: #1A1A1E;
  --slate: #242428;
  --iron: #2E2E33;
  --pewter: #4A4A52;
  --stone: #8A8A94;
  --silver: #B8B8C0;
  --warm-white: #EDEDEB;
  --cream: #F5F5F2;

  /* Accent */
  --accent: #C9A84C;
  --accent-hover: #B8972F;
  --accent-muted: rgba(201, 168, 76, 0.12);

  /* Semantic */
  --go: #4A8C5E;
  --go-muted: rgba(74, 140, 94, 0.12);
  --marginal: #C9A84C;
  --marginal-muted: rgba(201, 168, 76, 0.12);
  --no-go: #8C4A4A;
  --no-go-muted: rgba(140, 74, 74, 0.12);
  --info: #4A6E8C;
  --info-muted: rgba(74, 110, 140, 0.12);
  --sage: #6B8F71;
  --sage-muted: rgba(107, 143, 113, 0.12);

  /* Alert — muted amber, between marginal and no-go */
  --alert: #8C6E3A;
  --alert-muted: rgba(140, 110, 58, 0.12);

  /* Aliases (used by form components) */
  --brass: #C9A84C;
  --fail: #8C4A4A;

  /* Typography */
  --font-display: 'Cormorant Garamond', serif;
  --font-body: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --header-height: 48px;
  --sidebar-width: 56px;

  /* Composite */
  --header-bg: #1a1a1e;
  --sidebar-bg: #121214;
  --body-bg: #0D0D0F;

  /* Sidebar drawer — iOS Safari viewport fix */
}

/* Light theme overrides */
[data-theme="light"] {
  --ink: #f5f3ef;
  --graphite: #ffffff;
  --slate: #f0ede8;
  --iron: #e0ddd6;
  --pewter: #b8b5ae;
  --stone: #777774;
  --silver: #555552;
  --warm-white: #333330;
  --cream: #1a1a1e;

  --accent: #9A7B2D;
  --accent-hover: #7D6324;
  --accent-muted: rgba(154, 123, 45, 0.10);

  --go: #1a9e32;
  --go-muted: rgba(26, 158, 50, 0.10);
  --marginal: #9A7B2D;
  --marginal-muted: rgba(154, 123, 45, 0.10);
  --no-go: #d93025;
  --no-go-muted: rgba(217, 48, 37, 0.08);
  --info: #2a6496;
  --info-muted: rgba(42, 100, 150, 0.08);

  --header-bg: #f5f3ef;
  --sidebar-bg: #ffffff;
  --body-bg: #f5f3ef;
}

/* Light theme — override Tailwind utility colors */
[data-theme="light"] .bg-ink { background-color: var(--ink) !important; }
[data-theme="light"] .bg-graphite { background-color: var(--graphite) !important; }
[data-theme="light"] .bg-slate { background-color: var(--slate) !important; }
[data-theme="light"] .bg-iron { background-color: var(--iron) !important; }
[data-theme="light"] .bg-accent { background-color: var(--accent) !important; }
[data-theme="light"] .text-ink { color: var(--ink) !important; }
[data-theme="light"] .text-cream { color: var(--cream) !important; }
[data-theme="light"] .text-silver { color: var(--silver) !important; }
[data-theme="light"] .text-stone { color: var(--stone) !important; }
[data-theme="light"] .text-pewter { color: var(--pewter) !important; }
[data-theme="light"] .text-accent { color: var(--accent) !important; }
[data-theme="light"] .text-go { color: var(--go) !important; }
[data-theme="light"] .text-no-go { color: var(--no-go) !important; }
[data-theme="light"] .text-info { color: var(--info) !important; }
[data-theme="light"] .text-marginal { color: var(--marginal) !important; }
[data-theme="light"] .border-iron { border-color: var(--iron) !important; }
[data-theme="light"] .border-accent { border-color: var(--accent) !important; }
[data-theme="light"] .border-slate { border-color: var(--slate) !important; }
[data-theme="light"] .hover\:text-silver:hover { color: var(--silver) !important; }
[data-theme="light"] .hover\:text-cream:hover { color: var(--cream) !important; }
[data-theme="light"] .hover\:text-no-go:hover { color: var(--no-go) !important; }
[data-theme="light"] .hover\:bg-slate:hover { background-color: var(--slate) !important; }
/* Opacity variant overrides — Tailwind CDN bakes in hardcoded hex values */
[data-theme="light"] .bg-slate\/30 { background-color: rgba(240, 237, 232, 0.3) !important; }
[data-theme="light"] .bg-slate\/20 { background-color: rgba(240, 237, 232, 0.2) !important; }
[data-theme="light"] .hover\:bg-slate\/20:hover { background-color: rgba(240, 237, 232, 0.2) !important; }
[data-theme="light"] .hover\:bg-slate\/30:hover { background-color: rgba(240, 237, 232, 0.3) !important; }
[data-theme="light"] .bg-ink\/70 { background-color: rgba(245, 243, 239, 0.7) !important; }
[data-theme="light"] .bg-ink\/80 { background-color: rgba(245, 243, 239, 0.8) !important; }
[data-theme="light"] .border-iron\/50 { border-color: rgba(224, 221, 214, 0.5) !important; }
[data-theme="light"] .border-iron\/30 { border-color: rgba(224, 221, 214, 0.3) !important; }
[data-theme="light"] .bg-no-go\/5 { background-color: rgba(217, 48, 37, 0.05) !important; }
[data-theme="light"] .bg-no-go\/10 { background-color: rgba(217, 48, 37, 0.1) !important; }
[data-theme="light"] .border-no-go\/20 { border-color: rgba(217, 48, 37, 0.2) !important; }
[data-theme="light"] .border-no-go\/40 { border-color: rgba(217, 48, 37, 0.4) !important; }
[data-theme="light"] .border-no-go { border-color: var(--no-go) !important; }
[data-theme="light"] .focus\:border-accent:focus { border-color: var(--accent) !important; }
[data-theme="light"] .hover\:bg-accent-hover:hover { background-color: var(--accent-hover) !important; }
[data-theme="light"] .hover\:text-accent:hover { color: var(--accent) !important; }
[data-theme="light"] .hover\:text-accent-hover:hover { color: var(--accent-hover) !important; }
[data-theme="light"] .text-warm-white { color: var(--warm-white) !important; }

/* Light theme — structural overrides */
[data-theme="light"] .card {
  background-color: var(--graphite) !important;
  border-color: var(--iron) !important;
}
[data-theme="light"] .bg-graphite { background-color: var(--graphite) !important; }
[data-theme="light"] .border-transparent { border-color: transparent !important; }
[data-theme="light"] .input,
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background-color: var(--ink) !important;
  border-color: var(--iron) !important;
  color: var(--cream) !important;
}

/* Mobile sidebar backdrop */
#sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 19;  /* one below sidebar z-20 */
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms ease;
}
#sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

@media (max-width: 767px) {
  .sidebar-drawer {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
}
:root {

  /* Spacing */
  --radius-sm: 2px;
  --radius-md: 4px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
}

/* --- Global Input Resets --- */
input, textarea, select {
  background-color: var(--slate) !important;
  color: var(--cream) !important;
  border: 1px solid var(--iron) !important;
  border-radius: 2px;
  font-family: 'Outfit', sans-serif;
  caret-color: var(--cream);
}
input::placeholder, textarea::placeholder {
  color: var(--pewter);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.1);
  outline: none;
}

/* Browser autofill override — Chrome, Safari, Edge */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--slate) inset !important;
  -webkit-text-fill-color: var(--cream) !important;
  caret-color: var(--cream) !important;
  border: 1px solid var(--iron) !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Firefox autofill */
input:-moz-autofill {
  background-color: var(--slate) !important;
  color: var(--cream) !important;
}

/* Checkbox and radio — don't override dimensions */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

/* Select dropdown options */
select option {
  background-color: var(--slate);
  color: var(--cream);
}

/* Disabled state */
input:disabled, textarea:disabled, select:disabled {
  background-color: var(--graphite) !important;
  color: var(--pewter) !important;
  border-color: var(--iron) !important;
  cursor: not-allowed;
  opacity: 0.6;
}

/* --- Base Styles --- */
body {
  background: var(--ink);
  color: var(--silver);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--accent-muted);
  color: var(--cream);
}

/* --- Typography Utilities --- */
.heading-display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.2;
  color: var(--cream);
  letter-spacing: -0.01em;
}

.heading-section {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.3;
  color: var(--cream);
}

.heading-card {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.3;
  color: var(--cream);
}

.body-text {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  color: var(--silver);
}

.label-upper {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stone);
}

.mono-text {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 13px;
}

.financial-number {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 28px;
  line-height: 1;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--silver);
  border-color: var(--iron);
}
.btn-secondary:hover { color: var(--cream); border-color: var(--pewter); }

.btn-destructive {
  background: transparent;
  color: var(--no-go);
  border-color: var(--no-go);
}
.btn-destructive:hover { background: var(--no-go-muted); }

.btn-text {
  background: transparent;
  color: var(--stone);
  border: none;
  padding: 6px 8px;
}
.btn-text:hover { color: var(--accent); }

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
}

/* --- Inputs --- */
/* Hide number input spinners globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--slate);
  border: 1px solid var(--iron);
  border-radius: var(--radius-sm);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color var(--transition-fast);
  outline: none;
}
.input::placeholder { color: var(--pewter); }
.input:focus { border-color: var(--accent); }
.input:disabled { opacity: 0.5; cursor: default; }

.input-currency {
  padding-left: 28px;
  font-variant-numeric: tabular-nums;
}

.input-error { border-color: var(--no-go); }

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

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238A8A94' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Alias for templates using input-field class */
.input-field {
  width: 100%;
  padding: 10px 12px;
  background: var(--slate);
  border: 1px solid var(--iron);
  border-radius: var(--radius-sm);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color var(--transition-fast);
  outline: none;
}
.input-field::placeholder { color: var(--pewter); }
.input-field:focus { border-color: var(--accent); }
.input-field:disabled { opacity: 0.5; cursor: default; }
select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238A8A94' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
textarea.input-field {
  resize: vertical;
  min-height: 80px;
}

/* --- Labels --- */
.field-label {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stone);
  margin-bottom: 6px;
}

.field-error {
  font-size: 12px;
  color: var(--no-go);
  margin-top: 4px;
}

/* --- Cards --- */
.card {
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: var(--radius-md);
}
.card-hover {
  transition: all 0.2s ease;
}
.card-hover:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(201, 168, 76, 0.1);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.badge-go { background: var(--go-muted); color: var(--go); }
.badge-marginal { background: var(--marginal-muted); color: var(--marginal); }
.badge-no-go { background: var(--no-go-muted); color: var(--no-go); }
.badge-info { background: var(--info-muted); color: var(--info); }
.badge-neutral { background: rgba(138, 138, 148, 0.12); color: var(--stone); }

/* Status-specific */
.badge-under_contract, .badge-closing { background: var(--info-muted); color: var(--info); }
.badge-acquired { background: rgba(201, 168, 76, 0.18); color: var(--accent); }
.badge-rehab { background: var(--marginal-muted); color: var(--marginal); }
.badge-stabilizing { background: var(--go-muted); color: var(--go); }
.badge-listed { background: var(--sage-muted); color: var(--sage); }
.badge-refinancing { background: var(--accent-muted); color: var(--accent); }
.badge-closed, .badge-cash_flow, .badge-stabilized, .badge-active { background: var(--go-muted); color: var(--go); }
.badge-exited, .badge-sold { background: rgba(138, 138, 148, 0.12); color: var(--stone); }

/* Role badges */
.badge-owner { background: var(--accent-muted); color: var(--accent); }
.badge-admin { background: var(--info-muted); color: var(--info); }
.badge-member, .badge-viewer { background: rgba(138, 138, 148, 0.12); color: var(--stone); }

/* Subscription / lifecycle */
.badge-trial { background: var(--marginal-muted); color: var(--marginal); }
.badge-canceled, .badge-revoked, .badge-inactive { background: rgba(138, 138, 148, 0.12); color: var(--stone); }
.badge-beta { background: var(--accent-muted); color: var(--accent); }
.badge-upcoming { background: rgba(138, 138, 148, 0.12); color: var(--stone); }
.badge-recommended { background: var(--accent-muted); color: var(--accent); }

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
}

table thead th {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stone);
  background: var(--slate);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--iron);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

table tbody td {
  font-size: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--iron);
  color: var(--silver);
  vertical-align: middle;
}

table tbody tr {
  height: 48px;
  transition: background var(--transition-fast);
}

table tbody tr:hover { background: rgba(36, 36, 40, 0.5); }
table tbody tr:last-child td { border-bottom: none; }

table tfoot td {
  font-size: 14px;
  padding: 12px 16px;
  color: var(--cream);
  font-weight: 500;
  vertical-align: middle;
}

table .text-right { text-align: right; }
table .tabular-nums { font-variant-numeric: tabular-nums; }

/* --- Dense Data Table (_data_table.html) --- */
.dt-wrap { overflow-x: auto; }
.dt-dense tbody tr { height: 36px; }
.dt-dense thead th { padding: 8px 12px; font-size: 10px; }
.dt-dense tbody td { padding: 6px 12px; font-size: 13px; }
.dt-cell { vertical-align: middle; }
.dt-mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: -0.01em; }

/* --- Card List (_card_list.html) --- */
.cl-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: 2px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  text-decoration: none;
  color: inherit;
}
.cl-card:hover {
  border-color: var(--accent);
  background: var(--slate);
}
.cl-card-body { flex: 1; min-width: 0; }
.cl-card-title { color: var(--cream); font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-card-sub { color: var(--stone); font-size: 12px; margin-top: 2px; }
.cl-card-meta { display: flex; gap: 12px; flex-shrink: 0; align-items: center; }
.cl-card-meta-item { font-family: var(--font-mono); font-size: 11px; color: var(--stone); white-space: nowrap; }
.cl-card-meta-item .text-cream { color: var(--cream); }

/* --- Timeline List (_timeline_list.html) --- */
.tl-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-top: 16px;
}
.tl-group-header:first-child { margin-top: 0; }
.tl-group-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); }
.tl-group-total { font-family: var(--font-mono); font-size: 12px; color: var(--cream); font-variant-numeric: tabular-nums; }
.tl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(46, 46, 51, 0.5);
  font-size: 13px;
}
.tl-row:last-child { border-bottom: none; }
.tl-row:hover { background: rgba(36, 36, 40, 0.3); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 2px; }
.tl-date { font-family: var(--font-mono); font-size: 11px; color: var(--stone); min-width: 52px; flex-shrink: 0; }
.tl-desc { flex: 1; color: var(--silver); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-amount { font-family: var(--font-mono); font-size: 12px; color: var(--cream); font-variant-numeric: tabular-nums; text-align: right; min-width: 80px; flex-shrink: 0; }
.tl-receipt { font-size: 10px; min-width: 48px; text-align: center; flex-shrink: 0; }
.tl-receipt-linked { color: var(--go); }
.tl-receipt-missing { color: var(--no-go); }
.tl-receipt-none { color: var(--stone); }

/* --- Inbox List (_inbox_list.html) --- */
.il-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(46, 46, 51, 0.4);
  transition: background var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.il-row:last-child { border-bottom: none; }
.il-row:hover { background: rgba(36, 36, 40, 0.4); }
.il-row-unread { font-weight: 500; }
.il-row-unread .il-subject { color: var(--cream); }
.il-icon { width: 28px; height: 28px; border-radius: 2px; display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; background: var(--slate); border: 1px solid var(--iron); color: var(--stone); }
.il-body { flex: 1; min-width: 0; }
.il-subject { font-size: 13px; color: var(--silver); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.il-detail { font-size: 11px; color: var(--stone); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.il-date { font-family: var(--font-mono); font-size: 10px; color: var(--stone); flex-shrink: 0; white-space: nowrap; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 20, 0.8);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-panel {
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: var(--radius-md);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-panel.modal-sm { max-width: 420px; }
.modal-panel.modal-md { max-width: 560px; }
.modal-panel.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--iron);
}

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--iron);
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  min-width: 280px;
  max-width: 420px;
  border: 1px solid;
}

.toast-success { background: var(--go-muted); color: var(--go); border-color: rgba(74, 140, 94, 0.25); }
.toast-error { background: var(--no-go-muted); color: var(--no-go); border-color: rgba(140, 74, 74, 0.25); }
.toast-info { background: var(--info-muted); color: var(--info); border-color: rgba(74, 110, 140, 0.25); }

/* --- Progress Bar --- */
.progress-track {
  width: 100%;
  height: 4px;
  background: var(--iron);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 300ms ease;
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, var(--slate) 25%, var(--iron) 50%, var(--slate) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state p { color: var(--stone); }
.empty-state .empty-title {
  font-size: 16px;
  color: var(--silver);
  margin-bottom: 8px;
}
.empty-state .empty-desc {
  font-size: 13px;
  margin-bottom: 20px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--iron);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--pewter);
}

/* --- Scroll offset for fixed header --- */
[id] {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

/* --- Utility --- */
.text-accent { color: var(--accent); }
.text-accent:hover { color: var(--accent-hover); }
.text-cream { color: var(--cream); }
.text-stone { color: var(--stone); }
.text-go { color: var(--go); }
.text-marginal { color: var(--marginal); }
.text-no-go { color: var(--no-go); }
.text-high-risk { color: #D4883C; }
.text-info { color: var(--info); }
.bg-graphite { background: var(--graphite); }
.bg-slate { background: var(--slate); }
.border-iron { border-color: var(--iron); }

/* Links */
a.link { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a.link:hover { color: var(--accent-hover); }

/* Tabular nums utility */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* Divider */
.divider { border-top: 1px solid var(--iron); }

/* HTMX loading indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

/* Skeleton pulse for HTMX loading */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}
.skeleton {
  background: linear-gradient(90deg, var(--slate) 0%, var(--graphite) 50%, var(--slate) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 2px;
}
.skeleton-line { height: 14px; margin-bottom: 10px; }
.skeleton-line:last-child { width: 60%; }

/* HTMX swap transition */
.htmx-swapping { opacity: 0.5; transition: opacity 0.15s ease; }
.htmx-settling { opacity: 1; transition: opacity 0.15s ease; }

/* --- Slide Animations (pagination transitions) --- */
@keyframes slideInFromRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideInFromLeft { from { transform: translateX(-40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.slide-in-left { animation: slideInFromLeft 250ms ease-out; }
.slide-in-right { animation: slideInFromRight 250ms ease-out; }

/* --- Pagination --- */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 12px 16px;
  border-top: 1px solid var(--iron);
  font-family: var(--font-body);
  font-size: 13px;
}

.pagination-info {
  position: absolute;
  left: 16px;
  color: var(--stone);
  font-variant-numeric: tabular-nums;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--silver);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.pagination-btn:hover {
  background: var(--slate);
  color: var(--cream);
  border-color: var(--iron);
}

.pagination-btn-active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
  cursor: default;
}

.pagination-btn-disabled {
  color: var(--pewter);
  cursor: default;
  pointer-events: none;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 32px;
  color: var(--pewter);
  font-size: 13px;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--iron);
  background: var(--graphite);
}

/* Search row — always visible */
.filter-search-row {
  width: 100%;
}

.filter-search-wrap {
  position: relative;
  width: 100%;
}

.filter-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--stone);
  pointer-events: none;
}

.filter-search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  background: var(--slate);
  border: 1px solid var(--iron);
  border-radius: var(--radius-sm);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  transition: border-color var(--transition-fast);
}

.filter-search-input:focus {
  border-color: var(--accent);
}

.filter-search-input::placeholder {
  color: var(--pewter);
}

/* Filter toggle button — visible on mobile only */
.filter-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--stone);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

.filter-toggle:hover {
  color: var(--silver);
}

.filter-toggle-icon {
  width: 14px;
  height: 14px;
}

.filter-chevron {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.filter-chevron.rotate-180 {
  transform: rotate(180deg);
}

.filter-count-badge {
  background: var(--accent);
  color: var(--ink);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.4;
}

/* Collapsible filter area — mobile: Alpine controls, desktop: always visible */
@media (min-width: 769px) {
  .filter-collapsible {
    display: block !important;
  }
}

.filter-bar-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.filter-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stone);
}

.filter-input {
  padding: 6px 10px;
  background: var(--slate);
  border: 1px solid var(--iron);
  border-radius: var(--radius-sm);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  transition: border-color var(--transition-fast);
  width: 100%;
}

.filter-input:focus {
  border-color: var(--accent);
}

.filter-input::placeholder {
  color: var(--pewter);
}

select.filter-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238A8A94' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.filter-apply-text {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

.filter-apply-text:hover {
  color: var(--accent-hover);
}

.filter-clear-text {
  color: var(--stone);
  font-family: var(--font-body);
  font-size: 13px;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.filter-clear-text:hover {
  color: var(--silver);
}

/* ===================== Form Field Components ===================== */

.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--silver);
  margin-bottom: 6px;
}
.form-required {
  color: var(--brass);
  margin-left: 2px;
}
.form-input {
  width: 100%;
  background: var(--slate);
  border: 1px solid var(--iron);
  border-radius: 2px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--cream);
  transition: border-color var(--transition-fast);
}
.form-input::placeholder {
  color: var(--stone);
}
.form-input:focus {
  outline: none;
  border-color: var(--brass);
}
.form-input-error {
  border-color: var(--fail);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
}
.form-money-wrap {
  position: relative;
}
.form-money-symbol {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--stone);
  font-family: var(--font-body);
  font-size: 14px;
  pointer-events: none;
}
.form-money-input {
  padding-left: 28px;
}
.form-error {
  margin-top: 4px;
  font-size: 12px;
  color: var(--fail);
  font-family: var(--font-body);
}
.form-help {
  margin-top: 4px;
  font-size: 12px;
  color: var(--stone);
  font-family: var(--font-body);
}
.form-checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.form-checkbox {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--brass);
  cursor: pointer;
}
.form-checkbox-label {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--silver);
  cursor: pointer;
}

/* --- Sortable Table Headers --- */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

th.sortable:hover {
  color: var(--cream);
}

.sort-indicator {
  display: inline-block;
  font-size: 8px;
  margin-left: 4px;
  color: var(--accent);
  vertical-align: middle;
}

.sort-indicator-inactive {
  color: var(--pewter);
  opacity: 0.4;
}

/* --- Filter bar responsive --- */
@media (max-width: 768px) {
  .filter-toggle {
    display: flex;
  }
  .filter-bar-fields {
    grid-template-columns: 1fr 1fr;
  }
  .pagination-controls {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* ================================================================
   Mobile Responsiveness (375px — 768px)
   ================================================================ */

/* --- Responsive Tables → Cards on Mobile --- */
@media (max-width: 768px) {
  .responsive-table thead { display: none; }
  .responsive-table tbody tr {
    display: block;
    margin-bottom: 12px;
    background: var(--graphite);
    border: 1px solid var(--iron);
    border-radius: var(--radius-md);
    padding: 12px;
  }
  .responsive-table tbody td {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border: none;
  }
  .responsive-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--stone);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: 12px;
    flex-shrink: 0;
  }
  .responsive-table tbody tr:hover { background: var(--graphite); }
}

/* --- Table horizontal scroll fallback --- */
@media (max-width: 768px) {
  .table-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* General table overflow protection on mobile */
  .card table, .modal-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Full-Width Buttons on Mobile --- */
@media (max-width: 768px) {
  .btn-mobile-full {
    width: 100%;
    text-align: center;
  }
}

/* --- Modals → Full Screen on Mobile --- */
@media (max-width: 768px) {
  .modal-panel {
    max-width: 100% !important;
    width: 100% !important;
    min-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  .modal-backdrop {
    align-items: stretch;
  }
}

/* --- Touch Targets --- */
@media (max-width: 768px) {
  .btn, .btn-sm {
    min-height: 44px;
  }
  .input, .input-field {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  select.input, select.input-field {
    min-height: 44px;
    font-size: 16px;
  }
}

/* --- Trial Banner Mobile --- */
@media (max-width: 640px) {
  #trial-banner {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    text-align: center;
  }
  #trial-banner a {
    width: 100%;
    text-align: center;
  }
}

/* --- Page Header Mobile --- */
@media (max-width: 640px) {
  .page-header-flex {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
  }
  .page-header-flex .btn {
    width: 100%;
    justify-content: center;
  }
}

/* --- Metric Cards Mobile --- */
@media (max-width: 640px) {
  .metric-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
}

@media (max-width: 400px) {
  .metric-grid {
    grid-template-columns: 1fr !important;
  }
}

/* --- Tabs Horizontal Scroll on Mobile --- */
@media (max-width: 768px) {
  .tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .tab-nav::-webkit-scrollbar { display: none; }
}

/* --- Chat Widget Full Screen on Mobile --- */
@media (max-width: 768px) {
  .chat-panel {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    z-index: 200 !important;
  }
}

/* --- Landing Page Mobile --- */
@media (max-width: 768px) {
  .landing-hero-text {
    font-size: 32px !important;
    line-height: 1.2 !important;
  }
  .landing-features-grid {
    grid-template-columns: 1fr !important;
  }
  .landing-pricing-grid {
    grid-template-columns: 1fr !important;
  }
  .landing-cta-btn {
    width: 100%;
    text-align: center;
  }
}

/* --- Alert Highlight (deep-link row glow) --- */
@keyframes alert-highlight-fade {
  0%   { border-color: var(--accent); background: var(--accent-muted); }
  100% { border-color: transparent; background: transparent; }
}
.alert-highlight {
  border: 1px solid var(--accent);
  background: var(--accent-muted);
  animation: alert-highlight-fade 3s ease-out forwards;
}

/* --- Pipeline Lane Pagination Slide --- */
@keyframes pipelineSlideLeft {
  0%   { transform: translateX(0); opacity: 1; }
  40%  { transform: translateX(-30px); opacity: 0; }
  60%  { transform: translateX(30px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes pipelineSlideRight {
  0%   { transform: translateX(0); opacity: 1; }
  40%  { transform: translateX(30px); opacity: 0; }
  60%  { transform: translateX(-30px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}
.pipeline-slide-left { animation: pipelineSlideLeft 350ms ease-in-out; }
.pipeline-slide-right { animation: pipelineSlideRight 350ms ease-in-out; }

/* --- Utility Animations --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.animate-spin { animation: spin 1s linear infinite; }
.animate-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* --- Pipeline Row (horizontal scroll) --- */
.pipeline-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: #2a2a30 transparent;
}
.pipeline-row::-webkit-scrollbar {
  height: 4px;
}
.pipeline-row::-webkit-scrollbar-track {
  background: transparent;
}
.pipeline-row::-webkit-scrollbar-thumb {
  background: #2a2a30;
  border-radius: 2px;
}
.pipeline-row > .card {
  min-width: 200px;
  flex: 1 0 200px;
}

/* --- Pipeline Lane Content --- */
.pipeline-lane-content {
  background: #121214;
  border-radius: 0 0 2px 2px;
}

/* --- Pipeline Cards (legacy aliases) --- */
.pipeline-card-empty {
  border: 1px dashed #2a2a30;
  border-radius: 2px;
  padding: 24px 16px;
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: #4A4A52;
}

/* --- Pipeline Board (unified kanban) --- */
.pipeline-board {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: #2a2a30 transparent;
}
.pipeline-board::-webkit-scrollbar { height: 4px; }
.pipeline-board::-webkit-scrollbar-track { background: transparent; }
.pipeline-board::-webkit-scrollbar-thumb { background: #2a2a30; border-radius: 2px; }

.pipeline-columns {
  display: flex;
  gap: 12px;
  min-width: max-content;
  padding: 0 4px;
}
.pipeline-column {
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
}
.pipeline-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1a1a1e;
  border: 1px solid #2E2E33;
  border-radius: 2px;
  margin-bottom: 8px;
}
.pipeline-column-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8A8A94;
}
.pipeline-column-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #4A4A52;
}
.pipeline-column-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pipeline-empty {
  padding: 24px 12px;
  text-align: center;
  border: 1px dashed #2E2E33;
  border-radius: 2px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  color: #4A4A52;
}
.pipeline-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
}
.pipeline-page-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1e;
  border: 1px solid #2E2E33;
  border-radius: 2px;
  color: #8A8A94;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}
.pipeline-page-btn:hover:not(:disabled) {
  color: #f5f0e8;
  border-color: #8A8A94;
}
.pipeline-page-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.pipeline-page-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #4A4A52;
}

/* Pipeline card (board version) */
.pipeline-card {
  display: block;
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: 2px;
  padding: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}
.pipeline-card:hover {
  border-color: var(--accent);
  background: var(--slate);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(201, 168, 76, 0.1);
  text-decoration: none;
  z-index: 10;
  position: relative;
}
.pipeline-card-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 2px;
  display: inline-block;
  margin-bottom: 10px;
  background: transparent;
}
.pipeline-tag-brrrr {
  color: var(--accent);
  border: 1px solid var(--accent);
}
.pipeline-tag-flip {
  color: var(--sage);
  border: 1px solid var(--sage);
}
.pipeline-card-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--cream);
  margin-bottom: 2px;
  line-height: 1.3;
}
.pipeline-card-addr {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  color: var(--pewter);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipeline-card-price {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--cream);
  margin-bottom: 2px;
}
.pipeline-card-metrics {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.pipeline-card-metric-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pewter);
  display: block;
}
.pipeline-card-metric-value {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--cream);
}
.pipeline-card-detail {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  color: var(--stone);
}
.pipeline-card-progress {
  height: 3px;
  background: #2E2E33;
  border-radius: 2px;
  margin-bottom: 4px;
  overflow: hidden;
}
.pipeline-card-progress-bar {
  height: 100%;
  background: #C9A84C;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.pipeline-card-schedule {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #2E2E33;
}
.pipeline-card-schedule.on-track { color: #5BA67C; }
.pipeline-card-schedule.behind { color: #C75050; }
.pipeline-card-schedule.at-risk { color: #D4A843; }

@media (max-width: 1200px) {
  .pipeline-column { width: 180px; min-width: 180px; }
}
@media (max-width: 768px) {
  .pipeline-columns {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .pipeline-column {
    scroll-snap-align: start;
    width: 75vw;
    min-width: 75vw;
  }
}


/* --- Attention Indicator (dot + count next to page header) --- */
.attention-indicator {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--stone);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.attention-indicator:hover {
  color: var(--cream);
}
.attention-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
}
.attention-dot::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0% { opacity: 0.4; transform: scale(0.5); }
  50% { opacity: 0; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(1.2); }
}
.attention-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--stone);
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 20;
}
.attention-indicator:hover .attention-tooltip {
  display: block;
}

/* --- Outline Button (lender deal sheet, etc.) --- */
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #2E2E33;
  background: transparent;
  color: #B8B8C0;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn-outline:hover {
  border-color: #C9A84C;
  color: #F5F5F2;
}

/* --- PDF Download Button --- */
.btn-download-report {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn-download-report:hover {
  background: var(--accent);
  color: var(--ink);
}
.btn-download-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--iron);
  background: transparent;
  color: var(--stone);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}
.btn-download-sm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Cashflow Waterfall --- */
.waterfall-section-header {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding-bottom: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--iron);
}
.waterfall-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}
.waterfall-row-label {
  color: var(--silver);
  display: flex;
  align-items: center;
  gap: 4px;
}
.waterfall-row-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.waterfall-separator {
  border-top: 1px solid var(--iron);
  margin: 6px 0;
}
.waterfall-subtotal {
  font-weight: 500;
}
.waterfall-napkin {
  background: var(--slate);
  border: 1px dashed var(--iron);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 12px;
}
.tooltip-info-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  color: var(--stone);
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}
.tooltip-info-icon:hover {
  color: var(--accent);
}

/* --- Verdict Action Items --- */
.verdict-actions {
  margin-top: 12px;
  padding: 12px 16px;
  border-left: 2px solid #C9A84C;
  background: rgba(201, 168, 76, 0.05);
}
.verdict-action-label {
  color: #C9A84C;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0 0 8px 0;
}
.verdict-action-item {
  color: #8a8a94;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 4px 0;
}
.verdict-action-item:last-child {
  margin-bottom: 0;
}

/* --- LOC Selector --- */
.loc-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loc-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--iron);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.loc-option:hover {
  border-color: var(--pewter);
}

.loc-option--selected {
  border-color: var(--accent);
  background: rgba(201, 168, 76, 0.05);
}

.loc-radio {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--pewter);
  border-radius: 50%;
  flex-shrink: 0;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  position: relative;
}

.loc-radio--checked {
  border-color: var(--accent);
}

.loc-radio--checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.loc-option-name {
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
}

.loc-option-details {
  color: var(--stone);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-left: auto;
}

.loc-using-label {
  color: var(--stone);
  font-family: var(--font-body);
  font-size: 12px;
  margin-bottom: 8px;
}

.input--autofilled {
  border-color: rgba(201, 168, 76, 0.3);
}

.input--is-default {
  border-left: 2px solid rgba(201, 168, 76, 0.3);
}

/* --- Feature Tooltips --- */
.feature-tooltip-wrap {
  position: relative;
  display: inline-block;
}
.feature-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  max-width: 320px;
  background: var(--graphite, #1a1a1e);
  border: 1px solid var(--iron, #2e2e33);
  border-radius: 2px;
  padding: 12px 14px;
  z-index: 200;
  pointer-events: auto;
}
.feature-tooltip--locked {
  border-top: 2px solid var(--accent, #C9A84C);
}
.feature-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 20px;
  border: 6px solid transparent;
  border-top-color: var(--iron, #2e2e33);
}
.feature-tooltip__desc {
  color: var(--silver, #B8B8C0);
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 8px;
}
.feature-tooltip__upgrade {
  color: var(--accent, #C9A84C);
  font-size: 11px;
  font-weight: 600;
  margin: 0 0 6px;
}
.feature-tooltip__link {
  color: var(--accent, #C9A84C);
  font-size: 11px;
  text-decoration: none;
  transition: opacity 0.15s;
}
.feature-tooltip__link:hover {
  opacity: 0.8;
}
.feature-tooltip-wrap:hover .feature-tooltip,
.feature-tooltip-wrap:focus-within .feature-tooltip {
  display: block;
}

/* --- Session Expired Modal --- */
.session-expired-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.session-expired-card {
  background: var(--graphite, #1a1a1e);
  border: 1px solid var(--iron, #2e2e33);
  border-radius: 4px;
  padding: 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.session-expired-card h3 {
  color: var(--cream, #F5F5F2);
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  margin: 0 0 8px;
}
.session-expired-card p {
  color: var(--stone, #8A8A94);
  font-size: 14px;
  margin: 0 0 20px;
}
.session-expired-card a {
  display: inline-block;
  background: var(--accent, #C9A84C);
  color: var(--ink, #121214);
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 2px;
}

/* --- Vendor Pattern / Routine Inbox Cards --- */
.inbox-card--routine {
  background: #1a1a1e;
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 2px;
  padding: 16px 20px;
}
.routine-indicator {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #C9A84C;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.inbox-card__routine-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-family: 'Outfit', sans-serif;
}
.routine-vendor {
  font-size: 14px;
  color: #f5f0e8;
  font-weight: 500;
}
.routine-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: #C9A84C;
}
.routine-routing {
  font-size: 12px;
  color: #8A8A94;
}
.pattern-confidence--high { color: #4A8C5E; }
.pattern-confidence--medium { color: #C9A84C; }
.pattern-confidence--low { color: #8A8A94; }

/* --- Retrospective Variance Dashboard --- */

.retro-timeline {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0;
}
.retro-milestone {
  flex: 1;
  min-width: 100px;
  text-align: center;
  position: relative;
  padding-top: 20px;
}
.retro-milestone::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 2px;
  background: #2E2E33;
}
.retro-milestone:first-child::before { left: 50%; }
.retro-milestone:last-child::before { right: 50%; }

.retro-milestone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2E2E33;
  margin: 0 auto 8px;
  position: relative;
  z-index: 1;
}
.retro-milestone--filled .retro-milestone-dot {
  background: #C9A84C;
}
.retro-milestone-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8A8A94;
  margin-bottom: 2px;
}
.retro-milestone-date {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  color: #EDEDEB;
}
.retro-milestone--pending .retro-milestone-date {
  color: #4A4A52;
}

.retro-variance-table th,
.retro-variance-table td {
  padding: 10px 16px;
}

.variance--under { color: #4A8C5E; }
.variance--over { color: #8C4A4A; }
.variance--close { color: #C9A84C; }
.variance--pending { color: #4A4A52; }

.retro-status-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 2px;
}
.retro-status--draft {
  color: #8A8A94;
  background: rgba(138,138,148,0.1);
  border: 1px solid rgba(138,138,148,0.2);
}
.retro-status--in_progress {
  color: #C9A84C;
  background: rgba(201,168,76,0.1);
  border: 1px solid rgba(201,168,76,0.2);
}
.retro-status--pending_exit {
  color: #4A6E8C;
  background: rgba(74,110,140,0.1);
  border: 1px solid rgba(74,110,140,0.2);
}
.retro-status--completed {
  color: #4A8C5E;
  background: rgba(74,140,94,0.1);
  border: 1px solid rgba(74,140,94,0.2);
}

/* ================================================================
   PWA Components — FAB, Bottom Sheet, Category Chips
   ================================================================ */

/* --- Floating Action Button --- */
.fab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: background var(--transition-fast), transform var(--transition-fast);
  touch-action: manipulation;
}
.fab-btn:hover { background: var(--accent-hover); }
.fab-btn-active { background: var(--accent-hover); }

.fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.fab-item-label {
  padding: 8px 14px;
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: var(--radius-sm);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
}
.fab-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--graphite);
  border: 1px solid var(--iron);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
}
.fab-item:hover .fab-item-icon {
  border-color: var(--accent);
  background: var(--accent-muted);
}

/* --- Bottom Sheet --- */
.bottom-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--graphite);
  border: none;
  border-radius: 0;
  padding: 24px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  overflow-y: auto;
  z-index: 101;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 480px) {
  .bottom-sheet {
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    max-width: 480px;
    max-height: 85vh;
    border: 1px solid var(--iron);
    border-radius: 2px;
    padding-top: 24px;
  }
}

/* --- Category Chips --- */
.category-chip {
  display: inline-block;
  cursor: pointer;
  flex-shrink: 0;
}
.category-chip span {
  display: inline-block;
  padding: 8px 14px;
  background: var(--slate);
  border: 1px solid var(--iron);
  border-radius: var(--radius-sm);
  color: var(--silver);
  font-family: var(--font-body);
  font-size: 13px;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
}
.category-chip input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}
.category-chip:hover span {
  border-color: var(--pewter);
  color: var(--cream);
}

/* --- Offline Indicator Banner --- */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--marginal-muted);
  border-bottom: 1px solid rgba(201, 168, 76, 0.3);
  font-size: 13px;
  color: var(--accent);
  position: sticky;
  top: 0;
  z-index: 51;
}
.offline-banner button {
  background: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  padding: 2px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-body);
}

/* ================================================================
   PWA Mobile Polish — Safe Areas, Touch Targets, Standalone Mode
   ================================================================ */

/* --- Safe Area Insets (notch / home indicator) --- */
@supports (padding: env(safe-area-inset-top)) {
  body {
    /* Don't pad body top — the fixed header handles it via top offset */
    /* Don't pad body bottom — the fixed icon-rail handles safe area via its own height/padding */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .fab-btn {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .bottom-sheet {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* --- Standalone (PWA) mode --- */
.pwa-standalone {
  overscroll-behavior-y: contain;
}

/* --- Touch target minimums on coarse pointers --- */
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-text, .btn-secondary {
    min-height: 44px;
    min-width: 44px;
  }
  .fab-item-icon {
    min-width: 44px;
    min-height: 44px;
  }
  .input, .input-field, select.input, select.input-field {
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  button.badge, a.badge, .icon-rail-item {
    min-height: 44px;
    min-width: 44px;
  }
  button.text-xs, a.text-xs {
    min-height: 44px;
  }
}

/* --- General Mobile Spacing --- */
@media (max-width: 640px) {
  .card { padding: 16px !important; }
  .empty-state { padding: 32px 16px; }
  .retro-timeline { flex-wrap: wrap; }
  .retro-milestone { min-width: 80px; }
}

/* --- Global Modal System --- */
.kaison-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kaison-modal[style*="display: none"] {
  display: none !important;
}
.kaison-modal-content {
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: 2px;
  max-height: 85vh;
  max-width: 600px;
  width: 90%;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ═══════════════════════════════════════════════
   ICON RAIL + SUB-NAV (Cortex XSOAR 8 pattern)
   ═══════════════════════════════════════════════ */

.icon-rail {
  position: fixed;
  left: 0;
  top: var(--header-height);
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--ink);
  border-right: 1px solid var(--iron);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  z-index: 40;
}

.icon-rail-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  text-decoration: none;
}

.kai-mark {
  font-family: 'Noto Serif JP', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  transition: color 0.15s ease;
}

.icon-rail-logo:hover .kai-mark {
  color: var(--cream);
}

.icon-rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.icon-rail-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--stone);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
  padding: 0;
  font-size: 0;
}

.icon-rail-item:hover {
  color: var(--cream);
  background: var(--graphite);
}

.icon-rail-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.icon-rail-item:focus:not(:focus-visible) {
  outline: none;
}

.icon-rail-item.active {
  color: var(--accent);
  background: var(--graphite);
}

.icon-rail-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 1px 1px 0;
}

.icon-rail-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.5;
}

.icon-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--ink);
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.icon-rail-mobile-only {
  display: none;
}

.icon-rail-bottom {
  position: relative;
}

/* --- Sub-nav panel --- */

.subnav-panel {
  position: fixed;
  left: var(--sidebar-width);
  top: var(--header-height);
  bottom: 0;
  width: 200px;
  background: var(--graphite);
  border-right: 1px solid var(--iron);
  padding: 20px 0 0;
  z-index: 39;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}
.subnav-collapse {
  margin-top: auto;
  padding: 10px 20px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--iron);
  color: var(--stone);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
}
.subnav-collapse svg { flex-shrink: 0; }
.subnav-collapse:hover { color: var(--cream); }

.subnav-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--cream);
  padding: 0 20px 16px;
  letter-spacing: 0.02em;
}

.subnav-link {
  display: block;
  padding: 8px 20px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: var(--stone);
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}

.subnav-link:hover {
  color: var(--cream);
  background: var(--slate);
}

.subnav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(201, 168, 76, 0.05);
}

.subnav-divider {
  height: 1px;
  background: var(--iron);
  margin: 8px 20px;
}

.subnav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 38;
}

/* --- Settings popup --- */

.settings-popup {
  position: absolute;
  bottom: 48px;
  left: 56px;
  width: 240px;
  background: var(--graphite);
  border: 1px solid var(--iron);
  border-radius: 2px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  padding: 8px 0;
  z-index: 60;
}

.settings-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}

.settings-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--iron);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.settings-initials {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}

.settings-user-info {
  min-width: 0;
}

.settings-user-name {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--cream);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-user-email {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  color: var(--stone);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-divider {
  height: 1px;
  background: var(--iron);
  margin: 6px 0;
}

.settings-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: var(--stone);
  text-decoration: none;
  transition: all 0.15s ease;
}

.settings-link:hover {
  color: var(--cream);
  background: var(--slate);
}

.settings-link svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
  flex-shrink: 0;
}

.settings-signout {
  color: var(--pewter);
}

.settings-signout:hover {
  color: var(--cream);
}

.settings-version {
  padding: 8px 16px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.settings-version-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pewter);
}

.settings-version-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--stone);
}

/* --- Header Analyze button --- */
.header-analyze-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
  margin-right: 12px;
}

.header-analyze-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.header-analyze-btn:active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

.header-analyze-btn svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 768px) {
  .header-analyze-label {
    display: none;
  }
  .header-analyze-btn {
    padding: 6px;
    margin-right: 8px;
  }
}

/* --- Header settings gear (mobile only) --- */
.header-settings-mobile {
  display: none;
}

/* --- Mobile: icon rail becomes bottom tab bar --- */

@media (max-width: 767px) {
  .icon-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: calc(56px + env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
    border-right: none;
    border-top: 1px solid var(--iron);
    z-index: 50;
  }

  .icon-rail-logo {
    display: none;
  }

  .icon-rail-nav {
    flex-direction: row;
    gap: 0;
    width: 100%;
    justify-content: space-around;
  }

  .icon-rail-item {
    width: 48px;
    height: 56px;
  }

  .icon-rail-item.active::before {
    left: 12px;
    right: 12px;
    top: 0;
    bottom: auto;
    width: auto;
    height: 2px;
    border-radius: 0 0 1px 1px;
  }

  .icon-rail-desktop-only {
    display: none !important;
  }

  .icon-rail-mobile-only {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .subnav-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom));
    top: auto;
    width: 100%;
    max-height: 60vh;
    border-right: none;
    border-top: 1px solid var(--iron);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
  }

  .settings-popup {
    bottom: auto;
    top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 4px);
    left: auto;
    right: 8px;
    width: 260px;
  }

  /* Main content needs bottom margin for tab bar + safe area */
  #main-content {
    margin-left: 0 !important;
    margin-bottom: calc(56px + env(safe-area-inset-bottom));
  }

  /* Header goes full-width on mobile (no icon rail offset) */
  header[style*="left:"] {
    left: 0 !important;
  }

  /* Push report-issue button above mobile tab bar */
  .report-issue-btn {
    bottom: 64px !important;
  }

  /* Show header settings gear on mobile */
  .header-settings-mobile {
    display: flex;
  }

  /* Chat panel: full-screen on mobile, flex layout */
  .kai-chat-mobile-safe {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    padding-top: env(safe-area-inset-top, 0px);
  }
}

/* --- Modal Close Button (44x44 tap target, HIG-compliant) --- */
.modal-close-btn {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--stone);
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
  flex-shrink: 0;
}
.modal-close-btn:hover,
.modal-close-btn:active {
  color: var(--cream);
}

/* --- Mobile Form Best Practices --- */
@media (max-width: 768px) {
  input, select, textarea, button[type="submit"] {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS auto-zoom on focus */
  }
}
