/* =============================================
   templates.useqly.com — Main CSS
   ============================================= */

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

:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --surface: #f9fafb;
  --surface2: #f3f4f6;
  --success: #16a34a;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-w: 1100px;
  --header-h: 60px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ---------- Skip Link ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 0 0 8px 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
}
.skip-link:focus { top: 0; }

/* ---------- Container ---------- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Site Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  position: relative;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  color: var(--fg);
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-text strong { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.site-nav-link:hover { background: var(--surface2); color: var(--fg); text-decoration: none; }

/* Mobile hamburger */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: none; background: none;
  border-radius: 8px;
  cursor: pointer; color: var(--fg);
}
.nav-toggle:hover { background: var(--surface2); }

@media (max-width: 520px) {
  .nav-toggle { display: flex; }
  .site-nav {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
  }
  .site-nav.is-open { display: flex; }
  .site-nav-link { width: 100%; padding: 10px 12px; font-size: 15px; }
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  padding: 64px 20px 56px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 900;
  color: var(--fg);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.hero h1 span { color: var(--accent); }
.hero .lead {
  font-size: clamp(15px, 2.5vw, 19px);
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto 28px;
  line-height: 1.65;
}
.badge-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(37,99,235,.08);
  border: 1px solid rgba(37,99,235,.18);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.hero-cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.outline {
  background: #fff;
  color: var(--accent);
  border-color: var(--border);
}
.btn.outline:hover { border-color: var(--accent); background: #eff6ff; }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn.ghost:hover { background: var(--surface2); color: var(--fg); }
.btn.lg { padding: 13px 28px; font-size: 15px; border-radius: 12px; }

/* Print button */
.btn.print-btn {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn.print-btn:hover { background: #15803d; border-color: #15803d; }

/* ---------- Category Section ---------- */
.section { padding: 56px 20px; }
.section-alt { background: var(--surface); }
.section-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--fg);
  margin-bottom: 6px;
}
.section-sub {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 32px;
}

/* ---------- Template Grid ---------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.template-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  transition: box-shadow .15s, border-color .15s, transform .12s;
  display: flex;
  flex-direction: column;
}
.template-card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,.09);
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--fg);
}
.card-thumb {
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; }
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
}
.card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
  margin-bottom: 14px;
}
.card-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  background: #dcfce7;
  color: #15803d;
}

/* ---------- Category Index Cards ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.cat-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  text-decoration: none;
  color: var(--fg);
  transition: box-shadow .15s, border-color .15s, transform .12s;
}
.cat-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.cat-icon { font-size: 36px; margin-bottom: 10px; }
.cat-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.cat-count { font-size: 13px; color: var(--muted); }

/* ---------- Why Section ---------- */
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}
.why-item { text-align: center; padding: 8px; }
.why-icon { font-size: 32px; margin-bottom: 12px; }
.why-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.why-desc { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ---------- FAQ Accordion ---------- */
.faq-list { max-width: 720px; margin: 0 auto; }
.faq-list details {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}
.faq-list summary {
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after {
  content: '+';
  font-size: 20px;
  font-weight: 400;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform .2s;
}
.faq-list details[open] summary::after { content: '−'; }
.faq-list .faq-body {
  padding: 0 20px 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  padding: 14px 20px;
  max-width: var(--max-w);
  margin: 0 auto;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb-sep { color: var(--border); }

/* ---------- Template Page Layout ---------- */
.tmpl-page { background: var(--surface); min-height: calc(100vh - var(--header-h)); }
.tmpl-toolbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: var(--header-h);
  z-index: 9999;
}
.tmpl-toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tmpl-toolbar-right { display: flex; align-items: center; gap: 8px; }
.tmpl-title-bar {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}
.tmpl-hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface2);
  padding: 4px 10px;
  border-radius: 6px;
}

.tmpl-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
@media (max-width: 900px) {
  .tmpl-layout { grid-template-columns: 1fr; }
  .tmpl-sidebar { order: -1; }
}

/* ---------- Invoice Document ---------- */
.invoice-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  overflow: hidden;
}
.invoice-doc {
  padding: 48px 56px;
  min-height: 900px;
  font-family: 'Georgia', serif;
  color: #1a1a1a;
  font-size: 14px;
  line-height: 1.6;
}
@media (max-width: 600px) {
  .invoice-doc { padding: 28px 20px; }
}

