/* Monovinyl super admin back-office. Hand-written, no build step. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dfe3e8; --text: #1b1f24; --muted: #5d6673;
  --accent: #3b4bd8; --accent-contrast: #ffffff; --danger: #c02f2f; --danger-bg: #fdecec; --ok: #1d7a46; --ok-bg: #e6f4ec;
  --warn: #8a5a00; --warn-bg: #fff3d6; --info-bg: #eaedfd; --sidebar: #161a22; --sidebar-text: #c9cfd8; --sidebar-active: #2b3140;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #161a22; --surface-2: #1d222c; --border: #2a303c; --text: #e6e9ee; --muted: #9aa3b1;
    --accent: #7c8cff; --accent-contrast: #0f1218; --danger: #ff7b7b; --danger-bg: #3a1c1f; --ok: #6fd39b; --ok-bg: #16301f;
    --warn: #f3c46b; --warn-bg: #352a12; --info-bg: #1d2340; --sidebar: #0b0d12; --sidebar-active: #1f2430; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 18px; display: block; }
.sidebar .brand small { display: block; color: var(--sidebar-text); font-weight: 400; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.sidebar nav a { display: block; color: var(--sidebar-text); padding: 8px 10px; border-radius: 6px; margin-bottom: 2px; }
.sidebar nav a:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.sidebar nav a[aria-current="page"] { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .6; padding: 14px 10px 6px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .who { display: flex; align-items: center; gap: 12px; }
.content { padding: 24px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  .sidebar.is-open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.metric .label { color: var(--muted); font-size: 12px; }
.metric .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--accent); }

/* Forms */
form.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=datetime-local], input[type=date], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; min-width: 0;
}
textarea { min-height: 80px; width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.checkbox { display: flex; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 6px; padding: 8px 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: progress; }
.btn.is-loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.errors { background: var(--danger-bg); color: var(--danger); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash.notice { background: var(--ok-bg); color: var(--ok); }
.flash.alert { background: var(--danger-bg); color: var(--danger); }

/* Pagination */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px; flex-wrap: wrap; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .panel { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.auth .panel h1 { margin-bottom: 4px; }
.auth input { width: 100%; }
.auth .btn.primary { width: 100%; justify-content: center; margin-top: 6px; }

/* Danger zone / confirm */
.confirm-box { border: 1px solid var(--danger); background: var(--danger-bg); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.swagger-frame { width: 100%; height: calc(100vh - 230px); min-height: 600px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

/* Catalog editor */
.catalog-cover { display: block; width: min(320px, 100%); aspect-ratio: 1; object-fit: contain; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.catalog-cover-thumbnail { display: block; width: 72px; height: 72px; margin-bottom: 5px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.media-tile { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.media-tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface); }
.media-tile figcaption { padding: 9px; font-size: 12px; }
.media-tile figcaption form { margin-top: 8px; }
.track-list { list-style: none; margin: 0; padding: 0; }
.track-list li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.track-list li:last-child { border-bottom: 0; }
.json-editor { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5; tab-size: 2; }
.json-editor.tall { min-height: 360px; }
.json-preview { max-height: 420px; overflow: auto; margin: 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.separator { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

.span-2 { grid-column: span 2; }
@media (max-width: 900px) { .span-2 { grid-column: auto; } }
.signature-preview { max-width: 220px; max-height: 90px; background: #fff; border: 1px solid var(--border, #ddd); border-radius: 4px; }
