/* Fonts */
@font-face {
  font-family: 'Basier Square';
  src: url('/fonts/BasierSquare-Regular.otf') format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Basier Square';
  src: url('/fonts/BasierSquare-Medium.otf') format('opentype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Basier Square';
  src: url('/fonts/BasierSquare-SemiBold.otf') format('opentype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Basier Square';
  src: url('/fonts/BasierSquare-Bold.otf') format('opentype');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --brand-primary: #10306e;
  --brand-primary-hover: #0b245a;
  --brand-accent: #f9c33d;
  --text: #222;
  --muted: #6b7280;
  --bg: #f7f7f5;
  --surface: #fff;
  --border: #e5e7eb;
  --border-strong: #bbb;
  --danger: #a02a2a;
  --success: #2b7a3c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Basier Square', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

:root {
  --topnav-h: 54px;
  --sidebar-w: 220px;
}

/* ===== App shell (logged-in layout) ===== */
body.app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topnav-h) 1fr;
  grid-template-areas:
    "topnav topnav"
    "sidebar main";
  transition: grid-template-columns 0.18s ease;
}
body.app > .topnav  { grid-area: topnav; }
body.app > .sidebar { grid-area: sidebar; }
body.app > .container { grid-area: main; }

/* Collapsed on desktop: hide the column entirely */
html.sidebar-collapsed body.app { grid-template-columns: 0 1fr; }
html.sidebar-collapsed body.app > .sidebar { transform: translateX(-100%); }

/* Public (login) layout: no sidebar, just centers content */
body.login-page .container { max-width: 920px; margin: 0 auto; padding: 1.5rem; }
body.app .container { max-width: 1120px; padding: 1.5rem 2rem; width: 100%; }

/* ===== Top nav ===== */
.topnav {
  background: var(--brand-primary);
  color: #fff;
  padding: 0 1rem;
  height: var(--topnav-h);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav a, .topnav .link { color: #fff; text-decoration: none; font-weight: 500; }
.topnav a:hover, .topnav button.link:hover { color: var(--brand-accent); }
.topnav .brand {
  display: flex; align-items: center;
  font-weight: 600;
  flex-shrink: 0;
}
.topnav .brand:hover { color: #fff; }
.topnav .brand-logo { height: 36px; width: 36px; display: block; border-radius: 4px; }
.topnav .page-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  flex: 1;
  margin-left: 0.5rem;
}
.topnav form.inline { margin: 0; display: inline; }
.topnav .topnav-logout { margin-left: auto; }
.topnav button.link {
  background: none; border: 0; padding: 0;
  cursor: pointer; font: inherit; color: #fff; font-weight: 500;
}

/* Hamburger */
.hamburger {
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.18s, opacity 0.18s;
}
.hamburger:hover { background: rgba(255, 255, 255, 0.1); }
.hamburger:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

/* ===== Sidebar ===== */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transition: transform 0.18s ease;
  position: sticky;
  top: var(--topnav-h);
  height: calc(100vh - var(--topnav-h));
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
}
.sidebar-link {
  display: block;
  padding: 0.55rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: #f3f4f6;
  color: var(--brand-primary);
  border-left-color: var(--brand-accent);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
}

/* Let grid items actually shrink below their content's intrinsic width. */
body.app > .container { min-width: 0; }
.topnav .page-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Modal ===== */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  overflow-y: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 48, 110, 0.55);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.modal-card {
  background: #fff;
  max-width: 760px;
  width: 100%;
  border-radius: 8px;
  padding: 2rem 2.5rem;
  position: relative;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
  z-index: 1;
}
.modal-card h2 { margin-top: 0; color: var(--brand-primary); }
.modal-card h3 { margin-top: 1.5rem; font-size: 1rem; color: var(--brand-primary); }
.modal-card h4 { margin: 1rem 0 0.35rem; font-size: 0.95rem; }
.modal-card p, .modal-card li { font-size: 0.92rem; }
.modal-card ul { padding-left: 1.25rem; }
.modal-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #f3f4f6;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-size: 0.88em;
}
.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: transparent;
  border: 0;
  font-size: 1.8rem;
  line-height: 1;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  color: var(--muted);
  border-radius: 4px;
}
.modal-close:hover { background: var(--border); color: var(--text); }
@media (max-width: 640px) {
  .modal { padding: 1rem 0.5rem; }
  .modal-card { padding: 1.25rem 1.25rem 1.5rem; }
}

