/* Central — design system.
   Redis-branded, high contrast, monospace for anything a developer would copy. */

:root {
  --brand: #DC382D;
  --brand-hover: #B92E24;
  --brand-subtle: #FDF0EF;
  --brand-ring: rgba(220, 56, 45, 0.20);

  --ink: #16110F;
  --text: #16110F;
  --text-2: #6B605C;
  --text-3: #9A908B;

  --bg: #FBF9F8;
  --surface: #FFFFFF;
  --border: #E8E2DF;
  --border-strong: #D4CBC7;

  --success: #1B8A5A;
  --success-bg: #EAF6F0;
  --warning: #C77A11;
  --warning-bg: #FDF4E7;
  --danger: #C0271C;
  --danger-bg: #FDF0EF;
  --info: #2563A8;
  --info-bg: #F2F6FA;

  --code-bg: #1C1614;
  --code-text: #F5EFEC;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --shadow: 0 1px 2px rgba(22, 17, 15, 0.06);
  --shadow-lg: 0 8px 32px rgba(22, 17, 15, 0.14);

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, "Menlo", "Consolas", monospace;

  --sidebar-w: 240px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 600; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.hidden { display: none !important; }

.label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.wrap { flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }

.btn-secondary { border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--surface); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

.btn-danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-solid:hover:not(:disabled) { background: #A31F16; }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 28px; height: 28px; padding: 0; }
.btn-block { width: 100%; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 500; }

.input, .select, .textarea {
  height: 40px;
  padding: 0 12px;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 72px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.input:disabled, .textarea:disabled {
  background: var(--bg);
  color: var(--text-3);
  cursor: not-allowed;
}
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 13px; }
.input-sm { height: 32px; font-size: 13px; }

.help { font-size: 12px; color: var(--text-2); }
.error-text { font-size: 12px; color: var(--danger); }

.checkbox-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; }
.checkbox-row input[type="checkbox"] { margin-top: 2px; accent-color: var(--brand); width: 15px; height: 15px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-strong); border-radius: 999px; transition: background 0.15s;
}
.switch span::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-body { padding: 20px; }
.card-foot {
  padding: 12px 20px; background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex; justify-content: flex-end; gap: 10px;
}
.card-danger { border-color: var(--danger); }
.card-danger .card-head { background: var(--danger-bg); border-bottom-color: rgba(192,39,28,0.25); }
.card-danger .card-head h2 { color: var(--danger); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── Badges ────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: var(--radius-xs);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--bg); color: var(--text-2);
  font-family: var(--mono);
}
.badge-brand { background: var(--brand-subtle); color: var(--brand); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot-active { background: var(--success); }
.dot-idle { background: var(--warning); }

/* ── Tables ────────────────────────────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 10px 16px;
  font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }
.table .mono { font-size: 12.5px; }

/* ── Code ──────────────────────────────────────────────────────────────────── */

.code {
  position: relative;
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius); padding: 16px 18px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  overflow-x: auto; white-space: pre;
}
.code .tok-cmd { color: #F0857D; }
.code .tok-flag { color: #9A908B; }
.code .tok-str { color: #8FD19E; }
.code .tok-key { color: #E8B33A; }
.code .tok-punc { color: #9A908B; }

.code-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.code-tab {
  padding: 8px 14px; font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-2); background: none; border: none; border-bottom: 2px solid transparent;
  font-family: var(--mono);
}
.code-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,0.08); color: var(--code-text);
  border: none; border-radius: var(--radius-xs);
  padding: 4px 9px; font-size: 11px; cursor: pointer; font-family: var(--sans);
}
.copy-btn:hover { background: rgba(255,255,255,0.16); }

.json-view {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word;
  position: relative;
}
.json-key { color: #A03028; }
.json-str { color: #1B7A4B; }
.json-num { color: #2563A8; }
.json-bool, .json-null { color: #8A5CC7; }

/* ── Copyable value ────────────────────────────────────────────────────────── */

.copyable {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 13px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px 6px 5px 10px;
  max-width: 100%;
}
.copyable > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius);
  font-size: 13px; border-left: 3px solid var(--info); background: var(--info-bg);
}
.alert-ok { border-left-color: var(--success); background: var(--success-bg); color: #10603E; }
.alert-err { border-left-color: var(--danger); background: var(--danger-bg); color: #8E1D14; }
.alert-warn { border-left-color: var(--warning); background: var(--warning-bg); color: #8A550C; }

/* ── Empty states ──────────────────────────────────────────────────────────── */

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 64px 24px; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface);
}
.empty-icon { color: var(--brand); }
.empty h2 { font-size: 17px; }
.empty p { margin: 0; color: var(--text-2); max-width: 420px; }
.empty-sm { padding: 32px 20px; border: none; background: none; }

/* ── App shell ─────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 16px 18px; font-weight: 700; font-size: 15px; letter-spacing: -0.02em;
  color: var(--text);
}
.sidebar-brand:hover { text-decoration: none; }

.project-switch { padding: 0 12px 12px; position: relative; }
.project-switch-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); font-family: var(--mono); font-size: 12.5px; cursor: pointer;
  color: var(--text);
}
.project-switch-btn:hover { border-color: var(--border-strong); }
.project-menu {
  position: absolute; left: 12px; right: 12px; top: 100%; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 4px; max-height: 320px; overflow-y: auto;
}
.project-menu a {
  display: block; padding: 7px 10px; border-radius: var(--radius-xs);
  font-family: var(--mono); font-size: 12.5px; color: var(--text);
}
.project-menu a:hover { background: var(--bg); text-decoration: none; }
.project-menu a.current { background: var(--brand-subtle); color: var(--brand); }
.project-menu .sep { height: 1px; background: var(--border); margin: 4px 0; }

.nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-subtle); color: var(--brand); }
.nav a.active svg { color: var(--brand); }
.nav-section { padding: 14px 22px 6px; }

.sidebar-foot {
  margin-top: auto; padding: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 9px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--brand-subtle); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 32px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 14px; font-weight: 600; }

.content { padding: 28px 32px 64px; max-width: 1200px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }

/* ── Auth screens ──────────────────────────────────────────────────────────── */

.auth { display: flex; min-height: 100vh; }
.auth-side {
  width: 45%; flex: none; background: var(--code-bg); color: var(--code-text);
  display: flex; flex-direction: column; justify-content: center; padding: 48px 56px;
}
.auth-side h1 { color: #fff; font-size: 32px; margin: 24px 0 12px; max-width: 460px; }
.auth-side p { color: #9A908B; max-width: 440px; margin: 0 0 32px; }
.auth-side .code { background: #241D1A; max-width: 520px; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }

.strength { display: flex; gap: 4px; margin-top: 6px; }
.strength i { height: 3px; flex: 1; background: var(--border); border-radius: 2px; transition: background 0.15s; }
.strength i.on-weak { background: var(--danger); }
.strength i.on-fair { background: var(--warning); }
.strength i.on-good { background: var(--success); }

/* ── Stats ─────────────────────────────────────────────────────────────────── */

.stat { padding: 16px 18px; }
.stat .value { font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.stat .delta { font-size: 12px; margin-top: 4px; }

.meter { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

.bar-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 12.5px; }
.bar-row .name { font-family: var(--mono); width: 84px; flex: none; color: var(--text-2); }
.bar-row .track { flex: 1; height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-row .track > i { display: block; height: 100%; background: var(--brand); }
.bar-row .num { font-family: var(--mono); width: 60px; text-align: right; flex: none; }

/* ── Data browser ──────────────────────────────────────────────────────────── */

.browser { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; align-items: start; }
.key-list { max-height: calc(100vh - 260px); overflow-y: auto; }
.key-row {
  display: flex; align-items: center; gap: 9px;
  padding: 0 12px; height: 44px; cursor: pointer;
  border-bottom: 1px solid var(--border); border-left: 2px solid transparent;
}
.key-row:hover { background: var(--bg); }
.key-row.selected { background: var(--brand-subtle); border-left-color: var(--brand); }
.key-row .name { font-family: var(--mono); font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-row .ttl { font-family: var(--mono); font-size: 11px; color: var(--text-3); flex: none; }

.type-badge { font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 3px; flex: none; }
.type-string { background: var(--info-bg); color: var(--info); }
.type-list { background: #F3EFFA; color: #7546C0; }
.type-hash { background: var(--warning-bg); color: var(--warning); }
.type-set { background: var(--success-bg); color: var(--success); }
.type-zset { background: #FDF0EF; color: var(--brand); }
.type-none { background: var(--bg); color: var(--text-3); }

.meta-strip { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg); }
.meta-strip .item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.meta-strip .item b { font-family: var(--mono); font-weight: 500; color: var(--text); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; background: rgba(22, 17, 15, 0.42);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-lg { max-width: 560px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 12px 20px; background: var(--bg); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.modal-foot .left { margin-right: auto; }
.modal-danger { border-top: 4px solid var(--danger); }

/* ── Toast ─────────────────────────────────────────────────────────────────── */

.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--code-bg); color: var(--code-text);
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toast-in 0.18s ease-out;
  max-width: 380px;
}
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Charts ────────────────────────────────────────────────────────────────── */

.chart { width: 100%; height: 200px; display: block; }
.chart-grid { stroke: var(--border); stroke-dasharray: 2 4; stroke-width: 1; }
.chart-axis { fill: var(--text-3); font-size: 10px; font-family: var(--mono); }

/* ── Segmented control ─────────────────────────────────────────────────────── */

.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.segmented button {
  border: none; background: none; padding: 4px 11px; border-radius: 4px;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--text-2); cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-family: var(--mono); font-size: 12px; cursor: pointer; color: var(--text-2);
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 500; cursor: pointer;
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-2);
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .browser { grid-template-columns: 1fr; }
  .key-list { max-height: 380px; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { width: 100%; }
  .page-head { flex-direction: column; align-items: stretch; }
}
