/* ═══════════════════════════════════════════════════════════
   OBHOLZ SOLUTIONS — Cockpit Admin Backoffice
   OS Brand Light Theme — Stripe-style Dashboard
   ═══════════════════════════════════════════════════════════ */

:root {
  --os-bg: #ffffff;
  --os-bg-subtle: #f8f8f9;
  --os-text: #0a0a0b;
  --os-text-secondary: #6b6b70;
  --os-muted: #6b6b70;
  --os-line: #e6e6e8;
  --os-accent: #e11f2e;
  --os-accent-hover: #c81a26;
  --os-success: #249e57;
  --os-success-bg: #eaf7f0;
  --os-danger: #e11f2e;
  --os-danger-bg: #fef2f2;
  --os-warning: #d97706;
  --os-warning-bg: #fefce8;
  --os-info: #206ba4;
  --os-info-bg: #eff6ff;
  --os-pending-bg: #f3f4f6;
  --os-font: "Montserrat", system-ui, -apple-system, sans-serif;
  --os-shadow-xs: 0 1px 2px rgba(10, 10, 11, 0.04);
  --os-shadow-sm: 0 2px 8px rgba(10, 10, 11, 0.06);
  --os-shadow-md: 0 6px 24px rgba(10, 10, 11, 0.08);
  --os-radius: 10px;
  --os-radius-sm: 6px;
  --os-radius-xs: 3px;
  --os-transition: 0.2s ease;
  --sidebar-w: 240px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: var(--os-font);
  font-size: 14px;
  font-weight: 400;
  color: var(--os-text);
  background: var(--os-bg);
  line-height: 1.6;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

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

/* ── App Shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--os-bg);
  border-right: 1px solid var(--os-line);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--os-line);
}

.sidebar-brand .logo-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--os-text);
}

.sidebar-brand .logo-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--os-muted);
  letter-spacing: 0.08em;
  margin-top: 2px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--os-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--os-text-secondary);
  cursor: pointer;
  transition: all var(--os-transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--os-font);
}

.nav-item:hover {
  background: var(--os-bg-subtle);
  color: var(--os-text);
}

.nav-item.active {
  background: var(--os-bg-subtle);
  color: var(--os-text);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 20px;
  background: var(--os-accent);
  border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.6;
  flex-shrink: 0;
}

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

.sidebar-footer {
  padding: 12px 8px 16px;
  border-top: 1px solid var(--os-line);
}

/* ── Main Content ── */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--os-bg-subtle);
}

.main-header {
  background: var(--os-bg);
  border-bottom: 1px solid var(--os-line);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.main-header h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.main-content {
  padding: 24px 32px;
  max-width: 1280px;
}

/* ── Cards ── */
.card {
  background: var(--os-bg);
  border: 1px solid var(--os-line);
  border-radius: var(--os-radius);
  box-shadow: var(--os-shadow-xs);
  padding: 20px;
  transition: box-shadow var(--os-transition);
}

.card:hover {
  box-shadow: var(--os-shadow-sm);
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--os-muted);
  margin: 0 0 16px;
}

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

.kpi-card {
  background: var(--os-bg);
  border: 1px solid var(--os-line);
  border-radius: var(--os-radius);
  padding: 20px;
  box-shadow: var(--os-shadow-xs);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--os-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 200;
  letter-spacing: 0.02em;
  color: var(--os-text);
  line-height: 1.1;
}

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

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

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

table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--os-muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--os-line);
  white-space: nowrap;
}

table td {
  padding: 12px;
  border-bottom: 1px solid var(--os-line);
  color: var(--os-text);
  vertical-align: middle;
}

table tbody tr {
  transition: background var(--os-transition);
}

table tbody tr:hover {
  background: var(--os-bg-subtle);
}

table tbody tr.clickable {
  cursor: pointer;
}

