/* ============================================================
   Media Simplified Business Metrics Dashboard
   Clean light mode — iOS / Claude aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Design Tokens --- */
:root {
  --bg-base:       #f5f5f7;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f9f9fb;
  --bg-input:      #f5f5f7;

  --border:        #e5e5ea;
  --border-light:  #ebebf0;

  --text-primary:  #1c1c1e;
  --text-secondary:#48484a;
  --text-muted:    #8e8e93;
  --text-placeholder: #aeaeb2;

  --green:         #30d158;
  --green-light:   #f2fbf4;
  --green-border:  #c6f0d0;

  --red:           #ff3b30;
  --red-light:     #fff2f1;
  --red-border:    #ffc9c6;

  --yellow:        #ff9500;
  --yellow-light:  #fff8ee;
  --yellow-border: #ffe4b2;

  --blue:          #007aff;
  --blue-light:    #f0f5ff;
  --blue-border:   #bdd5ff;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;

  --font-ui:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-data:     'JetBrains Mono', monospace;

  --sidebar-w:     220px;
  --header-h:      56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================ LAYOUT */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.brand-sub  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 18px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s ease;
  text-decoration: none;
}

.nav-item:hover  { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

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

.nav-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--yellow-light);
  color: var(--yellow);
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid var(--yellow-border);
}

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

.sync-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.sync-dot.synced { background: var(--green); }
.sync-dot.error  { background: var(--red); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.header-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

.header-right { display: flex; align-items: center; gap: 10px; }

.period-selector {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.period-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
}

.period-btn:hover { color: var(--text-primary); }
.period-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.sync-btn {
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  box-shadow: var(--shadow-sm);
}

.sync-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

.page { padding: 24px; display: none; }
.page.active { display: block; }

.page-header { margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

/* ============================================================ KPI CARDS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--font-data);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-card.positive .kpi-value { color: var(--green); }
.kpi-card.negative .kpi-value { color: var(--red); }
.kpi-card.neutral  .kpi-value { color: var(--blue); }
.kpi-card.warning  .kpi-value { color: var(--yellow); }

/* ============================================================ CHARTS */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.chart-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 16px; }
.chart-container { position: relative; height: 180px; }

/* ============================================================ TABLES */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

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

.table-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.table-wrap  { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-elevated);
  cursor: pointer;
  user-select: none;
}

tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }

tbody td { padding: 11px 16px; font-size: 13px; color: var(--text-primary); white-space: nowrap; }
.td-name     { font-weight: 600; }
.td-positive { color: var(--green); font-family: var(--font-data); }
.td-negative { color: var(--red);   font-family: var(--font-data); }
.td-muted    { color: var(--text-muted); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.pill-green  { background: var(--green-light);  color: var(--green);  border: 1px solid var(--green-border); }
.pill-red    { background: var(--red-light);    color: var(--red);    border: 1px solid var(--red-border); }
.pill-yellow { background: var(--yellow-light); color: var(--yellow); border: 1px solid var(--yellow-border); }
.pill-blue   { background: var(--blue-light);   color: var(--blue);   border: 1px solid var(--blue-border); }
.pill-gray   { background: var(--bg-input);     color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================================ SCENARIOS */
.scenario-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }

.scenario-controls {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.scenario-controls-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.scenario-controls-body { padding: 18px; }

.form-group { margin-bottom: 14px; }

.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  transition: all 0.12s;
}

.form-input:focus {
  border-color: var(--blue);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

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

.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13px; font-weight: 500; color: var(--text-primary); }

.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: #d1d1d6; border-radius: 22px; cursor: pointer; transition: all 0.2s; }
.toggle input:checked + .toggle-track { background: var(--green); }
.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: left 0.2s;
}
.toggle input:checked + .toggle-track::after { left: 20px; }

.scenario-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }

.preset-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-ui);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s;
  line-height: 1.3;
}

.preset-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.preset-btn span  { display: block; font-size: 9px; color: var(--text-muted); margin-top: 2px; }

.run-btn {
  width: 100%;
  padding: 10px;
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 4px;
}

