/* Applecado Documents — clean & modern, light-touch Applecado branding.
   Use the tokens below; don't hard-code colours elsewhere. Lora is for headings/brand only. */

:root {
  --green: #2EB872;
  --green-ink: #1f8f56;
  --leaf: #ADE58F;
  --leaf-soft: #e9f7df;
  --cream: #F8F5EB;
  --coral: #FF5D6E;
  --ink: #1E1E1E;
  --ink-2: #5b5b57;
  --ink-3: #8c8b85;
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --line: #ebe8df;
  --line-strong: #dcd8cc;
  --shadow: 0 1px 2px rgba(30, 30, 30, .06), 0 8px 24px rgba(30, 30, 30, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Lora, Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --green: #3ccb83;
    --green-ink: #6ee0a5;
    --leaf: #4f7a3a;
    --leaf-soft: #1f2a1c;
    --cream: #121412;
    --coral: #ff7584;
    --ink: #ecebe6;
    --ink-2: #b4b2aa;
    --ink-3: #7f7d76;
    --surface: #1a1c1a;
    --surface-2: #1e211e;
    --line: #2a2d2a;
    --line-strong: #383c38;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green-ink); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 14px var(--font); text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-ink); border-color: var(--green-ink); }
@media (prefers-color-scheme: dark) { .btn-primary, .btn-primary:hover { color: #0c1a12; } }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--leaf-soft); border-color: transparent; }
.btn-icon { width: 36px; padding: 0; font-size: 20px; line-height: 1; }
.btn-block { width: 100%; height: 44px; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--coral); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--coral) 10%, transparent); border-color: transparent; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=color], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 38px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent);
}
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); }
label > input, label > select, label > textarea, label > .dt { margin-top: 6px; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; color: var(--ink); cursor: pointer; }
label.check input { width: 16px; height: 16px; accent-color: var(--green); margin: 0; }
.stack > * + * { margin-top: 14px; }
.alert {
  background: color-mix(in srgb, var(--coral) 12%, var(--surface)); color: var(--ink);
  border-left: 4px solid var(--coral); padding: 10px 14px; border-radius: var(--radius-sm); margin: 0 0 16px;
}
.field-error { display: block; color: var(--coral); font-weight: 500; margin-top: 4px; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); font-weight: 500;
  animation: toast-out .4s ease 3.5s forwards;
}
.toast.is-gone { opacity: 0; pointer-events: none; }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 8px); visibility: hidden; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 40px;
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.logo { display: block; width: auto; }
.brand .logo { height: 30px; }
.brand .logo-small { display: none; }
.brand-sub {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--green-ink); background: var(--leaf-soft); padding: 3px 7px; border-radius: 999px;
}
.topbar-centre { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: var(--leaf); color: #1E1E1E;
}
.menu-panel {
  position: absolute; right: 0; top: 46px; width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.menu-panel a, .menu-panel .linkish {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-size: 14px;
}
.menu-panel a:hover, .menu-panel .linkish:hover { background: var(--leaf-soft); }
.menu-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-who span { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }

/* ---------- forms / panels ---------- */
.panel { max-width: 860px; margin: 32px auto 64px; padding: 0 40px; }
.panel-wide { max-width: 1240px; }
.panel-head { margin-bottom: 18px; }
.panel-head h1 { font-size: 30px; margin-top: 6px; }
.panel-head p { margin: 6px 0 0; }
.back { font-size: 14px; text-decoration: none; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 19px; margin-bottom: 12px; }

.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.field legend, .field .label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.field-title input {
  font-family: var(--serif); font-size: 24px; font-weight: 600; border: 0; border-bottom: 2px solid var(--line);
  border-radius: 0; padding: 4px 0 8px; background: transparent; box-shadow: none !important;
}
.field-title input:focus { border-bottom-color: var(--green); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; font-size: 14px; color: var(--ink); }
.switch input { position: absolute; opacity: 0; }
.switch-track { width: 40px; height: 23px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .2s; flex-shrink: 0; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--green); outline-offset: 2px; }

.form-actions { display: flex; gap: 8px; padding-top: 4px; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 16px; }
.danger-zone .muted { margin-left: auto; }

/* tables (users, types) */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 0 12px 8px; }
.table td { padding: 13px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table td.actions { text-align: right; white-space: nowrap; }
.table input[type=text], .table input[type=email] { min-height: 34px; padding: 6px 8px; }
.table input[type=color] { width: 44px; padding: 2px; min-height: 34px; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--leaf-soft); color: var(--green-ink); }
.inline-form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.blob { position: fixed; border-radius: 50%; z-index: 0; pointer-events: none; }
.blob-a { width: 70vmax; height: 70vmax; left: -25vmax; top: -30vmax; background: var(--leaf); opacity: .55; border-radius: 42% 58% 60% 40% / 45% 45% 55% 55%; }
.blob-b { width: 50vmax; height: 50vmax; right: -20vmax; bottom: -25vmax; background: var(--leaf-soft); border-radius: 58% 42% 40% 60% / 55% 50% 50% 45%; }
@media (prefers-color-scheme: dark) { .blob-a { opacity: .25; } }
.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px;
  background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.auth-brand { margin-bottom: 22px; }
.auth-brand .logo { height: 44px; }
.auth-card h1 { font-size: 26px; }
.auth-card .muted { margin: 4px 0 20px; }


/* ---------- documents app ---------- */
input[type=search] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 38px; width: 100%;
}
input[type=search]:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }

.topnav { display: flex; gap: 2px; margin-left: 12px; }
.topnav a {
  padding: 7px 12px; border-radius: var(--radius-sm); text-decoration: none;
  font-weight: 600; font-size: 14px; color: var(--ink-2);
}
.topnav a:hover { background: var(--leaf-soft); color: var(--ink); }
.topnav a[aria-current=page] { background: var(--leaf-soft); color: var(--green-ink); }

.page { max-width: 1480px; margin: 32px auto 64px; padding: 0 40px; }
.page-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 30px; }
.section-head { margin: 28px 0 12px; }
.section-head h2 { font-size: 21px; }
.btn span[aria-hidden] { font-size: 18px; line-height: 1; }

.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  text-decoration: none; font-weight: 600; font-size: 13px;
}
.tabs a span { font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tabs a:hover { border-color: var(--ink-3); color: var(--ink); }
.tabs a[aria-current=page] { background: var(--green); border-color: var(--green); color: #fff; }
.tabs a[aria-current=page] span { color: rgba(255, 255, 255, .8); }
.search { width: 360px; max-width: 100%; }

.card-flush { padding: 6px 0; }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: 26px; }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: 26px; }
.card-flush .table th { padding-top: 14px; }
.table-links tbody tr:hover { background: var(--surface-2); }
.table-links a { color: var(--ink); text-decoration: none; }
.table-links a:hover { color: var(--green-ink); }
.table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; width: 1%; }
.row-title { font-weight: 600; }
.row-sub { display: block; font-size: 13px; color: var(--ink-3); margin-top: 1px; }

.status {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-strong);
}
.status-sent { background: color-mix(in srgb, #3B82C4 12%, var(--surface)); border-color: color-mix(in srgb, #3B82C4 40%, transparent); color: #2d6aa3; }
.status-accepted { background: var(--leaf-soft); border-color: color-mix(in srgb, var(--green) 45%, transparent); color: var(--green-ink); }
.status-declined { background: color-mix(in srgb, var(--coral) 10%, var(--surface)); border-color: color-mix(in srgb, var(--coral) 40%, transparent); color: #c8394a; }
@media (prefers-color-scheme: dark) {
  .status-sent { color: #8cbbe8; }
  .status-declined { color: var(--coral); }
}
.pill-muted { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-strong); }

.empty { text-align: center; padding: 40px 22px; }
.empty h2 { margin-bottom: 6px; }
.empty p { margin: 0 0 16px; }
.empty p:last-child { margin-bottom: 0; }

.grid-2, .grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; align-items: start; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.hint { margin: 26px 0 0; }

.seg-radio { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.seg-radio label { position: relative; margin: 0; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: calc(var(--radius-sm) - 2px);
  font-weight: 600; font-size: 14px; color: var(--ink-2); cursor: pointer;
}
.seg-radio input:checked + span { background: var(--leaf-soft); color: var(--green-ink); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 1px; }

.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 24px; margin: 0 0 18px; }
.details .wide { grid-column: 1 / -1; }
.details dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-bottom: 3px; }
.details dd { margin: 0; }
.pre { white-space: pre-line; }

.split { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 28px; align-items: start; }
.split .section-head { margin-top: 0; min-height: 36px; }
.client-card h2 { margin-bottom: 14px; }
.details-stack { grid-template-columns: 1fr; }

.doc-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.placeholder { border-style: dashed; margin-bottom: 16px; }
.placeholder p { margin: 0; }
code { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }

@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .page, .panel { padding: 0 20px; }
  .topbar { padding: 0 20px; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 8px; height: 58px; }
  .brand .logo-full { display: none; }
  .brand .logo-small { display: block; }
  .brand-sub { display: none; }
  .topnav { margin-left: 0; }
  .topnav a { padding: 7px 9px; }
  .menu { margin-left: auto; }
  .page { padding: 0 12px; margin-top: 18px; }
  .page-head h1 { font-size: 24px; }
  .search { width: 100%; }
  .hide-sm { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hint { margin-top: 0; }
}

/* ---------- document editor ---------- */
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--green-ink); }
.tag {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap;
}
.tag-link { background: var(--leaf-soft); border-color: color-mix(in srgb, var(--green) 40%, transparent); color: var(--green-ink); }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.doc-aside { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }
.doc-aside .card + .card { margin-top: 0; }
.doc-aside .grid-2, .doc-aside .grid-3 { grid-template-columns: 1fr; }
.doc-aside .details-form h2, .doc-aside .card h2 { font-size: 17px; margin-bottom: 0; }
.total-card { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 22px; }
.total-card strong { font: 600 24px var(--serif); color: var(--green-ink); font-variant-numeric: tabular-nums; }
.status-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.status-buttons .is-current { background: var(--leaf-soft); border-color: var(--green); color: var(--green-ink); opacity: 1; cursor: default; }
.save-state { font-size: 13px; color: var(--ink-3); }
.save-state.is-saved::before { content: "\2713  "; color: var(--green); }
.save-state.is-error { color: var(--coral); font-weight: 600; }

.cover-stub {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 22px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2);
}
.cover-stub strong { font: 600 20px var(--serif); }
.cover-stub-end { margin-top: 16px; }

.sections { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.sections-empty { margin: 16px 0 0; text-align: center; padding: 24px; }
.sec {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px 18px; transition: border-color .15s, box-shadow .15s;
}
.sec:hover, .sec:focus-within { border-color: var(--line-strong); }
.sec.is-editing { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent); }
.sec.is-dragging { opacity: .45; }
.sec.is-new { animation: sec-new 1.6s ease; }
@keyframes sec-new { from { box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 35%, transparent); } }

/* Same two columns as the printed document: title rail + body. */
.sec-grid { display: grid; grid-template-columns: 30% minmax(0, 1fr); gap: 28px; }
.sec-rail { border-top: 2px solid var(--green); padding-top: 8px; min-width: 0; }
.sec-title {
  display: block; width: 100%; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; resize: none; overflow: hidden;
  font: 600 19px/1.3 var(--serif); color: var(--green-ink); box-shadow: none !important;
}
.sec-title::placeholder { color: var(--ink-3); font-weight: 500; }
.sec-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.sec-main { min-width: 0; }

.doc-body { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.doc-body > :first-child { margin-top: 0; }
.doc-body > :last-child { margin-bottom: 0; }
.doc-body p { margin: 0 0 10px; }
.doc-body h3 { font: 700 15px var(--font); margin: 18px 0 4px; }
.doc-body h4 { font: 600 14px var(--font); margin: 14px 0 4px; color: var(--ink-2); }
.doc-body ul, .doc-body ol { margin: 0 0 10px; padding-left: 22px; }
.doc-body li { margin-bottom: 4px; }
.sec.is-small .doc-body, .sec.is-small .trumbowyg-editor { font-size: 13px; }
.doc-body.is-editable { cursor: text; border-radius: var(--radius-sm); margin: -8px; padding: 8px; transition: background .15s; }
.doc-body.is-editable:hover { background: var(--surface-2); }
.doc-body.is-empty { color: var(--ink-3); font-style: italic; }

.linked-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 14px; padding: 9px 12px;
  border-radius: var(--radius-sm); background: var(--leaf-soft); font-size: 13px; color: var(--ink-2);
}
.linked-note a, .link-btn { font-weight: 600; color: var(--green-ink); font-size: 13px; }
.link-btn { text-decoration: underline; }

.sec-tools {
  display: flex; align-items: center; gap: 2px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line);
  opacity: .55; transition: opacity .15s;
}
.sec:hover .sec-tools, .sec:focus-within .sec-tools { opacity: 1; }
.tool {
  height: 28px; min-width: 28px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-2); font: 600 14px var(--font); cursor: pointer;
}
.tool:hover:not(:disabled) { background: var(--leaf-soft); color: var(--ink); }
.tool:disabled { opacity: .3; cursor: default; }
.tool.drag { cursor: grab; font-size: 16px; }
.tool-text { font-size: 12px; padding: 0 9px; border: 1px solid transparent; }
.tool-text[aria-pressed=true] { background: var(--leaf-soft); color: var(--green-ink); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.sec-tools .tool-danger { margin-left: auto; }
.tool-danger:hover:not(:disabled) { color: var(--coral); background: color-mix(in srgb, var(--coral) 10%, transparent); }

.sec-page_break { padding: 10px 26px; background: transparent; border-style: dashed; }
.sec-page_break .sec-tools { border-top: 0; margin-top: 0; padding-top: 0; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); }
.sec-break { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }

.add-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding: 14px 18px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
}

.rte-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
/* Trumbowyg, in the app colours */
.trumbowyg-box { margin: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); min-height: 0; background: var(--surface); }
.trumbowyg-box .trumbowyg-editor { min-height: 140px; padding: 14px 16px; font-size: 15px; line-height: 1.6; color: var(--ink); }
.trumbowyg-editor h3 { font: 700 15px var(--font); margin: 18px 0 4px; }
.trumbowyg-editor h4 { font: 600 14px var(--font); margin: 14px 0 4px; }
.trumbowyg-editor p { margin: 0 0 10px; }
.trumbowyg-button-pane { background: var(--surface-2); border-bottom-color: var(--line); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.trumbowyg-button-pane::after { background: var(--line); }
.trumbowyg-button-pane .trumbowyg-button-group::after { background: var(--line); }
.trumbowyg-button-pane button { color: var(--ink-2); }
.trumbowyg-button-pane button.trumbowyg-textual-button { padding: 0 10px; font-weight: 600; font-size: 13px; }
.trumbowyg-button-pane button:not(.trumbowyg-disable):hover,
.trumbowyg-button-pane button.trumbowyg-active { background: var(--leaf-soft); }
.trumbowyg-dropdown { background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; }
.trumbowyg-dropdown button { color: var(--ink); }
.trumbowyg-dropdown button:hover, .trumbowyg-dropdown button:focus { background: var(--leaf-soft); }
.trumbowyg-modal-box { background: var(--surface); color: var(--ink); }
.trumbowyg-box svg { fill: var(--ink-2); color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  .trumbowyg-box .trumbowyg-editor, .trumbowyg-textarea { background: var(--surface); color: var(--ink); }
  .trumbowyg-modal-box .trumbowyg-input-field input { background: var(--surface-2); color: var(--ink); }
}

/* pricing editor */
.price-edit { width: 100%; border-collapse: collapse; }
.price-edit th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 0 6px 6px; border-bottom: 1px solid var(--ink); }
.price-edit td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.price-edit .amt { width: 150px; text-align: right; white-space: nowrap; }
.price-edit .x { width: 36px; text-align: right; }
.price-edit input { min-height: 34px; padding: 6px 8px; border-color: transparent; background: transparent; }
.price-edit input:hover { border-color: var(--line-strong); }
.price-edit input:focus { background: var(--surface); }
.price-edit .in-desc { font-weight: 500; }
.price-edit .in-detail { font-size: 13px; color: var(--ink-2); min-height: 28px; padding-top: 3px; padding-bottom: 3px; }
.price-edit .in-amt { text-align: right; font-variant-numeric: tabular-nums; width: calc(100% - 14px); }
.price-edit .cur { display: inline-block; width: 12px; color: var(--ink-2); }
.price-edit tr.is-discount td { background: color-mix(in srgb, var(--leaf-soft) 50%, transparent); }
.price-edit tr.is-discount .tag { margin: 8px 6px 0 8px; float: left; }
.price-edit tr.is-discount .in-desc { width: calc(100% - 90px); }
.price-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.price-add { display: flex; gap: 6px; }
.price-totals { min-width: 240px; font-variant-numeric: tabular-nums; }
.price-totals div { display: flex; justify-content: space-between; gap: 24px; padding: 3px 42px 3px 0; color: var(--ink-2); }
.price-totals .grand { border-top: 1px solid var(--ink); margin-top: 4px; padding-top: 8px; color: var(--ink); font-weight: 700; font-size: 17px; }
.price-totals .grand span:last-child { color: var(--green-ink); }

/* snippet picker */
.picker {
  width: min(720px, calc(100vw - 32px)); max-height: min(80vh, 760px); padding: 0; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); flex-direction: column;
}
.picker[open] { display: flex; }
.picker::backdrop { background: rgba(30, 30, 30, .4); }
.picker-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 10px; }
.picker-head h2 { font-size: 21px; }
.picker > input[type=search] { margin: 0 22px; width: auto; }
.picker-list { overflow-y: auto; padding: 6px 22px 10px; flex: 1; min-height: 120px; }
.picker-cat { font: 700 11px var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 16px 0 6px; }
.picker-item { display: flex; gap: 14px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); }
.picker-item:hover { background: var(--surface-2); }
.picker-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.picker-text .tag { align-self: flex-start; }
.picker-actions { display: flex; gap: 6px; flex-shrink: 0; }
.picker-foot { margin: 0; padding: 12px 22px 18px; border-top: 1px solid var(--line); }

/* snippets library */
.group-head { font-size: 19px; margin: 26px 0 12px; }
.snippet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.snippet-grid .card + .card { margin-top: 0; }
.snippet-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.snippet-card:hover { border-color: var(--green); box-shadow: var(--shadow); }
.snippet-card strong { font-size: 16px; }
.snippet-excerpt { font-size: 14px; color: var(--ink-2); flex: 1; }
.snippet-meta { margin-top: 4px; }
.split-right { grid-template-columns: 1fr minmax(280px, 340px); }
.split-right .card + .card { margin-top: 0; }
.label-text { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field-list, .used-in { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 1fr; }
  .doc-aside { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .sec { padding: 16px; }
  .sec-grid { grid-template-columns: 1fr; gap: 10px; }
  .split-right { grid-template-columns: 1fr; }
  .picker-item { flex-direction: column; align-items: stretch; }
}

/* ---------- rates ---------- */
.side-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side-stack .card + .card { margin-top: 0; }
.rates-table { width: 100%; border-collapse: collapse; margin: 4px 0 14px; font-size: 14px; }
.rates-table th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 7px 10px 7px 0; border-top: 1px solid var(--line); }
.rates-table td { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding: 7px 0; border-top: 1px solid var(--line); white-space: nowrap; }
.rates-table tr:first-child th, .rates-table tr:first-child td { border-top: 0; }
.rates-table code { display: block; width: max-content; margin-top: 2px; font-size: 11px; }
.rates-table .tag { margin-left: 6px; font-weight: 600; }
.rates-fieldset { border-top: 1px solid var(--line); padding-top: 18px; }
.rates-fieldset p { margin: 0 0 12px; }
.grid-rates { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-rates label > .muted { display: block; font-weight: 400; margin-top: 4px; }
.money-input, .field-code { display: flex; align-items: center; margin-top: 6px; }
.money-input > span, .field-code > span {
  padding: 0 9px; min-height: 38px; display: flex; align-items: center; background: var(--surface-2);
  border: 1px solid var(--line-strong); color: var(--ink-2); font-weight: 500; font-size: 14px;
}
.money-input > span { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.money-input input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-variant-numeric: tabular-nums; margin-top: 0; }
.field-code > span { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.field-code > span:first-child { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.field-code > span:last-child { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.field-code input { border-radius: 0; margin-top: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; min-width: 0; }
.rate-row { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.rate-row .grid-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
.rate-row label.check { font-size: 13px; color: var(--ink-2); }
.rate-actions { display: flex; gap: 6px; }
.rate-new h3 { font: 600 15px var(--font); margin: 0; }

.editor-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; }

.signoff-stub { overflow: hidden; }
.signoff-stub .sig-box { float: left; width: calc(50% - 8px); height: 64px; margin-right: 16px; border: 1px solid var(--line-strong); border-top: 2px solid var(--green); border-radius: 4px; background: repeating-linear-gradient(transparent 0 20px, var(--line) 20px 21px); }
.signoff-stub .sig-box + .sig-box { margin-right: 0; }
.signoff-stub p { clear: both; margin: 10px 0 0; padding-top: 2px; }

/* ---------- sending & history ---------- */
.alert-info { background: color-mix(in srgb, #3B82C4 10%, var(--surface)); border-left-color: #3B82C4; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; font-weight: 500;
}
.send-total { display: flex; justify-content: space-between; align-items: baseline; margin: 0; }
.send-total strong { font: 600 22px var(--serif); color: var(--green-ink); }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history-list li { padding-top: 10px; border-top: 1px solid var(--line); }
.history-list li:first-child { padding-top: 0; border-top: 0; }
.history-top { display: flex; align-items: baseline; gap: 10px; }
.history-top a:first-child { text-decoration: none; }
.history-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.history-actions a { text-decoration: none; font-weight: 700; padding: 0 6px; }
.history-actions form { margin: 0; }
.history-mail { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.history-mail.is-failed { color: var(--coral); font-weight: 600; }

.status-template { background: color-mix(in srgb, #8B5CF6 12%, var(--surface)); border-color: color-mix(in srgb, #8B5CF6 40%, transparent); color: #6d43d6; }
@media (prefers-color-scheme: dark) { .status-template { color: #b9a0f7; } }
.page-intro { margin: -6px 0 18px; max-width: 760px; }

/* ---------- checks ---------- */
.checks-card h2 { display: flex; align-items: center; gap: 8px; }
.checks-count { font: 700 12px var(--font); min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center; }
.checks-count:empty { display: none; }
.checks-count.is-warn { background: color-mix(in srgb, #E8A317 20%, var(--surface)); color: #8a5d00; }
.checks-count.is-error { background: var(--coral); color: #fff; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.4; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check-icon { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font: 700 11px var(--font); margin-top: 1px; }
.check-error .check-icon { background: var(--coral); color: #fff; }
.check-warn .check-icon { background: color-mix(in srgb, #E8A317 25%, var(--surface)); color: #8a5d00; }
.check-info .check-icon { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line-strong); font-style: italic; }
.check-info .check-text { color: var(--ink-2); }
.check-where { display: block; font-weight: 600; font-size: 12px; color: var(--green-ink); text-decoration: underline; margin-bottom: 1px; text-align: left; }
.check-ok { color: var(--green-ink); font-weight: 600; font-size: 13px; margin: 0; }
.check-ok::before { content: "\2713  "; }
@media (prefers-color-scheme: dark) {
  .checks-count.is-warn, .check-warn .check-icon { color: #f2c35b; }
}
