/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1c1e21;
  --bg-card: #242526;
  --bg-input: #3a3b3c;
  --bg-hover: #3a3b3c;
  --border: #4e5256;
  --border-subtle: #3e4042;
  --text: #e4e6eb;
  --text-muted: #b0b3b8;
  --text-heading: #e4e6eb;
  --accent: #2d88ff;
  --accent-hover: #1a77f2;
  --accent-muted: rgba(45, 136, 255, 0.12);
  --accent-border: rgba(45, 136, 255, 0.3);
  --danger: #f02849;
  --danger-muted: rgba(240, 40, 73, 0.12);
  --success: #31a24c;
  --success-muted: rgba(49, 162, 76, 0.12);
  --warning: #f7b928;
  --radius: 8px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 56px;
}

[data-theme="light"] {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-input: #f0f2f5;
  --bg-hover: #e4e6e9;
  --border: #dadde1;
  --border-subtle: #e4e6e9;
  --text: #1c1e21;
  --text-muted: #65676b;
  --text-heading: #050505;
  --accent: #1877f2;
  --accent-hover: #166fe5;
  --accent-muted: rgba(24, 119, 242, 0.08);
  --accent-border: rgba(24, 119, 242, 0.25);
  --danger: #fa383e;
  --danger-muted: rgba(250, 56, 62, 0.08);
  --success: #31a24c;
  --success-muted: rgba(49, 162, 76, 0.08);
  --warning: #f7b928;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  display: flex;
}

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

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-right: 1px solid var(--border-subtle);
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 12px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-heading);
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-brand-text { opacity: 0; width: 0; }
.sidebar.collapsed .sidebar-brand { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text); }
.sidebar.collapsed .sidebar-toggle { margin: 0 auto; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  font-family: var(--font);
}

.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar-item.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.sidebar-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-icon svg { width: 24px; height: 24px; }

.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s, width 0.2s;
}

.sidebar.collapsed .sidebar-label { display: none; }
.sidebar.collapsed .sidebar-nav { padding: 8px; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px; gap: 0; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-footer { padding: 8px; }
.sidebar.collapsed .sidebar-footer .sidebar-label { display: none; }
.sidebar.collapsed .sidebar-footer .sidebar-item { justify-content: center; padding: 10px; gap: 0; }

/* ── Main Content ───────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  min-width: 960px;
  padding: 24px 32px;
  transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.page-container { min-width: 720px; }
.main-full { padding: 0; }

/* ── Typography ─────────────────────────────────────────── */
h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-heading);
}

h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 20px 0 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

hr { border: none; border-top: 1px solid var(--border-subtle); margin: 24px 0; }
p { margin-bottom: 8px; color: var(--text-muted); }
ol, ul { margin: 6px 0 12px 20px; color: var(--text-muted); }
li { margin-bottom: 3px; }

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

code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid var(--border-subtle);
}

pre {
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 6px 0;
  border: 1px solid var(--border-subtle);
}

