/* Dashboard layout — uses design tokens from theme.css */

.dashboard-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* SIDEBAR */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  padding: 2px 6px;
  border-radius: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  position: relative;
  border-radius: 0;
}

.nav-item:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.03);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left: 2px solid var(--accent);
}

.nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.nav-badge {
  background: #e87a2e;
  color: #0a0a0a;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.back-link {
  font-size: 13px;
  color: var(--fg-dim);
  text-decoration: none;
}

.back-link:hover { color: var(--fg-muted); }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.view {
  display: none;
  padding: 32px 36px;
  min-height: 100%;
}

.view.active {
  display: block;
}

/* VIEW HEADER */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.view-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 6px;
}

.view-title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.date-display {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-dim);
}

/* KPI GRID */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
}

.kpi-card.kpi-alert.has-alerts {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.kpi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--fg-dim);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
}

.kpi-value.accent { color: var(--accent-bright); }

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
}

.card-link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.card-hint {
  font-size: 12px;
  color: var(--fg-dim);
}

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

/* CHART */
.chart-container {
  padding: 16px 20px;
  height: 220px;
  position: relative;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  font-size: 14px;
}

/* ANOMALY LIST (sidebar widget) */
.anomaly-list {
  padding: 0;
}

.anomaly-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.anomaly-item:last-child { border-bottom: none; }
.anomaly-item:hover { background: rgba(255,255,255,0.02); }

.anomaly-severity {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 2px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.sev-critical { background: rgba(239,68,68,0.2); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }
.sev-high     { background: rgba(245,158,11,0.2); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.sev-warning  { background: var(--accent-glow); color: var(--accent); border: 1px solid var(--border-accent); }

.anomaly-well {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.anomaly-detail {
  font-size: 12px;
  color: var(--fg-muted);
}

/* REPORT TEXT */
.report-text {
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
  color: var(--fg-muted);
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

/* TABLE */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead tr {
  background: rgba(255,255,255,0.02);
}

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--fg-dim);
  font-size: 13px;
}

/* BUTTONS */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-bright); }

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) { color: var(--fg); border-color: var(--fg-dim); }

.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-danger {
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.3);
  font-size: 12px;
  padding: 3px 8px;
}

/* INPUTS */
.input-field {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.input-field:focus { border-color: var(--accent); }
.input-field::placeholder { color: var(--fg-dim); }

.input-sm {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-wide { width: 680px; }

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-dim);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.modal-close:hover { color: var(--fg); }

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

/* FORM */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--fg-dim);
  text-transform: uppercase;
}

/* CSV */
.csv-textarea {
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
  min-height: 160px;
}

.csv-guide {
  padding: 16px 20px;
}

.csv-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.csv-code {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--accent);
  word-break: break-all;
}

.csv-note {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 10px;
}

.csv-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-mono);
}

.csv-result.success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.csv-result.error   { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }

/* SETTINGS */
.settings-hint {
  padding: 0 20px 16px;
  font-size: 14px;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
}

.recipient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}

.recipient-email {
  font-family: var(--font-mono);
  font-size: 13px;
}

.input-row { padding: 16px 20px 20px; }

/* REPORTS LIST */
.report-row {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.report-row:hover { background: rgba(255,255,255,0.02); }
.report-row.active { background: var(--accent-glow); border-left: 2px solid var(--accent); }

.report-row-date {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.report-row-stats {
  font-size: 12px;
  color: var(--fg-dim);
  display: flex;
  gap: 12px;
}

.report-stat-alert { color: var(--accent); }

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  min-width: 260px;
  animation: toastIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.error   { border-color: rgba(239,68,68,0.4); }
.toast.warning { border-color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Drop pct color */
.drop-pct { color: var(--accent); font-family: var(--font-mono); font-weight: 600; }
.drop-critical { color: #ef4444; }

/* Responsive */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: 56px; }
  .sidebar-brand .brand-name,
  .sidebar-brand .brand-badge,
  .nav-item span:not(.nav-icon),
  .sidebar-footer { display: none; }
  .view { padding: 20px 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
