/* ══════════════════════════════════════════════════════════════
   My Invoice Generator — styles.css  v2026-05-28
   Full-page invoice generator with SEO-friendly layout
   ══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: #EFF6FF;
  --green:        #10B981;
  --red:          #EF4444;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted:   #9CA3AF;
  --border:       #E5E7EB;
  --border-focus: #93C5FD;
  --bg-page:      #F3F4F6;
  --bg-white:     #FFFFFF;
  --bg-hover:     #F9FAFB;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:    0 10px 30px rgba(0,0,0,.12);
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    16px;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --transition:   .18s ease;
  --max-width:    900px;
}

/* ── Dark mode variables ────────────────────────────────────── */
html[data-theme="dark"] {
  --accent-light:   #172554;
  --border:         #334155;
  --border-focus:   #60A5FA;
  --bg-page:        #0F172A;
  --bg-white:       #1E293B;
  --bg-hover:       #293548;
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md:      0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:      0 10px 36px rgba(0,0,0,.65);
}

/* Scrollbar in dark mode */
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }

/* Hero */
html[data-theme="dark"] .hero {
  background: linear-gradient(135deg, #0f1f45 0%, #0e2040 50%, #0a1929 100%);
  border-bottom-color: #1e3655;
}

/* Select dropdown arrow — lighter chevron for dark backgrounds */
html[data-theme="dark"] .meta-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394A3B8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

/* Input placeholder colour */
html[data-theme="dark"] ::placeholder { color: var(--text-muted); opacity: 1; }

/* Hardcoded-colour overrides */
html[data-theme="dark"] .total-row--balance  { background: #172554; }
html[data-theme="dark"] .faq-item[open]      { border-color: var(--border); }
html[data-theme="dark"] .add-line-btn        { background: var(--accent-light); border-color: var(--border); }
html[data-theme="dark"] .add-line-btn:hover  { background: var(--bg-hover); border-color: var(--accent); }
html[data-theme="dark"] .delete-line-btn:hover { background: rgba(239,68,68,.15); color: #F87171; }
html[data-theme="dark"] .modal-backdrop      { background: rgba(0,0,0,.65); }
html[data-theme="dark"] .modal-box            { color-scheme: dark; }
html[data-theme="dark"] .setting-input        { color-scheme: dark; }
html[data-theme="dark"] .line-table tbody tr:hover { background: var(--bg-hover); }

/* Footer */
html[data-theme="dark"] .site-footer         { background: #080D1A; }
html[data-theme="dark"] .footer-bottom       { border-top-color: #1e293b; }

/* Theme toggle button — icon visibility */
.icon-sun  { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun  { display: block; }

/* Theme toggle button */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition);
}
.theme-toggle:hover {
  background: var(--border);
  color: var(--text-primary);
  transform: rotate(20deg);
}
.theme-toggle svg { width: 16px; height: 16px; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; }

/* ══════════════════════════════════════════════════════════════
   HEADER / NAV
   ══════════════════════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav-container {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
}

/* Brand */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}
.brand-icon { width: 30px; height: 30px; }
.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text-primary);
}

/* Nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
}
.nav-link {
  padding: 6px 12px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover,
.nav-link.active { background: var(--accent-light); color: var(--accent); }

/* Nav actions */
.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.btn-ghost {
  padding: 7px 14px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-nav-cta {
  padding: 7px 16px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--bg-white);
  background: var(--accent);
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition);
}
.btn-nav-cta:hover { background: var(--accent-hover); transform: translateY(-1px); color: #fff; }

/* Hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 4px;
  margin-left: auto;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* Mobile menu */
.mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}
.mobile-menu.open { display: flex; }
.mobile-link {
  padding: 10px 12px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}
.mobile-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.mobile-link--cta {
  color: var(--accent);
  font-weight: 600;
}
.mobile-divider { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

/* ── Nav Dropdown (Good to Read) ──────────────────────────── */
.nav-dropdown-wrap { position: relative; }
.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px 12px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.nav-dropdown-btn:hover,
.nav-dropdown-btn[aria-expanded="true"] { background: var(--accent-light); color: var(--accent); }
.nav-dropdown-chevron { flex-shrink: 0; transition: transform var(--transition); }
.nav-dropdown-btn[aria-expanded="true"] .nav-dropdown-chevron { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 224px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  z-index: 200;
}
.nav-dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nav-dropdown-item {
  display: block;
  padding: 8px 12px;
  font-size: .875rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-dropdown-item:hover { background: var(--accent-light); color: var(--accent); }

/* Mobile section label & sub-links */
.mobile-section-label {
  display: block;
  padding: 10px 12px 4px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mobile-link--sub { padding-left: 22px; font-size: .85rem; }

/* ══════════════════════════════════════════════════════════════
   HERO
   ══════════════════════════════════════════════════════════════ */
.hero {
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 50%, #E0F2FE 100%);
  border-bottom: 1px solid #BFDBFE;
  padding: 36px 24px 32px;
  text-align: center;
}
.hero-inner { max-width: var(--max-width); margin: 0 auto; }
.hero-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════════
   APP CONTAINER
   ══════════════════════════════════════════════════════════════ */
.app-container {
  max-width: calc(var(--max-width) + 80px);
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* ── Action Bar ────────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 auto 16px;
  max-width: var(--max-width);
  flex-wrap: wrap;
}
.action-bar__left,
.action-bar__right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-action svg { width: 14px; height: 14px; }
.btn-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: #D1D5DB;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--bg-white);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  box-shadow: 0 2px 6px rgba(37,99,235,.35);
}
.btn-download svg { width: 15px; height: 15px; }
.btn-download:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37,99,235,.4);
}
.btn-download:active { transform: translateY(0); }

