:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e8ecf4;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: rgba(99,102,241,.08);
  --accent: #8b5cf6;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --green: #10b981;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --ink: #0f172a;
  --terminal: #0f172a;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.06), 0 4px 10px rgba(0,0,0,.04);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --glow: 0 0 0 3px rgba(99,102,241,.15);
  --h-topbar: 60px;
  --h-input: 38px;
  --h-btn: 38px;
  --h-panel-head: 50px;
  --h-dialog-head: 50px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  color: var(--text);
  background: var(--bg);
  font-family: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  font-size: 14px;
  letter-spacing: -.01em;
  line-height: 1.6;
  background-image: url("assets/bg.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; letter-spacing: -.01em; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
}

.brand {
  height: var(--h-topbar);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-mark, .avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav button {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
  transition: all .15s ease;
  font-size: 13.5px;
  font-weight: 500;
}

.nav button:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav button.active {
  background: rgba(99,102,241,.2);
  color: #fff;
  font-weight: 600;
}
.nav .glyph { font-size: 15px; opacity: .85; text-align: center; }

.rail-foot {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.workspace-pill {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
  padding: 12px;
  color: #94a3b8;
}

.page {
  min-width: 0;
  display: grid;
  grid-template-rows: var(--h-topbar) minmax(0, 1fr);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(248,249,252,.85);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
}

.page-title { min-width: 180px; }
.page-title h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; }

.global-search {
  flex: 1;
  max-width: 480px;
  height: var(--h-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 12px;
  color: var(--muted);
  transition: all .15s ease;
}
.global-search:focus-within { border-color: var(--primary); box-shadow: var(--glow); }

.global-search input {
  border: 0;
  outline: 0;
  width: 100%;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
}

.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-size: 12px; }

.main {
  min-width: 0;
  padding: var(--sp-6);
  overflow: auto;
}

.grid { display: grid; gap: var(--sp-4); }
.grid > *, .split > *, .form-grid > * { min-width: 0; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); align-items: start; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel.flat { box-shadow: none; }
.panel.detail { box-shadow: var(--shadow-md); }
.panel-head {
  height: var(--h-panel-head);
  padding: 0 var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
}

.panel-head h2, .panel-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.panel-body { padding: var(--sp-5); }

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-5);
  min-height: 120px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.metric::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: .7;
}
.metric .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.metric .value {
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.metric .hint { color: var(--muted); font-size: 12px; }
.metric-line { height: 24px; margin-top: 10px; color: var(--primary); }
.metric.mini { min-height: 80px; box-shadow: none; }
.metric.mini::before { display: none; }

.toolbar {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.toolbar.right { justify-content: flex-end; }
.toolbar.mt-14 { margin-top: var(--sp-4); }

.btn {
  height: var(--h-btn);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all .15s ease;
  font-weight: 500;
  font-size: 13px;
}
.btn:hover { border-color: #cbd5e1; background: var(--surface-2); text-decoration: none; box-shadow: var(--shadow); }
.btn.primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
  transform: translateY(-1px);
}
.btn.blue { background: var(--blue); border-color: transparent; color: #fff; }
.btn.danger { color: var(--red); border-color: rgba(239,68,68,.2); background: rgba(239,68,68,.04); }
.btn.danger:hover { border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.full { width: 100%; }

.input, input, select, textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  height: var(--h-input);
  padding: 0 12px;
  outline: 0;
  max-width: 100%;
  color: var(--text);
  transition: all .15s ease;
}
select { color: var(--text); }
select option { background: var(--surface); color: var(--text); }
textarea { padding: 10px 12px; height: auto; min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--glow);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: var(--sp-3);
}
.form-grid.three { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
.form-grid .span { grid-column: 1 / -1; }

.table-wrap { overflow: auto; }
.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.data th, .data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.data th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface-2);
}
.data tr:hover td { background: rgba(99,102,241,.02); }

.empty {
  min-height: 118px;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  color: var(--muted);
  text-align: center;
}

.list { display: flex; flex-direction: column; gap: var(--sp-2); }
.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
  transition: all .15s ease;
}
.item:hover { border-color: #c7d2fe; box-shadow: var(--shadow); }
.item.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-md); }
.item b, .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--sp-3);
}
.file-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: all .2s ease;
}
.file-card[draggable="true"] { cursor: grab; }
.file-card.dragging { opacity: .3; }
.file-card.drag-over { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.file-card:hover { border-color: #c7d2fe; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.file-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-md); }
.thumb {
  height: 118px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 24px;
  overflow: hidden;
  letter-spacing: .05em;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.file { background: linear-gradient(135deg, #94a3b8, #64748b); }
.thumb.folder { background: linear-gradient(135deg, #f59e0b, #d97706); }
.thumb.image { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.thumb.video { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.thumb.audio { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.thumb.doc { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.thumb.archive { background: linear-gradient(135deg, #10b981, #059669); }
.thumb.code { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.file-meta { padding: 10px 12px; }
.file-meta b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.drop {
  min-height: 88px;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  background: rgba(99,102,241,.02);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  margin-bottom: var(--sp-4);
  transition: all .15s ease;
}
.drop.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.upload-queue { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.upload-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 14px;
}
.upload-head {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: 8px;
}
.upload-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  border: 0;
  background: var(--surface-3);
  overflow: hidden;
}
.upload-bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.upload-bar::-webkit-progress-value { background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 999px; }
.upload-bar::-moz-progress-bar { background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 999px; }

.detail { position: sticky; top: calc(var(--h-topbar) + var(--sp-6)); }
.preview {
  height: 220px;
  border-radius: var(--radius);
  background: var(--surface-3);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
}
.preview img, .preview iframe, .preview audio, .preview video { width: 100%; height: 100%; border: 0; object-fit: contain; background: #fff; }
.preview audio { height: auto; padding: 0 var(--sp-3); background: transparent; }
.preview-symbol.large { font-size: 48px; }
.preview-symbol.medium { font-size: 42px; }

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0;
  margin-top: 8px;
}
.copy-row input { border-radius: 8px 0 0 8px; color: var(--muted); font-size: 12px; }
.copy-row button { min-width: 56px; border-left: 0; border-radius: 0 8px 8px 0; }

.provider-guide-card { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line-soft); }
.provider-guide-card:first-child { padding-top: 0; }
.provider-guide-card:last-child { border-bottom: 0; padding-bottom: 0; }
.provider-guide-card summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.provider-guide-card summary::-webkit-details-marker { display: none; }

.bucket-main { min-width: 0; }
.bucket-stats { align-items: stretch; }
.bucket-form-note { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.bucket-form-pill { flex: 0 0 auto; }
.bucket-form-actions { display: grid; gap: var(--sp-3); }
.bucket-actions { margin-bottom: 0; justify-content: flex-start; }
.bucket-actions .btn { flex: 0 0 auto; }

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  letter-spacing: .02em;
}
.pill.green { color: #059669; background: #ecfdf5; border-color: #a7f3d0; }
.pill.blue { color: #2563eb; background: #eff6ff; border-color: #bfdbfe; }
.pill.amber { color: #d97706; background: #fffbeb; border-color: #fde68a; }
.pill.red { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
.pill.gray { color: #64748b; background: #f1f5f9; border-color: #e2e8f0; }

.split {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}

.terminal {
  background: var(--terminal);
  color: #a5f3fc;
  min-height: 360px;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: var(--sp-4);
  font-family: "Cascadia Mono", "Fira Code", Consolas, monospace;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow: auto;
  font-size: 13px;
}
.terminal.xterm-host {
  height: 390px;
  min-height: 390px;
  padding: var(--sp-2);
  white-space: normal;
  outline: none;
}
.terminal.xterm-host:focus { box-shadow: inset 0 0 0 1px rgba(99,102,241,.3); }
.terminal.xterm-host .xterm { height: 100%; }
.terminal.audit-log { min-height: 160px; }
.terminal-bar {
  height: var(--h-panel-head);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #020617;
  color: #94a3b8;
  padding: 0 var(--sp-4);
  border-bottom: 1px solid #1e293b;
  font-weight: 500;
}
.terminal-bar span { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  background: var(--bg);
}
.login-copy {
  padding: 8vw 7vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99,102,241,.04), rgba(139,92,246,.02));
}
.login-copy h1 {
  font-size: 48px;
  margin: var(--sp-5) 0 var(--sp-4);
  max-width: 700px;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.15;
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-copy p { color: var(--muted); font-size: 16px; line-height: 1.8; max-width: 540px; }
.login-card {
  margin: auto var(--sp-8) auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: var(--sp-8);
}
.login-card input { width: 100%; margin-top: 10px; }
.login-card select { width: 100%; }
.login-card-title { margin: 0 0 var(--sp-1); font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.login-card-subtitle { margin: 0 0 var(--sp-5); color: var(--muted); }
.setup-card { width: min(520px, calc(100vw - 48px)); }
.setup-screen { grid-template-columns: minmax(0, 1fr) minmax(420px, 560px); }
.setup-db-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  height: var(--h-input);
}
.setup-db-actions span { min-width: 0; overflow-wrap: anywhere; }
.field-label {
  display: block;
  margin: 12px 0 -4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.form-row.compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  align-items: center;
  margin-top: var(--sp-3);
}
.check-row {
  height: var(--h-input);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--muted);
}
.check-row input { width: auto; margin: 0; }
.setup-summary {
  display: grid;
  gap: var(--sp-2);
  max-width: 600px;
  margin-top: var(--sp-4);
}
.setup-summary div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--sp-2);
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.setup-summary span { color: var(--muted); font-size: 12px; }
.setup-summary b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.setup-token-help { margin: var(--sp-2) 0 0; }
.mt-12 { margin-top: var(--sp-3); }
.mt-14 { margin-top: var(--sp-4); }
.spacer-12 { height: var(--sp-3); }
.spacer-14 { height: var(--sp-4); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  padding: 12px 18px;
  z-index: 20;
  box-shadow: 0 10px 25px rgba(0,0,0,.15);
  font-weight: 500;
  font-size: 13px;
}

.clipboard-fallback { position: fixed; left: -1000px; top: 0; width: 1px; height: 1px; opacity: 0; }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(8px);
}
.dialog {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0,0,0,.15);
}
.dialog-head {
  height: var(--h-dialog-head);
  padding: 0 var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
}
.dialog-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.dialog-x {
  width: var(--h-btn);
  height: var(--h-btn);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.dialog-x:hover { background: var(--surface-2); color: var(--text); }
.dialog-body { padding: var(--sp-5); }
.dialog-message { margin: 0; color: #475569; line-height: 1.7; }
.dialog-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}
.dialog-form label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
}
.dialog-form label.span { grid-column: 1 / -1; }
.dialog-form label span { font-weight: 600; }
.dialog-form input, .dialog-form select, .dialog-form textarea { width: 100%; }
.dialog-form textarea { min-height: 150px; font-family: "Cascadia Mono", Consolas, monospace; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 16px 16px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.danger-text { color: var(--red); }
.success-text { color: var(--green); }
.ok-text { color: var(--primary); }
.code {
  font-family: "Cascadia Mono", Consolas, monospace;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--accent);
}
.source-fields { max-width: 280px; white-space: normal; }
.source-fields summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.source-fields div { margin-top: 6px; overflow-wrap: anywhere; }
.source-fields .btn { margin-top: 8px; min-height: 28px; padding: 0 8px; }

@media (max-width: 1180px) {
  .grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .detail { position: static; }
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { position: static; flex-wrap: wrap; height: auto; min-height: var(--h-topbar); padding: var(--sp-4); }
  .page-title { min-width: 0; width: 100%; }
  .main { padding: var(--sp-4); }
  .panel, .panel-body, .metric, .form-grid input, .form-grid select, .form-grid textarea, .form-grid .btn { min-width: 0; width: 100%; }
  .grid.metrics, .grid.three, .grid.four, .split, .form-grid, .form-grid.three, .dialog-form, .form-row.compact { grid-template-columns: 1fr; }
  .bucket-form-note { flex-direction: column; }
  .bucket-actions { flex-wrap: wrap; }
  .setup-db-actions { align-items: flex-start; flex-direction: column; }
  .login-screen { grid-template-columns: 1fr; }
  .login-copy { padding: var(--sp-8) var(--sp-5) 0; }
  .login-copy h1 { font-size: 32px; }
  .login-card { margin: var(--sp-4); }
}
