/* Expiryview — Stylesheet
   Brand tokens from assets/brand.md implemented as CSS custom properties

   Fonts: Fraunces (display/headings), Figtree (body), JetBrains Mono (identifiers)
   Palette: Dark (#121314 bg, #1b1d1f surface), Amber (#b45309 primary), Danger (#dc2626)
   Stance: dense/utilitarian — tight vertical rhythm, no decorative whitespace
   Radius: 4px on interactive elements only; 0px on structural panels
   Base spacing unit: 4px
*/

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: Figtree, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--color-bg, #121314);
  color: var(--color-body, #d1d4d8);
  min-height: 100vh;
}

/* ===== CUSTOM PROPERTIES (DARK = default) ===== */
:root {
  --color-bg: #121314;
  --color-surface: #1b1d1f;
  --color-primary: #b45309;
  --color-on-primary: #ffffff;
  --color-on-surface: #e2e4e7;
  --color-body: #d1d4d8;
  --color-muted: #9ca3af;
  --color-border: #2a2c2e;
  --color-danger: #dc2626;
  --color-accent: #f59e0b;

  --font-display: Fraunces, Georgia, serif;
  --font-body: Figtree, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', monospace;

  --space-unit: 4px;
  --radius-interactive: 4px;
  --radius-structural: 0px;
  --page-margin: 16px;
  --content-max-width: 960px;
}

/* ===== LIGHT THEME ===== */
html[data-theme="light"] {
  --color-bg: #f8f6f0;
  --color-surface: #ffffff;
  --color-primary: #b45309;
  --color-on-primary: #ffffff;
  --color-on-surface: #1b1b1b;
  --color-body: #3a3a3a;
  --color-muted: #787878;
  --color-border: #d1d1d1;
  --color-danger: #dc2626;
  --color-accent: #d97706;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, .heading {
  font-family: var(--font-display);
  color: var(--color-on-surface);
  font-weight: 500;
  line-height: 1.2;
}

h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ===== EYEBROW ===== */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-primary);
  margin-bottom: calc(var(--space-unit) * 2);
  display: flex;
  align-items: center;
  gap: calc(var(--space-unit) * 1);
}

/* ===== SECTION NUMBERING ===== */
.section-num {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  position: relative;
}

/* ===== NAVIGATION ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--space-unit) * 2) var(--page-margin);
  height: 48px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: calc(var(--space-unit) * 2);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--color-on-surface);
  font-weight: 500;
}

.header-logo:hover {
  color: var(--color-primary);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: calc(var(--space-unit) * 3);
}

.header-nav a {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  text-decoration: none;
  padding: calc(var(--space-unit) * 1) 0;
}

.header-nav a:hover {
  color: var(--color-on-surface);
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-interactive);
  color: var(--color-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: calc(var(--space-unit) * 1) calc(var(--space-unit) * 2);
  line-height: 1;
  transition: none;
}

.theme-toggle:hover {
  color: var(--color-on-surface);
  border-color: var(--color-muted);
}

/* ===== LAYOUT CONTAINERS ===== */
.page {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: calc(var(--space-unit) * 4);
}

.page-wide {
  max-width: 100%;
  padding: calc(var(--space-unit) * 4);
}

/* ===== MARKETING PAGE ===== */
.hero {
  display: flex;
  flex-direction: row;
  gap: calc(var(--space-unit) * 8);
  padding: calc(var(--space-unit) * 12) calc(var(--space-unit) * 4);
  max-width: var(--content-max-width);
  margin: 0 auto;
  align-items: center;
}

.hero-text {
  flex: 1;
  max-width: 500px;
}

.hero-text h1 {
  font-size: 36px;
  margin-bottom: calc(var(--space-unit) * 4);
  color: var(--color-on-surface);
  line-height: 1.15;
}

.hero-text h1 .highlight {
  color: var(--color-primary);
}

.hero-text p {
  font-size: 16px;
  color: var(--color-body);
  margin-bottom: calc(var(--space-unit) * 3);
  max-width: 440px;
  line-height: 1.6;
}

.hero-visual {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: calc(var(--space-unit) * 3);
  min-height: 240px;
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-unit) * 2);
  position: relative;
  overflow: hidden;
}