/* "Saved ✓" inline toast next to the draft save button */
.saved-toast {
  align-self: center;
  font-size: 0.88rem;
  color: var(--success);
  background: #e7f5ea;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  opacity: 1;
  transition: opacity 1.6s ease 0.4s;
}
.saved-toast.fade { opacity: 0; }

/* Invoice list filter bar — compact row, wraps on narrow */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}
.filter-bar > label {
  font-size: 0.75rem;
  gap: 0.1rem;
  color: var(--muted);
}
.filter-bar input[type=date], .filter-bar select {
  padding: 0.3rem 0.45rem;
  font-size: 0.88rem;
}
.filter-bar .filter-status {
  display: flex;
  align-items: center;
  gap: 0.35rem 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.1rem;
}
.filter-bar .filter-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: none;
}
.filter-bar .chk {
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text);
  padding-bottom: 0;
}
.filter-bar .chk input[type=checkbox] { margin: 0; }
.filter-bar .filter-actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  padding-bottom: 0.05rem;
}
.filter-bar button, .filter-bar a.button {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

/* Bulk-action bar above the invoices table */
.bulk-bar {
  background: #fff7e0;
  border: 1px solid var(--brand-accent);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.bulk-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.bulk-bar label { flex-direction: row; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.bulk-bar select { padding: 0.25rem 0.4rem; font-size: 0.88rem; }
.bulk-bar button { padding: 0.3rem 0.75rem; font-size: 0.85rem; }
.bulk-notice {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: #5a4400;
  background: rgba(255, 255, 255, 0.4);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  border-left: 3px solid var(--brand-accent);
}
.bulk-notice.attn {
  color: #7a3b00;
  background: #ffedd5;
  border-left-color: #d97706;
  font-weight: 500;
}

/* Email status badge on invoices list */
.email-state {
  display: inline-block;
  font-size: 0.85rem;
  padding: 0.12rem 0.55rem;
  border-radius: 99px;
  text-decoration: none;
  background: #dbeafe;
  color: var(--brand-primary);
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
button.email-state { line-height: 1.4; }
.email-state:hover { background: var(--brand-primary); color: #fff; }
.email-state.muted { background: var(--border); color: var(--muted); }
.email-state.ok { background: #e7f5ea; color: var(--success); }
.email-state.ok:hover { background: var(--success); color: #fff; }
.email-state.attn { background: #fef3c7; color: #92400e; }
.email-state.attn:hover { background: #d97706; color: #fff; }

.help-link {
  color: var(--brand-primary);
  font-size: 0.9rem;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: inherit;
}
.help-link:hover { color: var(--brand-accent); }

.topnav .topnav-logout { flex-shrink: 0; }

/* ===== Mobile layout ===== */
@media (max-width: 900px) {
  body.app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topnav"
      "main";
  }
  body.app > .sidebar {
    position: fixed;
    top: var(--topnav-h);
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 45;
    transform: translateX(-100%);
    box-shadow: 2px 0 16px rgba(0,0,0,0.15);
  }
  html.sidebar-open body.app > .sidebar {
    transform: translateX(0);
  }
  html.sidebar-open .sidebar-backdrop { display: block; }
  body.app > .container { padding: 1rem; max-width: 100%; }

  .topnav { padding: 0 0.5rem; gap: 0.4rem; }
  .topnav .brand-logo { height: 32px; width: 32px; }
  .topnav .page-title { font-size: 0.95rem; text-align: left; margin: 0; flex: 1 1 auto; }
  .topnav .topnav-logout button.link { font-size: 0.85rem; }
}

/* Even tighter on really small devices */
@media (max-width: 420px) {
  .topnav .page-title { font-size: 0.85rem; }
  .topnav .brand-logo { height: 28px; width: 28px; }
  body.app > .container { padding: 0.75rem; }
}

/* Sub nav */
.subnav {
  display: flex; gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}
.subnav a {
  text-decoration: none;
  color: #444;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-weight: 500;
}
.subnav a:hover { background: var(--border); color: var(--brand-primary); }

/* Headings */
h1 { margin: 0.5rem 0 1rem; font-size: 1.6rem; font-weight: 600; color: var(--brand-primary); }
h2 { margin-top: 1.5rem; font-size: 1.25rem; font-weight: 600; }
h3 { margin-top: 1.5rem; font-size: 1.05rem; font-weight: 600; color: var(--brand-primary); }

/* Forms */
form.stack {
  display: flex; flex-direction: column;
  gap: 0.6rem; max-width: 560px; margin: 0;
}
form.stack.wide { max-width: 100%; }
form.stack.wide > label,
form.stack.wide > .row { max-width: 720px; }
form.stack.wide > #lines-table,
form.stack.wide > h3,
form.stack.wide > section,
form.stack.wide > p { max-width: 100%; }
form.row, .row {
  display: flex; flex-wrap: wrap;
  gap: 0.75rem; align-items: flex-end;
  margin: 0.5rem 0;
}
label {
  display: flex; flex-direction: column;
  font-size: 0.88rem; color: #555; gap: 0.25rem;
}
input, select, textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font: inherit;
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(16, 48, 110, 0.15);
}
input[type=checkbox] { width: auto; margin-right: 0.35rem; }
label:has(input[type=checkbox]) {
  flex-direction: row; align-items: center; color: var(--text); font-size: 0.95rem;
}
button {
  padding: 0.5rem 1rem;
  background: var(--brand-primary);
  color: #fff;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}
button:hover { background: var(--brand-primary-hover); }
button:disabled,
button:disabled:hover {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 1;
}
button.secondary:disabled,
button.secondary:disabled:hover {
  background: #f3f4f6;
  color: #9ca3af;
}
button[type=submit] { align-self: flex-start; }
.row button { align-self: flex-end; }

/* Feedback */
.ok { background: #e7f5ea; color: var(--success); padding: 0.5rem 0.75rem; border-radius: 4px; margin: 0.5rem 0; }
.error { background: #fbe9e7; color: var(--danger); padding: 0.5rem 0.75rem; border-radius: 4px; margin: 0.5rem 0; }
.hint { color: var(--muted); font-size: 0.9rem; }

/* Sections */
section {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
th, td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { background: #fafafa; font-weight: 600; font-size: 0.88rem; color: #374151; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafbfc; }
table a { color: var(--brand-primary); font-weight: 500; text-decoration: none; }
table a:hover { text-decoration: underline; }

/* Dashboard tiles */
ul.tiles {
  list-style: none; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
ul.tiles a {
  display: flex; flex-direction: column;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  gap: 0.25rem;
  transition: border-color 0.12s, transform 0.12s;
}
ul.tiles a:hover { border-color: var(--brand-primary); transform: translateY(-1px); }
ul.tiles strong { color: var(--brand-primary); font-weight: 600; }
ul.tiles span { color: var(--muted); font-size: 0.88rem; }

/* Login */
.login { max-width: 380px; margin: 3rem auto; text-align: center; }
.login-logo {
  width: 96px; height: 96px;
  margin: 0 auto 1rem;
  display: block;
  border-radius: 12px;
}
.login h1 { color: var(--brand-primary); margin-top: 0; }
.login form { text-align: left; margin-top: 1.5rem; }
.login form button { align-self: stretch; width: 100%; padding: 0.7rem; }

/* Misc */
.username-label { min-width: 120px; padding: 0.45rem 0; color: #333; }

/* Buttons as links */
a.button, .button {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  background: var(--brand-primary);
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  border: 0;
  font-weight: 500;
}
a.button:hover { background: var(--brand-primary-hover); }
a.button.secondary, .button.secondary, button.secondary {
  background: var(--border);
  color: var(--text);
}
a.button.secondary:hover, button.secondary:hover { background: #d1d5db; }

.row.spread { justify-content: space-between; align-items: center; }

/* Actions row on recurring template form: align button-like actions on a single centered baseline. */
.row.actions-row { align-items: center; gap: 0.75rem; }
.inline-actions { display: inline-flex; align-items: center; gap: 0.6rem; margin: 0; }
.run-now-group {
  padding: 0.4rem 0.65rem;
  background: var(--bg-alt, #f3f4f6);
  border-radius: 6px;
}
.inline-check {
  display: inline-flex; flex-direction: row; align-items: center;
  gap: 0.35rem; margin: 0; font-size: 0.9rem; color: var(--text);
  white-space: nowrap;
}
.inline-check input[type=checkbox] { margin: 0; }

/* Tags */
.tag {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  background: #dbeafe;
  color: var(--brand-primary);
  border-radius: 99px;
  font-size: 0.78rem;
  margin-right: 0.25rem;
  font-weight: 500;
}
.tag.muted { background: var(--border); color: var(--muted); }

/* Details/summary */
details { margin-top: 0.5rem; }
details summary { cursor: pointer; padding: 0.25rem 0; }
details[open] { padding-bottom: 0.5rem; }

/* Code */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: #f3f4f6;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  color: #374151;
}

/* Textarea */
textarea { resize: vertical; font: inherit; min-height: 3rem; }

/* Key-value list (email detail) */
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 0.25rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 0.88rem; }
dl.kv dd { margin: 0; }

/* Code blocks for email bodies */
.code-block {
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

/* Invoice form totals (auth view) */
.totals {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: inline-block;
  min-width: 260px;
}
.totals .grand { font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: 0.3rem; margin-top: 0.3rem; }

/* Lines-table tighter cell padding for editability */
#lines-table { table-layout: fixed; width: 100%; }
#lines-table th, #lines-table td { padding: 0.35rem 0.5rem; vertical-align: middle; overflow: hidden; }
#lines-table input, #lines-table textarea { width: 100%; box-sizing: border-box; padding: 0.35rem 0.4rem; }

/* Column sizing — applied to <colgroup><col> so table-layout: fixed honours them */
#lines-table col.col-qty    { width: 60px; }
#lines-table col.col-unit   { width: 90px; }
#lines-table col.col-price  { width: 100px; }
#lines-table col.col-check  { width: 40px; }
#lines-table col.col-actions{ width: 40px; }
#lines-table th:nth-child(5), #lines-table th:nth-child(6), #lines-table th:nth-child(7) { text-align: center; }
#lines-table td.col-check, #lines-table td.col-actions { text-align: center; }
#lines-table td.col-check input[type=checkbox] { width: auto; margin: 0; }

#lines-table .line-name { font-weight: 500; margin-bottom: 0.2rem; }
#lines-table .line-desc { min-height: 1.8rem; font-size: 0.88rem; color: #555; resize: vertical; }

#lines-table .remove-line {
  padding: 0.1rem 0.45rem;
  font-size: 1rem;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
}
#lines-table .remove-line:hover { color: var(--danger); border-color: var(--danger); background: #fbe9e7; }

.line-desc-text { color: var(--muted); font-size: 0.9rem; display: inline-block; margin-top: 0.15rem; }
.invoice-lines .line-desc-text { color: #666; }
.line-period { font-size: 0.82rem; color: var(--muted); display: block; margin-top: 0.2rem; }

.unbilled-panel {
  background: #fff8e1;
  border: 1px solid var(--brand-accent);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.unbilled-panel h3 { margin-top: 0; color: #5a4400; }
.unbilled-panel details { margin: 0.5rem 0; }
.unbilled-panel summary { cursor: pointer; padding: 0.35rem 0; color: var(--brand-primary); }
.unbilled-panel table { margin-top: 0.25rem; }

/* ===== Public invoice view ===== */
body.public-view { background: #eef1f6; }
.public-invoice { max-width: 820px; }
.invoice-paper {
  background: #fff;
  padding: 3rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(16, 48, 110, 0.08);
  margin-top: 2rem;
}
.invoice-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; border-bottom: 2px solid var(--brand-primary);
  padding-bottom: 1rem;
}
.invoice-logo { width: 96px; height: 96px; border-radius: 8px; }
.invoice-header .biz { text-align: right; font-size: 0.88rem; color: #444; }
.invoice-header .biz strong { color: var(--brand-primary); display: block; margin-bottom: 0.2rem; font-size: 1rem; }
.invoice-title {
  margin-top: 1.5rem;
  display: flex; align-items: baseline; gap: 1rem;
  position: relative;
}
.invoice-title h1 { color: var(--brand-primary); margin: 0; font-size: 2rem; letter-spacing: 0.02em; }
.invoice-title .number { color: #444; font-size: 1.1rem; }
.status-stamp {
  margin-left: auto;
  padding: 0.3rem 0.85rem;
  border: 2px solid;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  transform: rotate(-4deg);
  opacity: 0.9;
}
.status-stamp.paid { color: var(--success); border-color: var(--success); }
.status-stamp.overdue { color: var(--danger); border-color: var(--danger); }
.status-stamp.void { color: var(--muted); border-color: var(--muted); }

.invoice-meta {
  margin-top: 1.5rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;
  font-size: 0.92rem;
}
.invoice-meta .label {
  display: block; font-size: 0.75rem; color: var(--muted);
  letter-spacing: 0.08em; font-weight: 600; margin-bottom: 0.15rem; margin-right: 0.4rem;
}
.invoice-meta strong { color: var(--brand-primary); }

.invoice-lines {
  margin-top: 2rem; width: 100%;
  border-collapse: collapse; border: 0;
}
.invoice-lines th, .invoice-lines td {
  padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--border);
  text-align: left;
}
.invoice-lines th { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.08em; font-weight: 600; border-bottom: 2px solid var(--brand-primary); }
.invoice-lines .num { text-align: right; }

.invoice-totals {
  margin-top: 1rem; text-align: right; font-size: 0.95rem;
}
.invoice-totals div { padding: 0.2rem 0; }
.invoice-totals span { display: inline-block; min-width: 120px; color: var(--brand-primary); font-weight: 500; }
.invoice-totals .grand { color: var(--brand-primary); font-weight: 700; font-size: 1.15rem; border-top: 2px solid var(--brand-primary); padding-top: 0.4rem; margin-top: 0.3rem; }

.invoice-notes, .invoice-payment { margin-top: 1.5rem; }
.invoice-notes .label, .invoice-payment .label {
  font-size: 0.74rem; color: var(--muted); letter-spacing: 0.08em; font-weight: 600;
}
.invoice-actions { margin-top: 2rem; text-align: center; }

.preview-banner {
  background: #fff4d6;
  border-bottom: 2px solid var(--brand-accent);
  color: #5a4400;
  padding: 0.75rem 1.5rem;
  font-size: 0.92rem;
  text-align: center;
}
.preview-banner strong { color: #7a5800; letter-spacing: 0.08em; }
.preview-banner a { color: var(--brand-primary); text-decoration: none; font-weight: 500; }
.preview-banner a:hover { text-decoration: underline; }
.preview-banner .hint { color: #7a5800; }

