/* SRT Studio — internal tool styling. One accent, light bg, compact. */
:root {
  --accent: #4f46e5;
  --accent-weak: #eef2ff;
  --accent-ink: #3730a3;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6472;
  --muted: #8a93a3;
  --line: #e4e7ec;
  --line-2: #eef0f3;
  --ok: #0f7b4f;
  --ok-bg: #e6f5ee;
  --err: #b42318;
  --err-bg: #fdecea;
  --warn: #9a6700;
  --warn-bg: #fdf3d8;
  --queued: #1f6feb;
  --queued-bg: #e7f0ff;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
/* The `hidden` attribute must always win. Several components set an explicit
   `display` on a single-class selector (.boot, .gate, .toggle, .login-form…),
   which otherwise ties [hidden] on specificity and leaves the element visible.
   All visibility toggling in app.js relies on `el.hidden = true` hiding. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }

/* ---------- Boot / gate ---------- */
.boot {
  min-height: 60vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; color: var(--muted);
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gate { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; max-width: 460px; text-align: center;
}
.gate-card h1 { font-size: 20px; margin: 0 0 10px; }
.gate-card p { margin: 6px 0; color: var(--ink-2); }

/* ---------- Login ---------- */
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 24px; width: 100%; max-width: 380px;
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 650; font-size: 17px; }
.login-sub { text-align: center; margin: 5px 0 18px; }
.login-tabs { display: flex; width: 100%; margin-bottom: 16px; }
.login-tabs .seg-btn { flex: 1; text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form .field-label { margin-bottom: 0; }
.login-form .actions-row { margin-top: 4px; }
.login-form .btn-primary { flex: 1; }
.code-group { display: flex; flex-direction: column; gap: 8px; }
.login-hint { font-size: 12px; margin: 8px 0 0; }
#staff-msg, #admin-msg { margin: 6px 0 0; min-height: 1em; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; }
.logo { color: var(--accent); font-size: 18px; }
.who { display: flex; align-items: center; gap: 10px; }
.who-email { color: var(--ink-2); }
.badge {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 3px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2);
}
.badge-admin { background: var(--accent-weak); color: var(--accent-ink); }
.badge-user { background: var(--line-2); color: var(--ink-2); }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 18px; padding: 18px 22px; max-width: 1180px; margin: 0 auto; align-items: start;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.panel-title { font-size: 15px; font-weight: 650; margin: 0 0 12px; }
.sub-title { font-size: 13px; font-weight: 650; margin: 0 0 10px; }
.panel-head, .panel-head-right { display: flex; align-items: center; }
.panel-head { justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.panel-head .panel-title { margin: 0; }
.panel-head-right { gap: 12px; }

/* ---------- Fields ---------- */
.field { margin-bottom: 16px; }
.field-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px;
}
input[type="text"], input[type="number"], input[type="password"], input[type="email"] {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }

/* Dropzone */
.dropzone {
  display: block; border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 18px; text-align: center; cursor: pointer; background: #fafbfc;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-weak); }
.dropzone-inner { display: flex; flex-direction: column; gap: 3px; }
.dropzone-inner strong { color: var(--accent-ink); font-size: 14px; }

/* Selected files */
.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  border: 1px solid var(--line-2); border-radius: 6px; background: #fbfbfc;
}
.file-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { font-size: 12px; }
.mini-progress { width: 70px; height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; }
.mini-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.mini-bar.bar-done { background: var(--ok); }
.mini-bar.bar-error { background: var(--err); }
.icon-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 5px;
}
.icon-btn:hover { background: var(--line-2); color: var(--err); }

/* ---------- Params form ---------- */
.params-form { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.seg {
  display: inline-flex; background: var(--line-2); border-radius: 7px; padding: 3px; gap: 3px;
}
.seg-btn {
  border: none; background: transparent; padding: 6px 12px; border-radius: 5px;
  font: inherit; font-weight: 550; color: var(--ink-2); cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--accent-ink); box-shadow: var(--shadow); }
