:root {
  --bg: #f3f4f7; --card: #fff; --ink: #1c2130; --muted: #6b7280; --line: #e3e6ec;
  --brand: #1f2a44; --accent: #c98a1b; --ok: #15803d; --bad: #b91c1c; --warn: #b45309;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11141c; --card: #1a1f2b; --ink: #e8eaf0; --muted: #9aa3b5; --line: #2b3242; --brand: #0f1524; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 13px; } .grow { flex: 1; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; background: var(--brand); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.top .brand { font-weight: 700; letter-spacing: .3px; }
.top a { color: #cfd6e6; margin-left: auto; text-decoration: none; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: #cfd6e6; border: 0; padding: 6px 12px; border-radius: 8px; font-size: 15px; }
.tab.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }

main { padding: 12px; max-width: 900px; margin: 0 auto; }
.tab-panel { display: none; } .tab-panel.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
h2 { margin: 0 0 4px; font-size: 18px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.btn { display: inline-block; background: var(--card); color: var(--ink); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 15px; cursor: pointer; text-align: center; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.icon { background: none; border: 0; font-size: 24px; color: var(--muted); cursor: pointer; }
.upload-row { display: flex; gap: 10px; margin-top: 10px; }
.upload-row .btn { flex: 1; }

input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input[type=search] { font-size: 16px; }
label { display: block; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 3px; font-size: 14px; }
.filters select { flex: 1; }

/* job cards */
.job { position: relative; }
.job .thumb { width: 100%; max-height: 220px; object-fit: contain; background: #000; border-radius: 8px; }
.job .status { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.running { background: var(--warn); animation: pulse 1s infinite; }
.dot.done { background: var(--ok); } .dot.failed { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }
.entry { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 10px; }
.entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.entry-head strong { font-size: 16px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.badge.new { background: #dcfce7; color: var(--ok); }
.badge.exists { background: #fef3c7; color: var(--warn); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr 1fr; } }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 13px; }
.ok { color: var(--ok); font-size: 13px; }

/* catalog list */
.list .item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: center; cursor: pointer; }
.item .cat { font-weight: 700; font-size: 16px; }
.item .cat small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.item .main { min-width: 0; }
.item .main .sig { font-weight: 600; }
.item .main .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .price { font-weight: 700; color: var(--accent); white-space: nowrap; }
.item .price small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; text-align: right; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: var(--card); width: 100%; max-width: 760px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .modal-box { border-radius: 16px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.detail dl { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; margin: 0; font-size: 14px; }
.detail dt { color: var(--muted); } .detail dd { margin: 0; }
.detail img { width: 100%; border-radius: 8px; margin-top: 8px; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { margin: 0; font-size: 22px; }