/* ── Status Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-success { background: var(--os-success-bg); color: var(--os-success); }
.badge-danger  { background: var(--os-danger-bg);  color: var(--os-danger); }
.badge-warning { background: var(--os-warning-bg); color: var(--os-warning); }
.badge-info    { background: var(--os-info-bg);    color: var(--os-info); }
.badge-neutral { background: var(--os-pending-bg); color: var(--os-muted); }

/* ── Pipeline Bar ── */
.pipeline {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.pipeline-stage {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-radius: var(--os-radius-sm);
  background: var(--os-bg-subtle);
  border: 1px solid var(--os-line);
}

.pipeline-stage .stage-count {
  font-size: 22px;
  font-weight: 200;
  color: var(--os-text);
}

.pipeline-stage .stage-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--os-muted);
  margin-top: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--os-line);
  border-radius: var(--os-radius-sm);
  background: var(--os-bg);
  color: var(--os-text);
  font-family: var(--os-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--os-transition);
}

.btn:hover {
  background: var(--os-bg-subtle);
  border-color: #ccc;
}

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

.btn-primary:hover {
  background: var(--os-accent-hover);
  border-color: var(--os-accent-hover);
}

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

/* ── Form Inputs ── */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--os-text);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--os-line);
  border-radius: var(--os-radius-sm);
  font-family: var(--os-font);
  font-size: 14px;
  color: var(--os-text);
  background: var(--os-bg);
  transition: border-color var(--os-transition), box-shadow var(--os-transition);
  outline: none;
}

.input:focus {
  border-color: var(--os-accent);
  box-shadow: 0 0 0 3px rgba(225, 31, 46, 0.15);
}

.input::placeholder {
  color: #b0b0b4;
}

/* ── Login Overlay ── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--os-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-box {
  width: 360px;
  text-align: center;
}

.login-box .logo-text {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 32px;
  color: var(--os-text);
}

.login-box h2 {
  font-size: 20px;
  font-weight: 300;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.login-box p {
  color: var(--os-muted);
  font-size: 13px;
  margin: 0 0 24px;
}

.login-error {
  color: var(--os-danger);
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
}

/* ── Timeline / Events ── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--os-line);
}

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

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--os-line);
  margin-top: 6px;
  flex-shrink: 0;
}

.timeline-dot.accent { background: var(--os-accent); }
.timeline-dot.success { background: var(--os-success); }

.timeline-body {
  flex: 1;
  min-width: 0;
}

.timeline-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--os-text);
}

.timeline-meta {
  font-size: 11px;
  color: var(--os-muted);
  margin-top: 2px;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--os-muted);
}

.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  margin: 0;
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--os-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--os-text);
  box-shadow: var(--os-shadow-md);
  animation: toast-in 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--os-success); }
.toast.error   { background: var(--os-danger); }
.toast.warning { background: var(--os-warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading Spinner ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--os-line);
  border-top-color: var(--os-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Detail View ── */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.detail-header .back-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--os-muted);
  padding: 4px;
  font-family: var(--os-font);
}

.detail-header .back-btn:hover { color: var(--os-text); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--os-muted);
  margin-bottom: 4px;
}

.detail-field .value {
  font-size: 14px;
  color: var(--os-text);
  word-break: break-word;
}

/* ── Agent Cards ── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.agent-card {
  border: 1px solid var(--os-line);
  border-radius: var(--os-radius);
  padding: 20px;
  background: var(--os-bg);
  box-shadow: var(--os-shadow-xs);
}

.agent-card .agent-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.agent-card .agent-role {
  font-size: 12px;
  color: var(--os-muted);
  margin-bottom: 12px;
}

.agent-card .agent-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  border-top: 1px solid var(--os-line);
  color: var(--os-text-secondary);
}

.agent-card .agent-stat .stat-val {
  font-weight: 600;
  color: var(--os-text);
}

/* ── Hamburger (mobile) ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--os-text);
  font-size: 20px;
  font-family: var(--os-font);
}

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

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--os-shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }

  .main-area {
    margin-left: 0;
  }

  .hamburger { display: block; }

  .main-content { padding: 16px; }
  .main-header { padding: 12px 16px; }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .pipeline {
    flex-wrap: wrap;
  }

  .pipeline-stage {
    min-width: calc(50% - 4px);
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