.param-group { display: flex; flex-direction: column; gap: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn {
  border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 6px;
  font: inherit; cursor: pointer; color: var(--ink-2); min-width: 40px;
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.custom-num { width: 92px !important; }

.advanced { border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 10px; }
.advanced summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 4px 0; }
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 0; }
.num-field { display: flex; flex-direction: column; gap: 4px; }
.num-field .field-label { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }
.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Inline messages ---------- */
.inline-msg { font-size: 12.5px; color: var(--ink-2); }
.msg-ok { color: var(--ok); }
.msg-err { color: var(--err); }
.msg-info { color: var(--queued); }

/* ---------- Chips ---------- */
.chip {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.chip-done { background: var(--ok-bg); color: var(--ok); }
.chip-error { background: var(--err-bg); color: var(--err); }
.chip-proc { background: var(--accent-weak); color: var(--accent-ink); }
.chip-queued { background: var(--queued-bg); color: var(--queued); }
.chip-wait { background: var(--warn-bg); color: var(--warn); }
.chip-upload { background: var(--line-2); color: var(--ink-2); }

/* ---------- Jobs list ---------- */
.jobs-list { display: flex; flex-direction: column; gap: 10px; }
.empty { padding: 20px 0; text-align: center; }
.job-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.job-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  background: #fff; border: none; cursor: pointer; font: inherit; text-align: left;
}
.job-head:hover { background: #fafbfc; }
.caret { color: var(--muted); transition: transform 0.15s; display: inline-block; }
.caret.open { transform: rotate(90deg); }
.job-title { font-weight: 600; }
.job-meta { flex: 1; font-size: 12.5px; }
.job-files { border-top: 1px solid var(--line-2); padding: 6px 13px 12px; display: flex; flex-direction: column; gap: 4px; }

.file-row { padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.file-row:last-child { border-bottom: none; }
.file-row-top { display: flex; align-items: center; gap: 9px; }
.file-row-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.file-dur { font-size: 12px; }
.progress { height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 7px 0 4px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.progress .bar.bar-done { background: var(--ok); }
.progress .bar.bar-error { background: var(--err); }

.outputs { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
.outputs-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.output-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; padding: 2px 0; }
.flags { display: flex; gap: 5px; flex-wrap: wrap; }
.flag-badge {
  font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--line-2); color: var(--ink-2);
}
.flag-badge.flag-warn { background: var(--warn-bg); color: var(--warn); }

.file-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.reformat-mount {
  margin-top: 10px; padding: 12px; background: #fafbfc;
  border: 1px solid var(--line-2); border-radius: 6px;
}

/* ---------- Toggle ---------- */
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.toggle input { width: auto; }

/* ---------- Admin ---------- */
.admin { max-width: 1180px; margin: 0 auto; padding: 6px 22px 40px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 12px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.overview { display: flex; flex-direction: column; gap: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat-tile { border: 1px solid var(--line-2); border-radius: 6px; padding: 10px 12px; background: #fafbfc; }
.stat-value { font-size: 19px; font-weight: 650; }
.stat-label { font-size: 11.5px; margin-top: 2px; }
.keys-by-status { display: flex; flex-direction: column; gap: 5px; }
.kv { display: flex; align-items: center; justify-content: space-between; max-width: 240px; }
.raw-json {
  background: #0f1220; color: #d6dbe5; padding: 12px; border-radius: 6px;
  font-family: var(--mono); font-size: 12px; overflow: auto;
}

.key-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.key-form .actions-row { grid-column: 1 / -1; }

.table-scroll { overflow-x: auto; }
.keys-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys-table th, .keys-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.keys-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
.key-label { font-weight: 600; }
.key-base { font-size: 11px; }
.usage { display: flex; flex-direction: column; gap: 3px; min-width: 130px; }
.usage-track { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.usage-fill { height: 100%; background: var(--accent); }
.usage-fill.over { background: var(--err); }
.usage-text { font-size: 11.5px; }
.key-actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .adv-grid, .key-form { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .layout, .admin { padding-left: 14px; padding-right: 14px; }
}
