/* ============================================================
   Claude Server Console — design tokens
   Console/rack-hardware aesthetic: graphite panels, LED status
   colors, monospace telemetry. Not a generic admin template.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0b0f14;
  --bg-grid: #0d1219;
  --panel: #121821;
  --panel-raised: #1a212c;
  --border: #262f3b;
  --border-soft: #1c2430;
  --text: #e7ecf2;
  --text-muted: #7d8a9a;
  --text-dim: #4c5866;

  --accent: #d97757;
  --accent-soft: rgba(217, 119, 87, 0.14);
  --accent-strong: #e88a68;

  --ok: #6fcf97;
  --ok-soft: rgba(111, 207, 151, 0.14);
  --warn: #e8b339;
  --warn-soft: rgba(232, 179, 57, 0.14);
  --err: #e5534b;
  --err-soft: rgba(229, 83, 75, 0.14);

  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Consolas, monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 34px 34px;
  background-position: -1px -1px;
}

a { color: inherit; }

::selection { background: var(--accent-soft); color: var(--accent-strong); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Layout shells ---------- */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
}

.brand-sub {
  color: var(--text-dim);
  font-size: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
}

.logout-link {
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.logout-link:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.main {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

.section-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 12px;
}

/* ---------- Status console ---------- */

.status-panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 32px;
}

.status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.status-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
}

.led {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.led::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--ok);
  opacity: 0.6;
  animation: pulse-ring 2.2s ease-out infinite;
}

.led.offline { background: var(--err); box-shadow: 0 0 8px var(--err); }
.led.offline::after { border-color: var(--err); animation: none; opacity: 0; }

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.4); opacity: 0; }
}

.status-updated {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.telemetry-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.telemetry-item {
  font-family: var(--mono);
}

.telemetry-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.telemetry-value {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}

.disk-gauge {
  display: flex;
  gap: 3px;
  margin-top: 10px;
}

.disk-gauge span {
  flex: 1;
  height: 7px;
  border-radius: 1px;
  background: var(--border-soft);
}

.disk-gauge span.filled {
  background: var(--accent);
}

.disk-gauge span.filled.hot {
  background: var(--warn);
}

/* ---------- Backup action row ---------- */

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #17110d;
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.5; cursor: progress; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }

.btn-danger {
  background: var(--err-soft);
  color: var(--err);
  border-color: transparent;
}

.btn-danger:hover { background: var(--err); color: #1a0d0c; }

/* ---------- Backups manifest table ---------- */

.manifest {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}

.manifest-row {
  display: grid;
  grid-template-columns: 1fr 120px 180px 100px 90px;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}

.manifest-row:last-child { border-bottom: none; }

.manifest-row.head {
  background: var(--panel-raised);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.manifest-row.body {
  background: var(--panel);
  transition: background 0.15s ease;
}

.manifest-row.body:hover { background: var(--panel-raised); }

.manifest-filename {
  font-family: var(--mono);
  color: var(--text);
}

.manifest-size,
.manifest-date {
  font-family: var(--mono);
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  width: fit-content;
}

.status-pill.completed { background: var(--ok-soft); color: var(--ok); }
.status-pill.in_progress { background: var(--warn-soft); color: var(--warn); }
.status-pill.failed { background: var(--err-soft); color: var(--err); }

.manifest-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 13px;
  background: var(--panel);
}

.restore-btn {
  font-family: var(--mono);
  font-size: 12px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.restore-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.restore-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- Activity log ---------- */

.log-feed {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #090c11;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.9;
  max-height: 260px;
  overflow-y: auto;
}

.log-line { white-space: pre-wrap; }
.log-line .ts { color: var(--text-dim); }
.log-line .tag-backup { color: var(--accent-strong); }
.log-line .tag-restore { color: #8fb8e8; }
.log-line .tag-success { color: var(--ok); }
.log-line .tag-failed { color: var(--err); }
.log-line .tag-running { color: var(--warn); }

.log-empty { color: var(--text-dim); }

/* ---------- Modal (restore confirm) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  width: min(420px, 90vw);
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transform: translateY(6px);
  transition: transform 0.15s ease;
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
}

.modal-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 20px;
}

.modal-body code {
  font-family: var(--mono);
  color: var(--text);
  background: var(--border-soft);
  padding: 1px 5px;
  border-radius: 2px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  transform: translateY(12px);
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 200;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-left-color: var(--err); }

/* ---------- Settings page ---------- */

.notice-banner {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ok);
  background: var(--ok-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px 20px;
  margin-bottom: 18px;
}

.radio-group {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
}

.field .radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 0;
  cursor: pointer;
}

.radio-group input[type="radio"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

/* ---------- Login page ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: min(380px, 100%);
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 32px 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-family: var(--mono);
}

.login-brand .brand-mark { width: 9px; height: 9px; }

.login-title {
  font-size: 16px;
  font-weight: 600;
}

.login-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 26px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
}

.field input:focus {
  border-color: var(--accent);
  outline: none;
}

.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.field select:focus {
  border-color: var(--accent);
  outline: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  height: 40px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.login-error {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 16px;
}

.login-submit {
  width: 100%;
  margin-top: 6px;
}

@media (max-width: 640px) {
  .telemetry-row { grid-template-columns: 1fr; gap: 16px; }
  .manifest-row { grid-template-columns: 1fr 90px; }
  .manifest-row .manifest-date,
  .manifest-row .manifest-size,
  .manifest-row.head > div:nth-child(2),
  .manifest-row.head > div:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .led::after { animation: none; }
  * { transition: none !important; }
}
