/* ═══════════════════════════════════════════════════════════════════
   Material Design 3 — Dark Theme
   Solana Validator Dashboard
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
  --md-sys-color-background:       #0f1118;
  --md-sys-color-surface:          #1a1d27;
  --md-sys-color-surface-variant:  #21242f;
  --md-sys-color-surface-container: #171a23;
  --md-sys-color-surface-bright:   #282c38;
  --md-sys-color-on-surface:       #e2e4ed;
  --md-sys-color-on-surface-var:   #9196a8;
  --md-sys-color-outline:          #2d3140;
  --md-sys-color-outline-variant:  #393e4f;
  --md-sys-color-primary:          #93b4ff;
  --md-sys-color-primary-container:#1b3a6b;
  --md-sys-color-on-primary:       #002f6b;
  --md-sys-color-secondary:        #b8c8e8;
  --md-sys-color-tertiary:         #d4bbff;
  --md-sys-color-error:            #ffb4ab;
  --md-sys-color-error-container:  #93000a;
  --md-sys-color-success:          #7adc8e;
  --md-sys-color-success-container:#004d1a;
  --md-sys-color-warning:          #ffd666;
  --md-sys-color-warning-container:#5c4300;
  --md-sys-color-inverse-surface:  #e2e4ed;

  --md-elevation-1: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.24);
  --md-elevation-2: 0 3px 6px rgba(0,0,0,.32), 0 3px 6px rgba(0,0,0,.23);
  --md-elevation-3: 0 6px 12px rgba(0,0,0,.35);
  --md-radius-sm: 8px;
  --md-radius-md: 12px;
  --md-radius-lg: 16px;
  --md-radius-xl: 28px;

  --sidebar-width: 260px;
  --header-height: 44px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-surface);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Layout Shell ─────────────────────────────────────────────── */

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

/* ── Sidebar / Drawer ─────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--md-sys-color-surface-container);
  border-right: 1px solid var(--md-sys-color-outline);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--md-radius-md);
  background: linear-gradient(135deg, #9945FF 0%, #14F195 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-var);
  font-weight: 400;
}

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

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-var);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 16px 16px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--md-radius-xl);
  color: var(--md-sys-color-on-surface-var);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s ease;
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(147, 180, 255, .08);
  color: var(--md-sys-color-on-surface);
}

.nav-item.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--md-sys-color-outline);
  font-size: 11px;
  color: var(--md-sys-color-on-surface-var);
  text-align: center;
}

.sidebar-footer a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
}

/* ── Top Header Bar ───────────────────────────────────────────── */

.top-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--md-sys-color-outline);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  gap: 16px;
  z-index: 90;
  font-size: 11px;
}

.header-versions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--md-sys-color-on-surface-var);
}

.header-ver-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--md-sys-color-surface-variant);
  font-family: 'Roboto Mono', monospace;
  font-size: 10px;
  white-space: nowrap;
}

.header-ver-chip.ok { color: var(--md-sys-color-success); }
.header-ver-chip.missing { color: var(--md-sys-color-error); background: var(--md-sys-color-error-container); }

.header-epoch { margin-left: auto; }

.epoch-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  border-radius: 10px;
  background: var(--md-sys-color-surface-variant);
  font-size: 11px;
  white-space: nowrap;
  color: var(--md-sys-color-on-surface-var);
}
.epoch-chip b { color: var(--md-sys-color-primary); font-size: 11px; }
.epoch-bar {
  width: 60px;
  height: 4px;
  border-radius: 2px;
  background: var(--md-sys-color-outline);
  overflow: hidden;
}
.epoch-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--md-sys-color-primary);
  transition: width .5s ease;
}
.epoch-detail { font-family: 'Roboto Mono', monospace; font-size: 10px; }

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Main Content ─────────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.page-header-subtitle {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-var);
  margin-top: 2px;
}

.page-body {
  flex: 1;
  padding: 24px 32px 40px;
}

/* ── Mobile Toggle ────────────────────────────────────────────── */

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: var(--md-radius-md);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-elevation-2);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .main-content {
    margin-left: 0;
  }
  .top-header {
    left: 0;
    padding-left: 52px;
  }
  .page-header {
    padding-left: 68px;
  }
  .page-body {
    padding: 16px;
  }
}

/* ── Card ─────────────────────────────────────────────────────── */

.md-card {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-md);
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow .2s ease;
}

.md-card:hover {
  box-shadow: var(--md-elevation-1);
}

.md-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.md-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--md-sys-color-primary);
}

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

.md-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--md-radius-xl);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}

.md-btn-filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.md-btn-filled:hover { filter: brightness(1.1); }
.md-btn-filled:disabled { opacity: .38; cursor: not-allowed; }

