/* ==========================================================================
   Invoice Generator — style.css
   Vanilla CSS, no framework, no build step.
   Editor UI supports light/dark. The printed invoice paper is always light.
   ========================================================================== */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #2563eb;
  --danger: #dc2626;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 8px 24px rgba(17, 24, 39, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f24;
  --surface-2: #23262c;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #2f333a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App bar ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-bar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}

.app-bar__logo {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
}

.app-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn--sm { padding: 6px 10px; font-size: 13px; }
.btn--icon { padding: 8px 10px; line-height: 1; }
.btn--ghost-danger { border-color: transparent; color: var(--danger); background: transparent; }
.btn--ghost-danger:hover { background: rgba(220, 38, 38, .1); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(380px, 500px) 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  padding-right: 4px;
}

/* ---------- First-run setup cue ---------- */
/* Shown only until a company default is saved, because "Your company" lives
   in the collapsed Setup group and would otherwise be easy to miss. */
.setup-cue {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  padding: 12px 14px;
  border: 1px solid var(--border);    /* fallbacks for engines without color-mix() */
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  transition: background .12s, border-color .12s;
}
.setup-cue:hover { background: var(--surface); background: color-mix(in srgb, var(--accent) 13%, var(--surface)); }
.setup-cue__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
}
.setup-cue__text { display: flex; flex-direction: column; min-width: 0; }
.setup-cue__text b { font-size: 13.5px; }
.setup-cue__text small { color: var(--muted); font-size: 12px; }
.setup-cue__arrow { margin-left: auto; flex: none; color: var(--accent); font-size: 16px; }

/* ---------- Editor group heading ---------- */
.editor__group {
  flex: none;
  margin: 8px 0 -4px 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  opacity: .75;
}
.editor__group:first-child { margin-top: 0; }

/* ---------- Panels ---------- */
.panel {
  flex: none;               /* never let the scroll container compress panels */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  user-select: none;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "+"; float: right; font-size: 15px; }
.panel[open] > summary::after { content: "\2212"; }
.panel__body { padding: 4px 14px 16px; }

/* ---------- Fields ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field--full { grid-column: 1 / -1; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field--check {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field--check > span { color: var(--text); font-weight: 500; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);   /* fallback for engines without color-mix() */
  outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}
input[type="color"] { padding: 4px; height: 38px; }
input[type="file"] { padding: 6px; background: transparent; border-style: dashed; }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }

.input-row { display: flex; gap: 6px; }
.input-row select { width: 90px; flex: none; }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* ---------- Saved list ---------- */
.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.saved-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.saved-list__meta { display: flex; flex-direction: column; min-width: 0; }
.saved-list__meta b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-list__meta small { color: var(--muted); font-size: 11px; }
.saved-list__btns { display: flex; gap: 4px; flex: none; }
.saved-list__empty { color: var(--muted); font-size: 13px; padding: 4px 0; }

/* ---------- Line items editor ---------- */
.items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

