/* Viite — calm Nordic, modern */

:root {
  --paper: #f5f3ed;
  --paper-2: #ecead0;
  --surface: #ffffff;
  --surface-2: #faf9f4;
  --ink: #15161a;
  --ink-2: #353539;
  --muted: #6e6e66;
  --muted-2: #a3a298;
  --hair: #e3e0d4;
  --hair-soft: #eeebe0;
  --field: #faf9f4;
  --field-focus: #ffffff;
  --moss: oklch(46% 0.062 155);
  --moss-2: oklch(52% 0.080 155);
  --moss-soft: oklch(46% 0.062 155 / 0.10);
  --moss-tint: oklch(96% 0.020 155);
  --warn: oklch(58% 0.13 60);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-card: 0 1px 0 rgba(28,26,18,.02), 0 1px 2px rgba(28,26,18,.04);
  --shadow-lift: 0 1px 0 rgba(28,26,18,.03), 0 12px 30px -16px rgba(28,26,18,.16);
  --shadow-paper: 0 1px 0 rgba(28,26,18,.04), 0 30px 60px -34px rgba(28,26,18,.30);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.serif { font-family: 'Instrument Serif', 'Iowan Old Style', Georgia, serif; font-weight: 400; letter-spacing: -0.005em; }
.mono { font-family: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

button { font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ──────────────────────────────── App shell */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.topbar.scrolled { border-bottom-color: var(--hair); background: rgba(245,243,237,.85); backdrop-filter: blur(10px); }

.wordmark {
  font-family: 'Instrument Serif', serif;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.015em;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  color: var(--ink);
}
.wordmark .mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist', sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: 2px;
  align-items: center;
}
.nav-link {
  font-size: 14px;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, background .12s;
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); background: rgba(0,0,0,.05); }

.lang {
  display: inline-flex;
  background: rgba(0,0,0,.04);
  border-radius: 999px;
  padding: 3px;
  font-size: 12px;
}
.lang button {
  appearance: none; border: 0; background: transparent;
  padding: 5px 11px; border-radius: 999px; color: var(--muted);
  cursor: pointer; font-weight: 500;
}
.lang button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* ──────────────────────────────── Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 20px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .06s, background .12s, border-color .12s;
}
.btn:hover { background: var(--ink-2); }
.btn:active { transform: translateY(0.5px); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--hair);
}
.btn.ghost:hover { background: rgba(0,0,0,.04); border-color: var(--ink-2); }
.btn.moss { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.moss:hover { background: var(--moss-2); border-color: var(--moss-2); }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.lg { padding: 14px 22px; font-size: 15px; }
.btn.link { background: transparent; border: 0; color: var(--moss); padding: 0; font-weight: 500; }
.btn.link:hover { color: var(--moss-2); background: transparent; }

/* ──────────────────────────────── Container */
.page {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 28px 100px;
}
.page-narrow { max-width: 720px; }
.page-wide { max-width: 1180px; }

.page-head {
  margin-bottom: 28px;
}
.page-head h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 40px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.012em;
  margin: 0 0 8px;
}
.page-head .lede {
  color: var(--muted);
  font-size: 16px;
  max-width: 60ch;
  margin: 0;
}

/* ──────────────────────────────── Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.card-tight { padding: 18px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.card-head h2 {
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.008em;
  white-space: nowrap;
}
.card-head .meta {
  font-size: 13px;
  color: var(--muted);
}

/* ──────────────────────────────── Form */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.field label .opt {
  font-size: 11.5px;
  color: var(--muted-2);
  font-weight: 400;
}
.field .hint {
  font-size: 12.5px;
  color: var(--muted-2);
}
.field .hint.ok { color: var(--moss); }
.field .hint.warn { color: var(--warn); }

.input, .textarea, .select {
  appearance: none;
  border: 1px solid var(--hair);
  background: var(--field);
  padding: 11px 13px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  border-radius: var(--r-sm);
  transition: border-color .12s, background .12s, box-shadow .12s;
  width: 100%;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--muted-2); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--ink);
  background: var(--field-focus);
  box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}
.input.mono { font-family: 'Geist Mono', monospace; font-size: 14.5px; letter-spacing: 0.01em; }
.input.error { border-color: var(--warn); }
.input::placeholder { color: var(--muted-2); }
.textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23888' d='M0 0h10L5 6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 760px) {
  .row, .row-3, .row-4 { grid-template-columns: 1fr; gap: 14px; }
}

/* Input-with-prefix-suffix wrapper */
.input-affix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-affix .input { padding-right: 80px; }
.input-affix .suffix {
  position: absolute;
  right: 12px;
  font-size: 12px;
  color: var(--muted-2);
  font-family: 'Geist Mono', monospace;
  pointer-events: none;
}

/* ──────────────────────────────── Pills, chips */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(0,0,0,.05);
  color: var(--muted);
}
.pill.moss { color: var(--moss); background: var(--moss-soft); }
.pill.ink { color: var(--paper); background: var(--ink); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }

/* ──────────────────────────────── Landing */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 64px;
  align-items: center;
  padding: 80px 0 60px;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; gap: 40px; padding: 32px 0 40px; } }