.md-btn-tonal {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
}
.md-btn-tonal:hover { filter: brightness(1.15); }

.md-btn-outlined {
  background: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline-variant);
}
.md-btn-outlined:hover { background: rgba(147,180,255,.08); }

.md-btn-text {
  background: transparent;
  color: var(--md-sys-color-primary);
  padding: 10px 12px;
}
.md-btn-text:hover { background: rgba(147,180,255,.08); }

.md-btn-danger {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}
.md-btn-danger:hover { filter: brightness(1.15); }

.md-btn-success {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-success);
}
.md-btn-success:hover { filter: brightness(1.15); }

.md-btn-warn {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-warning);
}

.md-btn-sm {
  padding: 6px 16px;
  font-size: 12px;
}

.md-btn-icon {
  padding: 8px;
  border-radius: var(--md-radius-sm);
}

/* ── Form Fields ──────────────────────────────────────────────── */

.md-field {
  margin-bottom: 16px;
}

.md-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-var);
  margin-bottom: 6px;
}

.md-input, .md-select, .md-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-sm);
  font-family: inherit;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.md-input:focus, .md-select:focus, .md-textarea:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(147,180,255,.2);
}

.md-textarea {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  resize: vertical;
  min-height: 60px;
}

.md-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.md-checkbox-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}

.md-checkbox-wrap span {
  font-size: 13px;
  font-weight: 600;
}

/* ── Table ────────────────────────────────────────────────────── */

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.md-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-var);
  border-bottom: 1px solid var(--md-sys-color-outline);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.md-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(45,49,64,.5);
  vertical-align: top;
}

.md-table tbody tr:hover {
  background: rgba(147,180,255,.04);
}

.md-table tbody tr:last-child td {
  border-bottom: none;
}

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

.md-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--md-radius-sm);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  gap: 4px;
}

.md-chip-primary {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
}

.md-chip-success {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-success);
}

.md-chip-error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}

.md-chip-warning {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-warning);
}

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

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-md);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-var);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Grids ────────────────────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Tabs ─────────────────────────────────────────────────────── */

.md-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--md-sys-color-outline);
  margin-bottom: 20px;
}

.md-tab {
  padding: 12px 24px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-var);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  user-select: none;
}

.md-tab:hover {
  color: var(--md-sys-color-on-surface);
  background: rgba(147,180,255,.05);
}

.md-tab.active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

.md-tab-badge {
  font-size: 11px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 8px;
}

.md-tab-panel { display: none; }
.md-tab-panel.active { display: block; }

/* ── Utility ──────────────────────────────────────────────────── */

.mono {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  word-break: break-all;
}

.text-muted { color: var(--md-sys-color-on-surface-var); }
.text-primary { color: var(--md-sys-color-primary); }
.text-success { color: var(--md-sys-color-success); }
.text-error { color: var(--md-sys-color-error); }
.text-warning { color: var(--md-sys-color-warning); }

.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.right { text-align: right; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.hidden { display: none !important; }

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

.md-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  border-radius: var(--md-radius-sm);
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  box-shadow: var(--md-elevation-3);
  opacity: 0;
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
  pointer-events: none;
}

.md-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.md-toast.ok {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-success);
  border: 1px solid rgba(122,220,142,.2);
}

.md-toast.err {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
  border: 1px solid rgba(255,180,171,.2);
}

/* ── Inline Alert ─────────────────────────────────────────────── */

.md-alert {
  padding: 12px 16px;
  border-radius: var(--md-radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.md-alert-info {
  background: rgba(147,180,255,.08);
  border: 1px solid rgba(147,180,255,.15);
  color: var(--md-sys-color-primary);
}

.md-alert-error {
  background: rgba(255,180,171,.08);
  border: 1px solid rgba(255,180,171,.15);
  color: var(--md-sys-color-error);
}

.md-alert-success {
  background: rgba(122,220,142,.08);
  border: 1px solid rgba(122,220,142,.15);
  color: var(--md-sys-color-success);
}

.md-alert-warning {
  background: rgba(255,214,102,.08);
  border: 1px solid rgba(255,214,102,.15);
  color: var(--md-sys-color-warning);
}

/* ── Step Progress (Bond) ─────────────────────────────────────── */

.step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(45,49,64,.4);
}

.step-item:last-child { border-bottom: none; }

.step-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.step-icon.pending  { background: var(--md-sys-color-surface-bright); color: var(--md-sys-color-on-surface-var); }
.step-icon.running  { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-primary); animation: md-pulse 1.4s infinite; }
.step-icon.success  { background: var(--md-sys-color-success-container); color: var(--md-sys-color-success); }
.step-icon.failed   { background: var(--md-sys-color-error-container); color: var(--md-sys-color-error); }
.step-icon.skipped  { background: var(--md-sys-color-warning-container); color: var(--md-sys-color-warning); }