pre code { background: none; padding: 0; border: none; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

[data-theme="light"] .btn-primary { color: #fff; }

.btn-danger {
  background: var(--danger-muted);
  border-color: rgba(240, 40, 73, 0.3);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(240, 40, 73, 0.2); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-family: var(--font);
  font-size: 13px;
}
.btn-link:hover { color: var(--text); }

/* ── Forms ────────────────────────────────────────────────── */
label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.inline-form input { margin-top: 0; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
  border: 1px solid;
}

.alert-error {
  background: var(--danger-muted);
  border-color: rgba(240, 40, 73, 0.25);
  color: #fca5a5;
}

[data-theme="light"] .alert-error { color: var(--danger); }

.alert-success {
  background: var(--success-muted);
  border-color: rgba(49, 162, 76, 0.25);
  color: #7ee787;
}

[data-theme="light"] .alert-success { color: var(--success); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

.badge-success {
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid rgba(49, 162, 76, 0.25);
}

.badge-neutral {
  background: rgba(176, 179, 184, 0.12);
  color: var(--text-muted);
  border: 1px solid rgba(176, 179, 184, 0.2);
}

/* ── Tables ──────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-heading);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* ── Channel Cards ───────────────────────────────────────── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.12s;
}

.channel-card:hover { border-color: var(--accent-border); }

.channel-header { display: flex; gap: 12px; align-items: center; }

.channel-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  flex-shrink: 0;
}
.channel-icon.channel-icon-lg {
  width: 44px;
  height: 44px;
  border: none;
}

.channel-desc { font-size: 12px; color: var(--text-muted); margin: 3px 0 0; }
.channel-actions { flex-shrink: 0; }

.channel-section { margin-bottom: 10px; }

/* ── Profile layout ─────────────────────────────── */

.profile-layout {
  display: flex;
  gap: 2rem;
  margin-top: 1rem;
}
.profile-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  flex-shrink: 0;
}
.profile-tab {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.profile-tab:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.profile-tab.active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 500;
}
.profile-content {
  flex: 1;
  min-width: 0;
}
.profile-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
}

/* ── Vitals ─────────────────────────────────────── */

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.vital-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vital-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vital-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.vital-value {
  font-size: 0.9rem;
  color: var(--text);
}

/* ── Tier badge ─────────────────────────────────── */

.tier-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

/* ── Toggle switch ──────────────────────────────── */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-subtle);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

@media (max-width: 640px) {
  .profile-layout { flex-direction: column; gap: 1rem; }
  .profile-sidebar { flex-direction: row; overflow-x: auto; min-width: 0; }
  .profile-tab.active { background: var(--accent-muted); color: var(--accent); padding-left: 0.75rem; }
}

.channel-setup {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 14px;
  margin-top: -10px;
}

.channel-setup .setup-form { max-width: 400px; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ── Info Card ───────────────────────────────────────────── */
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.info-row {
  margin-bottom: 4px;
  font-size: 13px;
}

/* ── Chat ────────────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
}

.menu-container { position: relative; flex-shrink: 0; }

.menu-trigger {
  font-size: 16px;
  padding: 6px 8px;
  line-height: 1;
}

.menu-dropdown {
  position: absolute;
  left: 0;
  bottom: calc(100% + 4px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}

.menu-item:hover { background: var(--bg-hover); }

.hidden { display: none !important; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.chat-welcome {
  text-align: center;
  padding: 48px 32px;
  color: var(--text-muted);
}

.chat-welcome p {
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}

.load-more {
  text-align: center;
  padding: 8px;
}

/* ── Messages ────────────────────────────────────────────── */
.message-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.message-wrapper-user { justify-content: flex-end; }
.message-wrapper-agent, .message-wrapper-assistant { justify-content: flex-start; }

.message-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
}

.message-wrapper:hover .message-actions { opacity: 1; }

.msg-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color 0.12s, background 0.12s;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.msg-action-btn:hover { color: var(--text); background: var(--bg-input); }
.msg-action-delete:hover { color: var(--danger); background: var(--danger-muted); }

.message {
  padding: 10px 14px;
  border-radius: 18px;
  max-width: 75%;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.5;
}

.message-user {
  background: var(--accent);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.message-agent, .message-assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px 18px 18px 18px;
}

/* ── Chat Input Area ─────────────────────────────────────── */
.chat-input-area {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 24px 16px;
  background: var(--bg);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.quick-action {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.quick-action:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-muted);
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-form textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  border-radius: 20px;
  padding: 10px 16px;
}

.chat-form .btn-primary {
  padding: 8px;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-trigger {
  font-size: 16px;
  padding: 6px 8px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Attachment Preview ──────────────────────────────────── */
.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px;
  color: var(--text);
  max-width: 220px;
  position: relative;
}

.attach-chip-icon { font-size: 14px; flex-shrink: 0; }

.attach-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.attach-chip-size { color: var(--text-muted); flex-shrink: 0; }

.attach-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  font-family: var(--font);
}

