:root {
  color-scheme: dark;
  --canvas: #090c12;
  --surface: #111722;
  --surface-hover: #1b2536;
  --field: #0d121b;
  --border: #29344a;
  --border-strong: #3b4a65;
  --text: #f4f7fc;
  --text-soft: #c7d0de;
  --muted: #96a3b6;
  --accent: #6f60df;
  --accent-hover: #8174ed;
  --accent-soft: #282454;
  --focus: #72d3ff;
  --danger: #ff9ba9;
  --danger-soft: #4a202c;
  --success: #8ae7bd;
  --success-soft: #143c33;
  --info: #b9d7ff;
  --info-soft: #1a3158;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--canvas);
  line-height: 1.5;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 960px; background: var(--canvas); }
body {
  min-width: 960px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(900px 540px at 88% -10%, #252050 0%, transparent 63%),
    radial-gradient(760px 480px at -8% 22%, #123043 0%, transparent 58%),
    var(--canvas);
}
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: .26;
  background-image: linear-gradient(#ffffff06 1px, transparent 1px), linear-gradient(90deg, #ffffff06 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 72%);
}

.shell { max-width: 1500px; margin: auto; padding: 32px clamp(32px, 4vw, 72px) 72px; }
.topbar { display: flex; align-items: center; min-height: 72px; gap: 24px; padding: 0 2px 25px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 1.2rem; font-weight: 780; letter-spacing: -.035em; }
.brand::before { width: 11px; height: 11px; border-radius: 50%; content: ""; background: linear-gradient(135deg, #a5f3da, #8174ed 62%); box-shadow: 0 0 0 5px #8174ed1c, 0 0 22px #8174ed77; }
.subtle, .muted { color: var(--muted); }
.subtle { font-size: .875rem; }
.nav, .actions, .quick, .field-row, .job-head, .asset-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.nav { margin-left: auto; }
.nav .subtle { margin: 0 6px 0 8px; color: var(--text-soft); }

button, .button, input, textarea, select { font: inherit; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; cursor: pointer; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 13px; color: var(--text-soft); background: #151c29; text-decoration: none; line-height: 1.2; transition: border-color .14s ease, background .14s ease, color .14s ease, transform .14s ease; }
button:hover, .button:hover { border-color: #586a89; background: var(--surface-hover); color: #fff; }
button:active, .button:active { transform: translateY(1px); }
button:disabled, .button[aria-disabled="true"] { cursor: wait; opacity: .58; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .dropzone:focus-visible { outline: 3px solid #72d3ff99; outline-offset: 3px; }
.primary { border-color: #8477ef; color: #fff; background: var(--accent); box-shadow: 0 7px 18px #30257a55; }
.primary:hover { border-color: #a49bff; background: var(--accent-hover); color: #fff; }
.danger { border-color: #7c3848; color: var(--danger); background: #291820; }
.danger:hover { border-color: #b65d70; color: #ffd6dc; background: var(--danger-soft); }
.link { min-height: unset; border: 0; padding: 5px 6px; color: #9fc6ff; background: transparent; }
.link:hover { color: #d5e7ff; background: #1b2941; }

.card { position: relative; overflow: hidden; margin-top: 22px; border: 1px solid var(--border); border-radius: 14px; padding: 25px 27px; background: linear-gradient(145deg, #151c29, #101620 56%); box-shadow: 0 22px 52px #0000001f, inset 0 1px #ffffff07; }
.card h1, .card h2, .card h3 { margin: 0 0 14px; color: #fff; line-height: 1.2; letter-spacing: -.025em; }
.card h1 { font-size: 1.5rem; }
.card h2 { font-size: 1.08rem; }
.card h3 { font-size: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
label, .label { display: block; margin-bottom: 7px; color: var(--text-soft); font-size: .875rem; font-weight: 670; }
input, textarea, select { width: 100%; border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 11px; color: var(--text); background: var(--field); box-shadow: inset 0 1px 2px #00000034; transition: border-color .14s ease, box-shadow .14s ease, background .14s ease; }
input::placeholder, textarea::placeholder { color: #718096; }
input:hover, textarea:hover, select:hover { border-color: #52637f; }
input:focus, textarea:focus, select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px #72d3ff1f, inset 0 1px 2px #00000034; }
select option { color: var(--text); background: #121925; }
textarea { min-height: 120px; resize: vertical; }
input[type="checkbox"] { accent-color: #8a7ff5; }
.hint, .field-error { margin: 7px 0 0; font-size: .8125rem; }
.hint { color: var(--muted); }
.field-error { color: #ffabb7; }
.check { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; color: var(--text-soft); font-weight: 500; }
.check input { width: auto; }

.dropzone { min-height: 94px; border: 1px dashed #52637f; border-radius: 10px; padding: 20px; color: var(--text-soft); text-align: center; background: #0e1521; transition: border-color .14s ease, background .14s ease, box-shadow .14s ease; }
.dropzone:hover, .dropzone.drag { border-color: #8a7ff5; background: #161d31; box-shadow: inset 0 0 0 1px #8a7ff52b; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.reference { display: flex; align-items: center; gap: 14px; text-align: left; }
.reference img { width: 72px; height: 72px; border: 1px solid var(--border-strong); border-radius: 8px; object-fit: cover; }

.jobs { display: grid; gap: 11px; }
.job { border: 1px solid var(--border); border-radius: 10px; padding: 15px 16px; background: #0e141e; transition: border-color .14s ease, background .14s ease; }
.job:hover { border-color: #40506c; background: #111924; }
.job-head { justify-content: space-between; gap: 18px; }
.job-title { max-width: 780px; overflow: hidden; color: #eef2f8; font-weight: 690; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { display: inline-block; border: 1px solid #3a465a; border-radius: 999px; padding: 3px 8px; color: #bdc9d9; background: #202938; font-size: .75rem; line-height: 1.25; }
.status-ready { border-color: #286650; color: var(--success); background: var(--success-soft); }
.status-error { border-color: #813a4b; color: var(--danger); background: var(--danger-soft); }
.status-progress { border-color: #365785; color: var(--info); background: var(--info-soft); }
.job-detail { margin-top: 15px; border-top: 1px solid var(--border); padding-top: 16px; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 13px; }
.asset-grid-stable { grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); margin-top: 13px; }
.asset { overflow: hidden; min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: #111823; box-shadow: 0 8px 20px #0000001c; }
.asset figure { position: relative; aspect-ratio: 1; margin: 0; background: #0a0e15; }
.asset img { display: block; width: 100%; height: 100%; object-fit: contain; transition: transform .22s ease, opacity .16s ease; }
.asset:hover img { transform: scale(1.025); }
.asset input { position: absolute; z-index: 1; top: 10px; left: 10px; width: 18px; height: 18px; box-shadow: 0 1px 6px #000000ad; }
.asset-meta { padding: 10px; color: var(--muted); font-size: .8125rem; }
.asset-meta b { color: var(--text-soft); font-weight: 670; }
.asset-placeholder figure { display: grid; overflow: hidden; place-items: center; background: linear-gradient(135deg, #101827, #0b111b); }
.asset-placeholder-mark { position: relative; width: 38%; aspect-ratio: 1; border: 2px solid #4b5a72; border-right-color: transparent; border-radius: 50%; opacity: .72; animation: asset-spin 1.15s linear infinite; }
.asset-placeholder-index { position: absolute; top: 10px; left: 11px; color: #8492a7; font-size: .75rem; font-weight: 700; }
.asset-placeholder .asset-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-height: 53px; }
.asset-placeholder .asset-meta span { color: var(--muted); font-size: .75rem; text-align: right; }
.asset-pending { border-style: dashed; }
.asset-working { border-color: #365785; }
.asset-working .asset-placeholder-mark { border-color: #72d3ff; border-right-color: transparent; }
.asset-saving { border-color: #5a577e; }
.asset-saving .asset-placeholder-mark { border-color: #9d92ff; border-right-color: transparent; }
.asset-failed { border-color: #813a4b; background: #1d151d; }
.asset-failed .asset-placeholder-mark { width: 28%; border: 0; border-radius: 0; animation: none; }
.asset-failed .asset-placeholder-mark::before, .asset-failed .asset-placeholder-mark::after { position: absolute; width: 4px; height: 100%; border-radius: 5px; content: ''; background: #ff9ba9; transform: rotate(45deg); }
.asset-failed .asset-placeholder-mark::after { transform: rotate(-45deg); }
.asset-failed .asset-meta span { color: #ffabb7; }
.gallery-progress { margin-top: 13px; border: 1px solid #365785; border-radius: 8px; padding: 8px 11px; color: var(--info); background: var(--info-soft); font-size: .8125rem; }
.gallery-partial { border-color: #813a4b; color: #ffbdc5; background: var(--danger-soft); }
@keyframes asset-spin { to { transform: rotate(360deg); } }
.asset-actions { margin-top: 8px; }
.asset-actions .button { min-height: 33px; padding: 6px 10px; }

.empty { padding: 34px; color: var(--muted); text-align: center; }
.loading { padding: 72px; color: var(--muted); text-align: center; }
.auth { max-width: 430px; margin: 11vh auto; }
.auth .card { margin-top: 0; padding: 29px; }
.notice { margin-bottom: 18px; border: 1px solid #315280; border-radius: 9px; padding: 11px 13px; color: #c7ddff; background: #142442; font-size: .875rem; }
.notice.error { border-color: #813a4b; color: #ffc4cc; background: var(--danger-soft); }

.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.settings > div { min-height: 86px; border: 1px solid var(--border); border-radius: 9px; padding: 13px; background: #0e141e; }
.settings b { display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--text-soft); font-size: .9rem; }
.admin-list { width: 100%; border-collapse: separate; border-spacing: 0; color: var(--text-soft); font-size: .875rem; }
.admin-list th, .admin-list td { border-bottom: 1px solid var(--border); padding: 12px 9px; text-align: left; vertical-align: middle; }
.admin-list th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #151c29; font-weight: 650; }
.admin-list tr:hover td { background: #171f2d; }
.admin-list td.actions { min-width: 290px; }

.stats-intro { margin: -6px 0 0; }
.stats-filter { display: grid; grid-template-columns: 1fr 1fr minmax(220px, 1.3fr) auto; align-items: end; gap: 14px; margin-top: 22px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: #0e141e; }
.stats-filter-action { padding-bottom: 0; }
.stats-filter-action button { min-width: 118px; }
.stats-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.stats-cards article { min-height: 128px; border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: linear-gradient(145deg, #121b29, #0d131d); }
.stats-cards article:nth-child(2), .stats-cards article:nth-child(4) { border-color: #3b3970; background: linear-gradient(145deg, #1a1a36, #111524); }
.stats-cards span, .stats-cards small { display: block; color: var(--muted); font-size: .78rem; }
.stats-cards b { display: block; margin: 9px 0 6px; color: #fff; font-size: 1.45rem; letter-spacing: -.03em; }
.provider-spend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 9px 0 6px; }
.provider-spend > div + div { border-left: 1px solid var(--border); padding-left: 12px; }
.provider-spend span { white-space: nowrap; font-size: .72rem; }
.provider-spend b { margin: 3px 0 0; font-size: 1.05rem; }
.stats-section { margin-top: 25px; }
.stats-section h2 { margin-bottom: 0; }
.stats-table { margin-top: 11px; }
.stats-table td:not(:first-child), .stats-table th:not(:first-child) { text-align: right; }
.stats-empty { padding: 23px; }
.stats-loading { padding: 48px; }

.modal { width: min(900px, calc(100vw - 56px)); max-width: 900px; border: 1px solid #3b4a65; border-radius: 14px; padding: 0; color: var(--text); background: #131a26; box-shadow: 0 26px 72px #00000099; }
.modal::backdrop { background: #05070cc4; backdrop-filter: blur(4px); }
.modal-inner { padding: 22px; }
.modal img { display: block; max-width: 100%; max-height: 76vh; margin: 14px auto 0; border-radius: 8px; background: #070a10; }
.toast { position: fixed; right: 28px; bottom: 28px; z-index: 5; max-width: 390px; border: 1px solid #3b4a65; border-radius: 9px; padding: 11px 14px; color: #fff; background: #151c29; box-shadow: 0 16px 42px #0000006e; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: none; }
.hidden { display: none !important; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.expiry { color: #ffc778; }
.mini { font-size: .75rem; }
.tab-active { border-color: #8174ed; color: #e3e0ff; background: var(--accent-soft); box-shadow: inset 0 0 0 1px #8e83f536; }
details { border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; color: var(--text-soft); background: #0e141e; }
summary { cursor: pointer; color: #cbd7e8; font-weight: 650; }
details ol { max-height: 230px; overflow: auto; padding-left: 24px; color: var(--muted); }

@media (min-width: 1800px) {
  .shell { max-width: 1680px; }
  .form-grid { grid-template-columns: 1.25fr 1fr 1fr; }
  .form-grid .wide { grid-column: 1 / -1; }
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media (max-width: 1199px) {
  .shell { padding-inline: 32px; }
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
  .job-title { max-width: 520px; }
  .stats-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-filter-action button { width: 100%; }
  .stats-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