.hero-disclosure {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: calc(var(--space-unit) * 2);
  max-width: 440px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* Sample row in hero */
.sample-row {
  display: flex;
  align-items: center;
  gap: calc(var(--space-unit) * 2);
  padding: calc(var(--space-unit) * 1) 0;
  font-size: 13px;
  color: var(--color-on-surface);
  border-bottom: 1px solid var(--color-border);
}

.sample-row:last-child { border-bottom: none; }

.sample-badge {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sample-badge.urgent { background: var(--color-danger); }
.sample-badge.soon { background: var(--color-primary); }
.sample-badge.future { background: var(--color-muted); }

.sample-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-body);
}

.sample-date {
  font-size: 11px;
  color: var(--color-muted);
  font-family: var(--font-mono);
}

.sample-cost {
  font-size: 12px;
  color: var(--color-on-surface);
  font-family: var(--font-mono);
}

/* Marketing sections */
.section {
  padding: calc(var(--space-unit) * 8) calc(var(--space-unit) * 4);
  max-width: 640px;
  margin: 0 auto;
  border-top: 1px solid var(--color-border);
}

.section:first-of-type {
  border-top: none;
}

.section h2 {
  margin-bottom: calc(var(--space-unit) * 3);
  color: var(--color-on-surface);
}

.section h3 {
  margin-bottom: calc(var(--space-unit) * 2);
  color: var(--color-on-surface);
}

.section p {
  margin-bottom: calc(var(--space-unit) * 2);
  color: var(--color-body);
  line-height: 1.6;
  max-width: 560px;
}

.section p:last-child {
  margin-bottom: 0;
}

.section .eyebrow {
  margin-bottom: calc(var(--space-unit) * 2);
}

.section hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: calc(var(--space-unit) * 4) 0;
}

/* ===== DRAWN FIGURE ===== */
.figure-wrap {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-structural);
  padding: calc(var(--space-unit) * 4);
  margin: calc(var(--space-unit) * 6) 0 calc(var(--space-unit) * 2) 0;
  position: relative;
  overflow: hidden;
}

.figure-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.figure-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-muted);
  letter-spacing: 0.05em;
  text-align: center;
  margin-top: calc(var(--space-unit) * 1);
  margin-bottom: 0;
}

/* Figure highlight accent */
.figure-accent { stroke: var(--color-primary); fill: none; }
.figure-muted { stroke: var(--color-border); fill: none; }
.figure-body { stroke: var(--color-body); fill: none; }
.figure-fill-accent { fill: var(--color-primary); }
.figure-fill-surface { fill: var(--color-surface); }
.figure-fill-bg { fill: var(--color-bg); }

/* Animated flow paths — removed per brand motion rules: continuous decorative
   motion on a static illustration is not allowed. */

/* ===== PROOF STRIP ===== */
.proof-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  margin: calc(var(--space-unit) * 6) 0;
}

.proof-cell {
  padding: calc(var(--space-unit) * 4) calc(var(--space-unit) * 3);
  border-right: 1px solid var(--color-border);
}

.proof-cell:last-child {
  border-right: none;
}

.proof-number {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--color-primary);
  display: block;
  margin-bottom: calc(var(--space-unit) * 1);
}

.proof-label {
  font-size: 12px;
  color: var(--color-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .proof-cell {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .proof-cell:last-child { border-bottom: none; }
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--space-unit) * 1);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 4);
  border-radius: var(--radius-interactive);
  border: 1px solid transparent;
  cursor: pointer;
  transition: none;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
}

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

.btn-secondary {
  background: transparent;
  color: var(--color-on-surface);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-muted);
}

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

.btn-danger:hover {
  background: var(--color-danger);
  color: var(--color-on-primary);
}

.btn-sm {
  font-size: 12px;
  padding: calc(var(--space-unit) * 1) calc(var(--space-unit) * 2);
}

/* ===== FORMS (shared) ===== */
.form-group {
  margin-bottom: calc(var(--space-unit) * 3);
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: calc(var(--space-unit) * 1);
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-on-surface);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-interactive);
  padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 2);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

