:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-alt: #f9f8f5;
  --border: #e4e0d8;
  --text: #1a1a17;
  --muted: #7a7974;
  --faint: #bab9b4;
  --primary: #0d9488;
  --primary-dark: #0a6b62;
  --primary-light: #ccfbf1;
  --red: #c0392b;
  --red-light: #fdecea;
  --green: #2d8659;
  --green-light: #e8f5e9;
  --amber: #b8860b;
  --amber-light: #fef9e7;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

#app { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 14px;
  border-bottom: 2px solid var(--primary);
  margin-bottom: 20px;
}
.header-left h1 {
  font-family: 'DM Sans', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.header-left .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.header-right {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.header-right .timestamp {
  font-weight: 600;
  color: var(--text);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* KPI Cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 16px 18px;
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.kpi .val {
  font-family: 'DM Sans', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.kpi .tgt {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Section titles */
.section-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
th, td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
  overflow-wrap: anywhere;
}
th:first-child, td:first-child { text-align: left; }
thead th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: var(--surface-alt); }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-ready { background: var(--green-light); color: var(--green); }
.badge-auth { background: var(--amber-light); color: var(--amber); }
.badge-mednec { background: #fff3cd; color: #856404; }
.badge-unstatused { background: #f0f0f0; color: #555; }
.badge-hold { background: var(--red-light); color: var(--red); }
.badge-remove { background: #fce4ec; color: #c2185b; }

/* Funnel bar */
.funnel-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.funnel-bar .stage-name {
  width: 160px;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
}
.funnel-bar .bar-track {
  flex: 1;
  height: 28px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.funnel-bar .bar-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  transition: width 0.4s ease;
}
.funnel-bar .count {
  width: 40px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Action items */
.action-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.action-item:last-child { border-bottom: none; }
.action-item .priority {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.priority-high { background: var(--red); }
.priority-med { background: var(--amber); }
.priority-low { background: var(--primary); }
.action-item .action-content { flex: 1; }
.action-item .action-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.action-item .action-desc { font-size: 12px; color: var(--muted); }

/* Empty state */
.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Desc text */
.desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* Alert banner */
.alert-banner {
  background: var(--red-light);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.alert-banner .alert-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.alert-banner .alert-text {
  font-size: 13px;
  color: var(--red);
  font-weight: 600;
}

/* Chart containers */
.chart-container {
  position: relative;
  height: 280px;
  margin-top: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  #app { padding: 12px; }
  .header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .header-right { text-align: left; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .funnel-bar .stage-name { width: 100px; font-size: 12px; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; font-size: 12px; }
}
