/* envi-reports — Uber-inspired UI v2 (Inter font, polished) */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f6f6;
  --fg: #000000;
  --fg-muted: #6b6b6b;
  --gray-1: #f6f6f6;
  --gray-2: #e2e2e2;
  --gray-3: #afafaf;
  --gray-4: #757575;
  --gray-5: #353535;
  --gray-6: #1a1a1a;
  --accent: #000000;
  --accent-hover: #1a1a1a;
  --accent-fg: #ffffff;
  --error: #e11900;
  --warn: #f6a623;
  --ok: #108060;
  --border: 1px solid #e2e2e2;
  --border-strong: 2px solid #000000;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.10);
  --radius: 8px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;
}

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

html, body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

a { color: var(--fg); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* === Layout === */
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.container-narrow { max-width: 440px; margin: 0 auto; padding: 24px; }
.container-wide { max-width: 1320px; margin: 0 auto; padding: 24px; }
.container-fluid { max-width: 100%; margin: 0; padding: 0; }

.stack > * + * { margin-top: var(--space-md); }
.stack-sm > * + * { margin-top: var(--space-sm); }
.stack-lg > * + * { margin-top: var(--space-lg); }

.flex { display: flex; gap: var(--space-md); align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-md); }

/* === Typography === */
h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: var(--space-md);
}
h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: var(--space-md);
}
h3 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-sm);
}
p { margin-bottom: var(--space-md); }

.muted { color: var(--fg-muted); font-size: 0.875rem; }
.subtitle { color: var(--fg-muted); font-size: 1rem; margin-bottom: var(--space-xl); }
.mono { font-family: var(--font-mono); font-size: 0.85rem; }
.eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

/* === Top nav (Uber-style thin) === */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: var(--border);
  backdrop-filter: saturate(180%) blur(20px);
}
.nav-brand {
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.nav-brand:hover { text-decoration: none; }
.nav-links {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}
.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-muted);
  transition: color 0.15s;
}
.nav-link:hover { color: var(--fg); text-decoration: none; }
.nav-link.active { color: var(--fg); }
.nav-user {
  font-size: 0.8rem;
  color: var(--fg-muted);
  padding: 4px 10px;
  background: var(--gray-1);
  border-radius: 4px;
}

@media (max-width: 768px) {
  .nav { padding: 12px 16px; }
  .nav-links { gap: var(--space-md); }
  .nav-user { display: none; }
}

/* === Buttons (Uber: solid black, sharp, generous padding) === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 24px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  background: var(--gray-3);
  border-color: var(--gray-3);
  cursor: not-allowed;
  opacity: 0.6;
}
.btn:focus-visible {
  outline: 3px solid rgba(0, 0, 0, 0.15);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--gray-2);
}
.btn-secondary:hover {
  background: var(--gray-1);
  border-color: var(--gray-3);
  color: var(--fg);
}

.btn-danger {
  background: var(--bg);
  color: var(--error);
  border-color: var(--error);
}
.btn-danger:hover {
  background: var(--error);
  color: var(--accent-fg);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg);
}
.btn-ghost:hover {
  background: var(--gray-1);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8125rem;
}
.btn-lg {
  padding: 16px 28px;
  font-size: 1rem;
}
.btn-block { display: flex; width: 100%; }

/* === Cards (Uber: subtle border, generous padding) === */
.card {
  background: var(--bg);
  border: var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  transition: box-shadow 0.15s;
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-elevated { box-shadow: var(--shadow-md); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: var(--border);
}
.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* === Forms (Uber: underline-style inputs, focus = thicker line) === */
.field { margin-bottom: var(--space-lg); }
.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--fg);
  letter-spacing: 0.01em;
}
.hint {
  font-size: 0.8125rem;
  color: var(--fg-muted);
  margin-top: var(--space-xs);
}
.input, .select, .textarea {
  width: 100%;
  padding: 14px 0;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--fg);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--gray-2);
  border-radius: 0;
  outline: none;
  transition: border-color 0.2s ease, padding 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}
.input:hover, .select:hover, .textarea:hover { border-bottom-color: var(--gray-3); }
.input:focus, .select:focus, .textarea:focus {
  border-bottom: 2.5px solid var(--fg);
  padding-bottom: 13px;
}
.input::placeholder, .textarea::placeholder { color: var(--gray-3); }
.input:disabled { color: var(--gray-3); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 80px; }

/* === Banners === */
.banner {
  padding: 14px 18px;
  margin-bottom: var(--space-md);
  border-radius: var(--radius);
  border-left: 3px solid var(--gray-3);
  background: var(--gray-1);
  font-size: 0.875rem;
  line-height: 1.5;
}
.banner strong { font-weight: 600; }
.banner-warn { border-left-color: var(--warn); background: #fff8e6; }
.banner-error { border-left-color: var(--error); background: #fff0ec; color: var(--error); }
.banner-ok { border-left-color: var(--ok); background: #e8f5f1; }

/* === Tables === */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  border-bottom: 2px solid var(--fg);
  white-space: nowrap;
}
td {
  padding: 16px;
  border-bottom: var(--border);
  vertical-align: middle;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: var(--gray-1); }
tbody tr:last-child td { border-bottom: none; }

/* === Auth pages (Uber-style split) === */
.auth-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
}
.auth-form {
  width: 100%;
  max-width: 360px;
}
.auth-aside {
  background: var(--accent);
  color: var(--accent-fg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-2xl);
  position: relative;
  overflow: hidden;
}
.auth-aside::before {
  content: "";
  position: absolute;
  top: 10%;
  right: -20%;
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 70%);
}
.auth-aside h2 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 400px;
  position: relative;
  z-index: 1;
}
.auth-aside p {
  font-size: 1rem;
  opacity: 0.7;
  margin-top: var(--space-md);
  max-width: 360px;
  position: relative;
  z-index: 1;
}
.auth-footer {
  position: absolute;
  bottom: var(--space-lg);
  left: var(--space-lg);
  right: var(--space-lg);
  font-size: 0.75rem;
  opacity: 0.5;
  display: flex;
  justify-content: space-between;
}
@media (max-width: 768px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-panel { padding: var(--space-lg); }
}