/* Editable fields */
[contenteditable="true"] {
  outline: none;
  border-radius: 3px;
  transition: background .12s;
  cursor: text;
}
[contenteditable="true"]:hover { background: #fef9c3; }
[contenteditable="true"]:focus { background: #fef3c7; outline: 2px solid #f59e0b; outline-offset: 1px; }

/* Invoice header */
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
  gap: 20px;
}
.inv-logo {
  font-size: 26px;
  font-weight: 900;
  font-family: var(--font);
  color: #111;
  min-width: 180px;
}
.inv-meta {
  text-align: right;
}
.inv-meta-title {
  font-size: 32px;
  font-weight: 900;
  font-family: var(--font);
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 12px;
}
.inv-meta-row {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 13px;
  margin-bottom: 4px;
}
.inv-meta-label { color: #6b7280; font-weight: 600; font-family: var(--font); }

/* Bill to / from */
.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 36px;
}
@media (max-width: 520px) {
  .inv-parties { grid-template-columns: 1fr; }
  .inv-header { flex-direction: column; }
  .inv-meta { text-align: left; }
  .inv-meta-row { justify-content: flex-start; }
}
.inv-party-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #9ca3af;
  font-family: var(--font);
  margin-bottom: 6px;
}
.inv-party-name {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  margin-bottom: 4px;
}
.inv-party-info {
  font-size: 13px;
  color: #374151;
  line-height: 1.65;
}

/* Items table */
.inv-table-wrap { margin-bottom: 32px; overflow-x: auto; }
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font);
  font-size: 13px;
}
.inv-table thead tr {
  background: #f3f4f6;
}
.inv-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
}
.inv-table th.right, .inv-table td.right { text-align: right; }
.inv-table tbody tr { border-bottom: 1px solid #f3f4f6; }
.inv-table tbody tr:last-child { border-bottom: none; }
.inv-table td {
  padding: 11px 14px;
  color: #111827;
  vertical-align: top;
}
.inv-table td.desc { min-width: 200px; }
.inv-table td.desc small { display: block; color: #9ca3af; font-size: 12px; margin-top: 2px; }
.inv-table tfoot td {
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 13px;
}
.inv-table tfoot .total-row td {
  font-weight: 800;
  font-size: 15px;
  padding-top: 12px;
  border-top: 2px solid #111827;
}

/* Totals */
.inv-totals {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 36px;
}
.inv-totals-box {
  width: 280px;
  font-family: var(--font);
}
.inv-total-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
}
.inv-total-row:last-child {
  border-bottom: none;
  border-top: 2px solid #111827;
  font-weight: 800;
  font-size: 16px;
  padding-top: 10px;
  margin-top: 4px;
}
.inv-total-label { color: #6b7280; }
.inv-total-val { font-weight: 600; }

/* Notes / bank / thank you */
.inv-notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}
@media (max-width: 520px) { .inv-notes-grid { grid-template-columns: 1fr; } }
.inv-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #9ca3af;
  font-family: var(--font);
  margin-bottom: 8px;
}
.inv-notes-body {
  font-size: 13px;
  color: #374151;
  line-height: 1.65;
}
.inv-thankyou {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid #f3f4f6;
  font-size: 13px;
  color: #9ca3af;
  font-style: italic;
  font-family: var(--font);
}

/* ---------- Sidebar ---------- */
.tmpl-sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.sidebar-card-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 14px;
}
.sidebar-links { display: flex; flex-direction: column; gap: 8px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  text-decoration: none;
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  transition: border-color .12s, background .12s;
}
.sidebar-link:hover {
  border-color: var(--accent);
  background: #eff6ff;
  color: var(--accent);
  text-decoration: none;
}
.sidebar-link-icon { font-size: 16px; flex-shrink: 0; }
.sidebar-link-sub { font-size: 11px; color: var(--muted); display: block; }
.sidebar-link:hover .sidebar-link-sub { color: inherit; opacity: 0.8; }

/* How-to steps */
.how-steps { counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
.how-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--fg);
  line-height: 1.55;
}
.how-step::before {
  counter-increment: step;
  content: counter(step);
  flex-shrink: 0;
  width: 24px; height: 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  margin-top: 1px;
}

/* Affiliate disclosure */
.affiliate-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  line-height: 1.55;
}