/* Ligatures off where people type */
input, textarea, select { font-variant-ligatures: none; }

.form-row {
  display: flex;
  gap: calc(var(--space-unit) * 3);
}

.form-row .form-group {
  flex: 1;
}

/* ===== DASHBOARD ===== */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--space-unit) * 4) 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: calc(var(--space-unit) * 2);
}

.dashboard-header h1 {
  font-size: 28px;
}

.dashboard-actions {
  display: flex;
  gap: calc(var(--space-unit) * 2);
  align-items: center;
}

/* Urgency bands */
.urgency-band {
  margin-bottom: calc(var(--space-unit) * 2);
}

.urgency-band:last-child {
  margin-bottom: 0;
}

.urgency-band-header {
  display: flex;
  align-items: center;
  gap: calc(var(--space-unit) * 2);
  padding: calc(var(--space-unit) * 2) 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: calc(var(--space-unit) * 2);
}

.urgency-band-header h2 {
  font-size: 16px;
  color: var(--color-on-surface);
}

.urgency-count {
  font-size: 12px;
  color: var(--color-muted);
  font-family: var(--font-mono);
}

/* Urgency band dimming — per brand spec: 60 days slightly dimmer, 90 days dimmest */
#band-60.urgency-band { opacity: 0.85; }
#band-90.urgency-band { opacity: 0.7; }

/* Note icon indicator */
.item-note-icon {
  display: inline-flex;
  align-items: center;
  margin-left: calc(var(--space-unit) * 1);
  color: var(--color-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}
.item-note-icon::before {
  content: "📋";
  font-size: 10px;
  margin-right: 2px;
}

/* Item rows */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.item-row {
  display: flex;
  align-items: center;
  gap: calc(var(--space-unit) * 2);
  padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 2);
  height: 44px;
  border-radius: var(--radius-structural);
  cursor: default;
}

.item-row:hover {
  background: var(--color-border);
}

.item-row.row-past-due {
  color: var(--color-danger);
}

.item-row.row-past-due .item-name {
  color: var(--color-danger);
}

.item-urgency-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-past-due { background: var(--color-danger); }
.dot-30-days { background: var(--color-primary); }
.dot-60-days { background: var(--color-accent); }
.dot-90-days { background: var(--color-muted); }

.item-name {
  flex: 1;
  font-size: 14px;
  color: var(--color-on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-date {
  font-size: 12px;
  color: var(--color-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}

.item-cost {
  font-size: 13px;
  color: var(--color-on-surface);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 64px;
  text-align: right;
}

.item-actions {
  display: flex;
  gap: calc(var(--space-unit) * 1);
  opacity: 0;
  transition: none;
}

.item-row:hover .item-actions {
  opacity: 1;
}

.item-actions .btn-action {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: var(--radius-interactive);
}

.item-actions .btn-action:hover {
  color: var(--color-on-surface);
  background: var(--color-surface);
}

.item-actions .btn-action.btn-delete:hover {
  color: var(--color-danger);
}

/* Total annual cost — double rule per brand spec */
.total-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: calc(var(--space-unit) * 3) 0;
  margin-top: calc(var(--space-unit) * 2);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 -3px 0 0 var(--color-border);
}

.total-label {
  font-size: 14px;
  color: var(--color-muted);
  margin-right: calc(var(--space-unit) * 2);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.total-amount {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--color-on-surface);
}

/* ===== SIDEBAR OVERLAY (Add/Edit) ===== */
.overlay-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: none;
}

.overlay-bg.active { display: block; }

.sidebar-form {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 12px rgba(0,0,0,0.3);
  z-index: 101;
  padding: calc(var(--space-unit) * 4);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 200ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-form { transition: none; }
}

.sidebar-form.open {
  transform: translateX(0);
}

.sidebar-form h2 {
  margin-bottom: calc(var(--space-unit) * 4);
  color: var(--color-on-surface);
  font-size: 20px;
}

.sidebar-form .form-actions {
  display: flex;
  gap: calc(var(--space-unit) * 2);
  margin-top: auto;
  padding-top: calc(var(--space-unit) * 4);
}

/* ===== ALERTS ===== */
.alert {
  padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 3);
  border-radius: var(--radius-interactive);
  font-size: 13px;
  margin-bottom: calc(var(--space-unit) * 2);
}