/* === Error pages === */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}
.error-card { max-width: 520px; text-align: center; }
.error-code {
  font-size: 6rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  margin-bottom: var(--space-md);
  background: linear-gradient(180deg, var(--fg) 0%, var(--gray-3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.error-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-md);
}
.error-msg {
  color: var(--fg-muted);
  font-size: 1rem;
  margin-bottom: var(--space-xl);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.error-actions { display: flex; gap: var(--space-md); justify-content: center; flex-wrap: wrap; }

/* === Logs === */
.log-stream {
  background: var(--gray-6);
  color: #fafafa;
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
  max-height: 75vh;
  overflow-y: auto;
  border-radius: var(--radius);
}
.log-line { padding: 2px 0; }
.log-line-debug { color: var(--gray-3); }
.log-line-info { color: #4d9fff; }
.log-line-warn { color: var(--warn); }
.log-line-error { color: var(--error); }
.log-line-audit { color: #b88aff; }
.log-line time {
  color: var(--gray-4);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* === Status pills === */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--gray-1);
  color: var(--gray-5);
  border-radius: 100px;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-ok { background: #e8f5f1; color: var(--ok); }
.pill-warn { background: #fff8e6; color: #8b6914; }
.pill-error { background: #fff0ec; color: var(--error); }

/* === Utilities === */
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--fg-muted); }
.w-full { width: 100%; }

/* === Progress === */
.progress {
  width: 100%;
  height: 4px;
  background: var(--gray-2);
  overflow: hidden;
  border-radius: 100px;
}
.progress-bar {
  height: 100%;
  background: var(--fg);
  transition: width 0.3s ease;
}

/* === Mobile optimizations === */
@media (max-width: 640px) {
  .container, .container-narrow, .container-wide { padding: 16px; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.25rem; }
  .card { padding: var(--space-md); }
  .btn-lg { padding: 14px 20px; }
  .nav-user { display: none; }
  .nav-links .nav-link { font-size: 0.8rem; }
  table th, table td { padding: 10px 8px; font-size: 0.8rem; }
}

/* === Hamburger menu + mobile drawer === */
.hamburger {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  margin-right: 8px;
  color: var(--fg);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}
.hamburger:hover { background: var(--gray-1); }

@media (max-width: 768px) {
  .hamburger { display: inline-flex; }
  .nav-links-desktop {
    display: none;
  }
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--bg);
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: var(--border);
}
.drawer-brand { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.drawer-close {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--fg);
  border-radius: 4px;
}
.drawer-close:hover { background: var(--gray-1); }

.drawer-nav {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}
.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.1s;
}
.drawer-link:hover { background: var(--gray-1); text-decoration: none; }
.drawer-link.active { background: var(--gray-1); color: var(--fg); }
.drawer-link svg { flex-shrink: 0; }
.drawer-footer {
  padding: 16px 20px;
  border-top: var(--border);
  font-size: 0.8rem;
  color: var(--fg-muted);
}
.drawer-footer form { margin-top: 12px; }

/* === Nav link with icon === */
.nav-link { display: inline-flex; align-items: center; gap: 6px; }
.nav-link svg { flex-shrink: 0; }

/* === Select styled (underline style) === */
.select-styled {
  width: 100%;
  padding: 14px 32px 14px 0;
  font-family: inherit;
  font-size: 1rem;
  color: var(--fg);
  background: transparent
    url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3e%3c/svg%3e")
    no-repeat right 8px center;
  border: none;
  border-bottom: 1.5px solid var(--gray-2);
  border-radius: 0;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.select-styled:hover { border-bottom-color: var(--gray-3); }
.select-styled:focus {
  border-bottom: 2.5px solid var(--fg);
  padding-bottom: 13px;
}

/* === Color field === */
.color-field {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-picker {
  width: 48px;
  height: 48px;
  padding: 4px;
  border: 1.5px solid var(--gray-2);
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg);
}
.color-picker:hover { border-color: var(--gray-3); }
.color-hex {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-transform: uppercase;
}

/* === Switch (boolean field) === */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--gray-2);
  transition: background 0.2s;
  border-radius: 100px;
}
.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: white;
  transition: transform 0.2s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--fg); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* === Settings section nav (icon grid) === */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-md);
}
.settings-tile {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg);
  border: var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  text-decoration: none;
  color: var(--fg);
}
.settings-tile:hover {
  border-color: var(--gray-3);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-1px);
}
.settings-tile-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-1);
  border-radius: 8px;
  flex-shrink: 0;
}
.settings-tile-content { flex: 1; min-width: 0; }
.settings-tile-title { font-weight: 600; font-size: 0.95rem; }
.settings-tile-desc { font-size: 0.8125rem; color: var(--fg-muted); margin-top: 2px; }
.settings-tile svg { color: var(--fg); }