/**
 * UTOGRID — Shared Design System
 * ================================
 * Edit this file to retheme the entire app.
 *
 * Sections:
 *   1. Fonts
 *   2. Design tokens (CSS variables)
 *   3. Reset & base
 *   4. Layout shell (sidebar, main, pages)
 *   5. Navigation
 *   6. Cards & containers
 *   7. Typography helpers
 *   8. Data components (KPIs, charts, tables, bars)
 *   9. Badges & chips
 *  10. Buttons
 *  11. Forms & inputs
 *  12. Toast
 *  13. Modal
 *  14. Edit mode (brick system)
 *  15. Responsive
 */

/* ── 1. Fonts ──────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,700;0,900;1,700&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&display=swap');

/* ── 2. Design tokens ──────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:      #FAF7F2;
  --bg2:     #F3EEE5;
  --card:    #FFFFFF;

  /* Brand */
  --mint:    #02C39A;
  --mint2:   #00A882;
  --teal:    #028090;
  --teal2:   #026E7A;

  /* Text */
  --dark:    #1A2332;
  --white:   #FFFFFF;
  --muted:   #6B7280;
  --mutedlt: #94A3B8;
  --muteddk: #4B5563;

  /* Borders */
  --border:    #DDD8CF;
  --border2:   #C8C0B4;
  --borderint: rgba(0,0,0,0.07);

  /* Semantic colours */
  --amber: #D97706;
  --red:   #DC2626;
  --green: #059669;
  --blue:  #2563EB;

  /* Energy mix colours */
  --nuclear: #D97706;
  --hydro:   #2563EB;
  --solar:   #CA8A04;
  --wind:    #059669;
  --gas:     #EA580C;
  --bio:     #65A30D;

  /* Typography */
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(2,128,144,0.10);
}

/* ── 3. Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
}

/* ── 4. Layout shell ───────────────────────────────────────────────── */
.app  { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; overflow-y: auto; min-width: 0; position: relative; background: var(--bg); }

.page { display: none; padding: 18px 22px 28px; overflow: auto; max-height: 100%; }
.page.active { display: block; }

.page-carte-layout { position: absolute; inset: 0; z-index: 20; background: var(--bg); }
.page-carte-layout.active { display: flex; flex-direction: column; padding: 0; }

/* ── 5. Navigation ─────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  box-shadow: 1px 0 0 var(--border);
}

.sidebar-logo { padding: 18px 18px 12px; border-bottom: 1px solid var(--border); }

.logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--dark);
}
.logo span { color: var(--teal); }
.logo-sub  { font-size: .68rem; color: var(--muted); margin-top: 2px; }

.nav-section  { padding: 10px 0 4px; }
.nav-label    { font-size: .62rem; text-transform: uppercase; letter-spacing: .12em; color: var(--mutedlt); padding: 0 16px 4px; }
.nav-divider  { height: 1px; background: var(--border); margin: 6px 14px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: .82rem;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover  { background: rgba(2,128,144,.05); color: var(--dark); }
.nav-item.active { background: rgba(2,128,144,.07); color: var(--teal); border-left-color: var(--teal); }
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

/* Journey progress (sidebar bottom) */
.progress-section {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: var(--bg);
}
.progress-title   { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.progress-bar-wrap { background: var(--border); border-radius: 4px; height: 5px; margin-bottom: 6px; }
.progress-bar-fill { height: 5px; border-radius: 4px; background: linear-gradient(90deg, var(--teal), var(--mint)); }
.progress-label   { font-size: .72rem; color: var(--muted); display: flex; justify-content: space-between; }
.progress-steps   { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }

.pstep { display: flex; align-items: center; gap: 7px; font-size: .75rem; cursor: pointer; padding: 4px 0; }
.pstep:hover { color: var(--dark); }
.pstep.done   { color: var(--mint2); }
.pstep.active { color: var(--dark); font-weight: 600; }
.pstep.todo   { color: var(--muted); }
.pstep-dot    { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pstep.done   .pstep-dot { background: var(--mint); }
.pstep.active .pstep-dot { background: var(--teal); }
.pstep.todo   .pstep-dot { background: var(--border2); }

/* Mobile burger */
.burger {
  display: none;
  position: fixed; top: 0; left: 0; z-index: 200;
  width: 52px; height: 52px;
  background: var(--white);
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border-radius: 0 0 10px 0;
}
.burger span { display: block; width: 20px; height: 2px; background: var(--dark); border-radius: 2px; transition: .25s; }
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 149;
  opacity: 0;
  transition: opacity .25s;
}
.overlay.visible { opacity: 1; }

/* ── 6. Cards & containers ─────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.csm {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

/* Grid layouts */
.g2 { display: grid; grid-template-columns: 1fr 1fr;           gap: 12px; margin-bottom: 12px; }
.g3 { display: grid; grid-template-columns: repeat(3,1fr);     gap: 10px; margin-bottom: 12px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr);     gap: 10px; margin-bottom: 12px; }