.hero h1 {
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: clamp(44px, 6.5vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.018em;
  margin: 0 0 18px;
  text-wrap: balance;
}
.hero h1 em { font-style: italic; color: var(--moss); }
.hero p.lede {
  font-size: 18px;
  color: var(--muted);
  max-width: 50ch;
  margin: 0 0 28px;
  text-wrap: pretty;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero-foot {
  margin-top: 18px;
  font-size: 13.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.hero-foot .moss-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--moss);
  display: inline-block;
}

/* Landing invoice card (real-feeling) */
.invoice-preview {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 24px 26px;
  box-shadow: var(--shadow-paper);
  font-size: 12px;
  line-height: 1.5;
  position: relative;
}
.invoice-preview .ip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hair-soft);
}
.invoice-preview .ip-logo {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Instrument Serif', serif; font-size: 16px;
  white-space: nowrap;
}
.invoice-preview .ip-logo .sq {
  width: 22px; height: 22px; border-radius: 5px; background: var(--ink);
  color: var(--paper); display: inline-flex; align-items:center; justify-content: center;
  font-family: 'Geist', sans-serif; font-size: 12px; font-weight: 600;
}
.invoice-preview .ip-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0; color: #333;
}
.invoice-preview .ip-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-preview .ip-row > span:last-child { white-space: nowrap; flex-shrink: 0; }
.invoice-preview .ip-grand {
  margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--ink);
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.invoice-preview .ip-grand .lab, .invoice-preview .ip-grand .amt { white-space: nowrap; }
.invoice-preview .ip-grand .lab { color: var(--muted); }
.invoice-preview .ip-grand .amt { font-family: 'Geist Mono', monospace; font-size: 20px; }
.invoice-preview .ip-foot {
  margin-top: 16px;
  display: flex; align-items: center; gap: 14px;
  padding-top: 14px; border-top: 1px dashed var(--hair);
}
.invoice-preview .ip-foot .qr {
  width: 64px; height: 64px;
  background: #fff;
  border: 1px solid var(--hair-soft);
  border-radius: 4px;
  padding: 4px;
}
.invoice-preview .ip-foot .ip-pay {
  font-family: 'Geist Mono', monospace; font-size: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 32px 0 40px;
}
@media (max-width: 720px) { .value-grid { grid-template-columns: 1fr; gap: 18px; } }
.value-item {
  padding: 22px 22px 24px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
}
.value-item h3 {
  font-family: 'Geist', sans-serif;
  font-weight: 500;
  font-size: 15px;
  margin: 0 0 6px;
  letter-spacing: -0.005em;
}
.value-item p {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}
.value-item .ic {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--moss-tint);
  color: var(--moss);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
  font-weight: 500;
}