/* ── Invoice Wrapper ───────────────────────────────────────── */
.invoice-wrapper {
  background: transparent;
  display: flex;
  justify-content: center;
}

/* ══════════════════════════════════════════════════════════════
   INVOICE PAPER
   ══════════════════════════════════════════════════════════════ */
.invoice-paper {
  width: 100%;
  max-width: var(--max-width);
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 44px;
  margin-bottom: 36px;
}

/* ── Shared field styles ─────────────────────────────────── */
.inv-textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: .875rem;
  color: var(--text-primary);
  line-height: 1.5;
  background: transparent;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
.inv-textarea:hover { border-color: var(--border); background: var(--bg-hover); }
.inv-textarea:focus { border-color: var(--border-focus); background: var(--bg-white); box-shadow: 0 0 0 3px rgba(147,197,253,.3); }
.inv-textarea::placeholder { color: var(--text-muted); }

.inv-label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

/* ── Invoice Header row ──────────────────────────────────── */
.inv-header {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

/* Logo + From */
.inv-from-block {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}

/* Logo zone */
.logo-zone {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  align-self: flex-start;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-zone:hover { border-color: var(--accent); background: var(--accent-light); }
.logo-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}
.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: .75rem;
  pointer-events: none;
  width: 100%;
  height: 100%;
  padding: 6px;
}
.logo-placeholder svg { width: 22px; height: 22px; }
.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}
.logo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  font-size: .8rem;
  line-height: 1;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.logo-remove:hover { background: var(--red); }

.from-textarea { min-height: 56px; flex: 1; }

/* Invoice Meta (right column) */
.inv-meta-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.invoice-type-input {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 2px 6px;
  text-align: right;
  width: 220px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  caret-color: var(--accent);
}
.invoice-type-input:hover { border-color: var(--border); background: var(--bg-hover); }
.invoice-type-input:focus { border-color: var(--border-focus); background: var(--bg-white); box-shadow: 0 0 0 3px rgba(147,197,253,.3); }

.inv-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  width: 280px;
}

.meta-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.meta-input {
  padding: 5px 8px;
  font-size: .85rem;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  outline: none;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.meta-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(147,197,253,.3); }
.meta-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; background-size: 16px; padding-right: 24px; }

/* ── Bill To / Ship To ───────────────────────────────────── */
.inv-address-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.address-block { display: flex; flex-direction: column; gap: 4px; }
.address-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .6px;
}

/* ── Line Items ──────────────────────────────────────────── */
.line-items-section { margin-bottom: 28px; }

.line-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: .875rem;
}

/* Column widths via <colgroup> */
.col-item   { width: auto; }
.col-qty    { width: 72px; }
.col-rate   { width: 100px; }
.col-amount { width: 100px; }
.col-del    { width: 40px; }

