:root {
  --navy: #0C1A4E;
  --navy-2: #142C86;
  --navy-3: #08133A;
  --bronze: #C9A27A;
  --bronze-light: #E6CBA9;
  --bronze-dark: #8E6A45;
  --bg: #F4F2EE;
  --card: #FFFFFF;
  --line: #E2DED6;
  --text: #1A2140;
  --muted: #646B85;
  --ok: #1E7F4F;
  --ok-bg: #E3F4EA;
  --warn: #9A5B00;
  --warn-bg: #FDF0D9;
  --err: #B3261E;
  --err-bg: #FBE6E4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(12,26,78,.06), 0 4px 16px rgba(12,26,78,.06);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }
.boot { padding: 40px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.side-brand strong { letter-spacing: .12em; font-size: 14px; }
.side-brand span { display: block; font-size: 11px; color: var(--bronze); letter-spacing: .1em; }
.side-logo { width: 38px; height: 38px; border-radius: 50%; background: var(--bronze); color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 11px; overflow: hidden; }
.side-logo img { width: 100%; height: 100%; object-fit: cover; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #C9D3F5; text-decoration: none; padding: 10px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a[aria-current="page"] { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 var(--bronze); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 13px; padding: 0 8px; }
.side-foot a, .side-foot button { color: #9FB0E8; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: none; }
.side-foot a:hover, .side-foot button:hover { color: #fff; }
.count { background: var(--bronze); color: var(--navy); border-radius: 999px; font-size: 12px; font-weight: 700; padding: 0 8px; }

.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 10; background: rgba(244,242,238,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 14px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.top-status { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.content { padding: 28px 32px 120px; max-width: 1100px; display: flex; flex-direction: column; gap: 24px; }
.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-title p { margin: 4px 0 0; color: var(--muted); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: #E6EBFA; color: var(--navy-2); }
.badge.plain { background: #EEECE8; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 14px; border: 1px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: #C9C3B8; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.accent { background: var(--bronze); border-color: var(--bronze); color: var(--navy); box-shadow: 0 3px 0 var(--bronze-dark); }
.btn.accent:hover { background: var(--bronze-light); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 6px 9px; }
.btn.ghost { background: none; border-color: transparent; }
.btn.ghost:hover { background: #EEECE8; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: #fff; min-height: 40px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(20,44,134,.12); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: #CFCAC0; border-radius: 999px; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--bronze); outline-offset: 2px; }

/* Media picker */
.media { display: flex; gap: 14px; align-items: center; border: 1px dashed #CFCAC0; border-radius: var(--radius); padding: 10px; background: #FBFAF8; }
.media-thumb { width: 96px; height: 72px; border-radius: 6px; background: #EEECE8; overflow: hidden; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-actions { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.media-actions .row { gap: 6px; }
.progress { height: 4px; background: #EEECE8; border-radius: 4px; overflow: hidden; width: 160px; }
.progress span { display: block; height: 100%; background: var(--navy-2); transition: width .2s; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: grid; grid-template-columns: auto 64px 1fr auto; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.item.off { opacity: .6; }
.item img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #EEECE8; }
.item-title { font-weight: 600; }
.item-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.order { display: flex; flex-direction: column; gap: 2px; }
.order button { border: 1px solid var(--line); background: #fff; border-radius: 5px; width: 26px; height: 22px; cursor: pointer; font-size: 11px; line-height: 1; }
.order button:disabled { opacity: .3; cursor: default; }
.section-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.section-item > header { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; }
.section-item > .body { border-top: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.color-row { display: grid; grid-template-columns: 1fr 140px 1.4fr auto; gap: 10px; align-items: center; }
.swatch-input { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: #fff; }
.swatch-input input[type="color"] { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }
.swatch-input input[type="text"] { border: 0; min-height: 30px; padding: 2px; font-family: ui-monospace, monospace; font-size: 13px; }
.swatch-input input[type="text"]:focus { box-shadow: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: #EEECE8; border-radius: 999px; padding: 3px 4px 3px 12px; font-size: 13px; }
.tag button { border: 0; background: #DDD8CF; width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 1; }

/* Theme preview */
.preview { border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.preview .pv-kicker { font-family: ui-monospace, monospace; font-size: 11px; letter-spacing: .16em; }
.preview .pv-title { font-size: 28px; font-weight: 800; text-transform: uppercase; letter-spacing: -.02em; line-height: 1; }
.preview .pv-card { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.preview .pv-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.preview .pv-btn { padding: 10px 16px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.new td:first-child { box-shadow: inset 3px 0 0 var(--bronze); }
.details { font-size: 13px; color: var(--muted); display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin-top: 6px; }
.details dt { font-weight: 600; color: var(--text); }
.details dd { margin: 0; }

/* Feedback */
.alert { border-radius: 8px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: #E6EBFA; color: var(--navy-2); }
.log { background: var(--navy-3); color: #C9D3F5; font-family: ui-monospace, monospace; font-size: 12px; padding: 14px; border-radius: 8px; max-height: 340px; overflow: auto; white-space: pre-wrap; }
.savebar { position: fixed; left: 240px; right: 0; bottom: 0; z-index: 20; background: var(--navy); color: #fff; padding: 12px 32px; display: flex; justify-content: space-between; align-items: center; gap: 16px; box-shadow: 0 -6px 20px rgba(0,0,0,.15); }
.savebar .err { color: #FFB4A6; font-size: 14px; }
.toasts { position: fixed; right: 20px; top: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; border-radius: 8px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 380px; font-size: 14px; border-left: 4px solid var(--bronze); }
.toast.err { border-left-color: #FF8A7A; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--navy); padding: 20px; }
.login form { background: #fff; border-radius: 14px; padding: 36px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 16px; box-shadow: 0 10px 0 var(--bronze), 0 30px 60px -20px rgba(0,0,0,.5); }
.login h1 { font-size: 22px; }

.burger { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .burger { display: inline-flex; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .savebar { left: 0; padding: 12px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .item { grid-template-columns: auto 48px 1fr; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .color-row { grid-template-columns: 1fr 1fr; }
}
