/* ── Reset & Base ─────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f8fafc; --surface: #ffffff; --border: #e2e8f0;
  --text: #0f172a; --text-muted: #64748b; --text-light: #94a3b8;
  --primary: #0f172a; --primary-hover: #1e293b;
  --accent: #3b82f6; --accent-hover: #2563eb;
  --success: #22c55e; --warning: #f59e0b; --danger: #ef4444;
  --radius: 8px; --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Header ───────────────────────────── */
.app-header {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-left { flex-shrink: 0; }
.logo { font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; }
.logo span { font-weight: 300; }
.tab-nav { display: flex; gap: 4px; flex: 1; }
.tab-btn {
  padding: 8px 16px; border: none; background: transparent;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; border-radius: 6px; transition: all 0.15s;
}
.tab-btn:hover { background: #f1f5f9; color: var(--text); }
.tab-btn.active { background: #f1f5f9; color: var(--text); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.user-info { font-size: 12px; color: var(--text-muted); }

/* ── Buttons ──────────────────────────── */
.btn {
  padding: 8px 16px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500; border-radius: 6px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Main Content ─────────────────────── */
.app-main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.panel-header h2 { font-size: 20px; font-weight: 600; }
.panel-controls { display: flex; align-items: center; gap: 8px; }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* ── Select ───────────────────────────── */
.select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: 13px; color: var(--text); cursor: pointer;
}

/* ── Tables ───────────────────────────── */
.table-container {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  position: relative;
}
.table-container::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0;
  width: 24px; pointer-events: none;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.04));
  opacity: 0; transition: opacity 0.2s;
}
.table-container.has-scroll::after { opacity: 1; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  padding: 10px 12px; text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid #f1f5f9; white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .positive { color: var(--success); }
.data-table .negative { color: var(--danger); }

/* ── Table Column Sizing ─────────────── */
.data-table th:first-child,
.data-table td:first-child { width: 22%; min-width: 140px; }
.data-table .col-actions { width: 120px; white-space: nowrap; }
.costing-table { min-width: 1200px; }
.wholesale-table th:first-child,
.wholesale-table td:first-child { width: 18%; min-width: 140px; }

/* ── Region Cards ─────────────────────── */
.region-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.region-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.region-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-color: var(--accent); }
.region-card h3 { font-size: 16px; margin-bottom: 4px; }
.region-card .region-code { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.region-card .stat { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.region-card .stat-label { color: var(--text-muted); }
.region-card .stat-value { font-weight: 600; }

/* ── Accordion ────────────────────────── */
.accordion-container { display: flex; flex-direction: column; gap: 8px; }
.accordion-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer; user-select: none;
}
.accordion-header:hover { background: #f8fafc; }
.accordion-header h3 { font-size: 15px; }
.accordion-chevron { transition: transform 0.2s; color: var(--text-muted); }
.accordion-item.open .accordion-chevron { transform: rotate(180deg); }
.accordion-body { display: none; padding: 0 16px 16px; }
.accordion-item.open .accordion-body { display: block; }

/* ── Forms ─────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.form-group input, .form-group select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; color: var(--text);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* ── Surcharge List ───────────────────── */
.surcharge-list { margin-top: 12px; }
.surcharge-item {
  display: grid; grid-template-columns: 1fr 100px 80px 60px; gap: 8px;
  align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.surcharge-item:last-child { border-bottom: none; }

/* ── Scenarios ────────────────────────── */
.scenario-list { display: flex; flex-direction: column; gap: 8px; }
.scenario-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.scenario-item .scenario-name { font-weight: 600; }
.scenario-item .scenario-meta { font-size: 12px; color: var(--text-muted); }
.scenario-item .ssot-badge { background: var(--accent); color: white; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.scenario-actions { display: flex; gap: 6px; }

/* ── Tariff Notice ────────────────────── */
.tariff-notice {
  margin-top: 16px; padding: 12px 16px; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius); font-size: 12px; color: #92400e;
}

/* ── Modal ─────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: var(--surface); border-radius: 12px; padding: 24px;
  max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-content h3 { margin-bottom: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

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

/* ── Status ───────────────────────────── */
.status-bar { position: fixed; bottom: 0; left: 0; right: 0; padding: 8px 24px; background: var(--surface); border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; }
