:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --bg: #f8fafc;
  --white: #fff;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --success: #16a34a;
  --success-bg: #dcfce7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { text-decoration: none; color: inherit; }

/* -------------------------------------------------------------
   TOPBAR & NAVIGATION
   ------------------------------------------------------------- */
.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, calc((100% - 1380px) / 2));
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0f172a;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}
.top-tagline {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-link {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  transition: color 0.15s;
}
.nav-link:hover { color: var(--blue); }
.nav-user {
  font-size: 12px;
  color: #64748b;
  margin-right: 4px;
}
.nav-btn-secondary {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  transition: all 0.15s;
}
.nav-btn-secondary:hover { background: #f1f5f9; color: #0f172a; }

/* -------------------------------------------------------------
   CONTAINER & COMMON
   ------------------------------------------------------------- */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 30px 20px 48px;
}
.container.wide-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.button.secondary:hover { background: #f1f5f9; }
.button.small { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.button.large { padding: 13px 22px; font-size: 15px; }
.button.full-width { width: 100%; }

.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 1.2px; color: var(--blue); margin-bottom: 6px; }
.hero { text-align: center; padding: 50px 10px 45px; }
.hero h1 { font-size: clamp(32px, 5vw, 50px); line-height: 1.12; letter-spacing: -2px; margin: 0; }
.hero h1 span { color: var(--blue); }
.hero-copy { color: var(--muted); font-size: 16px; max-width: 580px; margin: 16px auto 24px; }
.trust-row { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 20px; }
.trust-row span { background: #fff; border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 30px; }
.feature { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.feature-icon { width: 38px; height: 38px; border-radius: 10px; background: #eff6ff; display: grid; place-items: center; font-size: 18px; margin-bottom: 12px; }
.feature h3 { margin: 0 0 6px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.footer { text-align: center; color: #94a3b8; font-size: 12px; padding: 20px; border-top: 1px solid var(--line); background: #fff; }
.alert { background: #fef2f2; border: 1px solid #fee2e2; color: #b91c1c; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* -------------------------------------------------------------
   MS WORD-STYLE TEMPLATE GALLERY RIBBON
   ------------------------------------------------------------- */
.template-gallery-panel {
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.template-gallery-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 6px;
  background: #fff;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.gallery-card:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
}
.gallery-card.active {
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Mini invoice sheet representation */
.mini-sheet {
  width: 100%;
  aspect-ratio: 1 / 1.15;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.mini-sheet-header { height: 16%; }
.mini-sheet-body { padding: 4px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.mini-line { height: 3px; background: #e2e8f0; border-radius: 2px; }
.w-30 { width: 30%; } .w-40 { width: 40%; } .w-50 { width: 50%; } .w-60 { width: 60%; }
.mini-table { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.mini-row { height: 3px; background: #f1f5f9; border-radius: 1px; }
.mini-row.head { height: 4px; }
.mini-total { height: 5px; width: 45%; margin-left: auto; border-radius: 2px; margin-top: auto; }

/* Palette per mini-sheet */
.modern-blue-sheet .mini-sheet-header { background: #2563eb; }
.modern-blue-sheet .mini-row.head { background: #bfdbfe; }
.modern-blue-sheet .mini-total { background: #2563eb; }

.classic-slate-sheet .mini-sheet-header { background: #0f172a; }
.classic-slate-sheet .mini-table.boxed { border: 1px solid #cbd5e1; padding: 1px; }
.classic-slate-sheet .mini-row.head { background: #0f172a; }
.classic-slate-sheet .mini-total { background: #0f172a; }

.minimal-mono-sheet .mini-sheet-header { background: transparent; border-bottom: 1.5px solid #18181b; }
.minimal-mono-sheet .mini-row.head { background: #18181b; }
.minimal-mono-sheet .mini-total { background: #18181b; }

.emerald-sheet .mini-sheet-header { background: #047857; }
.emerald-sheet .mini-row.head { background: #a7f3d0; }
.emerald-sheet .mini-total { background: #047857; }

.teal-sheet .mini-sheet-header { background: #0d9488; }
.teal-sheet .mini-row.head { background: #99f6e4; }
.teal-sheet .mini-total { background: #0d9488; }

.amber-sheet .mini-sheet-header { background: #d97706; }
.amber-sheet .mini-row.head { background: #fde68a; }
.amber-sheet .mini-total { background: #d97706; }

.navy-sheet .mini-sheet-header { background: #1e3a8a; }
.navy-sheet .mini-table.boxed { border: 1px solid #c7d2fe; }
.navy-sheet .mini-row.head { background: #1e3a8a; }
.navy-sheet .mini-total { background: #1e3a8a; }

.crimson-sheet .mini-sheet-header { background: #b91c1c; }
.crimson-sheet .mini-row.head { background: #fecaca; }
.crimson-sheet .mini-total { background: #b91c1c; }

.gallery-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  text-align: center;
}
.tpl-name {
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}
.tpl-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  background: #f1f5f9;
  color: #64748b;
}
.tpl-badge.popular { background: #dbeafe; color: #1e40af; }
.tpl-badge.green { background: #dcfce7; color: #15803d; }
.tpl-badge.teal { background: #ccfbf1; color: #0f766e; }
.tpl-badge.amber { background: #fef3c7; color: #b45309; }
.tpl-badge.navy { background: #e0e7ff; color: #3730a3; }
.tpl-badge.red { background: #fee2e2; color: #b91c1c; }

/* -------------------------------------------------------------
   BUILDER HEADER & ACTIONS
   ------------------------------------------------------------- */
.builder-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.builder-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin: 0;
  color: #0f172a;
}
.builder-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-memory {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-weight: 600;
  font-size: 12px;
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-memory:hover { background: #dbeafe; }
.lead-pill-link {
  font-size: 11px;
  font-weight: 600;
  color: #4338ca;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 4px 10px;
  border-radius: 999px;
}
.lead-pill-link:hover { background: #e0e7ff; }

/* -------------------------------------------------------------
   BUILDER TWO-COLUMN LAYOUT
   ------------------------------------------------------------- */
.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}
.builder-main {
  display: flex;
  flex-direction: column;
}
.builder-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 10px;
}
.card-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.subtle-note {
  font-size: 11px;
  color: #94a3b8;
}

/* -------------------------------------------------------------
   THE LIVE INVOICE CANVAS (Transforms live with selected template)
   ------------------------------------------------------------- */
.invoice-sheet-container {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  padding: 18px 20px;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.06);
  transition: all 0.25s ease;
  position: relative;
}

.sheet-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--template-primary, #2563eb);
  margin-bottom: 12px;
}
.sheet-doc-type {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--template-primary, #2563eb);
}
.sheet-inv-badge {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}
.sheet-banner-right {
  display: flex;
  gap: 10px;
  align-items: center;
}
.field-inline {
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-inline label { font-size: 11px; font-weight: 700; color: #475569; }
.field-inline select {
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
}

.sheet-dates-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: var(--template-light, #eff6ff);
  border: 1px solid var(--template-border, #bfdbfe);
  border-radius: 6px;
  padding: 7px 12px;
  margin-bottom: 14px;
}
.sheet-date-col { display: flex; flex-direction: column; gap: 2px; }
.sheet-date-col label { font-size: 10px; font-weight: 700; color: #475569; text-transform: uppercase; }
.sheet-date-col input {
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  font-size: 12px;
}

.sheet-parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.party-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.party-box-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--template-primary, #2563eb);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.memory-hint {
  font-size: 10px;
  color: #16a34a;
  text-transform: none;
  font-weight: 600;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
  position: relative;
}
.field label { font-size: 11px; font-weight: 600; color: #475569; }
.field-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.field input, .field select, .field textarea, .item-row input, .item-row select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 5px 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .item-row input:focus {
  outline: none;
  border-color: var(--template-primary, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.field textarea { resize: vertical; min-height: 42px; }
.field-hint { font-size: 10px; color: #94a3b8; margin-top: 2px; }

/* Memory auto-suggest dropdown */
.memory-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  z-index: 100;
  max-height: 180px;
  overflow-y: auto;
  display: none;
}
.memory-dropdown-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.memory-dropdown-item:hover { background: #eff6ff; }

/* -------------------------------------------------------------
   ITEMS TABLE (Live Styled)
   ------------------------------------------------------------- */
.sheet-items-section { margin-top: 12px; }
.sheet-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.items-table-header {
  display: grid;
  grid-template-columns: minmax(160px, 1.8fr) 75px 65px 95px 100px 38px;
  gap: 6px;
  padding: 6px 8px;
  background: var(--template-header-bg, #2563eb);
  color: var(--template-header-text, #fff);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-items: center;
}
.items-table-header .th-amount { text-align: right; padding-right: 4px; }
.items-table-header .th-action { text-align: center; }

#items-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}
.item-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.8fr) 75px 65px 95px 100px 38px;
  gap: 6px;
  padding: 3px 0;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
}
.col-amount {
  text-align: right;
  padding-right: 4px;
  font-weight: 700;
  font-size: 12px;
  color: #0f172a;
}
.col-action { display: flex; justify-content: center; }

.btn-remove-row {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-remove-row:hover {
  background: var(--danger-bg);
  border-color: #fca5a5;
  color: var(--danger);
  transform: scale(1.08);
}
.items-table-actions { margin-top: 6px; }
.btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 5px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}
.btn-add-row:hover { background: #e2e8f0; border-color: #94a3b8; }

/* Amount in words live box */
.sheet-words-box {
  background: var(--template-light, #eff6ff);
  border: 1px solid var(--template-border, #bfdbfe);
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 12px;
  display: flex;
  gap: 6px;
  font-size: 11px;
  align-items: baseline;
}
.words-label { font-weight: 700; color: #475569; }
.words-text { font-weight: 700; color: var(--template-primary, #2563eb); }

.sheet-notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

/* -------------------------------------------------------------
   THE 8 LIVE THEME DEFINITIONS
   ------------------------------------------------------------- */
/* 1. Modern Blue */
.template-theme-modern_blue {
  --template-primary: #2563eb;
  --template-light: #eff6ff;
  --template-border: #bfdbfe;
  --template-header-bg: #2563eb;
  --template-header-text: #fff;
}

/* 2. Classic Slate */
.template-theme-classic_slate {
  --template-primary: #0f172a;
  --template-light: #f1f5f9;
  --template-border: #cbd5e1;
  --template-header-bg: #0f172a;
  --template-header-text: #fff;
  border: 2px solid #0f172a;
}
.template-theme-classic_slate .party-box { border: 1px solid #cbd5e1; }

/* 3. Minimalist Mono */
.template-theme-minimal_mono {
  --template-primary: #18181b;
  --template-light: #fafafa;
  --template-border: #e4e4e7;
  --template-header-bg: transparent;
  --template-header-text: #18181b;
  border: 1px solid #e4e4e7;
  box-shadow: none;
}
.template-theme-minimal_mono .items-table-header {
  border-bottom: 2px solid #18181b;
  border-radius: 0;
  background: transparent;
  color: #18181b;
}

/* 4. Emerald Executive */
.template-theme-emerald_exec {
  --template-primary: #047857;
  --template-light: #ecfdf5;
  --template-border: #a7f3d0;
  --template-header-bg: #047857;
  --template-header-text: #fff;
}

/* 5. Tech Teal */
.template-theme-tech_teal {
  --template-primary: #0d9488;
  --template-light: #f0fdfa;
  --template-border: #99f6e4;
  --template-header-bg: #0d9488;
  --template-header-text: #fff;
  border-left: 6px solid #0d9488;
}

/* 6. Warm Amber */
.template-theme-warm_amber {
  --template-primary: #d97706;
  --template-light: #fffbeb;
  --template-border: #fde68a;
  --template-header-bg: #d97706;
  --template-header-text: #fff;
}

/* 7. Corporate Navy */
.template-theme-corp_navy {
  --template-primary: #1e3a8a;
  --template-light: #eef2ff;
  --template-border: #c7d2fe;
  --template-header-bg: #1e3a8a;
  --template-header-text: #fff;
  border: 2px solid #1e3a8a;
}

/* 8. Crimson Bold */
.template-theme-crimson_bold {
  --template-primary: #b91c1c;
  --template-light: #fef2f2;
  --template-border: #fecaca;
  --template-header-bg: #b91c1c;
  --template-header-text: #fff;
}

/* -------------------------------------------------------------
   RIGHT SIDEBAR: TAX, DISCOUNT & LIVE SUMMARY
   ------------------------------------------------------------- */
.sidebar-card { padding: 10px 12px; }
.gst-input-wrap { position: relative; display: flex; align-items: center; }
.pct-sign { position: absolute; right: 8px; color: #94a3b8; font-size: 11px; font-weight: 600; pointer-events: none; }
.gst-preset-chips { display: flex; gap: 4px; margin-top: 5px; }
.preset-chip {
  flex: 1;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 4px;
  padding: 3px 0;
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}
.preset-chip:hover, .preset-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.summary-card { border-color: #cbd5e1; }
.summary-lines { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.summary-line { display: flex; justify-content: space-between; font-size: 12px; color: #475569; }
.summary-line strong { color: #0f172a; }
.summary-line.grand-total {
  border-top: 1px solid #e2e8f0;
  padding-top: 8px;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}
.summary-line.grand-total strong { color: var(--blue); font-size: 18px; }
.action-buttons { display: flex; flex-direction: column; gap: 6px; }

/* -------------------------------------------------------------
   DETAIL & PREVIEW PAGE
   ------------------------------------------------------------- */
.detail-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.detail-actions { display: flex; gap: 8px; }
.lead-banner {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.lead-banner-icon { font-size: 20px; }
.lead-banner-text { flex: 1; }
.lead-banner-text strong { font-size: 13px; color: #3730a3; display: block; }
.lead-banner-text p { font-size: 11px; color: #4338ca; margin: 2px 0 0; }
.status-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-badge.paid { background: var(--success-bg); color: var(--success); }
.status-badge.unpaid { background: #fef3c7; color: #b45309; }

.invoice-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.invoice-table th {
  text-align: left;
  background: var(--template-header-bg, #2563eb);
  color: var(--template-header-text, #fff);
  padding: 8px;
}
.invoice-table td { padding: 8px; border-bottom: 1px solid var(--line); }

.totals-block { width: min(300px, 100%); margin: 12px 0 0 auto; display: flex; flex-direction: column; gap: 5px; }
.totals-line { display: flex; justify-content: space-between; font-size: 12px; }
.totals-line.grand-total-highlight {
  border-top: 1.5px solid var(--template-primary, #2563eb);
  padding-top: 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--template-primary, #2563eb);
}
.detail-bottom-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}
.toast-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  display: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* -------------------------------------------------------------
   ACCOUNT DASHBOARD & HISTORY
   ------------------------------------------------------------- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.dashboard-actions { display: flex; gap: 8px; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.metric-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.metric-card.success { border-left: 4px solid var(--success); }
.metric-card.warning { border-left: 4px solid #f59e0b; }
.metric-label { font-size: 10px; font-weight: 800; color: #64748b; letter-spacing: 0.5px; }
.metric-value { font-size: 24px; font-weight: 800; color: #0f172a; margin: 4px 0 2px; }
.metric-sub { font-size: 11px; color: #94a3b8; }

.dashboard-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 10px;
}
.status-tabs {
  display: flex;
  gap: 6px;
}
.tab-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  transition: all 0.15s;
}
.tab-pill:hover { background: #f8fafc; border-color: #cbd5e1; }
.tab-pill.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.dashboard-search-form {
  display: flex;
  align-items: center;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 28px 5px 10px;
  font-size: 12px;
  width: 220px;
}
.search-input:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
.clear-search {
  position: absolute;
  right: 76px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: bold;
}
.clear-search:hover { color: #ef4444; }

.dashboard-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dashboard-table th { text-align: left; background: #f8fafc; color: #475569; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.dashboard-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.inv-number-link { color: var(--blue); font-weight: 700; }
.table-client-name { font-weight: 600; color: #0f172a; }
.table-client-email { font-size: 11px; color: #94a3b8; }
.status-badge-btn {
  border: 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.15s;
}
.status-badge-btn.paid { background: var(--success-bg); color: var(--success); }
.status-badge-btn.unpaid { background: #fef3c7; color: #b45309; }
.status-badge-btn:hover { opacity: 0.8; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.action-link { font-size: 12px; color: #475569; font-weight: 600; }
.action-link:hover { color: var(--blue); }
.action-link-primary { font-size: 12px; color: var(--blue); font-weight: 700; }
.action-link-delete {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 2px;
  font-size: 13px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.action-link-delete:hover { opacity: 1; transform: scale(1.1); }

.messages-container {
  max-width: 1400px;
  margin: 10px auto 0;
  padding: 0 20px;
}
.alert.success { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.alert.warning { background: #fef3c7; border-color: #fde68a; color: #b45309; }
.alert.error { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }

.empty-state { text-align: center; padding: 36px 12px; }
.empty-icon { font-size: 32px; margin-bottom: 8px; }
.empty-state h3 { margin: 0 0 4px; font-size: 16px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

/* -------------------------------------------------------------
   AUTH CARD
   ------------------------------------------------------------- */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 12px;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}
.auth-title { font-size: 24px; font-weight: 800; letter-spacing: -0.6px; margin: 4px 0 6px; text-align: center; }
.auth-subtitle { font-size: 13px; color: var(--muted); margin: 0 0 20px; text-align: center; line-height: 1.45; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-footer { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }
.auth-footer a { color: var(--blue); font-weight: 600; }
.text-center { text-align: center; }

/* -------------------------------------------------------------
   PRINT MEDIA RULES
   ------------------------------------------------------------- */
@media print {
  body { background: #fff; }
  .topbar, .footer, .detail-top-bar, .lead-banner, .detail-bottom-nav, #copy-toast { display: none !important; }
  .container.wide-container { padding: 0; max-width: 100%; }
  .invoice-sheet-container { border: 0; box-shadow: none; padding: 0; }
}

/* -------------------------------------------------------------
   RESPONSIVE ADJUSTMENTS
   ------------------------------------------------------------- */
@media (max-width: 1024px) {
  .builder-layout { grid-template-columns: 1fr; }
  .builder-sidebar { position: static; }
  .template-gallery-grid { grid-template-columns: repeat(4, 1fr); }
  .metrics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .template-gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .sheet-parties-grid, .sheet-dates-bar, .sheet-notes-grid, .feature-grid { grid-template-columns: 1fr; }
  .items-table-header, .item-row { grid-template-columns: minmax(120px, 1fr) 50px 50px 70px 75px 30px; gap: 4px; }
  .topbar { padding: 0 14px; }
  .top-tagline { display: none; }
}
