:root {
  --petrol: #234a4f;
  --teal: #1f7f8c;
  --teal-soft: #e6f3f4;
  --peach: #fbceb1;
  --bg: #f5f7f7;
  --panel: #ffffff;
  --ink: #17282b;
  --muted: #66797c;
  --faint: #98a8aa;
  --line: #e6ecec;
  --draft: #b5651d; --draft-bg: #fdf1e7;
  --approved: #1f6b8c; --approved-bg: #e7f1f7;
  --sent: #1f7a52; --sent-bg: #e6f4ec;
  --skipped: #7b8b8d; --skipped-bg: #eef1f1;
  --bad: #b3372e; --bad-bg: #fbeceb;
  --r: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 43, .04), 0 2px 8px rgba(16, 40, 43, .04);
  font: 14px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { height: 20px; }
.divider { width: 1px; height: 20px; background: var(--line); }
.product { font-weight: 600; color: var(--muted); }
.week { display: flex; align-items: center; gap: 6px; }
.week-label { display: grid; text-align: center; min-width: 150px; line-height: 1.2; }
.week-label b { font-size: 15px; }
.week-label span { font-size: 12px; color: var(--muted); }
.icon { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; line-height: 1; }
.icon:hover:not(:disabled) { background: var(--bg); }
.bar-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.progress { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.progress-track { width: 90px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-track i { display: block; height: 100%; background: var(--sent); border-radius: 3px; transition: width .3s; }
.me { font-size: 12px; color: var(--faint); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 60px); }
.side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; height: calc(100vh - 60px); position: sticky; top: 60px; }
.side-tools { padding: 14px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.side-tools input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.side-tools input:focus { background: var(--panel); border-color: var(--teal); outline: none; }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--bg); border-radius: 8px; }
.tabs button { flex: 1; border: 0; background: none; padding: 5px 4px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.tabs .n { color: var(--faint); margin-left: 3px; font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.list button {
  width: 100%; display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 4px 10px;
  text-align: left; border: 0; background: none; padding: 10px; border-radius: 8px;
}
.list button:hover { background: var(--bg); }
.list button[aria-current="true"] { background: var(--teal-soft); }
.list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { grid-column: 2 / 4; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list .flag { font-size: 11px; color: var(--draft); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.draft { background: var(--draft); } .dot.approved { background: var(--approved); }
.dot.sent { background: var(--sent); } .dot.skipped { background: var(--line); border: 1px solid var(--faint); }
.dot.error { background: var(--bad); }
.list .empty { padding: 24px 12px; color: var(--muted); text-align: center; }

/* ---------- main ---------- */
.main { padding: 24px 32px 64px; max-width: 1200px; width: 100%; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.head h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.01em; }
.sub { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.draft { color: var(--draft); background: var(--draft-bg); } .pill.approved { color: var(--approved); background: var(--approved-bg); }
.pill.sent { color: var(--sent); background: var(--sent-bg); } .pill.skipped { color: var(--skipped); background: var(--skipped-bg); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #cfd9da; background: var(--bg); }
.btn.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1a3a3e; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); }
.kbd { font-size: 10px; opacity: .6; margin-left: 6px; font-weight: 500; }

.grid { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 20px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.card-h h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.card-b { padding: 12px 16px 16px; display: grid; gap: 12px; }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { display: flex; gap: 8px; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--draft-bg); color: #6d3d12; }
.checks li::before { content: "!"; flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--draft); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; margin-top: 1px; }
.checks li.err { background: var(--bad-bg); color: var(--bad); } .checks li.err::before { background: var(--bad); }
.checks li.ok { background: var(--sent-bg); color: var(--sent); } .checks li.ok::before { content: "✓"; background: var(--sent); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-radius: 8px; overflow: hidden; }
.kpi { background: var(--panel); padding: 10px 8px; text-align: center; }
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; color: var(--petrol); }
.kpi span { font-size: 11px; color: var(--muted); }

.field { display: grid; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel); }
.field input:focus, .field textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.field input:disabled, .field textarea:disabled { background: var(--bg); color: var(--muted); }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.hint { font-size: 12px; color: var(--faint); }
.hint.bad { color: var(--bad); }
.saved { font-size: 12px; color: var(--sent); opacity: 0; transition: opacity .2s; }
.saved.on { opacity: 1; }

.ins-group { display: grid; gap: 6px; }
.ins-group h3 { margin: 4px 0 0; font-size: 13px; }
.ins-row { display: grid; grid-template-columns: 44px 1fr 28px; gap: 6px; }
.ins-row input { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 13px; min-width: 0; }
.ins-row input.count { text-align: center; }
.ins-row button { border: 0; background: none; color: var(--faint); font-size: 16px; border-radius: 6px; }
.ins-row button:hover { background: var(--bad-bg); color: var(--bad); }
.link { border: 0; background: none; color: var(--teal); font-weight: 600; font-size: 12px; padding: 0; justify-self: start; }

.preview { position: sticky; top: 84px; overflow: hidden; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.preview iframe { display: block; width: 100%; height: calc(100vh - 160px); border: 0; background: #f4f8f8; }

.confirm { position: fixed; inset: 0; background: rgba(15, 31, 33, .35); display: grid; place-items: center; z-index: 50; }
.confirm .card { width: min(460px, 92vw); padding: 22px; display: grid; gap: 14px; }
.confirm h2 { margin: 0; font-size: 18px; }
.confirm p { margin: 0; color: var(--muted); }
.confirm .to { font-weight: 600; color: var(--ink); word-break: break-all; }

.blank { display: grid; place-items: center; text-align: center; min-height: 60vh; color: var(--muted); }
.blank b { display: block; font-size: 16px; color: var(--ink); margin-bottom: 4px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; transition: .2s; pointer-events: none; z-index: 60; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

@media (max-width: 1100px) { .grid { grid-template-columns: 1fr; } .preview { position: static; } .preview iframe { height: 900px; } }
@media (max-width: 760px) {
  .bar { grid-template-columns: 1fr auto; height: auto; padding: 10px 14px; }
  .bar-right { display: none; }
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; max-height: 40vh; }
  .main { padding: 16px; }
  .head { flex-direction: column; }
}
