/* Garage Analytics 2.0 — dashboard UI */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --sidebar: #111827;
  --sidebar-hover: #1f2937;
  --sidebar-active: #2563eb;
  --text: #111827;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 15px/1.5 var(--font);
}

a {
  color: var(--primary);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* —— App shell —— */
.app-shell {
  min-height: 100vh;
}

.app-shell.has-sidebar {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #e5e7eb;
  padding: 20px 14px 16px;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px 20px;
  text-decoration: none;
  color: #fff;
}

.sidebar-brand strong {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.sidebar-brand span {
  font-size: 12px;
  color: #94a3b8;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow: auto;
  padding-bottom: 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(37, 99, 235, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.nav-ico {
  width: 18px;
  text-align: center;
  opacity: 0.85;
  font-size: 13px;
}

.sidebar-foot {
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 12px;
  color: #94a3b8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.status-dot.warn {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
}

.status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 6px;
  padding: 9px 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  background: transparent;
  color: #e2e8f0;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn-logout:hover {
  background: var(--sidebar-hover);
}

.main-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-left h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 18px;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.neutral {
  background: #f1f5f9;
  color: #475569;
}

.pill.ok {
  background: #dcfce7;
  color: #166534;
}

.pill.warn {
  background: #fef3c7;
  color: #92400e;
}

.pill.danger {
  background: #fee2e2;
  color: #991b1b;
}

.content {
  padding: 24px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar-backdrop {
  display: none;
}

/* —— Typography blocks —— */
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 52rem;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

/* —— Cards / metrics —— */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 16px 18px;
}

.metric-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.metric-card strong {
  display: block;
  font-size: 24px;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.metric-card em {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.panel {
  padding: 18px 20px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.cat-card {
  padding: 16px;
}

.cat-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  text-transform: capitalize;
}

.cat-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  font-size: 13px;
}

.cat-card dt {
  color: var(--muted);
}

.cat-card dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.delta-up {
  color: var(--danger);
}

.delta-down {
  color: var(--success);
}

.delta-flat {
  color: var(--muted);
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: var(--surface);
}

table.data th,
table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
  font-size: 13.5px;
}

table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
  cursor: default;
}

table.data th.sortable {
  cursor: pointer;
  user-select: none;
}

table.data th.sortable:hover {
  color: var(--text);
}

table.data tbody tr:nth-child(even) {
  background: #fafbfc;
}

table.data tbody tr:hover {
  background: #f1f5f9;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.data tr.hidden-row {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}

.badge.ok,
.badge.success,
.badge.info {
  background: #dcfce7;
  color: #166534;
}

.badge.info {
  background: #e0f2fe;
  color: #075985;
}

.badge.warn,
.badge.warning,
.badge.partial {
  background: #fef3c7;
  color: #92400e;
}

.badge.danger,
.badge.critical,
.badge.failed {
  background: #fee2e2;
  color: #991b1b;
}

.badge.muted {
  background: #f1f5f9;
  color: #64748b;
}

/* —— Filters —— */
.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.filters input,
.filters select,
.field input,
.field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--text);
}

.filters-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-block {
  width: 100%;
}

/* —— Timeline / charts —— */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.timeline-item time {
  font-size: 12px;
  color: var(--muted);
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 8px 4px 0;
}

.chart-bars .bar {
  flex: 1;
  min-width: 10px;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  border-radius: 6px 6px 2px 2px;
  opacity: 0.9;
}

.chart-bars .bar span {
  display: none;
}

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

.empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 16px;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.tool {
  border-bottom: 1px dotted var(--muted);
  cursor: help;
}

/* —— Login —— */
body.login-body {
  background:
    radial-gradient(1200px 500px at 10% -10%, #dbeafe 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e2e8f0 0%, transparent 50%),
    var(--bg);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.login-card .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-weight: 700;
  margin-bottom: 14px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-card .sub {
  margin: 0 0 18px;
  color: var(--muted);
}

.login-card label {
  display: block;
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
}

.login-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* —— Responsive —— */
@media (max-width: 1100px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell.has-sidebar {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    width: min(280px, 86vw);
    box-shadow: var(--shadow);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
  }

  body.nav-open .sidebar-backdrop {
    display: block;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-meta .pill.hide-sm {
    display: none;
  }

  .content {
    padding: 16px;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .metrics,
  .cat-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 10px 12px;
  }
}