.alert-error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-info {
  background: var(--color-surface);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: calc(var(--space-unit) * 8) calc(var(--space-unit) * 4);
  color: var(--color-muted);
}

.empty-state p {
  margin-bottom: calc(var(--space-unit) * 3);
  font-size: 14px;
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: calc(var(--space-unit) * 8);
  color: var(--color-muted);
  font-size: 14px;
}

/* ===== LOGIN BUTTON (on dashboard) ===== */
.login-prompt {
  text-align: center;
  padding: calc(var(--space-unit) * 12) calc(var(--space-unit) * 4);
  max-width: 400px;
  margin: 0 auto;
}

.login-prompt h2 {
  margin-bottom: calc(var(--space-unit) * 2);
}

.login-prompt p {
  color: var(--color-muted);
  margin-bottom: calc(var(--space-unit) * 4);
}

/* ===== TERMS / PRIVACY PAGES ===== */
.terms-page,
.privacy-page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--space-unit) * 6) calc(var(--space-unit) * 4);
}

.terms-page h1,
.privacy-page h1 {
  margin-bottom: calc(var(--space-unit) * 6);
  font-size: 28px;
}

.terms-page h2,
.privacy-page h2 {
  margin-top: calc(var(--space-unit) * 6);
  margin-bottom: calc(var(--space-unit) * 2);
  font-size: 20px;
}

.terms-page p,
.privacy-page p {
  color: var(--color-body);
  margin-bottom: calc(var(--space-unit) * 2);
  line-height: 1.6;
}

.terms-page .last-updated,
.privacy-page .last-updated {
  font-size: 12px;
  color: var(--color-muted);
  font-family: var(--font-mono);
  margin-bottom: calc(var(--space-unit) * 4);
}

/* ===== OBJECTION ANSWER ===== */
.objection-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-structural);
  padding: calc(var(--space-unit) * 4);
  margin: calc(var(--space-unit) * 4) 0;
}

.objection-question {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--color-on-surface);
  margin-bottom: calc(var(--space-unit) * 2);
}

.objection-answer {
  color: var(--color-body);
  line-height: 1.6;
}

/* ===== FOOTER ===== */
.site-footer {
  text-align: center;
  padding: calc(var(--space-unit) * 6) calc(var(--space-unit) * 4);
  color: var(--color-muted);
  font-size: 12px;
  border-top: 1px solid var(--color-border);
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: calc(var(--space-unit) * 4);
  margin-bottom: calc(var(--space-unit) * 2);
}

.footer-links a {
  color: var(--color-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-links a:hover {
  color: var(--color-on-surface);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  :root { --page-margin: 8px; }
  .hero { flex-direction: column; padding: calc(var(--space-unit) * 4) calc(var(--space-unit) * 2); gap: calc(var(--space-unit) * 4); }
  .hero-text { max-width: 100%; }
  .hero-text h1 { font-size: 28px; }
  .hero-visual { width: 100%; }
  .dashboard-header { flex-direction: column; align-items: flex-start; gap: calc(var(--space-unit) * 2); }
  .dashboard-actions { width: 100%; flex-wrap: wrap; }
  .sidebar-form { width: 100%; max-width: 100vw; }
  .item-row { height: auto; min-height: 40px; flex-wrap: wrap; gap: 4px; }
  .item-date { min-width: 0; }
  .item-cost { min-width: 0; }
  .item-actions { opacity: 1; }
  .form-row { flex-direction: column; gap: 0; }
  .page { padding: calc(var(--space-unit) * 2); }
  .section { padding: calc(var(--space-unit) * 6) calc(var(--space-unit) * 2); }
  .header-nav a { display: none; }
  .header-nav .btn-sm { display: inline-flex; }
  .figure-wrap { padding: calc(var(--space-unit) * 2); }
}

@media (max-width: 480px) {
  .header-inner { height: 44px; padding: calc(var(--space-unit) * 2); }
  .header-logo span { display: none; }
}