/* ---------- Ad Slots ---------- */
.ad-slot {
  text-align: center;
  padding: 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-slot ins { display: block; width: 100%; }

/* ---------- Site Footer ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 20px;
  margin-top: 48px;
}
.site-footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.footer-brand { font-weight: 700; font-size: 15px; color: var(--fg); }
.footer-brand span { color: var(--accent); }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; }
.footer-nav a { font-size: 13px; color: var(--muted); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; }
.footer-copy { font-size: 12px; color: var(--muted); }
.disclaimer {
  font-size: 11px;
  color: var(--muted);
  max-width: 600px;
  line-height: 1.6;
}

/* ---------- Dark Mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --fg: #e2e8f0;
    --muted: #94a3b8;
    --border: #334155;
    --surface: #1e293b;
    --surface2: #334155;
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
  }
  .site-header { background: rgba(15,23,42,.95); }
  .hero { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #0f172a; }
  .btn.outline { background: #1e293b; color: var(--accent); border-color: var(--border); }
  .btn.print-btn { background: #15803d; border-color: #15803d; color: #fff; }
  .template-card { background: #1e293b; }
  .cat-card { background: #1e293b; }
  .invoice-wrap { box-shadow: 0 4px 24px rgba(0,0,0,.4); }
  .invoice-doc { background: #fff; color: #1a1a1a; } /* keep doc white in dark mode */
  .sidebar-card { background: #1e293b; }
  .sidebar-link { background: #0f172a; }
  .sidebar-link:hover { background: #1e3a5f; }
  .faq-list details { background: #1e293b; }
  .site-footer { background: #0f172a; }
  [contenteditable="true"]:hover { background: rgba(251,191,36,.15); }
  [contenteditable="true"]:focus { background: rgba(251,191,36,.2); outline-color: #f59e0b; }
}

/* ---------- Print Styles ---------- */
@media print {
  /* Hide everything except invoice doc */
  .site-header,
  .tmpl-toolbar,
  .tmpl-sidebar,
  .ad-slot,
  .site-footer,
  .breadcrumb,
  .section,
  .print-hide {
    display: none !important;
  }

  /* Aggressively hide all AdSense / Google ad injected elements */
  ins.adsbygoogle,
  ins.adsbygoogle *,
  iframe,
  [id^="google_ads_"],
  [id^="aswift_"],
  [id="google_vignette"],
  #google_vignette,
  #google_vignette_container,
  div[data-google-query-id],
  div[data-ad-status] { display: none !important; }

  body { background: #fff; margin: 0; padding: 0; }
  .tmpl-page { background: #fff; }
  .tmpl-layout {
    display: block;
    padding: 0;
    max-width: 100%;
  }
  .invoice-wrap {
    box-shadow: none;
    border-radius: 0;
  }
  .invoice-doc {
    padding: 13mm 16mm;
    font-size: 10.5pt;
    min-height: 0;
  }
  .inv-meta-title { font-size: 24pt; }

  /* Tighten spacing for 1-page fit */
  .inv-header { margin-bottom: 16px; }
  .inv-parties { margin-bottom: 16px; }
  .inv-table-wrap { margin-bottom: 12px; }
  .inv-totals { margin-bottom: 16px; }
  .inv-notes-grid { margin-bottom: 16px; gap: 16px; }
  .inv-total-row { padding: 5px 0; }

  /* Prevent unwanted page breaks inside sections */
  .inv-totals-box,
  .inv-notes-grid,
  .inv-thankyou { page-break-inside: avoid; }

  /* Show actual typed values (no highlight) */
  [contenteditable="true"]:hover,
  [contenteditable="true"]:focus {
    background: transparent !important;
    outline: none !important;
  }

  @page {
    margin: 0;
    size: A4;
  }
}

/* =============================================
   Phase A additions — auto-calc, row ops, save
   ============================================= */

/* ---------- Tax rate input ---------- */
.tax-rate-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: text;
}
.tax-rate-input {
  width: 52px;
  padding: 3px 6px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  background: var(--bg);
  color: var(--fg);
  -moz-appearance: textfield;
}
.tax-rate-input::-webkit-inner-spin-button,
.tax-rate-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tax-rate-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ---------- Row delete button ---------- */
.inv-table [data-col="amount"] { position: relative; }

.row-del-btn {
  position: absolute;
  top: 50%;
  right: -26px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: #fee2e2;
  color: #dc2626;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  user-select: none;
  transition: background .12s;
}
.inv-table tbody tr:hover .row-del-btn { display: flex; }
.row-del-btn:hover { background: #fca5a5; }
.inv-table-wrap { overflow: visible; }

/* ---------- Saved indicator ---------- */
.saved-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
  background: #dcfce7;
  padding: 3px 9px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .25s;
  white-space: nowrap;
}
.saved-badge.visible { opacity: 1; }

/* ---------- Toolbar responsive ---------- */
@media (max-width: 700px) {
  .tmpl-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .tmpl-toolbar-right { flex-wrap: wrap; }
  .tax-rate-wrap { order: -1; }
}

/* ---------- Dark mode overrides for new elements ---------- */
@media (prefers-color-scheme: dark) {
  .tax-rate-input { background: #1e293b; border-color: #475569; color: #e2e8f0; }
  .row-del-btn { background: #450a0a; color: #fca5a5; }
  .row-del-btn:hover { background: #7f1d1d; }
  .saved-badge { background: #14532d; color: #86efac; }
}

/* ---------- Print: hide new elements ---------- */
@media print {
  .row-del-btn,
  .saved-badge,
  #btn-add-row { display: none !important; }
}