.run-btn:hover { background: #0066dd; box-shadow: 0 4px 12px rgba(0,122,255,0.3); }

.save-btn {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.12s;
}

.save-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

.scenario-results { display: flex; flex-direction: column; gap: 12px; }

.results-compare {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.compare-header  { display: grid; grid-template-columns: 1fr 1fr 1fr; background: var(--bg-elevated); border-bottom: 1px solid var(--border); }
.compare-col-header { padding: 10px 16px; font-size: 11px; font-weight: 600; color: var(--text-muted); border-right: 1px solid var(--border); }
.compare-col-header:last-child { border-right: none; color: var(--blue); }

.compare-row { display: grid; grid-template-columns: 1fr 1fr 1fr; border-bottom: 1px solid var(--border-light); }
.compare-row:last-child { border-bottom: none; }

.compare-cell { padding: 12px 16px; border-right: 1px solid var(--border-light); font-family: var(--font-data); font-size: 13px; }
.compare-cell:last-child { border-right: none; }
.compare-cell-label { font-family: var(--font-ui); font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.delta-positive { color: var(--green); }
.delta-negative { color: var(--red); }

.impact-box {
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 16px;
  text-align: center;
}

.impact-item-label  { font-size: 10px; font-weight: 600; color: #1a7a3a; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.impact-item-value  { font-family: var(--font-data); font-size: 22px; font-weight: 500; color: var(--green); letter-spacing: -0.02em; }
.impact-item-sub    { font-size: 10px; color: #4caf6e; margin-top: 3px; }

.lever-breakdown { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.lever-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; }
.lever-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.lever-row:last-child { border-bottom: none; }
.lever-row-label { color: var(--text-secondary); }
.lever-row-value { font-family: var(--font-data); color: var(--green); font-weight: 500; }

/* ============================================================ LOADING */
.loading-skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border-light) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.empty-state-icon { font-size: 26px; margin-bottom: 10px; }

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

.toast {
  background: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 500;
  color: white;
  animation: toast-in 0.2s ease;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
}

.toast.error { background: var(--red); }

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

/* ============================================================ MANUAL ENTRY */
.manual-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.manual-month-wrap { display: flex; flex-direction: column; gap: 4px; }
.manual-actions    { display: flex; gap: 8px; align-items: center; }

.manual-clear-btn {
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
}

.manual-clear-btn:hover { color: var(--red); border-color: var(--red-border); background: var(--red-light); }

.manual-push-btn {
  padding: 8px 18px;
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,122,255,0.25);
  transition: all 0.12s;
}

.manual-push-btn:hover { background: #0066dd; }

.manual-layout { display: grid; grid-template-columns: 1fr 285px; gap: 16px; align-items: start; }
.manual-inputs { display: flex; flex-direction: column; gap: 12px; }

.manual-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.manual-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.manual-section-icon {
  width: 26px; height: 26px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.manual-section-total { margin-left: auto; font-family: var(--font-data); font-size: 14px; font-weight: 500; color: var(--green); }
.manual-section-total.negative { color: var(--red); }

.manual-section-sub { padding: 8px 18px 0; font-size: 11px; color: var(--text-muted); }
.manual-field-grid  { padding: 4px 18px 14px; }

.mf-row {
  display: grid;
  grid-template-columns: 1fr 200px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 14px;
}

.mf-row:last-child { border-bottom: none; }

.mf-row.header-row {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 0 6px;
}

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

.mf-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.12s;
}

.mf-input-wrap:focus-within {
  border-color: var(--blue);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

.mf-prefix {
  padding: 0 9px;
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  min-height: 34px;
  white-space: nowrap;
}

.mf-prefix-neg { color: var(--red); }

.mf-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 7px 10px;
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
  min-width: 0;
}

.mf-input::placeholder { color: var(--text-placeholder); }

.team-header-row { grid-template-columns: 2fr 160px 130px 90px 32px !important; }
.mf-row.team-row { grid-template-columns: 2fr 160px 130px 90px 32px; }

.mf-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.12s;
}

.mf-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,0.1); }

.mf-pct-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mf-pct-wrap input {
  background: transparent;
  border: none;
  outline: none;
  padding: 7px 8px;
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--text-primary);
  width: 50px;
}

