/* T3 Code look: neutral dark canvas, raised sidebar, hairline borders, compact controls. */
:root {
  color-scheme: dark;
  --background: #0a0a0a;
  --card: color-mix(in srgb, var(--background) 97%, white);
  --foreground: #f5f5f5;
  --muted-fg: color-mix(in srgb, #737373 90%, white);
  --muted: rgb(255 255 255 / 3%);
  --accent: rgb(255 255 255 / 4%);
  --accent-strong: rgb(255 255 255 / 7%);
  --border: rgb(255 255 255 / 6%);
  --input: rgb(255 255 255 / 9%);
  --primary: oklch(57.1% 0.21 264);
  --success: #34d399;
  --warning: #fbbf24;
  --error: #fb414a;
  --info: #60a5fa;
  --radius: 0.625rem;
  --control-radius: 0.5rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --background: #fdfdfd;
    --card: #ffffff;
    --foreground: #27272a;
    --muted-fg: #71717a;
    --muted: #fafafa;
    --accent: #f4f4f5;
    --accent-strong: #e9e9ec;
    --border: #e4e4e7;
    --input: #d4d4d8;
    --primary: oklch(48.8% 0.217 264);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--background); color: var(--foreground); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a.link, .content p a, td a.link { color: var(--info); }
a.link:hover { text-decoration: underline; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
code, .mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted-fg); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 0.5rem; background: var(--card); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.5rem 0.875rem; font-weight: 600; letter-spacing: -0.01em; }
.logo { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--primary); color: #fff; font: 600 12px var(--mono); }
.side-label { padding: 0.75rem 0.5rem 0.25rem; font-size: 12px; color: var(--muted-fg); }
.side-row { display: flex; align-items: center; gap: 0.5rem; min-height: 30px; padding: 0.25rem 0.5rem; border-radius: var(--control-radius); color: var(--muted-fg); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row:hover { background: var(--accent); color: var(--foreground); }
.side-row.active { background: var(--accent-strong); color: var(--foreground); }
.side-foot { margin-top: auto; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.side-foot button { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-fg); opacity: 0.45; }
.dot.on { background: var(--success); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 8%, transparent); } }

.main { display: flex; flex-direction: column; min-width: 0; }
.toolbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 0.75rem; min-height: 48px; padding: 0.5rem 1.25rem; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 82%, transparent); backdrop-filter: blur(16px) saturate(1.08); }
.toolbar h1 { margin: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar .crumb { color: var(--muted-fg); font-weight: 400; }
.toolbar .spacer { flex: 1; }
.content { width: 100%; max-width: 1360px; padding: 1.25rem; }

.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { padding: 0.5rem 0.75rem; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted-fg); font-size: 13px; white-space: nowrap; }
.tab:hover { color: var(--foreground); }
.tab.active { color: var(--foreground); border-color: var(--foreground); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card.pad { padding: 1rem 1.125rem; }
.scroll { overflow-x: auto; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.25rem 1.5rem; }
.kv dt { font-size: 12px; color: var(--muted-fg); }
.kv dd { margin: 0 0 0.625rem; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
.stat { padding: 0.75rem 1rem; }
.stat b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--muted-fg); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--muted); }
td.prompt { max-width: 280px; color: var(--muted-fg); font-size: 12px; }
td.prompt a { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
td.prompt a:hover { color: var(--foreground); }
tr.off td { opacity: 0.55; }

input, select, textarea { padding: 0.3125rem 0.5rem; border: 1px solid var(--input); border-radius: var(--control-radius); background: transparent; color: var(--foreground); font: inherit; font-size: 13px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: color-mix(in srgb, var(--primary) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
select option { background: var(--card); color: var(--foreground); }
input[type="number"] { width: 4.25rem; }
input.time { width: 4.25rem; text-align: center; font-variant-numeric: tabular-nums; }
.row.nowrap { flex-wrap: nowrap; }
input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; }
input.wide, select.wide { width: 100%; }
textarea { width: 100%; min-height: 160px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
textarea.tall { min-height: 460px; }
label.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 12px; color: var(--muted-fg); }
label.field > :not(span) { color: var(--foreground); }
label.check { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.875rem 1rem; }

.btn { display: inline-flex; align-items: center; gap: 0.375rem; height: 30px; padding: 0 0.75rem; border: 1px solid var(--input); border-radius: var(--control-radius); background: var(--muted); color: var(--foreground); font: 500 13px var(--font); white-space: nowrap; cursor: pointer; }
.btn:hover { background: var(--accent-strong); }
.btn.primary { border-color: transparent; background: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--error); }
.btn.sm { height: 26px; padding: 0 0.5rem; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: default; }
form.inline { display: inline; }

.badge { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0 0.5rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted-fg); font-size: 12px; line-height: 20px; white-space: nowrap; }
.badge.done { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); background: color-mix(in srgb, var(--success) 8%, transparent); }
.badge.error, .badge.interrupted { color: var(--error); border-color: color-mix(in srgb, var(--error) 30%, transparent); background: color-mix(in srgb, var(--error) 8%, transparent); }
.badge.running { color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); background: color-mix(in srgb, var(--info) 8%, transparent); }
.badge.stopped { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); background: color-mix(in srgb, var(--warning) 8%, transparent); }

.flash { margin-bottom: 1rem; padding: 0.625rem 0.875rem; border: 1px solid; border-radius: var(--control-radius); font-size: 13px; }
.flash.error { color: var(--error); border-color: color-mix(in srgb, var(--error) 35%, transparent); background: color-mix(in srgb, var(--error) 8%, transparent); }
.flash.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 8%, transparent); }

pre { max-height: 72vh; margin: 0; padding: 0.875rem 1rem; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--muted); font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
details.block > summary { padding: 0.25rem 0; color: var(--muted-fg); font-size: 13px; font-weight: 500; cursor: pointer; }
details.block[open] > summary { margin-bottom: 0.5rem; color: var(--foreground); }
.entry + .entry { margin-top: 1.25rem; }
.entry h3 { margin: 0 0 0.375rem; font-size: 13px; font-weight: 600; }
.pager { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.75rem; }

.login { display: grid; place-items: center; min-height: 100vh; }
.login form { display: flex; flex-direction: column; gap: 0.75rem; width: 320px; padding: 1.5rem; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--input); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .side-label { display: none; }
  .side-foot { margin: 0; padding: 0; border: 0; display: flex; }
  .content { padding: 0.875rem; }
}
