:root {
  --navy: #0B1526; --navy-2: #13213A; --navy-3: #1C2D4D;
  --gold: #D4A84B; --gold-2: #B98D33; --gold-soft: #FBF5E6;
  --bg: #F3F5F9; --card: #FFFFFF; --text: #0F172A; --muted: #64748B; --line: #E3E8EF; --line-2: #EEF1F6;
  --ok: #059669; --ok-soft: #E7F7F1; --warn: #B45309; --warn-soft: #FEF5E3; --bad: #DC2626; --bad-soft: #FDECEC; --info: #2563EB; --info-soft: #EAF1FE;
  --radius: 12px; --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--navy) 0%, #0E1C33 100%); color: #CBD5E1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: 12px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, var(--gold), #F3D78A); color: var(--navy); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.brand-name { color: #fff; font-weight: 700; font-size: 13px; line-height: 1.2; }
.brand-sub { color: var(--gold); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: #CBD5E1; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(212,168,75,.14); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.nav .badge-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot button { margin-top: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; grid-column: 2; }
.scrim { display: none; }
.topbar { display: none; }
.content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .main { grid-column: 1; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .shell.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(11,21,38,.45); z-index: 25; }
  .shell.nav-open .scrim { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar .t { font-weight: 700; font-size: 14px; flex: 1; }
  .content { padding: 16px 14px 80px; }
  h1 { font-size: 19px; }
}

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat .s { font-size: 12px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #CBD5E1; background: #F8FAFC; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-3); }
.btn.gold { background: linear-gradient(180deg, #DDB45C, var(--gold-2)); color: #1B1405; border-color: var(--gold-2); }
.btn.gold:hover { filter: brightness(1.04); }
.btn.danger { color: var(--bad); border-color: #F5C2C2; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(15,23,42,.05); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 34px; padding: 0; }
.sidebar .btn { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #E2E8F0; }
.topbar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 600; color: #334155; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--bad); font-weight: 600; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--bad); background: #FFF8F8; }
input[type=text], input[type=url], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid #D5DCE6; border-radius: 9px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; min-height: 80px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,168,75,.18); }
input[type=color] { width: 46px; height: 38px; padding: 3px; border: 1px solid #D5DCE6; border-radius: 9px; background: #fff; }
input[type=range] { width: 100%; accent-color: var(--gold-2); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--navy); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: #334155; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: #8A6414; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #CBD5E1; }
.dot.ok { background: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.dot.warn { background: #F59E0B; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--gold); }
.tabs button .count { margin-left: 5px; font-size: 11px; background: var(--line-2); padding: 1px 6px; border-radius: 99px; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #F8FAFC; }
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
@media (max-width: 700px) {
  .tbl.responsive thead { display: none; }
  .tbl.responsive tr { display: block; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 4px; }
  .tbl.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 10px; }
  .tbl.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
}

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.list-item { border: 1px solid var(--line); border-radius: 11px; padding: 14px; background: #fff; }
.list-item + .list-item { margin-top: 10px; }
.list-item .li-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

/* editor layout */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.editor > * { min-width: 0; }
.preview-col { position: sticky; top: 16px; }
.preview-stage { background: radial-gradient(1200px 400px at 70% -10%, #3B5B8C 0%, #1D3357 35%, #0F1D33 75%); border-radius: 14px; padding: 22px 18px; display: flex; justify-content: center; min-height: 300px; overflow: auto; border: 1px solid #0F1D33; }
.preview-stage .bgt-panel { flex: 0 0 auto; }
.preview-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.publish-bar { position: sticky; top: 0; z-index: 10; background: rgba(243,245,249,.92); backdrop-filter: blur(6px); padding: 10px 0; margin: -10px 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.publish-bar .status { flex: 1; min-width: 200px; }
@media (max-width: 1150px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
  .preview-col.collapsed .preview-body { display: none; }
}
@media (max-width: 900px) { .publish-bar { top: 52px; } .publish-bar .status { min-width: 100%; } }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(11,21,38,.5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: calc(100vw - 32px); }
.toast { background: var(--navy); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 500; max-width: 420px; border-left: 4px solid var(--gold); }
.toast.bad { border-left-color: #F87171; }
.toast.ok { border-left-color: #34D399; }

/* auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(900px 500px at 80% 0%, #24406E 0%, var(--navy) 60%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth-card .brand { border: 0; padding: 0 0 18px; margin: 0; }
.auth-card .brand-name { color: var(--text); font-size: 15px; }
.auth-card .brand-sub { color: var(--gold-2); }
.alert { padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.alert.bad { background: var(--bad-soft); color: #991B1B; }
.alert.info { background: var(--info-soft); color: #1E40AF; }
.alert.warn { background: var(--warn-soft); color: #92400E; }
.alert.ok { background: var(--ok-soft); color: #065F46; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.timeline li:last-child { border: 0; }
.timeline .when { color: var(--muted); white-space: nowrap; min-width: 92px; font-size: 12px; }
.bar { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.thumb { width: 120px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #F8FAFC; }
.logo-thumb { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 4px; }
.qr-box { width: 180px; height: 180px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr-box svg { width: 100%; height: 100%; shape-rendering: crispEdges; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 99px; margin: 0 6px 6px 0; cursor: pointer; font-size: 13px; }
.chip-check input { accent-color: var(--navy); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(15,23,42,.15); border-top-color: var(--gold-2); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
