  :root {
    --bg:           #ffffff;
    --surface:      #f8f9fa;
    --surface2:     #f0f2f5;
    --surface3:     #e8eaed;
    --border:       #d0d0d0;
    --border-light: #e0e0e0;
    --accent:       #3b82f6;
    --accent2:      #06b6d4;
    --green:        #10b981;
    --amber:        #f59e0b;
    --red:          #ef4444;
    --purple:       #a78bfa;
    --text:         #1a1a1a;
    --text-muted:   #666666;
    --text-dim:     #888888;
    --highlight:    #e3f2fd;
  }

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

  body {
    font-family: 'Sora', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 13px;
  }

  /* ── TOPBAR ─────────────────────────────────────────────────────────── */
  .topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    position: sticky; top: 0; z-index: 200;
  }
  .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.3px; }
  .logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
  }
  .logo span { color: var(--text-muted); font-weight: 300; margin-left: 4px; }
  .topbar-nav { display: flex; gap: 4px; }
  .nav-item {
    padding: 6px 14px; border-radius: 6px;
    color: var(--text-muted); cursor: pointer;
    font-size: 12px; font-weight: 500;
    transition: all .15s; user-select: none;
  }
  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active { background: var(--highlight); color: var(--accent); }
  .topbar-right { display: flex; align-items: center; gap: 12px; }
  .conn-badge {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    border: 1px solid;
  }
  .conn-badge.mock   { background: rgba(167,139,250,.1); border-color: rgba(167,139,250,.3); color: var(--purple); }
  .conn-badge.fabric { background: rgba(16,185,129,.1);  border-color: rgba(16,185,129,.3);  color: var(--green); }
  .conn-dot { width: 6px; height: 6px; border-radius: 50%; }
  .conn-badge.mock .conn-dot   { background: var(--purple); box-shadow: 0 0 5px var(--purple); }
  .conn-badge.fabric .conn-dot { background: var(--green);  box-shadow: 0 0 5px var(--green); animation: pulse 2s infinite; }
  @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
  .avatar { width:30px;height:30px;background:var(--surface2);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:14px;border:1px solid var(--border); }

  /* ── LAYOUT ─────────────────────────────────────────────────────────── */
  .layout { display: flex; height: calc(100vh - 56px); }

  /* ── SIDEBAR ─────────────────────────────────────────────────────────── */
  .sidebar {
    width: 290px; flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow-y: auto;
  }
  .sidebar-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
  .sidebar-title {
    font-size: 10px; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
  }
  .sidebar-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

  .field-group { margin-bottom: 12px; }
  .field-label { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
  .select-wrap { position: relative; }
  .select-wrap::after {
    content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none; font-size: 10px;
  }
  select, input[type=number], input[type=text] {
    width: 100%;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 7px;
    color: var(--text); padding: 8px 12px;
    font-family: 'Sora', sans-serif; font-size: 12px;
    appearance: none; transition: border-color .15s; outline: none;
  }
  select:focus, input:focus { border-color: var(--accent); }
  select option { background: var(--surface2); }

  /* multi-select checkboxes */
  .check-list { display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; padding: 2px 0; }
  .check-item { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
  .check-item input[type=checkbox] { width: auto; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
  .check-item label { font-size: 12px; color: var(--text-dim); cursor: pointer; }
  .check-item label:hover { color: var(--text); }
  .check-all { font-size: 11px; color: var(--accent); cursor: pointer; text-decoration: underline; margin-bottom: 6px; display: inline-block; }
  .keep-badge {
    font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
    margin-left: auto; letter-spacing: .04em; flex-shrink: 0;
  }
  .keep-badge.keep { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
  .keep-badge.drop { background: rgba(239,68,68,.12);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }

  /* ── TAG / CHIP STYLES ───────────────────────────────────────────────── */
  .tag-container { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 24px; }
  .tag {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--highlight); border: 1px solid rgba(59,130,246,.3);
    color: var(--accent); border-radius: 20px; padding: 4px 10px;
    font-size: 12px; font-weight: 500; flex-shrink: 0;
  }
  .tag .tag-remove { cursor: pointer; font-size: 14px; line-height: 1; opacity: .7; transition: opacity .15s; }
  .tag .tag-remove:hover { opacity: 1; color: var(--red); }

  .add-item-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .add-item-dropdown {
    flex: 1; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 7px; color: var(--text); padding: 8px 10px;
    font-family: 'Sora', sans-serif; font-size: 12px;
    appearance: none; cursor: pointer; transition: border-color .15s;
  }
  .add-item-dropdown:focus { border-color: var(--accent); outline: none; }
  .add-item-btn {
    padding: 8px 12px; background: var(--accent); color: white; border: none;
    border-radius: 7px; font-size: 11px; font-weight: 600; cursor: pointer;
    transition: all .15s; white-space: nowrap;
  }
  .add-item-btn:hover { background: #2563eb; }
  .add-item-btn:active { transform: scale(.97); }
  .add-item-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

  .step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); color: white;
    font-size: 10px; font-weight: 700; flex-shrink: 0;
  }
  .step-num.done { background: var(--green); }
  .step-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--text); }

  .btn {
    width: 100%; padding: 10px; border-radius: 8px; border: none;
    font-family: 'Sora', sans-serif; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all .15s; letter-spacing: .02em;
  }
  .btn-primary  { background: var(--accent); color: white; }
  .btn-primary:hover  { background: #2563eb; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(59,130,246,.4); }
  .btn-secondary { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); margin-top: 8px; }
  .btn-secondary:hover { background: var(--surface3); color: var(--text); }
  .btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

  /* scenario mini list */
  .sc-mini {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 7px;
    padding: 8px 12px; cursor: pointer; transition: all .15s; margin-bottom: 6px;
  }
  .sc-mini:hover { border-color: var(--border-light); background: var(--surface3); }
  .sc-mini.active { background: var(--highlight); border-color: rgba(59,130,246,.4); }
  .sc-mini-del {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 11px; padding: 2px 5px; border-radius: 4px; transition: all .1s;
  }
  .sc-mini-del:hover { background: rgba(239,68,68,.15); color: var(--red); }

  /* ── MAIN ─────────────────────────────────────────────────────────────── */
  .main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
  .view { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
  .view.hidden { display: none !important; }

  .main-header {
    padding: 14px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); flex-shrink: 0;
  }
  .main-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
  .main-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
  .header-actions { display: flex; gap: 8px; flex-shrink: 0; }
  .icon-btn {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 7px;
    color: var(--text-dim); padding: 7px 13px; font-size: 11px; font-weight: 600;
    cursor: pointer; transition: all .15s;
    display: flex; align-items: center; gap: 6px;
    font-family: 'Sora', sans-serif; white-space: nowrap;
  }
  .icon-btn:hover { background: var(--surface3); color: var(--text); }
  .icon-btn.accent { background: rgba(59,130,246,.15); border-color: rgba(59,130,246,.4); color: var(--accent); }
  .icon-btn.accent:hover { background: rgba(59,130,246,.25); }
  .icon-btn:active { transform: scale(.97); }
  .icon-btn:disabled { opacity: .35; cursor: not-allowed; }

  /* ── SUMMARY CARDS ───────────────────────────────────────────────────── */
  .summary-row {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 12px; padding: 14px 24px;
    background: var(--bg); border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .summary-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px; transition: border-color .2s;
  }
  .summary-card.flash { border-color: var(--accent); }
  .s-label { font-size: 10px; color: var(--text-muted); font-weight: 500; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 6px; }
  .s-val { font-size: 20px; font-weight: 700; font-family: 'DM Mono', monospace; }
  .s-val.cyan  { color: var(--accent2); }
  .s-val.green { color: var(--green); }
  .s-sub { font-size: 10px; color: var(--text-muted); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
  .delta { font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 4px; }
  .delta.pos { background: rgba(16,185,129,.15); color: var(--green); }
  .delta.neg { background: rgba(239,68,68,.15);  color: var(--red); }

  /* ── TABLE ─────────────────────────────────────────────────────────── */
  .sim-area { padding: 16px 24px; flex: 1; overflow: auto; }

  table { width: 100%; border-collapse: collapse; font-family: 'DM Mono', monospace; font-size: 11.5px; }
  thead { position: sticky; top: 0; z-index: 10; }

  th {
    background: var(--surface2); color: var(--text-muted);
    font-family: 'Sora', sans-serif; font-size: 9px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    padding: 8px 10px; text-align: center;
    border-bottom: 2px solid var(--border);
    border-right: 1px solid var(--border);
    white-space: nowrap;
  }
  th.th-info   { color: var(--text-dim);   border-bottom-color: var(--border); }
  th.th-input  { color: var(--amber);      border-bottom-color: var(--amber); }
  th.th-cur    { color: var(--accent2);    border-bottom-color: var(--accent2); }
  th.th-proj   { color: var(--green);      border-bottom-color: var(--green); }
  th.th-calc   { color: var(--text-muted); border-bottom-color: var(--border-light); }
  th.th-total  { color: var(--amber);      border-bottom-color: var(--amber); }
  th.sticky-col { position: sticky; left: 0; z-index: 12; background: var(--surface2); }
  th.sticky-col2{ position: sticky; left: 110px; z-index: 12; background: var(--surface2); }

  td {
    padding: 7px 10px; border-bottom: 1px solid var(--border);
    border-right: 1px solid rgba(38,49,72,.5);
    white-space: nowrap; vertical-align: middle; text-align: right;
  }
  tr:hover td { background: rgba(30,58,95,.25); }
  .section-divider td {
    background: var(--surface2); font-family: 'Sora', sans-serif;
    font-size: 10px; font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase; color: var(--text-muted);
    padding: 5px 10px; border-top: 1px solid var(--border); text-align: left;
  }

  td.sticky-col  { position: sticky; left: 0;     z-index: 5; background: var(--surface); text-align: left; }
  td.sticky-col2 { position: sticky; left: 110px; z-index: 5; background: var(--surface); text-align: left; }
  tr:hover td.sticky-col, tr:hover td.sticky-col2 { background: var(--surface2); }

  .td-brand { font-family: 'Sora', sans-serif; font-weight: 600; font-size: 12px; white-space: nowrap; }
  .td-size  { font-family: 'Sora', sans-serif; color: var(--text-dim); font-size: 11px; }

  /* editable cells */
  .editable {
    background: rgba(59,130,246,.06); border: 1px solid var(--border-light); border-radius: 5px;
    padding: 4px 7px; color: var(--text);
    font-family: 'DM Mono', monospace; font-size: 11.5px;
    width: 82px; outline: none; text-align: right;
    transition: border-color .15s, background .15s;
  }
  .editable:focus   { border-color: var(--accent);  background: var(--highlight); }
  .editable.changed { border-color: var(--amber); background: rgba(245,158,11,.06); }

  /* display cells */
  .v-cur   { color: var(--accent2); }
  .v-proj  { color: var(--green); }
  .v-total { color: var(--amber); font-weight: 600; }
  .v-muted { color: var(--text-dim); }

  /* left border accents for column groups */
  .grp-price-cur  { border-left: 2px solid rgba(6,182,212,.25); }
  .grp-price-proj { border-left: 2px solid rgba(16,185,129,.25); }
  .grp-calc-cur   { border-left: 2px solid rgba(6,182,212,.15); }
  .grp-total-cur  { border-left: 2px solid rgba(245,158,11,.3); }

  /* ── EMPTY / LOADING STATES ──────────────────────────────────────────── */
  .empty-state {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted); gap: 14px; padding: 60px;
  }
  .empty-icon { font-size: 52px; opacity: .25; }
  .empty-title { font-size: 16px; font-weight: 600; color: var(--text-dim); }
  .empty-sub { font-size: 12px; text-align: center; max-width: 380px; line-height: 1.6; }

  .spinner-wrap { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); }
  .spinner {
    width: 22px; height: 22px;
    border: 2px solid var(--border-light); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ── BOTTOM BAR ─────────────────────────────────────────────────────── */
  .bottom-bar {
    padding: 9px 24px; background: var(--surface); border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11px; color: var(--text-muted); flex-shrink: 0;
  }
  .legend { display: flex; gap: 16px; align-items: center; }
  .legend-item { display: flex; align-items: center; gap: 5px; }
  .legend-dot { width: 8px; height: 3px; border-radius: 2px; }

  /* ── SCENARIOS VIEW ─────────────────────────────────────────────────── */
  .sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; padding: 24px; }
  .sc-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 20px; transition: border-color .2s, box-shadow .2s;
  }
  .sc-card:hover { border-color: var(--border-light); box-shadow: 0 4px 20px rgba(0,0,0,.3); }
  .sc-card-name  { font-size: 14px; font-weight: 700; }
  .sc-card-meta  { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
  .sc-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
  .sc-metric { background: var(--surface2); border-radius: 8px; padding: 10px 12px; }
  .sc-metric-lbl { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
  .sc-metric-val { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 600; }
  .sc-metric-delta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
  .sc-card-footer { display: flex; gap: 8px; }
  .sc-btn {
    flex: 1; padding: 8px; border-radius: 7px; border: 1px solid var(--border);
    font-family: 'Sora', sans-serif; font-size: 11px; font-weight: 600;
    cursor: pointer; transition: all .15s; text-align: center; background: var(--surface2);
  }
  .sc-btn-load  { background: rgba(59,130,246,.15); color: var(--accent);    border-color: rgba(59,130,246,.3); }
  .sc-btn-load:hover { background: rgba(59,130,246,.25); }
  .sc-btn-del   { color: var(--text-muted); }
  .sc-btn-del:hover { background: rgba(239,68,68,.1); color: var(--red); border-color: rgba(239,68,68,.3); }

  /* ── DASHBOARD VIEW ─────────────────────────────────────────────────── */
  .dash-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; padding: 24px; }
  .dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
  .dash-card.span2 { grid-column: span 2; }
  .dash-card.span3 { grid-column: span 3; }
  .dash-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 16px; }
  .kpi-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
  .kpi-item { background: var(--surface2); border-radius: 8px; padding: 12px; }
  .kpi-lbl { font-size: 10px; color: var(--text-muted); margin-bottom: 6px; }
  .kpi-val { font-family: 'DM Mono', monospace; font-size: 17px; font-weight: 700; }
  .bar-chart { display: flex; flex-direction: column; gap: 10px; }
  .bar-row { display: flex; align-items: center; gap: 10px; }
  .bar-lbl { font-size: 11px; color: var(--text-dim); width: 90px; text-align: right; flex-shrink: 0; }
  .bar-track { flex: 1; height: 20px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 4px; transition: width .6s ease; display: flex; align-items: center; padding: 0 8px; }
  .bar-fill-txt { font-size: 10px; font-weight: 600; color: white; font-family: 'DM Mono', monospace; }
  .bar-pct { font-size: 11px; color: var(--text-muted); width: 50px; font-family: 'DM Mono', monospace; }

  /* ── TOAST ─────────────────────────────────────────────────────────── */
  .toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--surface3); border: 1px solid var(--border-light);
    border-radius: 8px; padding: 10px 16px; font-size: 12px; font-weight: 500;
    z-index: 9999; transform: translateY(100px); opacity: 0;
    transition: all .25s; pointer-events: none; max-width: 320px;
  }
  .toast.show { transform: translateY(0); opacity: 1; }
  .toast.success { border-color: rgba(16,185,129,.5);  color: var(--green); }
  .toast.warn    { border-color: rgba(245,158,11,.5);  color: var(--amber); }
  .toast.error   { border-color: rgba(239,68,68,.5);   color: var(--red); }

  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }