:root {
  --brand: #0a6e6e;
  --brand-dark: #075e5a;
  --brand-soft: #e2eee7;
  --bg: #f6f9f7;
  --surface: #ffffff;
  --ink: #142c2b;
  --muted: #526966;
  --line: #dce6e1;
  --line-strong: #bcd3c7;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --success: #027a48;
  --success-soft: #ecfdf3;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(16, 46, 38, 0.08);
  --shadow-sm: 0 2px 8px rgba(16, 46, 38, 0.06);
  --topbar-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 680; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.7em; }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 10px 14px;
  border-radius: var(--radius-sm); z-index: 1000;
}
.skip:focus { left: 12px; top: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 20px;
  min-height: var(--topbar-h); display: flex; align-items: center; gap: 22px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 760; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 21px; line-height: 1;
}
.brand-name { font-size: 1.18rem; letter-spacing: -0.5px; }
.brand-tag {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 1.1px; font-weight: 700;
  color: var(--brand-dark); background: var(--brand-soft); padding: 3px 7px; border-radius: 999px;
}
.mainnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.mainnav a:hover { background: #edf4f0; color: var(--ink); text-decoration: none; }
.mainnav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.website-link { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); padding: 5px 10px 5px 5px; border-radius: 999px; cursor: pointer;
}
.user-chip:hover { border-color: var(--line-strong); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 0.8rem;
}
.user-name { font-weight: 600; font-size: 0.88rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu {
  position: absolute; right: max(20px, calc((100vw - 1240px) / 2 + 20px)); top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 210px; padding: 6px; z-index: 60;
}
.user-menu a, .user-menu button {
  display: block; width: 100%; text-align: left; padding: 9px 11px; border-radius: var(--radius-sm);
  background: none; border: 0; cursor: pointer; color: var(--ink); font-size: 0.92rem;
}
.user-menu a:hover, .user-menu button:hover { background: #edf4f0; text-decoration: none; }

/* ---------- Layout ---------- */
.view { max-width: 1240px; margin: 0 auto; padding: 26px 20px 80px; min-height: 60vh; }
.boot { display: grid; place-items: center; gap: 14px; padding: 80px 0; color: var(--muted); }
.spinner {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--brand); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.page-title h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: 0.9rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; word-break: break-all; }
.small { font-size: 0.82rem; }
.hidden { display: none !important; }
.center { text-align: center; }
.right { text-align: right; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card + .card { margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 10px 16px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 9px 15px; font-weight: 620; cursor: pointer; white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.btn:hover { background: #f2f8f4; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand-dark); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px 9px; }
.btn.is-busy { pointer-events: none; opacity: 0.65; }
.btn.is-busy::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor;
  border-top-color: transparent; animation: spin 0.8s linear infinite;
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 620; font-size: 0.86rem; }
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px;
  padding: 9px 11px; outline: none; transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10, 110, 110, 0.13);
}
textarea.input { min-height: 84px; resize: vertical; }
textarea.input.autosize { min-height: 46px; }
.input-sm { padding: 6px 8px; font-size: 0.84rem; }
.hint { color: var(--muted); font-size: 0.8rem; }
.error-text { color: var(--danger); font-size: 0.85rem; min-height: 1.1em; }
.checkline { display: flex; align-items: flex-start; gap: 9px; font-size: 0.9rem; cursor: pointer; }
.checkline input { margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form .input { flex: 1 1 160px; width: auto; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; text-transform: capitalize; letter-spacing: 0.2px;
  background: #eef2f5; color: #44525c; white-space: nowrap;
}
.badge-draft { background: #eef2f5; color: #44525c; }
.badge-sent { background: var(--info-soft); color: var(--info); }
.badge-completed { background: var(--success-soft); color: var(--success); }
.badge-declined { background: var(--danger-soft); color: var(--danger); }
.badge-expired { background: var(--warn-soft); color: var(--warn); }
.badge-canceled { background: #f1f3f5; color: #5f6b76; }
.badge-source { background: var(--brand-soft); color: var(--brand-dark); text-transform: lowercase; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 650; background: #eef2f5; color: #44525c;
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-signed, .pill-completed, .pill-delivered, .pill-saved { background: var(--success-soft); color: var(--success); }
.pill-sent, .pill-viewed, .pill-accessed, .pill-accepted { background: var(--info-soft); color: var(--info); }
.pill-pending, .pill-partially_signed, .pill-queued { background: var(--warn-soft); color: var(--warn); }
.pill-declined, .pill-failed { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tabs / toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: inline-flex; align-self: flex-start; background: #e9f0ec; border-radius: 999px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.tab { border: 0; background: transparent; padding: 7px 13px; border-radius: 999px; font-weight: 620; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--surface); color: var(--brand-dark); box-shadow: var(--shadow-sm); }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .input { padding-left: 34px; }
.search::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.1rem; pointer-events: none; }

/* ---------- Document list ---------- */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-row {
  display: flex; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
  text-align: left; width: 100%; color: inherit;
}
.doc-row:hover { border-color: var(--line-strong); transform: translateY(-1px); text-decoration: none; }
.doc-row:focus-visible { outline: 3px solid rgba(10,110,110,0.25); outline-offset: 2px; }
.doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-title { font-weight: 680; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { color: var(--muted); font-size: 0.82rem; display: flex; gap: 10px; flex-wrap: wrap; }
.doc-side { display: flex; align-items: center; gap: 14px; flex: none; }
.doc-progress { min-width: 110px; }
.doc-progress .bar { height: 6px; border-radius: 999px; background: #e8efeb; overflow: hidden; }
.doc-progress .bar span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.doc-progress .count { font-size: 0.76rem; color: var(--muted); margin-top: 4px; }
.doc-chevron { color: var(--line-strong); font-size: 1.3rem; }

/* ---------- Empty / error / loading ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.empty .btn { margin-top: 14px; }
.error-card { background: var(--danger-soft); border: 1px solid #fecdca; color: #7a271a; border-radius: var(--radius); padding: 16px; }
.error-card strong { display: block; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, #eef3f0 25%, #f7faf8 50%, #eef3f0 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-line { height: 14px; margin: 8px 0; }
.notice { border-radius: var(--radius-sm); padding: 11px 13px; font-size: 0.88rem; border: 1px solid transparent; }
.notice-info { background: var(--info-soft); border-color: #b2ddff; color: #194185; }
.notice-warn { background: var(--warn-soft); border-color: #fedf89; color: #93370d; }
.notice-danger { background: var(--danger-soft); border-color: #fecdca; color: #912018; }
.notice-success { background: var(--success-soft); border-color: #abefc6; color: #05603a; }
.notice strong { font-weight: 700; }

/* ---------- Editor layout ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.editor-main { min-width: 0; }
.editor-side {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: calc(var(--topbar-h) + 16px);
  min-width: 0;
  /* The sidebar can be much taller than a laptop viewport. Without its own
     scroll area the lower panels (party routing, bulk assignment) are pinned
     below the fold and cannot be reached by scrolling the page. */
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.section-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.section-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.section-head .input { font-weight: 680; }
.section-items { display: flex; flex-direction: column; gap: 8px; }
.item-block { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 10px; background: #fbfdfc; transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.item-block.dragging { opacity: 0.5; }
.item-block.field-target { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10, 110, 110, 0.16); }
.item-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.item-toolbar .kind { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); font-weight: 700; }
.item-text { min-height: 40px; }
.field-edit { display: grid; grid-template-columns: minmax(0, 1.4fr) 150px auto; gap: 8px; align-items: end; }
.field-edit .field { gap: 4px; }
.table-edit { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.table-edit td { border: 1px solid var(--line); padding: 3px; }
.table-edit input { width: 100%; border: 0; background: transparent; padding: 4px; }
.table-edit .field-cell { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; padding: 4px 6px; white-space: nowrap; }
.columns-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.column-edit { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 8px; }
.column-edit .item-block { background: #fff; }
.add-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Overlay placement ---------- */
.overlay-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.overlay-stage { background: #e7eeea; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow: auto; }
.page-wrap { position: relative; margin: 0 auto; background: #fff; box-shadow: var(--shadow); width: fit-content; max-width: 100%; touch-action: none; }
.page-canvas { display: block; max-width: 100%; height: auto; }
.field-layer { position: absolute; inset: 0; }
.field-box {
  position: absolute; border: 1.5px solid rgba(10, 110, 110, 0.65); background: rgba(10, 110, 110, 0.10);
  border-radius: 3px; font-size: 10px; color: #064e4b; padding: 1px 3px;
  cursor: move; user-select: none; touch-action: none; min-width: 8px; min-height: 6px;
}
.field-box .fb-label {
  position: absolute; left: -1px; top: -15px; background: var(--brand); color: #fff; font-size: 9px;
  padding: 1px 4px; border-radius: 3px 3px 0 0; white-space: nowrap; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.field-box.type-signature { border-color: #7a5af8; background: rgba(122, 90, 248, 0.12); }
.field-box.type-signature .fb-label { background: #7a5af8; }
.field-box.type-date { border-color: #dc6803; background: rgba(220, 104, 3, 0.10); }
.field-box.type-date .fb-label { background: #dc6803; }
.field-box.type-checkbox { border-color: #039855; background: rgba(3, 152, 85, 0.10); }
.field-box.type-checkbox .fb-label { background: #039855; }
.field-box.selected { border-color: var(--brand-dark); box-shadow: 0 0 0 2px rgba(10,110,110,0.25); z-index: 3; }
.field-box .resize-handle {
  position: absolute; right: -5px; bottom: -5px; width: 11px; height: 11px; background: var(--brand-dark);
  border: 2px solid #fff; border-radius: 2px; cursor: nwse-resize; touch-action: none;
}
.place-mode .page-wrap { cursor: crosshair; }
.place-banner { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 12px; font-size: 0.86rem; font-weight: 600; }
.stage-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.stage-toolbar .input { width: auto; }
.page-nav { display: flex; gap: 6px; align-items: center; }
.page-nav .label { font-size: 0.84rem; color: var(--muted); min-width: 82px; text-align: center; }

/* ---------- Tracking ---------- */
.tracking-list { display: flex; flex-direction: column; gap: 8px; }
.tracking-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.tracking-row:last-child { border-bottom: 0; }
.tracking-who { flex: 1; min-width: 0; }
.tracking-who .name { font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracking-who .email { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracking-flags { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; max-width: 160px; }
.wrap-anywhere { overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.86rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex: none; }
.timeline .what { flex: 1; min-width: 0; }
.timeline .who { color: var(--muted); font-size: 0.78rem; }
.timeline .when { color: var(--muted); font-size: 0.76rem; white-space: nowrap; }
.link-box { display: flex; gap: 8px; align-items: center; background: #f8fbf9; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.link-box .url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; color: var(--muted); }
.hash-line { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.76rem; word-break: break-all; color: var(--muted); }

/* ---------- Usage ---------- */
.quota-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.quota-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.quota-card h3 { margin-bottom: 4px; }
.quota-card .numbers { font-size: 1.5rem; font-weight: 720; letter-spacing: -0.5px; }
.quota-card .numbers small { font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.quota-bar { height: 8px; border-radius: 999px; background: #e8efeb; overflow: hidden; margin: 10px 0 8px; }
.quota-bar span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.quota-bar.low span { background: var(--warn); }
.quota-bar.empty span { background: var(--danger); }

/* ---------- Template list ---------- */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.template-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; }
.template-card h3 { font-size: 1rem; }
.template-card .meta { color: var(--muted); font-size: 0.82rem; }
.template-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 18px; background: rgba(13, 34, 30, 0.45); }
.modal-root[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: 0 24px 80px rgba(0,0,0,0.28);
  width: min(680px, 100%); max-height: calc(100vh - 36px); display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: min(980px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { font-size: 1.1rem; }
.modal-close { border: 0; background: transparent; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: #eef3f0; }
.modal-body { padding: 20px; overflow: auto; }
.modal-actions { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pdf-preview { background: #e7eeea; border-radius: 10px; padding: 12px; max-height: 62vh; overflow: auto; }
.pdf-preview .page-wrap { margin-bottom: 12px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  background: #10231f; color: #fff; border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow);
  font-size: 0.88rem; animation: toast-in 0.16s ease-out;
}
.toast.error { background: #7a271a; }
.toast.success { background: #05603a; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.noscript { padding: 30px; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .editor-layout, .overlay-layout { grid-template-columns: 1fr; }
  .editor-side { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .field-edit { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  :root { --topbar-h: 58px; }
  .view { padding: 18px 14px 70px; }
  .topbar-inner { padding: 7px 14px 6px; gap: 10px; flex-wrap: wrap; }
  .brand { flex: 1 1 auto; }
  .brand-tag { display: none; }
  .user-name { display: none; }
  .website-link { display: none; }
  .mainnav { order: 3; flex: 1 1 100%; gap: 2px; }
  .topbar-right { margin-left: 0; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-start; }
  .toolbar { gap: 8px; }
  .search { max-width: none; flex-basis: 100%; }
  .doc-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .doc-side { justify-content: space-between; }
  .doc-progress { flex: 1; }
  .doc-title { white-space: normal; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field-edit { grid-template-columns: 1fr; }
  .columns-edit { grid-template-columns: 1fr; }
  .modal { max-height: calc(100vh - 20px); border-radius: 14px; }
  .modal-root { padding: 10px; }
  .modal-body { padding: 15px; }
  .modal-head, .modal-actions { padding: 12px 15px; }
  .toast-root { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .user-menu { right: 12px; }
}
@media (max-width: 460px) {
  h1 { font-size: 1.45rem; }
  .mainnav a { padding: 7px 9px; font-size: 0.86rem; }
  .doc-side { flex-wrap: wrap; }
  .quota-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
