:root {
  --ink: #14213d;
  --ink-2: #3d4a63;
  --muted: #6b7385;
  --line: #e2e5ec;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
[hidden] { display: none !important; }
a { color: var(--ink); }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; text-decoration: none; }
.trust { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); }
.pill.ok { color: var(--ok); border-color: #bfe3cf; background: #eef8f2; }
.pill.warn { color: #9a2a12; border-color: #f2c2b4; background: #fdf0ec; }
.link { font-size: 14px; }

.landing { max-width: 760px; margin: 0 auto; padding: 56px 24px 40px; }
.landing h1 { font-size: clamp(34px, 6vw, 54px); line-height: 1.05; margin: 0 0 16px; letter-spacing: -0.02em; }
.lead { font-size: 18px; color: var(--ink-2); line-height: 1.5; margin: 0 0 28px; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 190px; border: 2px dashed #c4c9d4; border-radius: var(--radius); background: var(--card);
  cursor: pointer; transition: border-color .15s, background .15s; text-align: center; padding: 24px;
}
.drop:hover, .drop:focus, .drop.over { border-color: var(--accent); background: #fff8f5; outline: none; }
.drop-title { font-size: 20px; font-weight: 600; }
.drop-sub { color: var(--muted); font-size: 14px; }
.samples { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 32px; color: var(--muted); font-size: 14px; }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.points li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink-2); line-height: 1.45; }
.points b { color: var(--ink); }

.btn {
  font: inherit; font-size: 14px; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.btn:hover { border-color: #b9bfcc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; width: 100%; padding: 12px; }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.workspace { display: grid; grid-template-columns: 330px 1fr; gap: 0; min-height: calc(100vh - 110px); }
.panel { background: var(--card); border-right: 1px solid var(--line); padding: 8px 0; overflow-y: auto; max-height: calc(100vh - 60px); position: sticky; top: 0; }
.panel-block { padding: 14px 20px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.panel-block:last-child { border-bottom: 0; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.file-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.status { margin: 0; font-size: 13px; color: var(--ink-2); min-height: 1em; }
select, input[type=text] { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; background: #fff; color: var(--ink); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input { flex: 1; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rules li label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; cursor: pointer; }
.rules .count { margin-left: auto; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--ink-2); }
.rules .none { font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }

.pages { padding: 24px; display: grid; gap: 24px; justify-items: center; align-content: start; overflow: auto; }
.page { position: relative; width: min(100%, 860px); box-shadow: 0 1px 3px rgba(20,33,61,.12), 0 8px 24px rgba(20,33,61,.08); background: #fff; user-select: none; touch-action: none; }
.page canvas { display: block; width: 100%; height: auto; }
.page .stamp { position: absolute; inset: 0; pointer-events: none; }
.page .layer { position: absolute; inset: 0; cursor: crosshair; }
.box { position: absolute; background: rgba(10, 12, 20, .78); outline: 2px solid var(--accent); outline-offset: 0; cursor: pointer; border-radius: 2px; }
.box:hover { background: rgba(10, 12, 20, .6); }
.box.manual { outline-color: #2f6fdd; }
.box.off { background: transparent; outline: 2px dashed rgba(228, 87, 46, .55); }
.box.draft { background: rgba(47, 111, 221, .25); outline: 2px dashed #2f6fdd; pointer-events: none; }
.final .box { background: #000; outline: none; }
.final .box.off { display: none; }
.page-label { position: absolute; top: -20px; left: 0; font-size: 12px; color: var(--muted); }

.footer { padding: 18px 24px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.doc { max-width: 720px; margin: 0 auto; padding: 40px 24px 60px; line-height: 1.6; color: var(--ink-2); }
.doc h1 { color: var(--ink); line-height: 1.15; }
.doc h2 { color: var(--ink); margin-top: 32px; font-size: 20px; }
.doc code { background: #eceef3; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .pages { padding: 28px 12px; }
}

.pill { white-space: nowrap; }
@media (max-width: 600px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .trust { order: 3; flex-basis: 100%; }
  .link { margin-left: auto; }
  .landing { padding-top: 32px; }
}

/* ---------- v2: business, batch, dialogs ---------- */
textarea { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; resize: vertical; color: var(--ink); background: #fff; }
.tag { font-size: 10.5px; font-weight: 700; color: #7a3d00; background: #fff1d6; border: 1px solid #f3d39b; border-radius: 999px; padding: 1px 7px; margin-left: 4px; vertical-align: middle; }
.biz-active .tag { display: none; }
.btn.primary.inline { width: auto; padding: 9px 18px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.row input[type=text] { flex: 1; min-width: 180px; }
.err { color: #9a2a12; }

.biz-card { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 22px 24px; }
.biz-card h2 { margin: 0 0 6px; font-size: 19px; }
.biz-card p { margin: 0; color: #c9d1e3; line-height: 1.5; font-size: 14.5px; }
.biz-actions { display: grid; gap: 8px; }
.biz-card .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); }

.batch { max-width: 1080px; margin: 0 auto; padding: 32px 24px 48px; }
.batch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.batch-head h1 { margin: 0 0 6px; font-size: 32px; }
.batch-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; margin: 8px 0 20px; }
.drop.small { min-height: 150px; }
.batch-settings { display: grid; gap: 8px; align-content: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.batch-table, .audit-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.batch-table th, .batch-table td, .audit-table th, .audit-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.batch-table th, .audit-table th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
.batch-table td:nth-child(3), .batch-table td:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; }
.batch-table td:last-child { white-space: nowrap; text-align: right; }
.batch-table .empty td { color: var(--muted); text-align: center; padding: 22px; }
.batch-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0 8px; }
.batch-actions .btn.primary { width: auto; }
.locked { background: #fff8eb; border: 1px solid #f3d39b; border-radius: var(--radius); padding: 18px 20px; margin: 12px 0; }
.locked p { margin: 0 0 12px; }
.locked .btn.primary { width: auto; }

.dialog { border: 0; border-radius: 14px; padding: 0; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(20,33,61,.3); color: var(--ink); }
.dialog::backdrop { background: rgba(20,33,61,.45); }
.dialog.small { width: min(420px, calc(100vw - 24px)); padding: 20px; }
.dialog.small form { display: grid; gap: 8px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog-body { padding: 4px 20px 20px; }
.dialog-body section { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.dialog-body section:last-child { border-bottom: 0; }
.dialog-body h3 { margin: 0; font-size: 15px; }
.plan-line { margin: 0; font-weight: 600; }
#co-logo-preview { height: 36px; width: auto; border: 1px solid var(--line); border-radius: 6px; padding: 3px; background: #fff; }
.tpl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tpl-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.scroll { overflow-x: auto; }
.audit-table { font-size: 13px; }

@media (max-width: 760px) {
  .biz-card, .batch-grid { grid-template-columns: 1fr; }
  .batch-table thead { display: none; }
  .batch-table tr { display: grid; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .batch-table td { border: 0; padding: 3px 12px; text-align: left !important; }
  .batch-table td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); }
}
