:root {
  --bg: #050816;
  --surface: #0f172ab8;
  --surface-strong: #111827e6;
  --surface-soft: #1e293b94;
  --line: #94a3b838;
  --line-strong: #94a3b85c;
  --text: #edf5ff;
  --muted: #9badc5;
  --subtle: #64748b;
  --cyan: #22d3ee;
  --blue: #60a5fa;
  --violet: #a78bfa;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #fb7185;
  --shadow: 0 30px 90px #0000006b;
  --radius: 20px;
  --radius-lg: 26px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  background: radial-gradient(circle at 8% -12%, #22d3ee3d, #0000 30rem),
    radial-gradient(circle at 88% -8%, #a78bfa3d, #0000 32rem),
    radial-gradient(circle at 50% 110%, #34d39924, #0000 34rem),
    linear-gradient(145deg, #050816, #09111f 46%, #050816);
}

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--cyan); }

.mono, code { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }

::selection { background: var(--cyan); color: #020617; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #94a3b873; border: 3px solid #0000; border-radius: 999px; background-clip: padding-box; }

/* ===== App shell: sidebar + main ===== */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0f172a80, #05081680);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 18px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  font-weight: 900; font-size: 15px; color: #02111b;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 12px 30px #22d3ee40;
}
.brand .brand-text b { display: block; font-size: 15px; letter-spacing: -0.02em; }
.brand .brand-text span { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }

.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 14px;
  color: var(--muted); font-weight: 700; font-size: 14px;
  cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: background .16s, color .16s, border-color .16s;
}
.nav-item:hover { background: #ffffff08; color: var(--text); }
.nav-item.active {
  color: var(--text);
  background: radial-gradient(circle at 0 0, #22d3ee29, #0000 60%), #0f172aad;
  border-color: #22d3ee5c;
}
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; }
.nav-item .badge {
  margin-left: auto; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px;
  background: #94a3b826; color: var(--muted);
}
.nav-item.active .badge { background: #22d3ee33; color: var(--cyan); }

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.conn-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 4px 8px; }
.dot { width: 9px; height: 9px; border-radius: 999px; background: var(--subtle); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.run { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 1.2s infinite; }
.dot.err { background: var(--red); box-shadow: 0 0 10px var(--red); }
@keyframes pulse { 50% { opacity: .35; } }

/* ===== Main ===== */
.main { min-width: 0; padding: 26px clamp(18px, 3vw, 40px) 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .eyebrow { color: var(--cyan); font-size: 11px; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.page-head .eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: linear-gradient(135deg, var(--cyan), var(--violet)); box-shadow: 0 0 16px #22d3eecc; }
.page-head h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.04em; }
.page-head .sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ===== Panels ===== */
.panel {
  position: relative;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff10, transparent 42%), var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.panel + .panel, .stack > * + * { margin-top: 16px; }
.stack { display: grid; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { font-size: 17px; letter-spacing: -0.02em; }
.panel-head .eyebrow { color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 4px; }
.panel-head .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.grid-2.wide-left { grid-template-columns: minmax(0,1.4fr) minmax(320px,0.6fr); }
@media (max-width: 1100px) { .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; } }

/* ===== Stat cards ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff12, transparent 44%), var(--surface);
  padding: 18px; min-height: 108px; box-shadow: var(--shadow);
}
.stat-card.glow { background: radial-gradient(circle at top right, #22d3ee2e, transparent 48%), var(--surface); border-color: #22d3ee59; }
.stat-card .label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.02em; }
.stat-card .value { display: block; margin-top: 12px; font-size: 36px; line-height: 1; letter-spacing: -0.05em; font-weight: 800; }
.stat-card .value.grad { background: linear-gradient(135deg, #fff, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card .foot { margin-top: 8px; font-size: 12px; color: var(--muted); }
.v-cyan { color: var(--cyan); } .v-green { color: var(--green); } .v-red { color: var(--red); } .v-yellow { color: var(--yellow); } .v-muted { color: var(--muted); }

/* ===== Buttons ===== */
button {
  font: inherit; border: 1px solid var(--line-strong); min-height: 38px; color: var(--text); cursor: pointer;
  background: #0f172ab8; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 15px; font-weight: 800; line-height: 1;
  transition: transform .16s, border-color .16s, box-shadow .16s, background .16s;
}
button:hover:not(:disabled) { border-color: #22d3ee7a; transform: translateY(-1px); box-shadow: 0 12px 30px #22d3ee1f; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { color: #02111b; background: linear-gradient(135deg, var(--cyan), var(--green)); border-color: transparent; box-shadow: 0 16px 40px #22d3ee42; }
button.ghost { background: #0f172a80; }
button.danger { color: #fecdd3; background: #fb71851f; border-color: #fb718573; }
button.danger:hover:not(:disabled) { border-color: #fb7185; box-shadow: 0 12px 30px #fb71851f; }
button.small { min-height: 32px; padding: 6px 12px; font-size: 12px; }
button.tiny { min-height: 26px; padding: 4px 9px; font-size: 11px; }
button.block { width: 100%; }

/* ===== Forms ===== */
label.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label.field > span { color: var(--muted); font-size: 12px; font-weight: 700; }
label.field > small { color: var(--subtle); font-size: 11px; line-height: 1.5; }
input, select, textarea {
  font: inherit; width: 100%; color: var(--text); background: #02061775;
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 9px 12px; outline: none;
  transition: border-color .16s, box-shadow .16s;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; font-family: "Cascadia Code", Consolas, monospace; }
input:focus, select:focus, textarea:focus { border-color: #22d3eeb8; box-shadow: 0 0 0 4px #22d3ee1f; }
input::placeholder, textarea::placeholder { color: #64748b; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--cyan); }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239badc5' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.field-inline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.field-inline input[type="checkbox"] { width: auto; }

.settings-section { border: 1px solid var(--line); background: #02061742; border-radius: var(--radius); padding: 18px; }
.settings-section + .settings-section { margin-top: 14px; }
.settings-section h3 { color: var(--cyan); font-size: 14px; margin-bottom: 14px; }
.key-state { font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.key-state.set { color: #bbf7d0; background: #34d3991f; border-color: #34d39957; }
.key-state.unset { color: #fde68a; background: #fbbf241a; border-color: #fbbf2452; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ===== Tables ===== */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); background: #0f172ac2; font-size: 12px; font-weight: 800; position: sticky; top: 0; z-index: 1; }
tbody tr { background: #02061733; }
tbody tr:hover { background: #22d3ee0f; }
tbody tr:last-child td { border-bottom: 0; }
td.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.empty-row { text-align: center; color: var(--muted); padding: 26px 12px; }
.action-cell { display: flex; flex-wrap: wrap; gap: 5px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.pending { color: var(--muted); background: #94a3b826; }
.pill.running { color: var(--cyan); background: #22d3ee33; }
.pill.success, .pill.active, .pill.ok { color: var(--green); background: #34d39926; }
.pill.failed, .pill.fail, .pill.error { color: var(--red); background: #fb718526; }
.pill.warn, .pill.stopped { color: var(--yellow); background: #fbbf2426; }
.pill.neutral, .pill.idle { color: var(--muted); background: #94a3b81f; }
.pill.done { color: var(--green); background: #34d39926; }
.pill.verified { color: var(--green); background: #34d39926; }

.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.warn-text { color: var(--yellow); font-size: 13px; line-height: 1.55; }

.badge-cred { display: inline-block; margin-right: 3px; padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.badge-cred.ok { color: var(--green); background: #34d39926; }
.badge-cred.fail { color: var(--red); background: #fb718526; }

.quota { display: flex; align-items: center; gap: 6px; }
.quota .bar { width: 54px; height: 6px; border-radius: 3px; background: #0000004d; overflow: hidden; }
.quota .fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--green)); transition: width .3s; }
.quota .fill.warn { background: linear-gradient(90deg, var(--yellow), var(--red)); }
.quota .txt { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 30px; text-align: right; }

/* ===== Progress ===== */
.progress { margin: 4px 0 2px; }
.progress .track { height: 10px; border-radius: 6px; background: #00000059; overflow: hidden; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .3s; }
.progress .txt { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* ===== Logs ===== */
.log-view { background: #0006; border-radius: 14px; padding: 14px; height: 420px; overflow-y: auto; font-family: "Cascadia Code", "SF Mono", monospace; font-size: 12px; line-height: 1.65; }
.log-view.short { height: 300px; }
.log-line { word-break: break-word; margin-bottom: 2px; color: var(--text); }
.log-line.warn { color: var(--yellow); }
.log-line.error { color: var(--red); }
.log-line .ts { color: var(--subtle); margin-right: 8px; }
.log-empty { color: var(--subtle); text-align: center; padding: 30px; }

/* ===== Toolbar / filters ===== */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.filter-select { width: auto; min-width: 130px; }
.count-tag { color: var(--muted); font-size: 13px; }

.pagination { display: flex; align-items: center; gap: 12px; padding: 12px 4px 2px; font-size: 13px; color: var(--muted); }
.pagination .jump { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pagination .jump input { width: 60px; text-align: center; padding: 5px 6px; }

/* ===== Modal ===== */
.modal-mask, .modal-overlay { position: fixed; inset: 0; z-index: 200; background: #0009; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { width: min(680px, 100%); max-height: 86vh; overflow-y: auto; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.modal.lg { width: min(920px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 22px; border-top: 1px solid var(--line); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.65; margin-bottom: 12px; }
.result-box { border: 1px solid var(--line); background: #02061740; border-radius: 12px; padding: 12px; margin-bottom: 14px; font-family: "Cascadia Code", monospace; font-size: 12px; white-space: pre-wrap; color: var(--muted); max-height: 200px; overflow-y: auto; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 24px; right: 24px; z-index: 300; min-width: 220px; padding: 13px 18px; border-radius: 16px; background: #0f172aee; border: 1px solid #22d3ee59; box-shadow: var(--shadow); backdrop-filter: blur(18px); font-size: 14px; }
.toast.err { border-color: #fb718573; }

.fade-enter-active, .fade-leave-active { transition: opacity .2s, transform .2s; }
.fade-enter-from, .fade-leave-to { opacity: 0; transform: translateY(8px); }

/* ===== Mobile ===== */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 4px 8px; }
  .nav { grid-auto-flow: column; grid-template-columns: none; overflow-x: auto; flex: 1; }
  .nav-item .badge { display: none; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
}