/* ──────────────────────────────── Line items table (form) */
.lines {
  border-top: 1px solid var(--hair);
  margin-top: 4px;
}
.lines-head, .line {
  display: grid;
  grid-template-columns: minmax(0,1fr) 70px 80px 110px 90px 40px;
  grid-template-areas: "desc qty unit price vat del";
  gap: 12px;
  align-items: center;
  padding: 10px 6px;
  border-bottom: 1px solid var(--hair-soft);
}
.lines-head {
  font-size: 12px;
  color: var(--muted);
  padding: 12px 0 10px;
}
.line .num-cell { text-align: right; }
.line input.input, .line select.select {
  padding: 8px 10px;
  border-color: var(--hair-soft);
  background: transparent;
}
.line:hover input.input, .line:hover select.select { border-color: var(--hair); background: var(--surface-2); }
.line input.input:focus, .line select.select:focus { border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.line { transition: background .12s; border-radius: 6px; }
.line:hover { background: rgba(0,0,0,.015); }
.line .delete {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.line .delete:hover { color: var(--warn); background: rgba(0,0,0,.04); }

/* Row menu (per-line actions) */
.rowmenu { position: relative; }
.rowmenu-trigger {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
}
.line:hover .rowmenu-trigger { color: var(--ink); }
.rowmenu-trigger:hover { background: rgba(0,0,0,.05); }
.rowmenu-trigger.open { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.rowmenu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 18px 40px -16px rgba(28,26,18,.30);
  padding: 6px;
  z-index: 30;
  display: flex; flex-direction: column;
  animation: rm-in .12s ease;
}
@keyframes rm-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.rowmenu-pop button {
  appearance: none; border: 0; background: transparent;
  text-align: left;
  font: inherit; font-size: 13.5px;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap;
}
.rowmenu-pop button .ic {
  width: 16px; text-align: center;
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.rowmenu-pop button:hover { background: rgba(0,0,0,.05); }
.rowmenu-pop button:disabled { opacity: .35; cursor: default; }
.rowmenu-pop button:disabled:hover { background: transparent; }
.rowmenu-pop button.danger { color: var(--warn); }
.rowmenu-pop button.danger .ic { color: var(--warn); }
.rowmenu-pop button.danger:hover { background: oklch(58% 0.13 60 / 0.08); }
.rowmenu-pop .sep { height: 1px; background: var(--hair); margin: 4px 2px; }

.invmenu { position: relative; }

/* Lines empty state */
.lines-empty {
  border: 1px dashed var(--hair);
  border-radius: var(--r-md);
  padding: 36px 20px;
  text-align: center;
  background: var(--surface-2);
}
.lines-empty-title { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.lines-empty-body { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.add-line {
  appearance: none;
  border: 1px dashed var(--hair);
  background: transparent;
  color: var(--moss);
  font-size: 13.5px;
  padding: 11px 18px;
  margin-top: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: border-color .12s, background .12s;
}
.add-line:hover { border-color: var(--moss); background: var(--moss-soft); }

@media (max-width: 760px) {
  .lines-head { display: none; }
  .line {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "desc desc"
      "qty unit"
      "price vat"
      "del del";
    padding: 14px 0;
    row-gap: 8px;
  }
}

/* ──────────────────────────────── Totals */
.totals {
  margin-left: auto;
  margin-top: 20px;
  max-width: 320px;
  font-size: 14px;
}
.totals .row-t {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  color: var(--muted);
  white-space: nowrap;
  gap: 16px;
}
.totals .row-t .num { font-family: 'Geist Mono', monospace; color: var(--ink); }
.totals .row-t.grand {
  border-top: 1px solid var(--ink);
  padding-top: 12px;
  margin-top: 8px;
  font-size: 18px;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
}
.totals .row-t.grand .num { font-size: 20px; }

/* ──────────────────────────────── Sticky action bar */
.action-bar {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--paper) 60%, rgba(245,243,237,.7));
  padding: 18px 0 6px;
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  z-index: 20;
}
.action-bar .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ──────────────────────────────── Preview / paper */
.preview-wrap {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}
@media (max-width: 980px) { .preview-wrap { grid-template-columns: 1fr; } }

.paper-sheet {
  background: white;
  border: 1px solid var(--hair);
  border-radius: 6px;
  box-shadow: var(--shadow-paper);
  aspect-ratio: 1 / 1.414;
  position: relative;
  overflow: hidden;
}
.paper-sheet .pad { padding: 56px 56px 64px; height: 100%; display: flex; flex-direction: column; }
@media (max-width: 720px) { .paper-sheet .pad { padding: 32px 30px 38px; } }

.side-controls {
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 92px;
}
.side-controls .group-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
}

.template-options { display: flex; flex-direction: column; gap: 6px; }
.template-opt {
  appearance: none;
  border: 1px solid var(--hair);
  background: var(--surface);
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: border-color .12s, background .12s;
}
.template-opt:hover { border-color: var(--muted-2); }
.template-opt.on { border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.template-opt .name { font-size: 14px; font-weight: 500; white-space: nowrap; }
.template-opt .desc { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; }

/* ──────────────────────────────── Invoice templates (PDF look) */
.inv-amt { font-variant-numeric: tabular-nums; font-family: 'Geist Mono', monospace; }
.inv-key { font-size: 10px; color: #888; margin-bottom: 4px; font-weight: 500; }
.inv-val { font-size: 11px; color: #111; line-height: 1.55; }

/* logo block (used in all templates) */
.inv-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #111;
  flex-shrink: 0;
}
.inv-logo img { max-width: 140px; max-height: 44px; display: block; object-fit: contain; }
.inv-logo .ph {
  width: 38px; height: 38px; border-radius: 7px;
  background: #111; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Geist', sans-serif; font-size: 16px; font-weight: 600;
  flex-shrink: 0;
}
.inv-logo .name {
  font-family: 'Instrument Serif', serif; font-size: 19px; line-height: 1.15;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.pay-block {
  margin-top: auto;
  border-top: 1px solid #ddd;
  padding-top: 16px;
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
  align-items: end;
}
.pay-block .info { font-family: 'Geist Mono', monospace; font-size: 9.5px; color: #555; line-height: 1.7; }
.pay-block .info .lab { color: #999; }
.pay-block .code-area .label { font-size: 8px; letter-spacing: 0.16em; text-transform: uppercase; color: #999; margin-bottom: 6px; text-align: center; }
.pay-block .code-area .qr {
  background: white; padding: 4px;
  border: 1px solid #eee; border-radius: 3px;
  /* A v6 EPC SEPA payload (~95 B, 41 modules square) at 160 px gave ~0.8 mm
     per module — within spec but borderline for bank-app cameras through
     screen glare. 200 px raises that to ~1.05 mm and still fits a sensible
     invoice layout. */
  width: 200px; height: 200px;
}
.pay-block .code-area .qr svg { width: 100%; height: 100%; display: block; }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 40px;
}
.bars span { display: block; background: #111; }
.barcode-full {
  grid-column: 1 / -1;
  /* Finanssiala spec: X (narrow bar) ≥ 0.25 mm × 356 modules (332 + 24 quiet
     zone) ⇒ ≥ ~89 mm total width. Enforce a print/screen minimum so narrow
     bars never compress below the scannable threshold. */
  min-width: 89mm;
}
.barcode-full svg { min-height: 13mm; }   /* spec: bar height ≥ 13 mm */
.barcode-full .label { font-size: 8px; letter-spacing: 0.16em; text-transform: uppercase; color: #999; margin-bottom: 6px; }
.barcode-full .code { font-family: 'Geist Mono', monospace; font-size: 9.5px; color: #444; margin-top: 6px; letter-spacing: 0.05em; }
@media print {
  .barcode-full { min-width: 89mm; }
  .barcode-full svg { height: 15mm !important; }
}

/* Classic template */
.inv-classic .head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 22px; border-bottom: 1px solid #111; gap: 24px;
}
.inv-classic .head .meta { text-align: right; font-size: 11px; color: #555; line-height: 1.8; min-width: 160px; }
.inv-classic .head .meta h1 {
  font-family: 'Instrument Serif', serif; font-size: 28px; font-weight: 400;
  margin: 0 0 4px; letter-spacing: -0.012em; color: #111; line-height: 1;
}
.inv-classic .head .meta .num-id {
  font-family: 'Geist Mono', monospace; font-size: 12px; color: #111;
  margin-bottom: 8px;
}
.inv-classic .head .meta .row-l { white-space: nowrap; }
.inv-classic .head .meta .row-l .lab { color: #999; }
.inv-classic .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; padding: 22px 0; }
.inv-classic .table { width: 100%; margin-top: 4px; border-collapse: collapse; font-size: 11px; }
.inv-classic .table thead th {
  text-align: left; font-weight: 500; font-size: 10px; color: #888;
  padding: 8px 6px; border-bottom: 1px solid #ccc; white-space: nowrap;
}
.inv-classic .table thead th:first-child { padding-left: 0; }
.inv-classic .table thead th:last-child { padding-right: 0; }
.inv-classic .table tbody td { padding: 9px 6px; border-bottom: 1px solid #eee; vertical-align: top; }
.inv-classic .table tbody td:first-child { padding-left: 0; }
.inv-classic .table tbody td:last-child { padding-right: 0; }
.inv-classic .table .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-classic .totals-block { margin-left: auto; margin-top: 14px; min-width: 240px; font-size: 11px; }
.inv-classic .totals-block .r { display: flex; justify-content: space-between; padding: 4px 0; color: #555; gap: 16px; white-space: nowrap; }
.inv-classic .totals-block .r.grand { color: #111; border-top: 1px solid #111; padding-top: 8px; margin-top: 6px; font-size: 16px; font-weight: 500; }

/* Modern template */
.inv-modern .head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 22px; border-bottom: 1px solid #eaeaea; }
.inv-modern .head .right { text-align: right; }
.inv-modern .head .right .label { font-size: 10px; color: #999; letter-spacing: 0.04em; }
.inv-modern .head .right .num-big { font-family: 'Geist Mono', monospace; font-size: 26px; font-weight: 400; color: #111; line-height: 1.1; margin-top: 4px; }
.inv-modern .grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 18px; padding: 18px 0; border-bottom: 1px solid #eaeaea;
}
.inv-modern .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; padding: 22px 0; }
.inv-modern .table { width: 100%; margin-top: 4px; border-collapse: collapse; font-size: 11px; }
.inv-modern .table thead th {
  text-align: left; font-weight: 500; font-size: 10px; color: oklch(46% 0.062 155);
  padding: 10px 8px; background: oklch(96% 0.020 155); white-space: nowrap;
}
.inv-modern .table thead th:first-child { padding-left: 12px; }
.inv-modern .table tbody td { padding: 10px 8px; border-bottom: 1px solid #f3f3f0; vertical-align: top; }
.inv-modern .table tbody td:first-child { padding-left: 12px; }
.inv-modern .table .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-modern .totals-block {
  margin-left: auto; margin-top: 18px; min-width: 260px; font-size: 11px;
  background: oklch(96% 0.020 155); padding: 14px 18px; border-radius: 6px;
}
.inv-modern .totals-block .r { display: flex; justify-content: space-between; padding: 4px 0; color: #555; gap: 16px; white-space: nowrap; }
.inv-modern .totals-block .r.grand { color: #111; border-top: 1px solid oklch(46% 0.062 155); padding-top: 8px; margin-top: 6px; font-size: 16px; font-weight: 500; }

/* Compact template */
.inv-compact { font-size: 10.5px; }
.inv-compact .head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px; border-bottom: 1px solid #111; }
.inv-compact .head .right { text-align: right; font-size: 10px; color: #555; line-height: 1.6; }
.inv-compact .head .right .num-id { font-family: 'Geist Mono', monospace; font-size: 12px; color: #111; }
.inv-compact .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid #ddd; font-size: 10px; }
.inv-compact .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 14px 0; border-bottom: 1px solid #ddd; }
.inv-compact .table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 10px; }
.inv-compact .table thead th { text-align: left; font-weight: 500; font-size: 9.5px; color: #888; padding: 6px 4px; border-bottom: 1px solid #ddd; white-space: nowrap; }
.inv-compact .table thead th:first-child { padding-left: 0; }
.inv-compact .table thead th:last-child { padding-right: 0; }
.inv-compact .table tbody td { padding: 6px 4px; border-bottom: 1px solid #f1f1f1; vertical-align: top; }
.inv-compact .table tbody td:first-child { padding-left: 0; }
.inv-compact .table tbody td:last-child { padding-right: 0; }
.inv-compact .table .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-compact .totals-block { margin-left: auto; margin-top: 10px; min-width: 220px; font-size: 10px; }
.inv-compact .totals-block .r { display: flex; justify-content: space-between; padding: 2px 0; color: #555; gap: 16px; white-space: nowrap; }
.inv-compact .totals-block .r.grand { color: #111; border-top: 1px solid #111; padding-top: 5px; margin-top: 4px; font-size: 13px; font-weight: 500; }

/* Rootroo template — tabular invoice (Google-Sheets style) */
.inv-sheet { font-size: 11px; color: #111; }
.inv-sheet .sh-head {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 24px; align-items: start;
  padding-bottom: 16px;
}
.inv-sheet .sh-brand { display: flex; gap: 16px; align-items: flex-start; }
.inv-sheet .sh-addr { font-size: 10.5px; color: #555; line-height: 1.55; }
.inv-sheet .sh-title { text-align: right; }
.inv-sheet .sh-title-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.inv-sheet .sh-title h1 {
  font-family: 'Geist', sans-serif; font-weight: 700;
  font-size: 18px; letter-spacing: 0.02em; margin: 0; color: #111;
}
.inv-sheet .sh-page { font-size: 10.5px; color: #888; }
.inv-sheet .sh-kv {
  display: grid; grid-template-columns: auto 1fr;
  gap: 24px; padding: 3px 0; align-items: baseline;
}
.inv-sheet .sh-kv > span { font-size: 10.5px; color: #555; }
.inv-sheet .sh-kv > b { font-weight: 500; text-align: right; }
.inv-sheet .sh-pill {
  display: inline-block;
  font-size: 11px; min-width: 90px; text-align: right;
}

.inv-sheet .sh-bill {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  padding-bottom: 18px; border-bottom: 1px solid #ddd;
}
.inv-sheet .sh-bill-to {
  padding: 14px 16px;
  min-height: 100px;
  color: #111;
  border: 1px solid #ddd;
  border-radius: 2px;
}
.inv-sheet .sh-bill-to.empty { color: #999; }
.inv-sheet .sh-bill-to .sh-line { font-size: 11px; line-height: 1.6; }
.inv-sheet .sh-bill-to .sh-line.muted { color: #777; }
.inv-sheet .sh-terms { display: grid; grid-template-columns: auto 1fr; gap: 8px 24px; align-content: end; }
.inv-sheet .sh-terms > div { display: contents; }
.inv-sheet .sh-terms span { font-size: 10.5px; color: #555; }
.inv-sheet .sh-terms b { font-weight: 500; text-align: right; }

.inv-sheet .sh-table {
  width: 100%; margin-top: 24px; border-collapse: collapse;
  font-size: 11px;
}
.inv-sheet .sh-table thead th {
  text-align: left; font-weight: 600; font-size: 11px; color: #111;
  padding: 8px 6px; border-bottom: 1px solid #111;
  white-space: nowrap;
}
.inv-sheet .sh-table thead th:first-child { padding-left: 0; }
.inv-sheet .sh-table thead th:last-child  { padding-right: 0; }
.inv-sheet .sh-table tbody td { padding: 8px 6px; vertical-align: top; }
.inv-sheet .sh-table tbody td:first-child { padding-left: 0; }
.inv-sheet .sh-table tbody td:last-child  { padding-right: 0; }
.inv-sheet .sh-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.inv-sheet .sh-vatlines { margin-top: 18px; border-top: 1px solid #999; padding-top: 8px; }
.inv-sheet .sh-vatline { display: flex; justify-content: space-between; gap: 24px; font-size: 10.5px; color: #555; padding: 2px 0; }

.inv-sheet .sh-totals { margin: 18px 0 0 auto; min-width: 240px; font-size: 11px; }
.inv-sheet .sh-totals .r { display: flex; justify-content: space-between; padding: 4px 0; gap: 24px; }
.inv-sheet .sh-totals .r span { color: #111; font-weight: 500; }
.inv-sheet .sh-totals .r b { font-weight: 500; font-variant-numeric: tabular-nums; }
.inv-sheet .sh-totals .r.grand {
  border-top: 1px solid #111; padding-top: 6px; margin-top: 4px;
  text-decoration: underline;
}
.inv-sheet .sh-totals .r.grand span,
.inv-sheet .sh-totals .r.grand b { font-weight: 700; }

.inv-sheet .sh-foot {
  display: grid;
  grid-template-columns: 110px 160px 110px 1fr 1.1fr;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid #ddd;
  font-size: 10.5px;
}
.inv-sheet .sh-foot .sh-lbl { font-size: 9.5px; color: #888; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 2px; }
.inv-sheet .sh-foot .sh-val { font-size: 11px; color: #111; }
.inv-sheet .sh-foot .sh-val.hl { font-weight: 500; }
.inv-sheet .sh-contact { font-size: 9.5px; color: #555; line-height: 1.55; text-align: right; }

@media (max-width: 760px) {
  .inv-sheet .sh-head,
  .inv-sheet .sh-bill { grid-template-columns: 1fr; }
  .inv-sheet .sh-foot { grid-template-columns: 1fr 1fr; }
  .inv-sheet .sh-contact { text-align: left; }
}

/* ──────────────────────────────── Tilisiirto template — Finnish bank-giro form */
.inv-tilisiirto { font-family: 'Geist', sans-serif; font-size: 10.5px; color: #111; }
.inv-tilisiirto .mono { font-family: 'Geist Mono', monospace; font-variant-numeric: tabular-nums; }

/* Zone 1 — Header band */
.inv-tilisiirto .ts-head {
  display: grid; grid-template-columns: 1fr 320px;
  gap: 24px; padding-bottom: 14px;
  align-items: start;
}
.inv-tilisiirto .ts-head-logo { display: flex; align-items: flex-start; }
.inv-tilisiirto .ts-head-meta { text-align: right; }
.inv-tilisiirto .ts-head-meta h1 {
  font-family: 'Geist', sans-serif; font-weight: 700;
  font-size: 22px; letter-spacing: 0.04em; margin: 0 0 10px;
}
.inv-tilisiirto .ts-head-meta table {
  margin-left: auto; border-collapse: collapse; font-size: 10.5px;
}
.inv-tilisiirto .ts-head-meta td {
  padding: 2px 0 2px 16px; vertical-align: top; white-space: nowrap;
}
.inv-tilisiirto .ts-head-meta td:first-child { color: #555; }
.inv-tilisiirto .ts-head-meta td:last-child { text-align: right; color: #111; }

/* Zone 2 — Sender block */
.inv-tilisiirto .ts-sender {
  padding: 4px 0 16px;
  font-size: 11px; line-height: 1.55;
}
.inv-tilisiirto .ts-sender strong { font-weight: 600; display: block; margin-bottom: 2px; }

/* Zone 3 — Line items */
.inv-tilisiirto .ts-table {
  width: 100%; border-collapse: collapse; font-size: 10.5px; margin-top: 20px;
}
.inv-tilisiirto .ts-table thead th {
  text-align: left; font-weight: 600; font-size: 10px;
  padding: 8px 6px; border-bottom: 1px solid #111; white-space: nowrap;
}
.inv-tilisiirto .ts-table thead th:first-child { padding-left: 0; }
.inv-tilisiirto .ts-table thead th:last-child { padding-right: 0; }
.inv-tilisiirto .ts-table tbody td {
  padding: 7px 6px; vertical-align: top; border-bottom: 1px solid #eee;
}
.inv-tilisiirto .ts-table tbody td:first-child { padding-left: 0; }
.inv-tilisiirto .ts-table tbody td:last-child { padding-right: 0; }
.inv-tilisiirto .ts-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Zone 4 — Totals stack */
.inv-tilisiirto .ts-totals {
  margin: 14px 0 0 auto; min-width: 260px; font-size: 11px;
}
.inv-tilisiirto .ts-totals .r {
  display: flex; justify-content: space-between; padding: 3px 0;
  gap: 24px; color: #333;
}
.inv-tilisiirto .ts-totals .r span:last-child { font-variant-numeric: tabular-nums; color: #111; }
.inv-tilisiirto .ts-totals .r.grand {
  border-top: 1px solid #111; padding-top: 8px; margin-top: 6px;
  font-size: 13px; font-weight: 700; color: #111;
}

.inv-tilisiirto .ts-notes {
  margin-top: 14px; font-size: 10px; color: #555; max-width: 65%;
}

/* Zone 5 — 3-column company footer band */
.inv-tilisiirto .ts-footband {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px;
  border-top: 1px solid #ddd; padding-top: 10px; margin-top: 14px;
  font-size: 9.5px; line-height: 1.6; color: #555;
}
.inv-tilisiirto .ts-footband .right { text-align: right; }

/* Mid-bottom barcode caption (the readable digit string) */
.inv-tilisiirto .ts-bcline {
  margin-top: 8px; font-size: 9px; color: #555;
}
.inv-tilisiirto .ts-bcline .mono {
  word-break: break-all; letter-spacing: 0.02em;
}

/* Zone 6 — Tilisiirto / Girering giro slip */
.inv-tilisiirto .ts-giro {
  margin-top: 12px;
  border: 1px solid #111;
  position: relative;
  display: flex; flex-direction: column;
}
.inv-tilisiirto .ts-giro-edge {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 16px;
  border-right: 1px solid #111;
  background: #fafafa;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 8.5px; font-weight: 600;
  letter-spacing: 0.18em;
  color: #111;
  display: flex; align-items: center; justify-content: center;
  padding: 6px 0;
  text-align: center;
}
.inv-tilisiirto .ts-giro-grid {
  margin-left: 16px;
  display: grid;
  grid-template-columns: 130px 1fr 140px 100px;
  grid-template-rows: auto auto auto auto auto;
  grid-template-areas:
    "k-iban  v-iban  v-bic   v-qr"
    "k-saaja v-saaja v-saaja v-qr"
    "k-maks  v-maks  v-maks  v-qr"
    "k-sign  v-sign  v-ref   v-ref"
    "k-due   v-due   v-eur   v-eur";
}
.inv-tilisiirto .ts-giro-key {
  padding: 6px 8px;
  font-size: 7.5px; line-height: 1.25;
  color: #111;
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #eee;
}
.inv-tilisiirto .ts-giro-key .sv { color: #777; font-style: italic; }
.inv-tilisiirto .ts-giro-val {
  padding: 6px 10px;
  font-size: 10.5px; line-height: 1.45;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
  min-height: 28px;
}

/* place each named cell */
.inv-tilisiirto .g-k-iban  { grid-area: k-iban; }
.inv-tilisiirto .g-k-saaja { grid-area: k-saaja; }
.inv-tilisiirto .g-k-maks  { grid-area: k-maks; }
.inv-tilisiirto .g-k-sign  { grid-area: k-sign; }
.inv-tilisiirto .g-k-due   { grid-area: k-due; }
.inv-tilisiirto .g-v-iban  { grid-area: v-iban; font-size: 12px; }
.inv-tilisiirto .g-v-bic   { grid-area: v-bic; }
.inv-tilisiirto .g-v-bic .ts-giro-lbl {
  font-size: 7.5px; color: #555; margin-bottom: 2px;
}
.inv-tilisiirto .g-v-qr {
  grid-area: v-qr;
  padding: 8px;
  display: flex; align-items: center; justify-content: center;
}
.inv-tilisiirto .g-v-qr svg { width: 100%; max-width: 88px; height: 88px; display: block; }

.inv-tilisiirto .g-v-saaja { grid-area: v-saaja; }
.inv-tilisiirto .g-v-maks  { grid-area: v-maks; }

.inv-tilisiirto .g-v-sign {
  grid-area: v-sign;
  border-bottom: 1px solid #111;
  margin: 12px 12px;
  min-height: 22px;
  border-right: 0;
}
.inv-tilisiirto .g-v-ref {
  grid-area: v-ref;
  padding: 8px 10px;
  display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center;
}
.inv-tilisiirto .g-v-ref .mono {
  text-align: right; font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}

.inv-tilisiirto .g-v-due {
  grid-area: v-due;
  display: flex; align-items: center; padding: 8px 10px;
}
.inv-tilisiirto .g-v-eur {
  grid-area: v-eur;
  padding: 8px 10px;
  display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center;
  border-top: 1px solid #111;
}
.inv-tilisiirto .g-v-eur .mono {
  text-align: right; font-size: 14px; font-weight: 700;
}

/* Inline keys (nested in v-ref / v-eur) — strip borders/padding */
.inv-tilisiirto .ts-giro-inline-key {
  font-size: 7.5px; line-height: 1.25; color: #111;
}
.inv-tilisiirto .ts-giro-inline-key .sv { color: #777; font-style: italic; }

/* Full-width Code 128 barcode under the giro grid */
.inv-tilisiirto .ts-giro-barcode {
  margin-left: 16px;
  padding: 10px 12px 6px;
  border-top: 1px solid #111;
  min-width: 89mm;
}
.inv-tilisiirto .ts-giro-barcode svg { min-height: 13mm; height: 60px; display: block; }

/* Bottom-right "PANKKI · BANKEN" + bilingual legal text */
.inv-tilisiirto .ts-giro-foot {
  margin-left: 16px;
  padding: 6px 12px 8px;
  border-top: 1px solid #ddd;
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  font-size: 7.5px; color: #555;
}
.inv-tilisiirto .ts-giro-foot-txt {
  flex: 1; text-align: right; line-height: 1.4;
}
.inv-tilisiirto .ts-giro-foot > span:first-child {
  font-weight: 700; letter-spacing: 0.06em; color: #111;
  white-space: nowrap;
}

@media print {
  .inv-tilisiirto .ts-giro-barcode { min-width: 89mm; }
  .inv-tilisiirto .ts-giro-barcode svg { height: 15mm !important; }
}

/* ──────────────────────────────── Logo upload */
.logo-upload {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo-preview {
  width: 64px; height: 64px;
  border-radius: var(--r-sm);
  background: var(--field);
  border: 1px dashed var(--hair);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-preview .ph {
  font-size: 11px; color: var(--muted-2); font-weight: 500;
}
.logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.logo-actions .file-btn {
  position: relative; overflow: hidden; white-space: nowrap;
}
.logo-actions .file-btn input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

/* ──────────────────────────────── Bill-to summary card (in create) */
.from-summary {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--hair-soft);
  border-radius: var(--r-sm);
}
.from-summary .from-logo {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--ink); color: var(--paper);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Geist', sans-serif; font-weight: 600; font-size: 18px;
  flex-shrink: 0; overflow: hidden;
}
.from-summary .from-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; background: white; }
.from-summary .from-body { flex: 1; min-width: 0; }
.from-summary .from-body .name { font-weight: 500; font-size: 15px; }
.from-summary .from-body .meta {
  color: var(--muted); font-size: 13px; margin-top: 3px; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.from-summary .edit { color: var(--moss); font-size: 13.5px; font-weight: 500; cursor: pointer; flex-shrink: 0; white-space: nowrap; align-self: flex-start; }
.from-summary .edit:hover { color: var(--moss-2); }

/* From-summary as a clickable button (profile switcher trigger) */
.from-summary.as-button {
  appearance: none;
  border: 1px solid var(--hair-soft);
  background: var(--surface-2);
  font: inherit; color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.from-summary.as-button:hover { border-color: var(--hair); background: var(--surface); }
.from-summary.as-button.open { border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.from-summary .switch-caret { color: var(--muted-2); font-size: 12px; margin-left: 4px; }

/* Profile switcher popover */
.profile-switcher { position: relative; }
.profile-pop {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 24px 50px -20px rgba(28,26,18,.30);
  padding: 8px;
  z-index: 40;
  display: flex; flex-direction: column;
  animation: rm-in .12s ease;
}
.profile-pop-head {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  padding: 6px 10px 8px;
  font-weight: 500;
}
.profile-pop-item {
  appearance: none; border: 0; background: transparent;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--ink);
  width: 100%;
}
.profile-pop-item:hover { background: rgba(0,0,0,.04); }
.profile-pop-item.on { background: var(--moss-tint); }
.profile-pop-item.action { color: var(--moss); }
.profile-pop-name { flex: 1; min-width: 0; }
.profile-pop-name .primary { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-pop-name .secondary { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.profile-pop-check { color: var(--moss); font-size: 14px; flex-shrink: 0; }
.profile-pop .sep { height: 1px; background: var(--hair-soft); margin: 6px 4px; }

.profile-chip-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.profile-chip-logo.sm { width: 28px; height: 28px; font-size: 13px; border-radius: 6px; }
.profile-chip-logo img { width: 100%; height: 100%; object-fit: contain; background: white; padding: 3px; }
.profile-chip-logo.plus { background: transparent; color: var(--moss); border: 1px dashed var(--hair); font-size: 16px; }

/* Profile strip on Settings */
.profiles-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
}
.profile-chip {
  appearance: none;
  border: 1px solid var(--hair);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.profile-chip:hover { border-color: var(--muted-2); }
.profile-chip.on { border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.profile-chip.add { color: var(--moss); border-style: dashed; }
.profile-chip .profile-chip-logo { width: 26px; height: 26px; font-size: 12px; border-radius: 6px; }
.profile-chip-name { font-size: 13.5px; font-weight: 500; }

.btn.link.danger { color: var(--warn); }
.btn.link.danger:hover { color: var(--warn); opacity: .8; }

/* Client typeahead */
.client-picker { position: relative; }
.client-pop {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 24px 50px -20px rgba(28,26,18,.30);
  padding: 6px;
  z-index: 50;
  display: flex; flex-direction: column;
  max-height: 320px; overflow-y: auto;
  animation: rm-in .12s ease;
}
.client-pop-head {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  padding: 6px 10px 6px;
  font-weight: 500;
}
.client-pop-item {
  appearance: none; border: 0; background: transparent;
  text-align: left;
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.client-pop-item.hi, .client-pop-item:hover { background: rgba(0,0,0,.05); }
.client-pop-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-pop-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ──────────────────────────────── Print */
@media print {
  body { background: white; }
  .topbar, .action-bar, .side-controls, .no-print, .twk-panel { display: none !important; }
  .preview-wrap { display: block; }
  .paper-sheet { box-shadow: none; border: 0; aspect-ratio: auto; border-radius: 0; }
  .page { padding: 0; max-width: none; }
}

/* ──────────────────────────────── Toast */
.toast-host {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.005em;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-action {
  appearance: none; border: 0; background: rgba(255,255,255,.15);
  color: var(--paper); font: inherit; font-weight: 500;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  transition: background .12s;
}
.toast-action:hover { background: rgba(255,255,255,.25); }

/* Mini section separator */
.divider {
  height: 1px;
  background: var(--hair);
  margin: 24px 0;
}

/* ──────────────────────────────── FAQ */
.faq {
  margin: 56px 0 24px;
  max-width: 760px;
}
.faq-title {
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: 30px;
  letter-spacing: -0.012em;
  margin: 0 0 18px;
  color: var(--ink);
}
.faq-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hair);
}
.faq-item {
  border-bottom: 1px solid var(--hair);
}
.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 36px 18px 2px;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  position: relative;
  transition: color .12s;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  font-weight: 300;
  color: var(--muted);
  transition: transform .18s, color .12s;
  line-height: 1;
}
.faq-item[open] summary::after {
  content: '−';
  color: var(--moss);
}
.faq-item summary:hover { color: var(--moss); }
.faq-item p {
  margin: 0;
  padding: 0 2px 20px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 68ch;
  text-wrap: pretty;
}

/* ──────────────────────────────── Footer */
.footer {
  border-top: 1px solid var(--hair);
  background: var(--surface-2);
  padding: 32px 28px 40px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.footer-brand .serif {
  font-family: 'Instrument Serif', serif;
  font-size: 19px;
  color: var(--ink);
  line-height: 1;
}
.footer-brand .mark-sm {
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--ink); color: var(--paper);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.dot-sep { color: var(--muted-2); }
.footer-disclaimer {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 78ch;
  text-wrap: pretty;
}
.footer-disclaimer strong { color: var(--ink-2); font-weight: 600; }
.footer-disclaimer .btn.link { font-size: 12.5px; }
.footer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted-2);
  padding-top: 10px;
  border-top: 1px solid var(--hair-soft);
}
.footer-link {
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1px solid var(--hair);
  transition: border-color .12s, color .12s;
}
.footer-link:hover { color: var(--moss); border-bottom-color: var(--moss); }
.footer-by {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  transition: color .12s, opacity .12s;
  opacity: .85;
}
.footer-by img {
  height: 16px;
  width: auto;
  display: block;
  opacity: .85;
  transition: opacity .12s;
}
.footer-by:hover { color: var(--ink); opacity: 1; }
.footer-by:hover img { opacity: 1; }