.line-table thead tr {
  background: var(--bg-page);
  border-bottom: 2px solid var(--border);
}
.line-table th {
  padding: 8px 8px;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.th-num { text-align: right; }

.line-table th:nth-child(2),
.line-table tbody td:nth-child(2) { width: 72px; }

.line-table th:nth-child(3),
.line-table tbody td:nth-child(3) { width: 100px; }

.line-table th:nth-child(4),
.line-table tbody td:nth-child(4) { width: 100px; }

.line-table th:nth-child(5),
.line-table tbody td:nth-child(5) { width: 40px; }

/* Rows */
.line-table tbody tr { border-bottom: 1px solid var(--border); }
.line-table tbody tr:hover { background: var(--bg-hover); }

.line-table tbody td { padding: 8px 8px; vertical-align: middle; overflow: hidden; }
.td-desc { text-align: left; }
.td-qty { text-align: left; }
.td-rate { text-align: right; }
.td-amount { text-align: left; }
.td-del { text-align: center; vertical-align: middle; padding: 5px 4px; }

/* Inputs — inset box-shadow for hover/focus so layout never shifts */
.line-input {
  width: 100%;
  min-width: 0;
  display: block;
  box-sizing: border-box;
  border: 1px solid #D1D5DB;
  border-radius: 3px;
  padding: 5px 8px;
  font-size: .875rem;
  line-height: 1.4;
  background: var(--bg-white);
  color: var(--text-primary);
  text-align: inherit;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.line-input:hover { background: var(--bg-hover); border-color: var(--border); }
.line-input:focus { background: var(--bg-white); border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(147,197,253,.3); outline: none; }

.line-desc-input { resize: none; overflow: hidden; text-align: left; }
.td-qty .line-num-input { text-align: left; }
.td-rate .line-num-input { text-align: right; }
.line-num-input  { font-variant-numeric: tabular-nums; }

.line-rate-input-wrap {
  position: relative;
}

.line-rate-symbol {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: .875rem;
  line-height: 1;
}

.line-rate-input {
  padding-left: 22px;
}

/* Hide number spinners so numeric text aligns with headers */
.line-num-input::-webkit-inner-spin-button,
.line-num-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.line-num-input { -moz-appearance: textfield; appearance: textfield; }

.line-amount {
  display: block;
  font-size: .875rem;
  line-height: 1.4;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 5px 0;
  text-align: left;
}

.delete-line-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  padding: 0;
  margin: auto;
}
.delete-line-btn:hover { background: #FEE2E2; color: var(--red); }

.add-line-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 7px 14px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px dashed #93C5FD;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.add-line-btn svg { width: 13px; height: 13px; }
.add-line-btn:hover { background: #DBEAFE; border-color: var(--accent); }

/* ── Notes / Terms + Totals ──────────────────────────────── */
.inv-footer-row {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.notes-col { display: flex; flex-direction: column; gap: 4px; }

/* Totals */
.totals-col { display: flex; flex-direction: column; gap: 10px; }

.totals-table {
  border-top: 2px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #F3F4F6;
  gap: 8px;
}
.total-row:last-child { border-bottom: none; }

.tl {
  font-size: .875rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tv {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}
.tv--discount { color: var(--green); }
.tv--grand { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.tv--balance { font-size: 1.2rem; font-weight: 800; color: var(--accent); }

.total-row--grand {
  background: var(--accent-light);
  margin: 4px -8px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  border-bottom: none;
}
.total-row--balance {
  background: #EFF6FF;
  margin: 4px -8px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  border-bottom: none;
  border-top: 2px solid var(--border);
}

/* Adjustable rows */
.adj-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 1px 4px;
}
.adj-group input {
  width: 58px;
  border: none;
  background: transparent;
  font-size: .8rem;
  color: var(--text-primary);
  text-align: right;
  outline: none;
  padding: 2px 2px;
}
.adj-group select {
  border: none;
  background: transparent;
  font-size: .75rem;
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
}
.adj-unit, .adj-symbol {
  font-size: .8rem;
  color: var(--text-muted);
}

.unit-toggle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-left: 2px;
  flex-shrink: 0;
}
.unit-toggle {
  padding: 2px 7px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  line-height: 1.6;
}
.unit-toggle.active {
  background: var(--accent);
  color: #fff;
}
.unit-toggle:not(.active):hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

/* Grand total row */
.total-row--grand .tl { font-weight: 700; font-size: 1rem; color: var(--text-primary); }

/* Amount Paid */
.total-row--adjustable .tl { font-size: .85rem; }

/* Balance due */
.total-row--balance .tl { font-weight: 700; font-size: 1rem; color: var(--text-primary); }

/* Toggle discount/shipping */
.adj-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle-adj-btn {
  padding: 5px 11px;
  font-size: .775rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid #BFDBFE;
  border-radius: 99px;
  transition: all var(--transition);
}
.toggle-adj-btn:hover { background: #DBEAFE; border-color: var(--accent); }
.toggle-adj-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Send / Share dropdown ───────────────────────────────────── */
.send-wrap { position: relative; }

.send-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 50;
  min-width: 158px;
  overflow: hidden;
  animation: fadeIn .15s ease;
}
.send-dropdown[hidden] { display: none; }

.send-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
  font-family: var(--font);
}
.send-option:hover { background: var(--bg-hover); }
.send-option svg { width: 18px; height: 18px; flex-shrink: 0; }
.send-option + .send-option { border-top: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════════
   FEATURES SECTION
   ══════════════════════════════════════════════════════════════ */
.features-section, .faq-section {
  max-width: var(--max-width);
  margin: 0 auto 32px;
}

.section-heading {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  text-align: center;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.feature-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 20px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.feature-icon svg { width: 22px; height: 22px; }

.feature-card h3 { font-size: .95rem; font-weight: 600; margin-bottom: 6px; }
.feature-card p { font-size: .85rem; color: var(--text-secondary); line-height: 1.55; }

/* ══════════════════════════════════════════════════════════════
   FAQ SECTION
   ══════════════════════════════════════════════════════════════ */
.faq-grid { display: flex; flex-direction: column; gap: 8px; }

.faq-item {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.faq-item:hover { box-shadow: var(--shadow-sm); }
.faq-item[open] { border-color: #BFDBFE; }

.faq-item summary {
  padding: 16px 20px;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  user-select: none;
  transition: background var(--transition);
}
.faq-item summary:hover { background: var(--bg-hover); }
.faq-item[open] summary { background: var(--accent-light); color: var(--accent); }

.faq-item summary::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-muted);
  flex-shrink: 0;
}
.faq-item[open] summary::after { content: '−'; color: var(--accent); }
.faq-item summary::-webkit-details-marker { display: none; }

.faq-item p {
  padding: 0 20px 16px;
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ══════════════════════════════════════════════════════════════
   INVOICE PREVIEW OVERLAY
   ══════════════════════════════════════════════════════════════ */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(4px);
  animation: fadeIn .18s ease;
}
.preview-overlay[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.preview-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 920px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.preview-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-primary);
}

.preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.preview-close-btn svg { width: 14px; height: 14px; }
.preview-close-btn:hover { background: #FEE2E2; color: var(--red); border-color: #FECACA; }
html[data-theme="dark"] .preview-close-btn:hover { background: rgba(239,68,68,.15); color: #F87171; border-color: rgba(239,68,68,.3); }

.preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 36px 20px;
  background: #CBD5E1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
html[data-theme="dark"] .preview-body { background: #07101E; }

.preview-body .pdfi {
  width: 760px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 6px 32px rgba(0,0,0,.25);
  animation: previewSlideIn .22s ease;
}
@keyframes previewSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 820px) {
  .preview-body { padding: 16px 0; }
  .preview-body .pdfi { width: 100%; min-width: 0; border-radius: 0; }
}

/* ══════════════════════════════════════════════════════════════
   SETTINGS MODAL
   ══════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.modal-box {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1.05rem; font-weight: 700; }

.modal-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-page);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.modal-close-btn svg { width: 16px; height: 16px; }
.modal-close-btn:hover { background: #FEE2E2; color: var(--red); }

.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 16px; }

.setting-row { display: flex; flex-direction: column; gap: 5px; }
.setting-row--toggle { flex-direction: row; align-items: center; justify-content: space-between; }

.setting-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.setting-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-primary);
  background: var(--bg-page);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.setting-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(147,197,253,.3); }

.setting-color-input {
  width: 48px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  cursor: pointer;
  background: none;
}

/* Toggle switch */
.toggle-label { display: inline-flex; align-items: center; cursor: pointer; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 42px;
  height: 24px;
  background: #D1D5DB;
  border-radius: 99px;
  position: relative;
  transition: background var(--transition);
}
.toggle-input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: left var(--transition);
}
.toggle-input:checked + .toggle-track .toggle-thumb { left: 21px; }

.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  padding: 9px 22px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--bg-white);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* ══════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1F2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: .85rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  z-index: 500;
  box-shadow: var(--shadow-md);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════ */
.site-footer {
  background: #111827;
  color: #9CA3AF;
  padding: 48px 0 24px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.footer-main {
  display: flex;
  align-items: flex-start;
  gap: 48px;
  padding-bottom: 28px;
  flex-wrap: wrap;
}

.footer-brand-col { flex: 1; min-width: 220px; }
.footer-brand-col .brand-logo { color: #fff; margin-bottom: 10px; display: inline-flex; }
.footer-brand-col .brand-name { color: #fff; }
.footer-tagline { font-size: .85rem; line-height: 1.6; max-width: 320px; }

.footer-nav {
  display: flex;
  gap: 28px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.footer-nav a {
  font-size: .875rem;
  color: #9CA3AF;
  transition: color var(--transition);
  white-space: nowrap;
}
.footer-nav a:hover { color: #fff; }

.footer-templates { flex-direction: column; gap: 10px; }
.footer-nav-heading {
  font-size: .7rem;
  font-weight: 700;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.footer-templates a { font-size: .85rem; }

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid #374151;
  flex-wrap: wrap;
}
.footer-bottom p { font-size: .8rem; }

.footer-legal-links {
  display: flex;
  gap: 18px;
}
.footer-legal-links a { font-size: .8rem; color: #9CA3AF; }
.footer-legal-links a:hover { color: #fff; }

/* ══════════════════════════════════════════════════════════════
   PDF CAPTURE CLASS  (applied by JS before html2canvas render)
   ══════════════════════════════════════════════════════════════ */

/* Force fixed-width desktop layout so html2canvas always
   captures the invoice as it looks on a wide screen. */
.pdf-capture {
  width: 860px !important;
  max-width: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 36px 40px !important;
}

/* Restore desktop header layout */
.pdf-capture .inv-header {
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start !important;
}
.pdf-capture .inv-from-block {
  max-width: 320px !important;
  min-width: 200px !important;
}
.pdf-capture .inv-meta-block {
  align-items: flex-end !important;
  width: auto !important;
}
.pdf-capture .inv-meta-grid  { width: 280px !important; }
.pdf-capture .invoice-type-input {
  width: 220px !important;
  text-align: right !important;
  font-size: 1.6rem !important;
  font-weight: 600 !important;
}

/* Restore 2-column Bill To / Ship To */
.pdf-capture .inv-address-row {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 20px !important;
}

/* Restore Notes + Totals side-by-side */
.pdf-capture .inv-footer-row {
  display: grid !important;
  grid-template-columns: 1fr 320px !important;
  gap: 24px !important;
}

/* Restore proper table layout (undo card-stacking from mobile CSS) */
.pdf-capture .line-table          { display: table !important; }
.pdf-capture .line-table thead    { display: table-header-group !important; }
.pdf-capture .line-table tbody    { display: table-row-group !important; }
.pdf-capture .line-table tbody tr { display: table-row !important; padding: 0 !important; }
.pdf-capture .line-table tbody td {
  display: table-cell !important;
  padding: 7px 8px !important;
  vertical-align: middle !important;
}
.pdf-capture .line-table tbody td::before { display: none !important; }
.pdf-capture .td-qty,
.pdf-capture .td-rate,
.pdf-capture .td-amount { text-align: right !important; }

/* Hide interactive-only elements */
.pdf-capture .logo-file-input,
.pdf-capture .delete-line-btn,
.pdf-capture .add-line-btn,
.pdf-capture .adj-toggles,
.pdf-capture .logo-remove { display: none !important; }

/* Clean up input / textarea borders */
.pdf-capture .inv-textarea,
.pdf-capture .meta-input,
.pdf-capture .invoice-type-input,
.pdf-capture .line-input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}
.pdf-capture .meta-select { background-image: none !important; }

/* Logo zone */
.pdf-capture .logo-zone {
  border: none !important;
  background: transparent !important;
  width: 45px !important;
  height: 45px !important;
}
.pdf-capture .logo-placeholder { display: none !important; }

/* Adjustment groups */
.pdf-capture .adj-group {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
}
.pdf-capture .adj-group input,
.pdf-capture .adj-group select { border: none !important; background: transparent !important; }
.pdf-capture .unit-toggle-group { display: none !important; }

/* Fix negative side-margins on highlighted rows */
.pdf-capture .total-row--grand,
.pdf-capture .total-row--balance {
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 6px !important;
  padding-right: 6px !important;
}

/* ══════════════════════════════════════════════════════════════
   INTERIOR PAGES — Help & History
   ══════════════════════════════════════════════════════════════ */

/* Page hero (replaces the blue gradient hero on inner pages) */
.page-hero {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 32px 24px 26px;
  text-align: center;
}
.page-hero-inner { max-width: 700px; margin: 0 auto; }
.page-hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.page-hero p { color: var(--text-secondary); font-size: 1.05rem; }

.page-container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ── Help page layout ───────────────────────────────────────── */
.help-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 40px;
  align-items: start;
}

.help-sidebar {
  position: sticky;
  top: 80px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
}
.help-sidebar nav h3 {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 8px;
  padding: 0 6px;
}
.help-sidebar nav ul { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.help-sidebar nav a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: .845rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}
.help-sidebar nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.help-sidebar nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

/* Help content */
.help-content section { margin-bottom: 36px; scroll-margin-top: 80px; }
.help-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent-light);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}
.help-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.help-icon svg { width: 15px; height: 15px; }
.help-content h3 { font-size: .975rem; font-weight: 600; margin: 20px 0 6px; color: var(--text-primary); }
.help-content p { font-size: .9375rem; color: var(--text-secondary); line-height: 1.72; margin-bottom: 10px; }
.help-content ul, .help-content ol {
  margin: 6px 0 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.help-content li { font-size: .9375rem; color: var(--text-secondary); line-height: 1.6; }

.help-tip {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 11px 15px;
  margin: 14px 0;
}
.help-tip p { margin: 0; color: var(--text-primary); font-size: .9rem; }
.help-tip strong { color: var(--accent); }

.help-steps {
  counter-reset: step;
  list-style: none;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.help-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  counter-increment: step;
}
.help-steps li::before {
  content: counter(step);
  min-width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Keyboard shortcuts table */
.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  margin-top: 10px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.shortcuts-table th {
  background: var(--bg-page);
  padding: 9px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.shortcuts-table td {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
}
.shortcuts-table tr:hover td { background: var(--bg-hover); }

/* ── Release Notes page ─────────────────────────────────────── */
.rn-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0 60px;
}
.rn-entry {
  position: relative;
  padding: 0 0 40px 32px;
  border-left: 2px solid var(--border);
}
.rn-entry::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-white);
  box-shadow: 0 0 0 2px var(--accent);
}
.rn-badge {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.rn-version {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
}
.rn-tag {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 3px 10px;
  border-radius: 99px;
}
.rn-tag--launch  { background: #D1FAE5; color: #065F46; }
.rn-tag--feature { background: #DBEAFE; color: #1E40AF; }
.rn-tag--fix     { background: #FEF3C7; color: #92400E; }
html[data-theme="dark"] .rn-tag--launch  { background: #064E3B; color: #6EE7B7; }
html[data-theme="dark"] .rn-tag--feature { background: #1E3A5F; color: #93C5FD; }
html[data-theme="dark"] .rn-tag--fix     { background: #451A03; color: #FCD34D; }
.rn-date {
  font-size: .82rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.rn-entry h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text-primary);
}
p.rn-summary {
  color: var(--text-secondary);
  font-size: .95rem;
  margin: 0 0 4px;
  line-height: 1.65;
}
.rn-section { margin-top: 22px; }
.rn-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-secondary);
  margin: 0 0 10px;
}
.rn-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.rn-list li {
  padding-left: 16px;
  position: relative;
  font-size: .9rem;
  color: var(--text-primary);
  line-height: 1.55;
}
.rn-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-page);
  font-size: .78rem;
  font-family: 'Courier New', monospace;
  color: var(--text-primary);
  box-shadow: 0 1px 0 var(--border);
}

/* ── History page ───────────────────────────────────────────── */
.history-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.history-search-wrap { position: relative; flex: 1; min-width: 200px; }
.history-search-wrap svg {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted); pointer-events: none;
}
.history-search {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: .9rem;
  transition: border-color var(--transition);
}
.history-search:focus { outline: none; border-color: var(--border-focus); }
.history-search::placeholder { color: var(--text-muted); }

.history-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  text-align: center;
}
.stat-value { font-size: 1.55rem; font-weight: 800; color: var(--accent); line-height: 1.1; margin-bottom: 4px; }
.stat-label { font-size: .73rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .055em; font-weight: 600; }

.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px 18px;
  align-items: center;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.history-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-focus); }

.hist-badge {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--accent-light);
  color: var(--accent);
  white-space: nowrap;
}
.hist-info h3 { font-size: .9175rem; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.hist-info p  { font-size: .78rem; color: var(--text-muted); }
.hist-amount  { font-size: .9375rem; font-weight: 700; color: var(--text-primary); text-align: right; white-space: nowrap; }
.hist-actions { display: flex; gap: 7px; }

.hist-btn {
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: .8rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-white);
  color: var(--text-secondary);
}
.hist-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.hist-btn--load { background: var(--accent); border-color: var(--accent); color: #fff; }
.hist-btn--load:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.hist-btn--delete:hover { background: #FEE2E2; color: var(--red); border-color: #FECACA; }
html[data-theme="dark"] .hist-btn--delete:hover { background: rgba(239,68,68,.15); color: #F87171; border-color: rgba(239,68,68,.3); }

.btn-danger {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid #FECACA;
  background: transparent;
  color: var(--red);
  font-size: .85rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger:hover { background: #FEE2E2; }
html[data-theme="dark"] .btn-danger { border-color: rgba(239,68,68,.3); color: #F87171; }
html[data-theme="dark"] .btn-danger:hover { background: rgba(239,68,68,.15); }

.history-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.history-empty svg { width: 52px; height: 52px; opacity: .3; margin: 0 auto 14px; display: block; }
.history-empty h3 { font-size: 1.05rem; color: var(--text-secondary); margin-bottom: 6px; }
.history-empty p  { font-size: .9rem; }
.history-empty a  { color: var(--accent); text-decoration: none; font-weight: 500; }

@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-sidebar { position: static; }
  .history-stats { grid-template-columns: repeat(2, 1fr); }
  .history-card {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }
  .hist-amount { text-align: left; }
  .hist-actions { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .history-stats { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   LEGAL PAGES — Terms, Privacy, Cookies
   ══════════════════════════════════════════════════════════════ */
.legal-content {
  max-width: 760px;
  margin: 0 auto;
}
.legal-updated {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.legal-content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 26px 0 10px;
  color: var(--text-primary);
  scroll-margin-top: 80px;
}
.legal-content h2:first-of-type { margin-top: 0; }
.legal-content p {
  font-size: .9375rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 12px;
}
.legal-content ul, .legal-content ol {
  margin: 6px 0 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.legal-content li {
  font-size: .9375rem;
  color: var(--text-secondary);
  line-height: 1.65;
}
.legal-content a { color: var(--accent); text-decoration: none; }
.legal-content a:hover { text-decoration: underline; }
.legal-highlight {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  margin: 16px 0 20px;
  font-size: .9rem;
  color: var(--text-primary);
  line-height: 1.65;
}
.legal-toc {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 36px;
}
.legal-toc h3 {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.legal-toc ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.legal-toc li { font-size: .875rem; }
.legal-toc a { color: var(--text-secondary); }
.legal-toc a:hover { color: var(--accent); text-decoration: none; }

/* ══════════════════════════════════════════════════════════════
   AD UNITS
   Three slots: top (below hero), mid ×2 (between content sections).
   All slots are hidden while empty so they never create blank gaps.
   ══════════════════════════════════════════════════════════════ */

/* Slot 1 — full-width banner between hero and the tool */
.ad-unit--top {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 24px;
  text-align: center;
  overflow: hidden;
}

/* Slots 2 & 3 — within the app-container, between content sections */
.ad-unit--mid {
  max-width: var(--max-width);
  margin: 0 auto 8px;
  padding: 12px 0;
  text-align: center;
  overflow: hidden;
}

/* Collapse any slot whose <ins> Google marked as unfilled */
.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }

/* Hide the wrapper entirely when it contains no rendered content
   (slot is still commented out / no ins element) */
.ad-unit:empty,
.ad-unit--top:not(:has(ins)),
.ad-unit--mid:not(:has(ins)) { display: none; }

/* Never print ads */
@media print { .ad-unit { display: none !important; } }

/* ══════════════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════════════ */
@media print {
  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body { background: #fff !important; margin: 0 !important; }

  /* ── Hide everything except the invoice paper ── */
  .site-header,
  .hero,
  .action-bar,
  .features-section,
  .faq-section,
  .site-footer,
  .adj-toggles,
  .add-line-btn,
  .logo-remove,
  .logo-file-input,
  .delete-line-btn,
  .th-del,
  .td-del,
  .modal-backdrop,
  .toast { display: none !important; }

  .app-container  { padding: 0 !important; max-width: 100% !important; }
  .invoice-wrapper { display: block !important; }

  .invoice-paper {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 22px 28px !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* ── Force desktop header layout (override ≤900px rule) ── */
  .inv-header {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 24px !important;
    align-items: flex-start !important;
  }
  .inv-from-block {
    max-width: 320px !important;
    min-width: 180px !important;
  }
  .inv-meta-block {
    align-items: flex-end !important;
    width: auto !important;
  }
  .inv-meta-grid  { width: 260px !important; }
  .invoice-type-input {
    width: 210px !important;
    text-align: right !important;
    font-size: 1.4rem !important;
    font-weight: 600 !important;
  }

  /* ── Force 2-column Bill To / Ship To (override ≤900px rule) ── */
  .inv-address-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
  }

  /* ── Force Notes + Totals side-by-side (override ≤900px rule) ── */
  .inv-footer-row {
    display: grid !important;
    grid-template-columns: 1fr 280px !important;
    gap: 20px !important;
    align-items: start !important;
  }

  /* ── Force proper table layout (override ≤480px card-stacking) ── */
  .line-table          { display: table !important; font-size: .8rem !important; }
  .line-table thead    { display: table-header-group !important; }
  .line-table tbody    { display: table-row-group !important; }
  .line-table tbody tr {
    display: table-row !important;
    padding: 0 !important;
    border-bottom: 1px solid #E5E7EB !important;
  }
  .line-table tbody tr:hover { background: transparent !important; }
  .line-table tbody td {
    display: table-cell !important;
    padding: 8px 8px !important;
    text-align: left !important;
  }
  .line-table tbody td::before { display: none !important; }
  .td-desc { text-align: left !important; }
  .td-qty { text-align: left !important; }
  .td-rate { text-align: right !important; }
  .td-amount { text-align: left !important; }

  .line-table th:nth-child(2),
  .line-table tbody td:nth-child(2) { width: 72px !important; }

  .line-table th:nth-child(3),
  .line-table tbody td:nth-child(3) { width: 100px !important; }

  .line-table th:nth-child(4),
  .line-table tbody td:nth-child(4) { width: 100px !important; }

  .line-table th:nth-child(5),
  .line-table tbody td:nth-child(5) { width: 40px !important; }

  /* ── Clean form elements ── */
  .inv-textarea,
  .meta-input,
  .invoice-type-input,
  .line-input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    resize: none !important;
    overflow: visible !important;
    padding: 2px 0 !important;
  }
  .meta-select { background-image: none !important; }

  /* ── Logo ── */
  .logo-zone {
    border: none !important;
    background: transparent !important;
    overflow: visible !important;
    width: 45px !important;
    height: 45px !important;
  }
  .logo-placeholder { display: none !important; }
  .logo-img { display: block !important; }

  /* ── Adjustment groups ── */
  .adj-group {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
  .adj-group input,
  .adj-group select { border: none !important; background: transparent !important; }
  .unit-toggle-group { display: none !important; }

  /* ── Fix negative side-margins on highlighted total rows ── */
  .total-row--grand,
  .total-row--balance {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
  }

  /* ── Page breaks ── */
  .invoice-paper { page-break-inside: avoid; }
  .line-table tbody tr { page-break-inside: avoid; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .invoice-paper { padding: 28px 24px; }

  .inv-header { flex-direction: column; gap: 18px; }
  /* Allow from-block to fill full width in stacked layout */
  .inv-from-block { max-width: 100%; }
  .inv-meta-block { align-items: flex-start; width: 100%; }
  .inv-meta-grid { width: 100%; max-width: 320px; }
  .invoice-type-input { width: 100%; text-align: left; font-size: 1.3rem; font-weight: 600; }

  .inv-address-row { grid-template-columns: 1fr; gap: 14px; }

  .inv-footer-row { grid-template-columns: 1fr; }
  /* Remove width constraint so totals fills the column naturally */
  .totals-col { max-width: 100%; }
}

@media (max-width: 700px) {
  /* Hide nav links but keep nav-actions (theme toggle) visible */
  .nav-links { display: none; }
  .nav-toggle { display: flex; }

  .hero { padding: 24px 16px 20px; }
  .hero-subtitle { padding: 0 8px; }

  .app-container { padding: 16px 12px 48px; }

  /* Push right group to the far right even when action-bar wraps */
  .action-bar { gap: 8px; }
  .action-bar__right { margin-left: auto; }

  /* Theme toggle stays in nav; only add 8px gap before hamburger */
  .nav-toggle { margin-left: 8px; }

  .invoice-paper { padding: 20px 16px; border-radius: var(--radius-md); }

  .line-table { font-size: .8rem; }
  .col-qty { width: 60px; }
  .col-rate, .col-amount { width: 80px; }

  .footer-main { flex-direction: column; align-items: flex-start; gap: 20px; }
  .footer-nav { gap: 20px; }
}

@media (max-width: 480px) {
  .features-grid { grid-template-columns: 1fr; }

  /* ── Action bar: icon-only to prevent overflow on narrow phones ── */
  .action-bar .btn-action {
    padding: 8px 9px;
    gap: 0;
    font-size: 0;   /* hides text; SVGs use fixed px dimensions */
  }
  .action-bar .btn-action svg { width: 16px; height: 16px; }

  /* Primary download button keeps its label */
  .btn-download { padding: 8px 12px; font-size: .8rem; }

  /* ── Preview toolbar: icon-only for secondary action button ── */
  .preview-toolbar .btn-action {
    padding: 8px 9px;
    gap: 0;
    font-size: 0;
  }
  .preview-toolbar .btn-action svg { width: 15px; height: 15px; }

  /* ── Toast: allow wrapping so it never overflows horizontally ── */
  .toast {
    white-space: normal;
    max-width: calc(100vw - 48px);
    text-align: center;
    border-radius: var(--radius-md);
  }

  /* ── Settings modal: scrollable on short viewports (landscape) ── */
  .modal-box {
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal-body { overflow-y: auto; }

  /* ── Line items card stacking ── */
  /* Override table display so grid/block rules apply cleanly */
  .line-table          { display: block; }
  .line-table thead    { display: none; }
  .line-table tbody    { display: block; }

  .line-table tbody tr {
    display: grid;
    grid-template-areas:
      "desc   desc   desc"
      "qty    rate   amount"
      "del    del    del";
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
  }
  .line-table tbody tr:hover { background: transparent; }

  /* Grid area assignment */
  .td-desc   { grid-area: desc; }
  .td-qty    { grid-area: qty; }
  .td-rate   { grid-area: rate; }
  .td-amount { grid-area: amount; }
  .td-del    { grid-area: del; }

  /* Each cell: label on top, input below */
  .line-table tbody td {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    overflow: visible;
    width: auto !important;
    text-align: left;
    vertical-align: unset;
  }
  .line-table tbody td::before {
    content: attr(data-label);
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .td-del::before { display: none; }

  /* Inputs fill their cell */
  .line-table tbody td .line-input {
    width: 100%;
    text-align: left !important;
  }
  .line-table tbody td .line-rate-input-wrap { width: 100%; }
  .line-table tbody td .line-rate-input-wrap .line-input { width: 100%; }

  /* Amount value */
  .td-amount .line-amount {
    padding: 5px 8px;
    font-weight: 600;
    font-size: .875rem;
    border: 1px solid transparent;
    border-radius: 3px;
  }

  /* Remove button: full-width tap target at the bottom */
  .td-del {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    margin-top: 4px;
  }
  .td-del .delete-line-btn {
    width: auto;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    background: #FEE2E2;
    color: var(--red);
    font-size: 0;               /* hide the × glyph */
  }
  .td-del .delete-line-btn::after {
    content: 'Remove';
    font-size: .75rem;
    font-weight: 500;
    font-family: var(--font);
  }
  html[data-theme="dark"] .td-del .delete-line-btn {
    background: rgba(239,68,68,.15);
    color: #F87171;
  }
}

/* ── Contact page ───────────────────────────────────────────── */
.contact-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 3rem;
}
.contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.contact-card-icon {
  width: 56px;
  height: 56px;
  background: rgba(37,99,235,.1);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  color: var(--accent);
}
.contact-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
}
.contact-card > p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 1.25rem;
}
.contact-email-link {
  display: inline-block;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.65rem 1.5rem;
  border: 2px solid var(--accent);
  border-radius: 10px;
  transition: background .15s, color .15s;
  word-break: break-all;
}
.contact-email-link:hover {
  background: var(--accent);
  color: #fff;
}
.contact-response-time {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 1rem 0 0;
}
.contact-tips {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 2.5rem;
}
.contact-tips h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 1rem;
}
.contact-tips ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.contact-tips li {
  padding-left: 1.5rem;
  position: relative;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
}
.contact-tips li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
@media (max-width: 480px) {
  .contact-card { padding: 1.75rem 1.25rem; }
  .contact-tips  { padding: 1.5rem 1.25rem; }
  .contact-email-link { font-size: .9rem; }
}
