/* B7 Shop Manager — shared styles */
:root {
  --ink: #18222d;
  --paper: #eef1f3;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --line: #d5dbe0;
  --text: #18222d;
  --muted: #5b6875;
  --accent: #0b7a94;
  --accent-ink: #ffffff;
  --accent-soft: #e0f1f5;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1d7a46;
  --ok-soft: #e4f4ea;
  --warn-soft: #fff4d6;
  --cyan: #00a3c7; --magenta: #d6246e; --yellow: #f2c200; --key: #18222d;
  --radius-sm: 4px;
  --radius: 8px;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12181e;
    --surface: #1a222a;
    --surface-2: #202a33;
    --line: #2f3b46;
    --text: #e6ebef;
    --muted: #9aa7b3;
    --accent: #3fb6d1;
    --accent-ink: #0c1a20;
    --accent-soft: #173640;
    --danger: #f2877d;
    --danger-soft: #3a1f1d;
    --ok: #6fcf97;
    --ok-soft: #173325;
    --warn-soft: #3a3217;
    --key: #e6ebef;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, #18222d 220px, transparent 220px); }
.sidebar {
  background: #18222d;
  color: #d9e1e7;
  display: flex;
  flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.reg-strip { display: grid; grid-template-columns: repeat(4, 1fr); height: 6px; }
.reg-strip span:nth-child(1) { background: var(--cyan); }
.reg-strip span:nth-child(2) { background: var(--magenta); }
.reg-strip span:nth-child(3) { background: var(--yellow); }
.reg-strip span:nth-child(4) { background: #5d6b78; }
.brand {
  padding: 22px 20px 26px;
  font-stretch: 125%;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: #fff;
}
.brand small { display: block; font-stretch: 100%; font-weight: 500; font-size: 13px; color: #8fa0ae; margin-top: 4px; letter-spacing: 0; }
.nav { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; }
.nav a {
  color: #c7d1d9; text-decoration: none; padding: 9px 12px; border-radius: var(--radius-sm);
  font-weight: 500;
}
.nav a:hover { background: #223040; color: #fff; }
.nav a[aria-current="page"] { background: #26394b; color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.sidebar-foot { margin-top: auto; padding: 16px 20px; }
.sidebar-foot button { background: none; border: 0; color: #8fa0ae; cursor: pointer; padding: 0; }
.sidebar-foot button:hover { color: #fff; }

.main { padding: 28px 36px 60px; max-width: 1280px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1 {
  font-stretch: 118%;
  font-weight: 750;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
}
h2 { font-size: 17px; font-weight: 700; margin: 0; }
.sub { color: var(--muted); margin: 4px 0 0; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .reg-strip { flex: 0 0 100%; }
  .hide-sm { display: none; }
  .brand { padding: 12px 16px; font-size: 18px; }
  .brand small { display: none; }
  .nav { flex-direction: row; padding: 0 8px; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 12px 16px; }
  .main { padding: 20px 16px 48px; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 4px 6px; color: var(--accent); }
.btn.link.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=password], input[type=search], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px 16px; }
.span-2 { grid-column: span 2; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

/* ---------- panels & tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 18px; }
.panel + .panel { margin-top: 16px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 280px; max-width: 420px; }
.toolbar select { width: auto; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: var(--surface-2); }
.name-cell a { color: var(--text); font-weight: 650; text-decoration: none; }
.name-cell a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.tag {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; margin: 0 4px 4px 0;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--text); border-color: transparent; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

.empty { padding: 48px 20px; text-align: center; }
.empty p { color: var(--muted); margin: 6px 0 16px; }

/* ---------- messages ---------- */
.notice { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #18222d; color: #fff; padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 600; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.error { background: #b42318; }
[hidden] { display: none !important; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  width: min(640px, calc(100vw - 32px)); background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(12, 18, 24, .55); }
dialog form { display: flex; flex-direction: column; max-height: 85vh; }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.fieldset-title { font-size: 14px; font-weight: 700; margin: 6px 0 -4px; }

/* ---------- customer page ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.crumb { font-size: 14px; margin-bottom: 8px; display: inline-block; }
.head-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.item-list li:last-child { border-bottom: 0; }
.item-list .actions { display: flex; gap: 2px; align-items: flex-start; flex-shrink: 0; }
.item-title { font-weight: 650; }
.item-empty { padding: 16px 18px; color: var(--muted); }

.note-form { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { padding: 10px 18px; }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li.system .body { color: var(--muted); font-size: 14px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); }
.login-card .brand { color: var(--text); padding: 22px 22px 0; }
.login-card .brand small { color: var(--muted); }

/* ---------- import ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.steps span { font-size: 14px; color: var(--muted); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); }
.steps span.on { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (prefers-color-scheme: dark) { .steps span.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } }
.map-table td { vertical-align: middle; }
table.list.map-table tbody tr { cursor: default; }
table.list.map-table tbody tr:hover td { background: none; }
.map-table select { min-width: 200px; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px 20px; text-align: center; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-row div { font-size: 14px; color: var(--muted); }
.stat-row strong { display: block; font-size: 28px; font-stretch: 118%; color: var(--text); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* =========================================================
   Phase 2: catalog and settings
   ========================================================= */
.nav-group { display: block; padding: 16px 12px 4px; font-size: 12px; font-weight: 600; color: #6f808e; }
@media (max-width: 800px) { .nav-group { display: none; } }

dialog.wide { width: min(980px, calc(100vw - 32px)); }
input[type=number] { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 15px; color: var(--text); }
.help { font-size: 13px; color: var(--muted); margin: 0; font-weight: 400; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }

/* segmented choice (pricing type, fee type) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--muted); border-left: 1px solid var(--line); }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg input:disabled + span { cursor: not-allowed; }
@media (prefers-color-scheme: dark) { .seg input:checked + span { background: var(--accent); color: var(--accent-ink); } }

/* location checkboxes */
.chip-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-pick { position: relative; cursor: pointer; }
.chip-pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip-pick span { display: inline-block; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.chip-pick input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* customer search picker */
.pick-results { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 4px; max-height: 220px; overflow-y: auto; background: var(--surface); }
.pick-results button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; cursor: pointer; }
.pick-results button:hover, .pick-results button:focus-visible { background: var(--accent-soft); }

/* ---------- pricing grid ----------
   Looks like a press sheet: quantity rows down the left edge, the
   highlighted cell gets registration-mark corners. */
.mx-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.mx { border-collapse: collapse; min-width: 100%; font-variant-numeric: tabular-nums; }
table.mx th, table.mx td { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 0; }
table.mx tr:last-child th, table.mx tr:last-child td { border-bottom: 0; }
table.mx thead th { background: var(--surface-2); vertical-align: top; padding: 6px; min-width: 128px; }
table.mx th.mx-corner { border-left: 0; min-width: 0; width: 1%; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 10px; white-space: nowrap; vertical-align: bottom; }
.mx-colhead { display: flex; gap: 2px; align-items: center; }
.mx-colhead input { font-weight: 650; font-size: 14px; padding: 5px 6px; }
.mx-range { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.mx-range input { padding: 3px 5px; font-size: 13px; min-width: 0; }
table.mx th.mx-qty { border-left: 0; background: var(--surface-2); }
.mx-qtycell { display: flex; align-items: center; padding: 0 8px 0 2px; }
.mx-qtycell input { width: 64px; text-align: right; font-weight: 650; border-color: transparent; background: transparent; padding: 8px 2px 8px 4px; }
.mx-plus { color: var(--muted); font-weight: 600; }
table.mx td { position: relative; }
table.mx td input {
  width: 100%; min-width: 96px; border: 0; border-radius: 0; background: transparent;
  padding: 10px 10px 10px 22px; text-align: right; font-size: 15px;
}
table.mx td input:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
table.mx td input.bad { box-shadow: inset 0 0 0 2px var(--danger); background: var(--danger-soft); }
.mx-cur { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.mx-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: var(--radius-sm); }
.mx-x:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.mx-x:disabled { visibility: hidden; }
.mx-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.mx-tip { margin-left: auto; }
@media (max-width: 640px) { .mx-tip { margin-left: 0; } }

table.mx tr.hl-row th.mx-qty, table.mx tr.hl-row td { background: var(--warn-soft); }
table.mx thead th.hl-col { background: var(--warn-soft); }
table.mx td.hl-cell { background: var(--warn-soft); }
table.mx td.hl-cell::before, table.mx td.hl-cell::after {
  content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none;
  border-color: var(--magenta); border-style: solid;
}
table.mx td.hl-cell::before { top: 3px; left: 3px; border-width: 2px 0 0 2px; }
table.mx td.hl-cell::after { bottom: 3px; right: 3px; border-width: 0 2px 2px 0; }
table.mx td.hl-cell input { font-weight: 700; }

/* price check strip */
.price-check { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 16px; align-items: end; }
.pc-result { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pc-amount { font-size: 30px; font-weight: 750; font-stretch: 118%; font-variant-numeric: tabular-nums; line-height: 1; }
.pc-amount.err { font-size: 15px; font-weight: 600; font-stretch: 100%; color: var(--danger); }

/* service editor layout */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.editor-grid .side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 16px; }
.editor-grid .side .panel + .panel { margin-top: 0; }
@media (max-width: 1080px) { .editor-grid { grid-template-columns: 1fr; } .editor-grid .side { position: static; } }
.savebar { display: flex; gap: 8px; align-items: center; }
.dirty-note { font-size: 13px; color: var(--muted); }

/* settings */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="true"] { color: var(--text); border-bottom-color: var(--magenta); }
.tier-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.tier-preview { font-size: 14px; color: var(--muted); }
.sort-list { list-style: none; margin: 0; padding: 0; }
.sort-list li { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.sort-list li:last-child { border-bottom: 0; }
.sort-list .grow { flex: 1; min-width: 0; }
.move { display: flex; flex-direction: column; }
.move button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; line-height: 1; font-size: 12px; }
.move button:hover:not(:disabled) { color: var(--text); }
.move button:disabled { opacity: .3; cursor: default; }
.stage { font-size: 12px; font-weight: 600; color: var(--muted); }
.discount-table td { vertical-align: middle; }
table.list.discount-table tbody tr, table.list.static tbody tr { cursor: default; }
table.list.discount-table tbody tr:hover td, table.list.static tbody tr:hover td { background: none; }
.discount-table input { width: 90px; text-align: right; }
.color-input { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.placeholders { font-size: 13px; color: var(--muted); }
.placeholders code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; font-size: 12px; }
.size-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.two-col .panel + .panel { margin-top: 0; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
div.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
div.field .seg { align-self: flex-start; }
@media (max-width: 800px) {
  .nav { order: 3; flex: 0 0 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 6px; }
  .nav a { white-space: nowrap; }
}