@keyframes md-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.step-body b { font-size: 13px; }
.step-msg { color: var(--md-sys-color-on-surface-var); font-size: 12px; margin-top: 2px; }
.step-tx  { font-size: 11px; color: var(--md-sys-color-primary); word-break: break-all; margin-top: 2px; }

/* ── Profile Cards (Settings) ─────────────────────────────────── */

.profile-card {
  background: var(--md-sys-color-surface-variant);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-md);
  padding: 16px;
  margin-bottom: 12px;
  transition: box-shadow .2s;
}

.profile-card:hover { box-shadow: var(--md-elevation-1); }

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.profile-name {
  font-size: 16px;
  font-weight: 700;
}

.key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(45,49,64,.35);
}

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

/* ── Check Block (Bond precheck) ──────────────────────────────── */

.chk-block { margin: 6px 0; font-size: 13px; }
.chk-line {
  padding: 3px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 40%, transparent);
}
.chk-line:last-child { border-bottom: none; }
.chk-line b {
  display: inline-block;
  min-width: 120px;
  color: var(--md-sys-color-on-surface-var);
  font-size: 12px;
}
.chk-line .mono { font-size: 12px; margin-right: 8px; }

/* ── Scrollbar ────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--md-sys-color-outline-variant); }

/* ── Skeleton loading ─────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--md-sys-color-surface-variant) 25%, var(--md-sys-color-surface-bright) 50%, var(--md-sys-color-surface-variant) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--md-radius-sm);
  height: 16px;
}

@keyframes skeleton-shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Divider ──────────────────────────────────────────────────── */

.md-divider {
  border: none;
  border-top: 1px solid var(--md-sys-color-outline);
  margin: 16px 0;
}

/* ── Row helpers (Bond page forms) ────────────────────────────── */

.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

a { color: var(--md-sys-color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Role-based visibility ────────────────────────────────────── */

body.viewer .admin-only { display: none !important; }

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--md-radius-sm);
  font-weight: 600;
}

.user-badge.role-admin {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-success);
}

.user-badge.role-viewer {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-warning);
}

.md-btn-logout {
  background: none;
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface-var);
  border-radius: var(--md-radius-sm);
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all .2s;
}
.md-btn-logout:hover {
  border-color: var(--md-sys-color-error);
  color: var(--md-sys-color-error);
  background: var(--md-sys-color-error-container);
}

/* ── Missing CLI Modal ───────────────────────────────────────── */

.cli-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cli-modal {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-error);
  border-radius: var(--md-radius-lg);
  padding: 28px 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--md-elevation-3);
}

.cli-modal h3 {
  color: var(--md-sys-color-error);
  font-size: 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cli-modal p {
  color: var(--md-sys-color-on-surface-var);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.cli-modal code {
  display: block;
  background: var(--md-sys-color-surface-variant);
  padding: 10px 14px;
  border-radius: var(--md-radius-sm);
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  color: var(--md-sys-color-warning);
  margin: 8px 0;
}

.cli-modal .actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.cp-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  vertical-align: middle;
  opacity: .5;
  transition: opacity .15s;
}
.cp-btn:hover { opacity: 1; }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}
.history-grid .md-card { margin: 0; }
.chart-wrap {
  position: relative;
  height: 260px;
  width: 100%;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ── Toast stack (right-side) ─────────────────────────────────── */
#toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 400px;
}

/* ── Login page (/login) ──────────────────────────────────────── */

body.login-body {
  color-scheme: dark;  /* нативные контролы (чекбокс, автозаполнение) — в тёмной теме */
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(147,180,255,.09), transparent 70%),
    var(--md-sys-color-background);
}

.login-shell {
  width: 100%;
  max-width: 400px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 28px 22px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-3);
}

.login-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: var(--md-radius-md);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  font-size: 18px;
  font-weight: 700;
}

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

.login-sub {
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-var);
}

.login-lead {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-var);
  margin-top: 2px;
}

.login-error {
  padding: 10px 12px;
  border-radius: var(--md-radius-sm);
  border: 1px solid var(--md-sys-color-error);
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
  font-size: 12px;
  font-weight: 500;
}

.login-field { margin-bottom: 0; }

.login-remember { margin: 2px 0 4px; }

.login-submit {
  width: 100%;
  padding: 12px 24px;
  font-size: 14px;
}

.login-foot {
  font-size: 11px;
  text-align: center;
  color: var(--md-sys-color-on-surface-var);
  margin-top: 2px;
}

@media (max-width: 480px) {
  .login-card { padding: 22px 18px 18px; }
}