.attach-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: color 0.12s, border-color 0.12s;
}
.attach-remove:hover { color: var(--danger); border-color: var(--danger); }

.attach-thumb {
  position: relative;
  display: inline-block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.attach-thumb-img {
  display: block;
  max-width: 80px;
  max-height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.attach-chip .attach-remove { top: 50%; right: -8px; transform: translateY(-50%); }

/* ── Drag & Drop Overlay ─────────────────────────────────── */
.chat-container.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: var(--accent-muted);
}

/* ── Chat Images ─────────────────────────────────────────── */
.chat-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius);
  margin: 8px 0;
  display: block;
  cursor: pointer;
}

.chat-image:hover { opacity: 0.9; }

.chat-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chat-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

.media-placeholder {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Auth Page ───────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
}

.auth-container {
  width: 100%;
  max-width: 380px;
  padding: 32px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.auth-header h1 {
  font-size: 20px;
  color: var(--text-heading);
  font-weight: 700;
}

.auth-header p { color: var(--text-muted); font-size: 14px; }

.auth-form label { margin-bottom: 12px; }
.auth-form .btn, .auth-magic-form .btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 8px 16px;
}

.auth-methods { display: flex; flex-direction: column; gap: 0; }
.auth-magic-form label { margin-bottom: 10px; }
.auth-magic-form .btn { margin-top: 0; }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn-google:hover { background: var(--bg-hover); border-color: var(--text-muted); text-decoration: none; }
.btn-google svg { flex-shrink: 0; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border-subtle);
}

.auth-password-toggle {
  font-size: 14px;
  color: var(--text-muted);
}
.auth-password-toggle summary {
  cursor: pointer;
  text-align: center;
  padding: 6px;
  transition: color 0.12s;
}
.auth-password-toggle summary:hover { color: var(--text); }
.auth-password-toggle[open] summary { color: var(--accent); }

.auth-success p { line-height: 1.5; }

/* ── Logs ────────────────────────────────────────────────── */
.log-content pre {
  max-height: 600px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

/* ── Setup Form ──────────────────────────────────────────── */
.setup-form {
  max-width: 500px;
}

.setup-form .btn {
  margin-top: 8px;
}

/* ── Footer ──────────────────────────────────────────────── */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  margin-top: 24px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }

.footer-links {
  display: flex;
  gap: 24px;
}

/* ── Confirm Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.12s ease;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-width: 420px;
  width: calc(100% - 32px);
  padding: 24px;
}

.modal-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
  text-transform: none;
  letter-spacing: 0;
}

.modal-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

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

.modal-actions .btn-cancel {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.12s;
}
.modal-actions .btn-cancel:hover { background: var(--bg-hover); }

.modal-actions .btn-confirm {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.12s;
}
.modal-actions .btn-confirm:hover { background: var(--accent-hover); }

.modal-actions .btn-confirm.destructive {
  background: var(--danger);
}
.modal-actions .btn-confirm.destructive:hover {
  background: #d6223a;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Copyable Code ──────────────────────────────────────── */
code.copyable { position: relative; transition: color 0.12s; cursor: pointer; }
code.copyable:hover { color: var(--accent); }
code.copyable[data-copied]::after {
  content: 'Copied!';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--accent);
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-collapsed-width); }
  .sidebar .sidebar-brand-text { opacity: 0; width: 0; }
  .sidebar .sidebar-label { opacity: 0; width: 0; overflow: hidden; }
  .sidebar .sidebar-nav { padding: 4px; }
  .sidebar .sidebar-item { justify-content: center; padding: 10px; }
  .sidebar .sidebar-footer { padding: 4px; }
  .sidebar-toggle { display: none; }
  .main-content { margin-left: var(--sidebar-collapsed-width); padding: 16px; }
}