/* Page header */
.ph { margin-bottom: 14px; }
.ph h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 3px; color: var(--dark); }
.ph p  { font-size: .78rem; color: var(--muted); }

/* Section title */
.stitle {
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--dark);
}

/* Tag (inline label in stitle) */
.tag {
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .08em;
  background: rgba(2,128,144,.10);
  color: var(--teal);
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
}

/* Feature cards */
.fi-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.fi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px;
  cursor: pointer;
  transition: .2s;
  box-shadow: var(--shadow-sm);
}
.fi-card:hover   { border-color: var(--teal); box-shadow: var(--shadow-md); }
.fi-emoji { font-size: 1.3rem; margin-bottom: 6px; }
.fi-title { font-size: .8rem; font-weight: 600; margin-bottom: 4px; color: var(--dark); }
.fi-val   { font-size: 1.4rem; font-weight: 800; color: var(--teal); margin-bottom: 4px; letter-spacing: -.02em; }
.fi-desc  { font-size: .74rem; color: var(--muted); line-height: 1.5; }

/* PDL info strip */
.pdl-strip {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.linky-badge {
  background: rgba(202,138,4,.1);
  border: 1px solid rgba(202,138,4,.25);
  color: var(--amber);
  font-size: .7rem; font-weight: 700;
  padding: 3px 9px; border-radius: 4px; flex-shrink: 0;
}
.pdl-info { display: flex; gap: 16px; flex-wrap: wrap; }
.pi       { display: flex; flex-direction: column; gap: 2px; }
.pi-l     { font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pi-v     { font-size: .84rem; font-weight: 600; color: var(--dark); }

/* Insight callout */
.insight {
  background: rgba(202,138,4,.05);
  border: 1px solid rgba(202,138,4,.2);
  border-radius: 11px;
  padding: 14px;
  display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 12px;
}
.insight h4 { font-size: .83rem; font-weight: 700; color: var(--amber); margin-bottom: 4px; }
.insight p  { font-size: .77rem; color: var(--muted); line-height: 1.6; }

/* Savings box */
.savings-box {
  background: linear-gradient(135deg,rgba(2,195,154,.07),rgba(2,128,144,.04));
  border: 1px solid rgba(2,128,144,.2);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.sav-num  { font-family: var(--font-display); font-size: 2.2rem; font-weight: 900; color: var(--mint2); line-height: 1; }
.sav-div  { width: 1px; height: 44px; background: var(--border); flex-shrink: 0; }
.sav-text h3 { font-size: .88rem; font-weight: 600; margin-bottom: 4px; color: var(--dark); }
.sav-text p  { font-size: .77rem; color: var(--muted); line-height: 1.5; }
.sav-btn {
  background: var(--teal); color: #fff;
  font-weight: 600; font-size: .77rem;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}

/* ── 7. Typography helpers ──────────────────────────────────────────── */
.kl  { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.kv  { font-size: 1.45rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: var(--dark); }
.ks  { font-size: .71rem; color: var(--muted); margin-top: 3px; }
.kv.mint  { color: var(--mint2); }
.kv.amber { color: var(--amber); }
.kv.red   { color: var(--red); }
.kv.blue  { color: var(--blue); }
.kv.green { color: var(--green); }

.ms      { color: var(--muted); }
.ms span { color: var(--dark); font-weight: 700; }

/* ── 8. Data components ─────────────────────────────────────────────── */

/* Chart wrappers */
.cw    { position: relative; height: 185px; margin-top: 8px; }
.cw-lg { position: relative; height: 220px; margin-top: 8px; }
.cw-sm { position: relative; height: 140px; margin-top: 6px; }

/* Progress rows (horizontal bar rows) */
.prow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.plbl { font-size: .73rem; color: var(--muted); width: 80px; flex-shrink: 0; text-align: right; }
.ptrk { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.pfil { height: 100%; border-radius: 3px; }
.pval { font-size: .71rem; color: var(--dark); font-weight: 600; width: 36px; text-align: right; }

/* Legend */
.leg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.li  { display: flex; align-items: center; gap: 4px; font-size: .71rem; color: var(--muted); }
.ld  { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }

/* Monthly mini-bars */
.monthly-bars  { display: flex; gap: 8px; align-items: flex-end; height: 192px; margin: 10px 0 4px; }
.mbar-wrap     { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.mbar          { width: 100%; border-radius: 3px 3px 0 0; min-height: 3px; }
.mbar-lbl      { font-size: .68rem; color: var(--muted); }
.mbar-val      { font-size: .66rem; color: var(--dark); font-weight: 600; }

/* Tables */
.pm-table { width: 100%; border-collapse: collapse; font-size: .77rem; }
.pm-table th { color: var(--muted); font-weight: 500; padding: 5px 9px; text-align: left; border-bottom: 1px solid var(--border); }
.pm-table td { padding: 7px 9px; border-bottom: 1px solid var(--border); color: var(--dark); }
.pm-table tr:last-child td { border-bottom: none; }
.pbar2  { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.pfil2  { height: 100%; border-radius: 2px; }

/* Mode / range toggles */
.mode-toggle {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 3px; width: fit-content;
}
.mode-btn {
  padding: 5px 14px; border-radius: 5px;
  font-size: .77rem; font-weight: 600;
  cursor: pointer; border: none; background: none;
  color: var(--muted); transition: .15s;
}
.mode-btn.active { background: var(--teal); color: #fff; }

.range-btn {
  padding: 4px 12px; border-radius: 5px;
  font-size: .74rem; font-weight: 600;
  cursor: pointer; border: none; background: none;
  color: var(--muted); transition: .15s;
}
.range-btn.active      { background: var(--teal); color: #fff; }
.range-btn:hover:not(.active) { color: var(--dark); }

/* Connections list */
.conn-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.conn-row:last-child { border-bottom: none; }
.conn-l  { display: flex; align-items: center; gap: 9px; }
.conn-ic { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.conn-nm { font-size: .82rem; font-weight: 600; margin-bottom: 1px; color: var(--dark); }
.conn-sb { font-size: .7rem; color: var(--muted); }
.cs      { font-size: .67rem; font-weight: 600; padding: 2px 7px; border-radius: 3px; white-space: nowrap; }
.cs-on   { background: rgba(5,150,105,.1);  color: #059669; }
.cs-pub  { background: rgba(37,99,235,.1);  color: #2563EB; }
.cs-warn { background: rgba(245,158,11,.1); color: #D97706; }
.cs-err  { background: rgba(239,68,68,.1);  color: #DC2626; }

/* Resource grid (RGPD rights) */
.rg  { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.rb  { background: var(--bg2); border: 1px solid var(--border); border-radius: 7px; padding: 10px; font-size: .77rem; color: var(--muted); cursor: pointer; transition: .2s; text-align: left; }
.rb:hover       { border-color: var(--teal); color: var(--dark); }
.rb .ri         { font-size: .95rem; margin-bottom: 3px; display: block; }
.rb.danger      { color: var(--red); border-color: rgba(220,38,38,.15); }

/* Score page */
.score-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 14px; }
.score-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 18px 14px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative; overflow: hidden; transition: .2s; box-shadow: var(--shadow-sm);
}
.score-card:hover { border-color: rgba(2,128,144,.3); box-shadow: var(--shadow-md); }
.score-icon      { font-size: 2rem; line-height: 1; margin-bottom: 2px; }
.score-name      { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: center; }
.score-val       { font-size: 2rem; font-weight: 900; line-height: 1; letter-spacing: -.03em; color: var(--dark); }
.score-bar-wrap  { width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.score-bar       { height: 6px; border-radius: 3px; transition: width 1s ease; }
.score-desc      { font-size: .68rem; color: var(--muted); text-align: center; line-height: 1.4; }

.utoscore-main {
  background: linear-gradient(135deg,rgba(2,195,154,.07),rgba(2,128,144,.04));
  border: 1px solid rgba(2,128,144,.2);
  border-radius: 16px; padding: 24px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 24px;
}
.utoscore-dial   { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.utoscore-dial svg { width: 110px; height: 110px; }
.utoscore-label  { font-size: .72rem; font-weight: 700; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.utoscore-number { font-family: var(--font-display); font-size: 3.2rem; font-weight: 900; color: var(--teal); line-height: 1; letter-spacing: -.04em; }
.utoscore-sub    { font-size: .77rem; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.score-breakdown { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.breakdown-row   { display: flex; align-items: center; gap: 8px; }
.breakdown-name  { font-size: .75rem; color: var(--muted); width: 110px; flex-shrink: 0; }
.breakdown-bar   { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.breakdown-fill  { height: 5px; border-radius: 3px; }
.breakdown-val   { font-size: .73rem; font-weight: 700; width: 36px; text-align: right; }

/* Method table */
.method-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.method-table th { color: var(--muted); font-weight: 500; padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.method-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); line-height: 1.5; color: var(--dark); }
.method-table tr:last-child td { border-bottom: none; }
.method-table td:first-child { font-weight: 700; color: var(--teal); white-space: nowrap; }

/* Journey steps */
.journey { display: flex; flex-direction: column; }
.jstep   { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.jstep:last-child { border-bottom: none; }
.jstep-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.jstep.done   .jstep-num { background: var(--mint); color: #fff; }
.jstep.active .jstep-num { background: var(--teal); color: #fff; }
.jstep.todo   .jstep-num { background: var(--bg2); color: var(--muted); border: 1px solid var(--border); }
.jstep-body h4 { font-size: .88rem; font-weight: 600; margin-bottom: 4px; color: var(--dark); }
.jstep-body p  { font-size: .77rem; color: var(--muted); line-height: 1.5; }
.jstep-action  { margin-top: 8px; background: none; border: 1px solid var(--teal); color: var(--teal); font-size: .74rem; padding: 5px 12px; border-radius: 5px; cursor: pointer; }

/* Chips */
.chip { background: var(--bg2); border: 1px solid var(--border); color: var(--muted); font-size: .71rem; padding: 3px 9px; border-radius: 5px; cursor: pointer; transition: .15s; }
.chip:hover        { border-color: var(--teal); color: var(--dark); }
.chip.active       { border-color: var(--teal); color: var(--teal); background: rgba(2,128,144,.07); }

/* Popup rows */
.popup-title { font-size: .83rem; font-weight: 600; margin-bottom: 5px; color: var(--dark); }
.popup-row   { display: flex; justify-content: space-between; gap: 10px; font-size: .73rem; margin-bottom: 2px; }
.popup-lbl   { color: var(--muted); }
.popup-val   { font-weight: 600; color: var(--dark); }
.popup-fil   { font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 3px; margin-bottom: 7px; display: inline-block; }

/* ── 9. Badges ──────────────────────────────────────────────────────── */
.badges { display: flex; gap: 7px; margin-bottom: 12px; flex-wrap: wrap; }
.badge  { display: flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: var(--radius-sm); font-size: .76rem; font-weight: 600; border: 1px solid transparent; }
.bdot   { width: 7px; height: 7px; border-radius: 50%; }

/* ── 10. Buttons ────────────────────────────────────────────────────── */
.btn         { padding: 7px 16px; border-radius: 7px; font-size: .78rem; font-weight: 700; cursor: pointer; border: none; transition: .15s; font-family: var(--font-body); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal2); }
.btn-mint    { background: var(--mint); color: var(--dark); }
.btn-mint:hover { opacity: .9; }
.btn-ghost   { background: none; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--teal); color: var(--dark); }
.btn-danger  { background: rgba(220,38,38,.08); border: 1px solid rgba(220,38,38,.2); color: var(--red); }
.btn-danger:hover { background: rgba(220,38,38,.15); }
.btn-sm      { padding: 4px 10px; font-size: .72rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 11. Forms & inputs ─────────────────────────────────────────────── */
.field       { margin-bottom: 14px; }
.field label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 5px; }
.input {
  width: 100%; padding: 9px 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--dark); font-family: var(--font-body); font-size: .84rem; outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--teal); }
.inline-input {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 5px;
  color: var(--dark); font-size: .8rem; padding: 3px 7px; width: 100%;
  font-family: monospace; outline: none; transition: border-color .15s;
}
.inline-input:focus { border-color: var(--teal); }

/* ── 12. Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--dark); border: 1px solid rgba(2,195,154,.25);
  color: var(--white); padding: 12px 18px; border-radius: 9px;
  font-size: .8rem; z-index: 200; display: none;
  max-width: 360px; line-height: 1.6; white-space: pre-line;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.toast.show { display: block; }

/* ── 13. Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(26,35,50,.7); z-index: 100;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 32px;
  width: 380px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal h3 { font-size: .95rem; font-weight: 700; margin-bottom: 16px; color: var(--dark); }
.modal-err { font-size: .78rem; color: var(--red); margin-top: 6px; min-height: 1.2em; }

/* ── 14. Edit mode (brick system) ───────────────────────────────────── */
.edit-bar-global {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
  background: var(--white); flex-shrink: 0;
}
.edit-btn-global {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-size: .73rem; padding: 4px 11px; border-radius: 5px; cursor: pointer; transition: .2s;
  font-family: var(--font-body);
}
.edit-btn-global:hover  { border-color: var(--teal); color: var(--dark); }
.edit-btn-global.active { border-color: var(--teal); color: var(--teal); background: rgba(2,128,144,.07); }

.hide-x {
  display: none; position: absolute; top: 6px; right: 6px;
  background: rgba(220,38,38,.08); border: 1px solid rgba(220,38,38,.2); color: var(--red);
  border-radius: 4px; width: 22px; height: 22px; cursor: pointer;
  font-size: .75rem; align-items: center; justify-content: center; z-index: 10;
}
body.editing .hide-x { display: flex; }
.brick { position: relative; transition: .2s; }
.brick.hidden { display: none !important; }

.restore-bar {
  display: none; background: var(--white); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; margin-bottom: 10px;
  font-size: .74rem; color: var(--muted); align-items: center; gap: 8px; flex-wrap: wrap;
}
.restore-bar.visible { display: flex; }
.restore-chip {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  padding: 3px 9px; cursor: pointer; font-size: .71rem; transition: .15s; color: var(--dark);
}
.restore-chip:hover { border-color: var(--teal); color: var(--teal); }

/* ── 15. Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .burger { display: flex; }
  .sidebar {
    position: fixed; left: -240px; top: 0; height: 100vh;
    z-index: 150; transition: left .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.open { left: 0; }
  .overlay { display: block; }
  .page { padding: 56px 12px 24px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .fi-grid { grid-template-columns: 1fr 1fr; }
  .score-grid { grid-template-columns: 1fr 1fr; }
  .cw-lg { height: 160px; }
  .cw    { height: 140px; }
  .cw-sm { height: 100px; }
  .savings-box { flex-direction: column; gap: 12px; }
  .sav-div { display: none; }
  .pdl-strip { flex-direction: column; gap: 10px; }
  .pdl-info  { flex-wrap: wrap; gap: 10px; }
  .utoscore-main { flex-direction: column; align-items: flex-start; gap: 14px; }
  .utoscore-dial { width: 80px; height: 80px; }
  .utoscore-dial svg { width: 80px; height: 80px; }
  .edit-bar-global { padding: 6px 12px; }
  .mode-toggle { flex-wrap: wrap; }
  table { font-size: .7rem; }
  .pm-table th, .pm-table td { padding: 5px 6px; }
  .monthly-bars { height: 140px; }
}
@media (max-width: 420px) {
  .fi-grid, .score-grid { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .range-btn { padding: 3px 8px; font-size: .68rem; }
}