.mf-pct-suffix {
  padding: 0 7px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-data);
  border-left: 1px solid var(--border);
  background: var(--bg-elevated);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.remove-row-btn {
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  flex-shrink: 0;
}

.remove-row-btn:hover { color: var(--red); border-color: var(--red-border); background: var(--red-light); }

.mf-row.overhead-row    { grid-template-columns: 2fr 160px 130px 32px; }
.overhead-header-row    { grid-template-columns: 2fr 160px 130px 32px !important; }

.add-row-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 14px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.add-row-btn:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-light); }

/* Live Results Panel */
.manual-results {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  box-shadow: var(--shadow-sm);
}

.results-month-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.results-field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.results-field-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.results-field-hint  { display: block; font-size: 10px; font-weight: 400; color: var(--text-muted); margin-top: 1px; }
.results-clients-input { text-align: right; }

.results-divider { height: 1px; background: var(--border); margin: 12px 0; }

.results-block { margin-bottom: 2px; }

.results-block-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.results-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.results-line.muted { color: var(--text-muted); }
.results-line.negative .rl-val { color: var(--text-muted); }

.results-line.total-line {
  border-top: 1px solid var(--border);
  margin-top: 5px;
  padding-top: 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.rl-val { font-family: var(--font-data); font-size: 12px; color: var(--text-primary); font-weight: 500; }
.rl-val.positive { color: var(--green); }
.rl-val.negative { color: var(--red); }

.results-highlight {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 8px 0;
  transition: all 0.2s;
}

.results-highlight.is-positive { background: var(--green-light); border-color: var(--green-border); }
.results-highlight.is-negative { background: var(--red-light);   border-color: var(--red-border); }

.rh-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.results-highlight.is-positive .rh-label { color: #1a7a3a; }
.results-highlight.is-negative .rh-label { color: #c0392b; }

.rh-value {
  font-family: var(--font-data);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.results-highlight.is-positive .rh-value { color: var(--green); }
.results-highlight.is-negative .rh-value { color: var(--red); }

.rh-margin { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-family: var(--font-data); }
.results-highlight.is-positive .rh-margin { color: #4caf6e; }
.results-highlight.is-negative .rh-margin { color: #e57070; }

.results-save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.save-status-idle  { font-size: 11px; color: var(--text-muted); }
.save-status-saved { font-size: 11px; color: var(--green); }

.save-local-btn {
  padding: 6px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
}

.save-local-btn:hover { color: var(--blue); border-color: var(--blue-border); background: var(--blue-light); }

/* ============================================================
   ASK AI PANEL
   ============================================================ */

.ask-ai-btn {
  margin-left: auto;
  padding: 5px 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.ask-ai-btn:hover {
  color: #5856d6;
  border-color: #c8b8ff;
  background: #f7f5ff;
}

.manual-section-header:has(.ask-ai-btn) .manual-section-total {
  margin-left: 0;
}

.ask-ai-panel {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 16px;
  border-top: 1px solid #ede8ff;
  background: #faf9ff;
}

.ask-ai-panel.open {
  display: flex;
  animation: ai-slide-in 0.15s ease;
}

@keyframes ai-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ask-ai-input {
  width: 100%;
  background: white;
  border: 1px solid #e0d8ff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.55;
  resize: none;
  height: 72px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.ask-ai-input:focus {
  border-color: #7c7aff;
  box-shadow: 0 0 0 3px rgba(88, 86, 214, 0.08);
  height: 96px;
}

.ask-ai-input::placeholder {
  color: #b8b0d8;
  line-height: 1.55;
}

.ask-ai-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.ask-ai-status {
  font-size: 12px;
  font-weight: 500;
  flex: 1;
}

.ask-ai-status-loading { color: #7c7aff; }
.ask-ai-status-success { color: var(--green); }
.ask-ai-status-error   { color: var(--red); }

.ask-ai-run {
  padding: 7px 18px;
  background: #5856d6;
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(88,86,214,0.25);
}

.ask-ai-run:hover    { background: #4341c0; box-shadow: 0 3px 10px rgba(88,86,214,0.35); }
.ask-ai-run:disabled { background: var(--text-muted); cursor: wait; box-shadow: none; }

/* ============================================================ RESPONSIVE */
@media (max-width: 1100px) {
  .scenario-layout { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .manual-layout { grid-template-columns: 1fr; }
  .manual-results { position: static; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-220px); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); width: 220px; }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .impact-box { grid-template-columns: 1fr; }
}

/* ============================================================
   FINANCIAL HEALTH CHECK — Improved layout
   ============================================================ */

.hc-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.hc-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.hc-inputs { display: flex; flex-direction: column; gap: 10px; }

/* Full-width KPI strip above the two-column area */
.hc-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.hc-run-btn {
  padding: 10px 22px;
  background: var(--text-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
}
.hc-run-btn:hover    { background: #3a3a3c; box-shadow: var(--shadow-md); }
.hc-run-btn:disabled { background: var(--text-muted); cursor: wait; }

.hc-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.hc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.hc-file-count { font-size: 11px; font-weight: 500; color: var(--text-muted); font-family: var(--font-data); }

.hc-drop-zone {
  margin: 12px 14px 10px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.hc-drop-zone:hover, .hc-drop-zone.dragging { border-color: var(--blue); background: var(--blue-light); }
.hc-drop-icon  { font-size: 20px; color: var(--text-muted); margin-bottom: 6px; }
.hc-drop-title { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.hc-drop-sub   { font-size: 10px; color: var(--text-muted); line-height: 1.6; }

.hc-file-list { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 5px; }

.hc-file-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 11px;
}
.hc-file-icon   { color: var(--blue); font-size: 13px; }
.hc-file-name   { flex: 1; color: var(--text-primary); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-file-size   { color: var(--text-muted); font-family: var(--font-data); font-size: 10px; white-space: nowrap; }
.hc-file-remove { width: 18px; height: 18px; background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 3px; flex-shrink: 0; }
.hc-file-remove:hover { color: var(--red); background: var(--red-light); }

.hc-payroll-edit {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.7;
  resize: vertical;
  min-height: 150px;
  outline: none;
}
.hc-payroll-edit:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,0.1); }

/* Results panel */
.hc-results {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  min-height: 500px;
  overflow: hidden;
}

.hc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  gap: 8px;
}
.hc-empty-icon  { font-size: 36px; color: var(--border); }
.hc-empty-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.hc-empty-sub   { font-size: 13px; color: var(--text-muted); }

.hc-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; gap: 16px; }
.hc-loading-spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
.hc-loading-text { font-size: 13px; color: var(--text-muted); }

/* Summary KPI cards */
.hc-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.hc-kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.hc-kpi.positive { border-left: 3px solid var(--green); }
.hc-kpi.negative { border-left: 3px solid var(--red); }
.hc-kpi.warning  { border-left: 3px solid var(--yellow); }
.hc-kpi.muted    { opacity: 0.6; }

.hc-kpi-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.hc-kpi-value {
  font-family: var(--font-data);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.hc-kpi.positive .hc-kpi-value { color: var(--green); }
.hc-kpi.negative .hc-kpi-value { color: var(--red); }
.hc-kpi.warning  .hc-kpi-value { color: var(--yellow); }

/* Tabs */
.hc-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  gap: 0;
  overflow-x: auto;
  background: var(--bg-surface);
}
.hc-tab {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}
.hc-tab:hover  { color: var(--text-primary); }
.hc-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* Edit mode button */
.hc-edit-mode-btn {
  padding: 5px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.hc-edit-mode-btn:hover  { color: #5856d6; border-color: #c8b8ff; background: #f7f5ff; }
.hc-edit-mode-btn.hc-edit-active { background: #5856d6; border-color: #5856d6; color: white; }

/* Tab content */
.hc-tab-content { padding: 20px 24px; }

.hc-table-wrap  { overflow-x: auto; }
.hc-table-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 12px; }

.hc-table       { width: 100%; border-collapse: collapse; font-size: 13px; }
.hc-table th    { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 10px 14px; text-align: left; background: var(--bg-elevated); border-bottom: 1px solid var(--border); white-space: nowrap; }
.hc-table td    { padding: 11px 14px; border-bottom: 1px solid var(--border-light); color: var(--text-primary); vertical-align: top; }
.hc-table tr:last-child td { border-bottom: none; }
.hc-table tr:hover td { background: var(--bg-elevated); }
.hc-table .hc-total-row td { font-weight: 700; font-size: 14px; border-top: 2px solid var(--border); border-bottom: none; padding-top: 14px; }

.hc-row-excluded td { opacity: 0.4; }

.hc-amt   { font-family: var(--font-data); text-align: right; white-space: nowrap; }
.hc-muted { color: var(--text-muted); }
.hc-pos   { color: var(--green); }
.hc-neg   { color: var(--red); }
.hc-warn  { color: var(--yellow); font-weight: 600; }

.hc-cat-pill { display: inline-block; padding: 2px 9px; background: var(--blue-light); color: var(--blue); border: 1px solid var(--blue-border); border-radius: 20px; font-size: 10px; font-weight: 600; white-space: nowrap; }

.hc-summary-block { max-width: 560px; }

.hc-raw-output { margin-top: 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-family: var(--font-data); font-size: 11px; color: var(--text-muted); overflow-x: auto; max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1300px) { .hc-layout { grid-template-columns: 340px 1fr; } }
@media (max-width: 900px)  { .hc-layout { grid-template-columns: 1fr; } }
@media (max-width: 900px)  { .hc-kpi-strip { grid-template-columns: repeat(3, 1fr); } }

/* Health Check — Save/Load buttons */
.hc-save-btn, .hc-load-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hc-save-btn {
  background: var(--green-light);
  border: 1px solid var(--green-border);
  color: #1a7a3a;
}
.hc-save-btn:hover { background: var(--green); color: white; border-color: var(--green); }

.hc-load-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.hc-load-btn:hover { background: var(--blue-light); border-color: var(--blue-border); color: var(--blue); }

/* Status / Debug box */
.hc-status-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.hc-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hc-status-body {
  padding: 10px 14px;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Accuracy bar */
.hc-accuracy-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.hc-accuracy-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hc-accuracy-btns { display: flex; gap: 8px; }

.hc-acc-btn {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.hc-acc-yes:hover { background: var(--green-light); border-color: var(--green-border); color: #1a7a3a; }
.hc-acc-no:hover  { background: var(--red-light);   border-color: var(--red-border);   color: var(--red); }

.hc-accuracy-status {
  font-size: 12px;
  font-weight: 500;
  margin-left: auto;
}

/* Correction panel */
.hc-correction-panel {
  padding: 14px 18px;
  background: var(--red-light);
  border-bottom: 1px solid var(--red-border);
}

/* Editable cells */
.hc-editable {
  display: inline-block;
  min-width: 20px;
  border-radius: 3px;
  padding: 1px 3px;
  transition: background 0.12s;
}

.hc-editable.is-editing {
  background: rgba(0,122,255,0.08);
  outline: 1px solid var(--blue);
  cursor: text;
}

.hc-editable[contenteditable="true"]:hover {
  background: rgba(0,122,255,0.06);
  cursor: text;
}

.hc-editable[contenteditable="true"]:focus {
  outline: 2px solid var(--blue);
  background: white;
}

/* Scenario source toggle */
.scenario-source-toggle {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.source-btn {
  flex: 1;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
}

.source-btn:hover { color: var(--text-primary); }
.source-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.source-status {
  font-size: 11px;
  margin-top: 6px;
  min-height: 16px;
  color: var(--text-muted);
}

/* Overview source badge */
.overview-source-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Month-over-Month */
.mom-header, .mom-row {
  display: grid;
  grid-template-columns: 1fr 140px 140px 160px;
  gap: 8px;
  padding: 10px 18px;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.mom-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 18px;
}

.mom-row:last-child { border-bottom: none; }
.mom-row:hover { background: var(--bg-elevated); }

.mom-label   { color: var(--text-secondary); font-weight: 500; }
.mom-val     { font-family: var(--font-data); color: var(--text-muted); text-align: right; }
.mom-current { color: var(--text-primary); font-weight: 500; }
.mom-delta   { font-family: var(--font-data); font-weight: 500; text-align: right; font-size: 12px; }

@media (max-width: 768px) {
  .mom-header, .mom-row { grid-template-columns: 1fr 100px 100px 110px; font-size: 11px; padding: 8px 12px; }
}

/* ============================================================
   DEBUG PANEL
   ============================================================ */
.hc-debug-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}

.hc-debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
}

.hc-debug-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.hc-debug-badge {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

.hc-debug-tab-btn {
  padding: 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
}
.hc-debug-tab-btn:hover  { color: var(--text-primary); }
.hc-debug-tab-btn.active { background: var(--text-primary); color: white; border-color: var(--text-primary); }

.hc-debug-body { max-height: 220px; overflow-y: auto; }

.hc-debug-pre {
  padding: 12px 14px;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: #fafafa;
}

/* Files debug */
.dbg-file-card {
  border-bottom: 1px solid var(--border-light);
  padding: 12px 14px;
}
.dbg-file-card:last-child { border-bottom: none; }
.dbg-file-card.dbg-file-warn { background: #fffbf0; }

.dbg-file-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.dbg-file-name   { font-size: 12px; font-weight: 700; color: var(--text-primary); flex: 1; }
.dbg-file-size   { font-size: 11px; color: var(--text-muted); font-family: var(--font-data); }
.dbg-ok          { font-size: 11px; font-weight: 600; color: var(--green); }
.dbg-bad         { font-size: 11px; font-weight: 600; color: var(--yellow); }

.dbg-file-preview {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-data);
  font-size: 10px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  max-height: 100px;
  overflow-y: auto;
}

.dbg-file-empty {
  font-size: 11px;
  color: var(--yellow);
  font-style: italic;
  padding: 4px 0;
}

/* Diagnosis */
.hc-diagnose-btn {
  display: block;
  width: calc(100% - 28px);
  margin: 10px 14px;
  padding: 10px;
  background: #5856d6;
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.hc-diagnose-btn:hover    { background: #4341c0; }
.hc-diagnose-btn:disabled { background: var(--text-muted); cursor: wait; }

.dbg-diagnosis     { padding: 12px 14px; font-size: 13px; line-height: 1.6; color: var(--text-primary); }
.dbg-diag-section  { font-weight: 700; color: var(--text-primary); margin-top: 12px; margin-bottom: 4px; }
.dbg-diag-line     { color: var(--text-secondary); padding: 1px 0; }

/* Twilio pull button */
.hc-twilio-pull-btn {
  padding: 4px 12px;
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-sm);
  color: var(--blue);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.hc-twilio-pull-btn:hover    { background: var(--blue); color: white; }
.hc-twilio-pull-btn:disabled { opacity: .6; cursor: wait; }

/* Inline editable inputs in tables */
.hc-inline-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color .12s, background .12s;
  min-width: 80px;
}
.hc-inline-input:hover  { border-color: var(--border); background: var(--bg-elevated); }
.hc-inline-input:focus  { border-color: var(--blue); background: white; box-shadow: 0 0 0 2px rgba(0,122,255,.1); }
.hc-inline-num          { text-align: right; font-family: var(--font-data); width: 90px; }
select.hc-inline-input  { cursor: pointer; }

/* Pass-through add row button */
.hc-add-row-btn {
  padding: 5px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .12s;
}
.hc-add-row-btn:hover { background: var(--blue); color: white; border-color: var(--blue); }

/* ============================================================
   CLIENT COSTS + SALES MKTG CARDS
   ============================================================ */

.hc-client-costs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.hc-cost-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.hc-cost-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.hc-cost-card-total {
  font-family: var(--font-data);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.hc-cost-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.hc-cost-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Pre-run panel */
.hc-prerun-panel {
  background: var(--bg-surface);
  border: 1px solid var(--yellow-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.hc-prerun-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}

.hc-prerun-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.hc-prerun-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.hc-prerun-check.hc-prerun-warn {
  background: var(--yellow-light);
  color: var(--yellow);
}

.hc-prerun-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

/* History source pills */
.hc-source-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
}

.hc-source-db    { background: var(--blue-light);  color: var(--blue); }
.hc-source-local { background: var(--green-light); color: var(--green); }