:root {
  --bg: #fafafa; --panel: #ffffff; --side: #f4f4f5; --text: #18181b; --muted: #71717a;
  --border: #e4e4e7; --hover: #f4f4f5; --primary: #18181b; --primary-text: #fafafa;
  --ok: #047857; --ok-bg: #10b98122; --warn: #b45309; --warn-bg: #f59e0b22;
  --error: #be123c; --error-bg: #f43f5e1f; --info: #0369a1; --info-bg: #0ea5e91f;
  --violet: #6d28d9; --violet-bg: #8b5cf61f; --orange: #c2410c; --orange-bg: #f9731622;
  --muted-bg: #71717a1f; --ring: #a1a1aa; --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b; --panel: #111113; --side: #0c0c0e; --text: #fafafa; --muted: #a1a1aa;
    --border: #27272a; --hover: #18181b; --primary: #fafafa; --primary-text: #18181b;
    --ok: #34d399; --warn: #fbbf24; --error: #fb7185; --info: #38bdf8; --violet: #a78bfa; --orange: #fb923c;
    --ring: #52525b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090b; --panel: #111113; --side: #0c0c0e; --text: #fafafa; --muted: #a1a1aa;
  --border: #27272a; --hover: #18181b; --primary: #fafafa; --primary-text: #18181b;
  --ok: #34d399; --warn: #fbbf24; --error: #fb7185; --info: #38bdf8; --violet: #a78bfa; --orange: #fb923c;
  --ring: #52525b; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
h1 { font-size: 22px; margin: 18px 0 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 22px 0 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; text-decoration: none; }
.nowrap { white-space: nowrap; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .error { color: var(--error); }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 230px; flex: none; background: var(--side); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 800; font-size: 18px; text-decoration: none; padding: 4px 10px 16px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius); text-decoration: none; }
.side nav a:hover { background: var(--hover); }
.side nav a.active { background: var(--panel); border: 1px solid var(--border); padding: 7px 9px; font-weight: 600; }
.side svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px; border-top: 1px solid var(--border); }
.side-foot .user { width: 100%; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.main { flex: 1; min-width: 0; padding: 18px 28px 60px; max-width: 1800px; }
.btn.menu-btn { display: none; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

@media (max-width: 860px) {
  .shell { display: block; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; transform: translateX(-100%); box-shadow: 0 0 30px #0006; }
  .side.open { transform: none; }
  .main { padding: 12px 16px 60px; }
  .btn.menu-btn { display: inline-flex; margin-bottom: 8px; }
}

/* elements */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 40px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs > * + *::before { content: "›"; margin-right: 6px; color: var(--muted); }
.crumbs span:last-child { color: var(--text); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.push { margin-left: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn.danger:hover { opacity: .9; }
.btn.danger-text { color: var(--error); }
.card.danger-zone { border-color: var(--error); margin-top: 16px; }
.danger-zone form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.danger-zone input { max-width: 320px; flex: 1 1 200px; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled], .btn.busy { opacity: .6; pointer-events: none; }
.btn.busy::before { 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); } }

input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); height: 36px; padding: 0 10px; width: 100%; }
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; flex: none; accent-color: var(--primary); }
input[type="color"] { width: 48px; padding: 2px; flex: none; cursor: pointer; }
input.readonly { background: var(--hover); color: var(--muted); }
input.alpha { width: 80px; flex: none; }
.search { max-width: 420px; margin: 14px 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.badge { display: inline-block; min-width: 22px; text-align: center; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--primary); color: var(--primary-text); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.error { background: var(--error-bg); color: var(--error); } .pill.info { background: var(--info-bg); color: var(--info); }
.pill.violet { background: var(--violet-bg); color: var(--violet); } .pill.orange { background: var(--orange-bg); color: var(--orange); }
.pill.muted { background: var(--muted-bg); color: var(--muted); }

.flash { position: relative; padding: 10px 36px 10px 14px; border-radius: var(--radius); margin: 8px 0 14px; white-space: pre-line; border: 1px solid transparent; }
.flash.ok { background: var(--ok-bg); color: var(--ok); } .flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.error { background: var(--error-bg); color: var(--error); }
.flash .x { position: absolute; right: 6px; top: 4px; border: 0; background: none; color: inherit; font-size: 20px; cursor: pointer; }

/* login */
.login { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login h1 { margin: 0 0 4px; }
label { display: grid; gap: 4px; }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }

/* projects */
.pulls { display: grid; gap: 10px; }
.pull { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.pull summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.pull summary a { text-decoration: none; }
.pull ul { list-style: none; margin: 0; padding: 0 0 6px; columns: 3 260px; column-gap: 0; }
.pull li { break-inside: avoid; }
.pull li a, .list a { display: block; padding: 6px 14px; text-decoration: none; border-radius: 6px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.pull li a:hover, .list a:hover { background: var(--hover); color: var(--text); }
.list { padding: 6px; columns: 3 260px; }
[hidden] { display: none !important; }

/* tabs */
.tabs { display: flex; gap: 4px; margin: 22px 0 6px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--text); font-weight: 600; }

/* assets */
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.asset { display: grid; gap: 4px; justify-items: center; }
.asset-drop { position: relative; width: 100%; aspect-ratio: 4/3; border: 1px dashed var(--border); border-radius: 10px; display: grid; place-items: center; cursor: pointer; overflow: hidden;
  background: repeating-conic-gradient(var(--hover) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.asset-drop:hover { border-color: var(--ring); }
.asset-drop img, .asset-drop video { max-width: 92%; max-height: 92%; object-fit: contain; }
.asset-missing, .asset-busy { display: none; font-size: 12px; color: var(--muted); }
.asset-drop.missing .asset-missing { display: block; }
.asset-drop.missing img { display: none; }
.asset.busy .asset-busy { display: grid; place-items: center; position: absolute; inset: 0; background: var(--panel); color: var(--text); }

/* forms */
.form .section, .section { margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 16px; }
.field-name { font-weight: 600; font-size: 13px; }
.help { display: block; font-size: 12px; color: var(--muted); }
.check.field { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.sticky-save { position: sticky; bottom: 0; padding: 14px 0; margin-top: 18px; background: linear-gradient(transparent, var(--bg) 35%); }

/* dialog */
.dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text); padding: 20px; width: min(440px, 92vw); }
.dialog::backdrop { background: #0008; }
.dialog form { display: grid; gap: 12px; }

/* tables */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.tile { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); text-decoration: none; }
.tile:hover { background: var(--hover); }
.tile.active { outline: 2px solid var(--ring); }
.tile b { font-size: 24px; font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[type="search"] { max-width: 300px; }
.filters select { width: auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-weight: 500; color: var(--muted); font-size: 13px; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--hover); }
.table .c { text-align: center; }
.table .problem { min-width: 160px; }
.table .domain { min-width: 130px; max-width: 280px; overflow-wrap: anywhere; }
.table .domain .ext { color: var(--muted); text-decoration: none; margin-left: 2px; }
.table .domain .ext:hover { color: var(--text); }
.table tr.dim { opacity: .6; }
.table td.actions { text-align: right; }
.table td.actions form { display: inline; }
.empty-row { text-align: center; padding: 40px !important; }
.warn-icon { color: var(--warn); cursor: help; margin-left: 4px; }

.switch { width: 42px; height: 24px; border-radius: 999px; border: 0; background: var(--border); position: relative; cursor: pointer; padding: 0; }
.switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); box-shadow: 0 1px 3px #0004; transition: left .15s; }
.switch.on { background: var(--primary); }
.switch.on span { left: 21px; }
.switch[disabled] { opacity: .4; cursor: not-allowed; }

/* domain detail */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.warnings { margin: 14px 0 0; padding: 10px 14px; list-style: none; border-radius: var(--radius); background: var(--warn-bg); }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.timeline li { border-left: 2px solid var(--border); padding: 2px 0 2px 12px; }
.timeline li.failed { border-color: var(--error); }
.timeline li.failed b { color: var(--error); }

/* orders */
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.orders { display: grid; gap: 8px; }
.order { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); display: grid; gap: 4px; }
.order code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.empty { text-align: center; padding: 60px 0; }

/* Bulk actions bar: sticks to the top while rows are checked. */
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); position: sticky; top: 8px; z-index: 5; }
.bulk-bar[hidden] { display: none; }
.table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
pre.hint { white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--muted-bg);
  padding: 12px; border-radius: var(--radius); margin: 8px 0 0; user-select: all; }
.redirect-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.redirect-form input[name="target"] { flex: 1 1 260px; }
.redirect-form select { width: auto; }
ol.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
ol.history details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 8px 12px; }
ol.history summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.diff-body { font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-x: auto; margin: 10px 0; padding: 8px;
  background: var(--muted-bg); border-radius: var(--radius); white-space: pre; }
.diff-body .add { color: var(--ok); } .diff-body .del { color: var(--error); }
.diff-body .hunk { color: var(--info); } .diff-body .file { font-weight: 600; }

/* groups and bulk change */
.group-preview { max-width: 420px; }
.bulk-group { display: inline-flex; gap: 6px; align-items: center; }
.bulk-group select { width: auto; height: 30px; }
.bulk-table .val { max-width: 320px; overflow-wrap: anywhere; }
.card.form h3, .bulk-form h3 { margin: 0 0 4px; }
.card.form { display: grid; gap: 10px; align-content: start; }