.item-head,
.item-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 58px 78px minmax(84px, auto) 22px 26px;
  gap: 6px;
  align-items: center;
}
.item-head {
  padding: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.item-head span:nth-child(3),
.item-head span:nth-child(4),
.item-head span:nth-child(5) { text-align: right; }

.item-row { border-radius: var(--radius-sm); }
.item-row textarea {
  min-height: 36px;
  height: 36px;
  padding: 8px 10px;
  resize: vertical;
}
.item-row input { text-align: right; }
.item-row input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.item-row input[type="number"]::-webkit-outer-spin-button,
.item-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.item-row__grip {
  cursor: grab;
  text-align: center;
  line-height: 1;
  font-size: 13px;
  letter-spacing: -3px;
  color: var(--muted);
  opacity: .5;
  user-select: none;
}
.item-row__grip:active { cursor: grabbing; }
.item-row:hover .item-row__grip { opacity: 1; }
.item-row__amount {
  text-align: right;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
.item-row__grip { touch-action: none; }
.items.is-sorting { user-select: none; }
.item-row.is-dragging {
  opacity: .9;
  box-shadow: 0 0 0 2px var(--accent), 0 6px 16px rgba(0, 0, 0, .18);
  background: var(--surface);
}

/* Flash a field that was reached by clicking the preview */
@keyframes fieldFlash {
  from { box-shadow: 0 0 0 3px var(--accent); }
  to   { box-shadow: 0 0 0 3px transparent; }
}
.is-flash { animation: fieldFlash .9s ease-out; }

/* ---------- Preview ---------- */
.preview-wrap {
  display: flex;
  justify-content: center;
  padding-bottom: 40px;
}

.invoice-paper {
  background: #fff;
  color: #14181f;
  width: 100%;
  max-width: 794px;          /* ~A4 @ 96dpi */
  min-height: 1123px;
  padding: 56px 56px 48px;
  box-shadow: var(--shadow);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.55;
}
.invoice-paper[dir="rtl"] { direction: rtl; }

/* In an RTL invoice, resolve each block of user text from its own first strong
   character. Arabic/Hebrew content reads right-to-left; Latin content keeps its
   punctuation in place ("Acme Ltd." instead of ".Acme Ltd") while the block
   itself stays aligned with the rest of the document. */
.invoice-paper[dir="rtl"] .inv-parties p,
.invoice-paper[dir="rtl"] .inv-foot p,
.invoice-paper[dir="rtl"] .inv-sign__space,
.invoice-paper[dir="rtl"] .inv-head__meta div { unicode-bidi: plaintext; text-align: right; }
.invoice-paper[dir="rtl"] .inv-table td.desc { unicode-bidi: plaintext; text-align: right; }
.invoice-paper[dir="rtl"] .inv-summary td:first-child { unicode-bidi: plaintext; text-align: right; }

/* Amounts are always Latin: keep the currency symbol and the minus sign where
   they belong ("−$188.00", never "$188.00−") while staying mirror-aligned. */
.invoice-paper[dir="rtl"] .inv-table td.num,
.invoice-paper[dir="rtl"] .inv-summary td:last-child {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

/* Clicking a region of the invoice jumps to its field in the editor */
.invoice-paper [data-edit],
.invoice-paper [data-edit-item] {
  cursor: pointer;
  border-radius: 4px;
  transition: background .12s, box-shadow .12s;
}
.invoice-paper [data-edit]:hover,
.invoice-paper tr[data-edit-item]:hover td {
  background: #eef2ff;                /* fallback for engines without color-mix() */
  background: color-mix(in srgb, var(--accent, #2563eb) 9%, transparent);
}
.invoice-paper [data-edit]:hover {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #2563eb) 9%, transparent);
}

.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  border-bottom: 3px solid var(--accent, #2563eb);
  padding-bottom: 20px;
}
.inv-head__logo { max-height: 72px; max-width: 220px; object-fit: contain; }
.inv-head__title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--accent, #2563eb);
  margin: 0;
  text-transform: uppercase;
}
.inv-head__meta { text-align: right; font-size: 12.5px; }
.invoice-paper[dir="rtl"] .inv-head__meta { text-align: left; }
.inv-head__meta div { margin-top: 2px; }
.inv-head__meta b { color: #14181f; }

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 26px 0 10px;
}
.inv-parties h4 {
  margin: 0 0 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8a919e;
}
.inv-parties p { margin: 0; white-space: pre-line; }
.inv-parties .name { font-weight: 700; font-size: 14px; }

table.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0 0;
}
.inv-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #fff;
  background: var(--accent, #2563eb);
  padding: 9px 10px;
}
.inv-table th.num, .inv-table td.num { text-align: right; }
.invoice-paper[dir="rtl"] .inv-table th { text-align: right; }
.invoice-paper[dir="rtl"] .inv-table th.num,
.invoice-paper[dir="rtl"] .inv-table td.num { text-align: left; }
.inv-table td { padding: 10px; border-bottom: 1px solid #e8eaee; vertical-align: top; }
.inv-table tr:nth-child(even) td { background: #fafbfc; }
.inv-table .desc { white-space: pre-line; }

.inv-summary {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}
.invoice-paper[dir="rtl"] .inv-summary { justify-content: flex-start; }
.inv-summary table { border-collapse: collapse; min-width: 280px; }
.inv-summary td { padding: 6px 10px; }
.inv-summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-paper[dir="rtl"] .inv-summary td:last-child { text-align: left; }
.inv-summary .grand td {
  border-top: 2px solid var(--accent, #2563eb);
  font-size: 15px;
  font-weight: 800;
  padding-top: 10px;
}
.inv-summary .muted td { color: #6b7280; }

.inv-foot { margin-top: 40px; display: grid; gap: 16px; }
.inv-foot h4 {
  margin: 0 0 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8a919e;
}
.inv-foot p { margin: 0; white-space: pre-line; color: #3f4650; }
.inv-foot__thanks { margin-top: 8px; font-weight: 600; }

/* ---------- Signature / stamp area ---------- */
.inv-sign {
  width: 250px;
  margin-top: 26px;
  margin-left: auto;
}
.invoice-paper[dir="rtl"] .inv-sign { margin-left: 0; margin-right: auto; }
.inv-sign__space {
  min-height: 46px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
  border-bottom: 1.5px solid #14181f;
  font-size: 18px;
  font-style: italic;
  color: #2b323c;
}
.inv-sign__label {
  margin-top: 6px;
  text-align: center;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8a919e;
}

/* ==========================================================================
   Invoice templates — the base rules above are the "Modern" look.
   ========================================================================== */

/* ---------- Classic: monochrome, serif, ruled table ---------- */
.invoice-paper.tpl-classic {
  font-family: Georgia, "Times New Roman", Times, serif;
}
.tpl-classic .inv-head {
  border-bottom: 1px solid #14181f;
}
.tpl-classic .inv-head__title {
  color: #14181f;
  letter-spacing: .14em;
  font-weight: 700;
}
.tpl-classic .inv-table th {
  background: transparent;
  color: #14181f;
  border-top: 2px solid #14181f;
  border-bottom: 2px solid #14181f;
  font-weight: 700;
}
.tpl-classic .inv-table tr:nth-child(even) td { background: transparent; }
.tpl-classic .inv-table td { border-bottom: 1px solid #d7dbe0; }
.tpl-classic .inv-summary .grand td { border-top-color: #14181f; }
.tpl-classic .inv-parties h4,
.tpl-classic .inv-foot h4,
.tpl-classic .inv-sign__label { color: #14181f; }

/* ---------- Compact: tighter, fits more lines on one page ---------- */
.invoice-paper.tpl-compact {
  padding: 36px 40px 32px;
  font-size: 12px;
}
.tpl-compact .inv-head { padding-bottom: 14px; border-bottom-width: 2px; }
.tpl-compact .inv-head__title { font-size: 23px; }
.tpl-compact .inv-head__logo { max-height: 56px; }
.tpl-compact .inv-parties { margin: 16px 0 6px; gap: 20px; }
.tpl-compact .inv-parties .name { font-size: 13px; }
.tpl-compact .inv-table { margin-top: 14px; }
.tpl-compact .inv-table th { padding: 6px 8px; }
.tpl-compact .inv-table td { padding: 6px 8px; }
.tpl-compact .inv-summary { margin-top: 10px; }
.tpl-compact .inv-summary td { padding: 4px 8px; }
.tpl-compact .inv-summary .grand td { font-size: 14px; }
.tpl-compact .inv-foot { margin-top: 24px; gap: 12px; }
.tpl-compact .inv-sign { margin-top: 16px; }

/* ---------- Display toggles ---------- */
.invoice-paper.no-zebra .inv-table tr:nth-child(even) td { background: transparent; }
.inv-parties.one { grid-template-columns: 1fr; }

.paid-stamp {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 14px;
  border: 2px solid #16a34a;
  color: #16a34a;
  font-weight: 800;
  letter-spacing: .1em;
  border-radius: 6px;
  transform: rotate(-4deg);
}

/* ---------- Button row ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 13, 18, .55);
}
.modal__box {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  padding: 22px 24px;
  max-width: 460px;
  width: 100%;
}
.modal__box h3 { margin: 0 0 10px; font-size: 17px; }
.modal__box p { margin: 0 0 10px; color: var(--muted); }
.modal__box ol { margin: 0 0 14px; padding-left: 20px; color: var(--text); }
.modal__box ol li { margin-bottom: 3px; }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #14181f;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .editor { position: static; max-height: none; overflow: visible; }
  .invoice-paper { min-height: 0; padding: 32px; }
}
@media (max-width: 560px) {
  /* The 6-column line-item grid collapses below ~560px: the description would
     be squeezed to a few characters. Reflow into two lines instead. */
  .item-head { display: none; }
  .item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
  }
  .item-row__grip { order: 1; flex: 0 0 16px; }
  .item-row > textarea { order: 2; flex: 1 1 120px; min-width: 0; }
  .item-row__more { order: 3; flex: 0 0 24px; }
  .item-row > .btn--ghost-danger { order: 4; flex: 0 0 30px; }
  /* Forced flex line break: description on top, the numbers underneath. */
  .item-row::after { content: ""; order: 5; flex: 1 0 100%; height: 0; }
  .item-row > input { order: 6; flex: 1 1 70px; min-width: 0; text-align: left; }
  .item-row__amount { order: 7; flex: 1 1 80px; text-align: right; }
  .item-adv { grid-template-columns: 1fr; padding-left: 10px; }
}

@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-bar { flex-direction: column; align-items: stretch; }
  .invoice-paper { padding: 22px; }
  .inv-head { flex-direction: column; }
  .inv-head__meta, .invoice-paper[dir="rtl"] .inv-head__meta { text-align: left; }
  .inv-parties { grid-template-columns: 1fr; }
}

/* ---------- Print ---------- */
@media print {
  .no-print { display: none !important; }
  .invoice-paper [data-edit],
  .invoice-paper [data-edit-item] { cursor: auto; background: none !important; box-shadow: none !important; }
  html, body { background: #fff; }
  .layout { display: block; padding: 0; margin: 0; max-width: none; }
  .preview-wrap { padding: 0; display: block; }
  .invoice-paper {
    box-shadow: none;
    border-radius: 0;
    max-width: none;
    width: auto;
    min-height: 0;
    padding: 0;
  }
  @page { size: A4; margin: 16mm; }
}

/* ---------- Line-item advanced (unit / per-line discount & tax) ---------- */
.item-row__more {
  appearance: none;
  border: 0; background: transparent;
  color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1;
  border-radius: var(--radius-sm);
  padding: 4px 0;
  position: relative;
}
.item-row__more:hover { color: var(--text); background: var(--surface-2); }
.item-row--adv-open .item-row__more { color: var(--accent); }
.item-row__more.has-override::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

.item-adv {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 10px 10px 28px;
  margin: -2px 0 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.item-adv label { display: flex; flex-direction: column; gap: 3px; }
.item-adv label > span { font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.item-adv input, .item-adv select { padding: 6px 8px; font-size: 13px; }
.item-adv input { text-align: left; }
.item-adv__pair { display: grid; grid-template-columns: 1fr 58px; gap: 4px; }

@media (max-width: 700px) {
  .item-adv { grid-template-columns: 1fr; }
}

/* ---------- Preview: per-line notes ---------- */
.inv-line-note {
  display: block;
  font-size: 10px;
  color: #8a919e;
  margin-top: 1px;
}

/* ---------- Sanity warnings above the preview ---------- */
.modal__box #printWarnings {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 13px;
}
[data-theme="dark"] .modal__box #printWarnings {
  background: rgba(234, 88, 12, .12);
  border-color: rgba(234, 88, 12, .35);
  color: #fdba74;
}
.modal__box #printWarnings .pw-title { margin: 0 0 4px; font-weight: 700; color: inherit; }
.modal__box #printWarnings ul { margin: 0; padding-left: 18px; }
.modal__box #printWarnings li { margin: 2px 0; }

/* ---------- Segmented control (matches the image tool) ---------- */
.seg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg-row button {
  appearance: none;
  flex: 1 1 auto;
  min-width: 54px;
  padding: 7px 8px;
  border: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.seg-row button:hover { color: var(--text); }
.seg-row button.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(17, 24, 39, .12);
}
[data-theme="dark"] .seg-row button.is-active { background: #2a2f3a; }

/* ---------- Help modal ---------- */
.modal__box--wide { max-width: 620px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal__head h3 { margin: 0; }
.modal__lead { color: var(--muted); margin: 0 0 6px; }
.modal__scroll { max-height: 64vh; overflow-y: auto; padding-right: 4px; }
.modal__scroll h4 {
  margin: 16px 0 4px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.modal__scroll p { margin: 4px 0; color: var(--text); }
.modal__scroll b { color: var(--text); }

/* ---------- Backup buttons in the Saved panel ---------- */
.saved-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* iOS-style on/off switch — restyles the native checkbox, no markup change */
.field--check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 40px; height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  position: relative; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.field--check input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s;
}
.field--check input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.field--check input[type="checkbox"]:checked::before { transform: translateX(16px); }
.field--check input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-theme="dark"] .field--check input[type="checkbox"]::before { background: #e8eaed; }

