:root {
  /* Mission Control aesthetic — cool clean neutrals + soft shadows.
     Little Rick magenta kept as the accent. */
  --accent: #e72176;
  --accent-soft: #fdeaf2;
  --plum: #84146b;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e9ebf1;
  --bg: #f6f7f9;
  --card: #ffffff;
  --card-muted: #fafbfc;
  --ok: #16a34a;
  --danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 3px rgba(16,24,40,.04), 0 6px 16px -6px rgba(16,24,40,.08);
  --shadow-hover: 0 2px 4px rgba(16,24,40,.04), 0 12px 24px -8px rgba(16,24,40,.12);
  --shadow-pop: 0 12px 32px -8px rgba(16,24,40,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11"; overflow-x: clip;
}
* { -webkit-tap-highlight-color: transparent; }
.topbar-brand, .login-logo, h1, h2 { font-family: "Poppins", "Inter", sans-serif; }
h1, h2, h3 { letter-spacing: -0.011em; }
.hidden { display: none !important; }

/* ---- buttons / inputs ---- */
.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; }
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 90%, #000); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, #fff); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, #fff); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-icon { padding: 4px 8px; font-size: 13px; line-height: 1; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; min-height: 60px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }

/* ---- login ---- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 34px; width: 340px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-pop); }
.login-logo { font-size: 26px; font-weight: 900; text-align: center; }
.login-sub { text-align: center; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; font-size: 12px; margin-bottom: 8px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }

/* ---- app shell: sidebar + main ---- */
.app { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: #fff; border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 12px; }
.side-brand { font-family: "Poppins", sans-serif; font-weight: 900; font-size: 17px; padding: 6px 10px 12px; }
.side-brand span { color: var(--muted); font-weight: 500; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-group { margin-top: 16px; }
.nav-label { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 4px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent;
  border: none; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s; }
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.ni-ic { width: 18px; text-align: center; font-size: 14px; opacity: .85; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800;
  min-width: 19px; height: 19px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.saved { color: var(--ok); }
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: sticky; top: 0; z-index: 30; flex-direction: row; align-items: center;
    gap: 8px; padding: 8px 12px; overflow-x: auto; }
  .side-brand { padding: 0 8px 0 2px; white-space: nowrap; }
  .side-nav { flex-direction: row; gap: 2px; overflow-x: auto; flex: 1; }
  .nav-group { margin-top: 0; display: flex; gap: 2px; }
  .nav-label { display: none; }
  .nav-item { white-space: nowrap; }
  .side-foot { border: none; padding: 0; margin: 0; }
}

/* ---- main ---- */
.main { flex: 1; min-width: 0; padding: 26px 32px 80px; }
.main > * { max-width: 1120px; }

/* ---- dashboard ---- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-card); }
.stat-card.link { cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.stat-card.link:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.stat-num { font-family: "Poppins", sans-serif; font-size: 30px; font-weight: 800; line-height: 1; }
.stat-lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-top: 6px; }
.notice { display: flex; gap: 12px; align-items: flex-start; background: #fff7ec; border: 1px solid #f5d9a8;
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.notice .ico { font-size: 18px; line-height: 1.2; }
.notice .title { font-weight: 700; margin-bottom: 2px; }
.notice .grow { flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.toolbar-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- cards / lists ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow-card); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 15px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; margin-bottom: 9px; box-shadow: var(--shadow-card); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 700; }
.list-row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.pill.us { background: #f3e7f0; color: var(--plum); }
.pill.uk { background: #fde9f2; color: var(--accent); }
.pill.done { background: #e7f6ec; color: var(--ok); }
.pill.standard { background: #eef0f4; color: #5b6472; }
.pill.bespoke { background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent); }
.group-label { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 13px; margin: 14px 2px 8px; }
.group-label > span:first-child { }
.group-link { font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; }
.group-link:hover { color: var(--accent); }
.req-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.req-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 4px 8px; border-bottom: 1px solid var(--line); }
.req-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.req-table tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 10px; }

/* ---- badges editor ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12px; font-weight: 600; }
.chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 2px; }

/* ---- pricing editor ---- */
.pricing-editor { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; background: var(--card-muted); }
.pe-table-wrap { overflow-x: auto; }
.pe-table { border-collapse: collapse; width: 100%; }
.pe-table th, .pe-table td { border: 1px solid var(--line); padding: 4px; }
.pe-table th { background: var(--bg); }
.pe-col-head { display: flex; gap: 4px; align-items: center; }
.pe-col-head input { min-width: 90px; font-size: 12px; padding: 4px 6px; }
.pe-disc { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 800; color: var(--accent); cursor: pointer; }
.pe-disc input { min-width: 0 !important; width: auto; }
.pe-table td input { border: none; padding: 6px; font-size: 12.5px; background: transparent; border-radius: 4px; }
.pe-table td input:focus { background: #fff; outline: 1px solid var(--accent); }
.pe-rowctl { white-space: nowrap; width: 1%; }

/* ---- sheet builder sections ---- */
.builder { display: grid; grid-template-columns: 1fr; gap: 12px; }
.sec-item { border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow-card); }
.sec-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card-muted); border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.sec-head .grow { flex: 1; }
.sec-type { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 800; }
.sec-body { padding: 12px; }
.sortctl { display: flex; flex-direction: column; gap: 2px; }
.prodpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; margin: 8px 0; }
.prodpick label { display: flex; align-items: center; gap: 7px; font-size: 13px; background: var(--bg); padding: 6px 9px; border-radius: 8px; font-weight: 500; }
.prodpick input { width: auto; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* ---- editor two-col ---- */
.editor-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }
.preview-pane { position: sticky; top: 72px; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.linkbox input { border: none; background: transparent; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: color-mix(in srgb, var(--ink) 45%, transparent); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: 18px; max-width: 720px; width: 100%; max-height: 88vh; overflow: auto; padding: 24px; box-shadow: var(--shadow-pop); }
.modal h3 { margin: 0 0 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; position: sticky; bottom: -24px; background: var(--card); padding-top: 12px; }

/* ---- toast ---- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 12px; z-index: 60; font-weight: 600; box-shadow: var(--shadow-pop); }
.toast.err { background: var(--danger); }

/* ---- guided flow scaffold (stepped editors) ---- */
.flow-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.flow-step { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--muted); padding: 7px 15px 7px 7px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; }
.flow-step:hover { border-color: var(--muted); }
.flow-step-n { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); color: var(--muted);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 800; flex: none; }
.flow-step.active { border-color: var(--ink); color: var(--ink); }
.flow-step.active .flow-step-n { background: var(--ink); color: #fff; }
.flow-foot { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.flow-foot .grow { flex: 1; }
@media (max-width: 560px) {
  .flow-step span:last-child { display: none; }
  .flow-step { padding: 7px; }
}

/* ---- tile grid + guided wizard (collateral flow) ---- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }
.tile { position: relative; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  overflow: hidden; cursor: pointer; padding: 0; font: inherit; color: var(--ink); display: flex; flex-direction: column;
  transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(231,33,118,.08); }
.tile-thumb { height: 92px; background: var(--bg) center/cover no-repeat; }
.tile-thumb-empty { display: grid; place-items: center; font-size: 26px; color: var(--muted); }
.tile-body { padding: 10px 12px 12px; }
.tile-name { font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.tile-meta { display: flex; gap: 6px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.tile-badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; padding: 2px 8px; border-radius: 999px; }
.tile-digital { background: #f3e7f0; color: var(--plum); }
.tile-physical { background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); }
.tile-cat { font-size: 11px; color: var(--muted); }
.tile-del { position: absolute; top: 6px; right: 6px; border: none; background: rgba(255,255,255,.92); color: #b23b2b;
  width: 24px; height: 24px; border-radius: 8px; cursor: pointer; font-size: 12px; opacity: 0; transition: opacity .15s; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.tile:hover .tile-del { opacity: 1; }
.tile-add { align-items: center; justify-content: center; min-height: 148px; border-style: dashed; color: var(--muted); gap: 6px; }
.tile-add:hover { color: var(--accent); }
.tile-add-plus { font-size: 28px; font-weight: 300; line-height: 1; }
.wz-lead { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; }
.wz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wz-choice { display: flex; flex-direction: column; gap: 5px; text-align: left; padding: 16px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; cursor: pointer; font: inherit; transition: border-color .15s, background .15s; }
.wz-choice:hover { border-color: var(--accent); }
.wz-choice.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, #fff); }
.wz-choice strong { font-size: 14px; }
.wz-choice span { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.wz-typebar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.wz-choices-3 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.wz-choices-3 .wz-choice { padding: 12px 14px; }
.tile-block { background: #eef0f4; color: #5b6472; }
@media (max-width: 460px) { .wz-choices { grid-template-columns: 1fr; } }

/* ---- mobile ---- */
@media (max-width: 560px) {
  .main { padding: 18px 14px 72px; }
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 20px; }
  .page-head .btn { width: 100%; }
  .row { gap: 10px; }
  .row > * { flex: 1 1 100%; min-width: 0; }
  .card { padding: 14px; }
  .list-row { flex-wrap: wrap; }
  .list-row .list-actions { width: 100%; }
  .modal { padding: 18px; border-radius: 12px; max-height: 92vh; }
  .modal-foot { bottom: -18px; }
  .prodpick { grid-template-columns: 1fr; }
  .toast { left: 12px; right: 12px; transform: none; text-align: center; }
  /* keep form fields at 16px so iOS doesn't auto-zoom on focus */
  input, select, textarea { font-size: 16px; }
}
