/* Autostudio — layout fintech Fase 1: shell, sidebar+iconos, header, KPIs base.
   Clases compatibles con el render actual de views/ (sin cambios de lógica). */

/* ---------- Shell ---------- */
.app-shell{display:flex;align-items:flex-start;min-height:100vh;}
.main-content{flex:1 1 auto;min-width:0;}
.main-content .wrap{max-width:none;margin:0;}

/* ---------- Sidebar (desktop) ---------- */
.sidebar{
  width:248px;flex:0 0 248px;
  background:color-mix(in srgb,var(--surface) 82%,transparent);
  backdrop-filter:blur(14px);
  border-right:1px solid var(--line);
  padding:24px 14px;position:sticky;top:0;min-height:100vh;
  display:flex;flex-direction:column;gap:26px;z-index:20;
}
.sidebar-brand{padding:0 10px;display:flex;align-items:center;gap:10px;}
.brand-mark{
  width:34px;height:34px;flex:0 0 34px;border-radius:11px;
  background:linear-gradient(135deg,var(--accent),var(--accent-strong));
  color:#06231B;font-family:var(--font-display);font-weight:600;font-size:18px;
  display:flex;align-items:center;justify-content:center;
}
:root[data-theme="light"] .brand-mark{color:#fff;}
.sidebar-brand h1{font-family:var(--font-display);font-weight:600;font-size:17px;margin:0;letter-spacing:-.01em;color:var(--ink);line-height:1.15;}
.sidebar-brand p{margin:2px 0 0;color:var(--ink-dim);font-size:11px;letter-spacing:.08em;text-transform:uppercase;font-weight:600;}
.sidebar-nav{display:flex;flex-direction:column;gap:4px;}
.sidebar-nav button{
  display:flex;align-items:center;gap:11px;
  width:100%;min-height:46px;text-align:left;border:1px solid transparent;background:transparent;color:var(--ink-dim);
  font-family:var(--font-ui);font-size:13.5px;font-weight:600;padding:8px 12px;border-radius:12px;cursor:pointer;
  transition:background .15s,color .15s,border-color .15s;
}
.sidebar-nav button svg{flex:0 0 auto;width:19px;height:19px;opacity:.85;}
.sidebar-nav button:hover{background:var(--surface-2);color:var(--ink);}
.sidebar-nav button[aria-pressed="true"]{background:var(--accent-soft);color:var(--accent-strong);border-color:color-mix(in srgb,var(--accent) 30%,transparent);}
.sidebar-nav button[aria-pressed="true"] svg{opacity:1;}
.nav-badge{
  margin-left:auto;
  font-family:var(--font-num);font-size:11px;font-weight:600;color:var(--ink-faint);
  background:var(--surface-2);border:1px solid var(--line);border-radius:999px;padding:2px 9px;min-width:26px;text-align:center;
}
.sidebar-nav button[aria-pressed="true"] .nav-badge{background:var(--surface);color:var(--accent-strong);border-color:transparent;}
.sidebar-foot{margin-top:auto;padding:0 10px;font-size:11px;color:var(--ink-faint);}

/* ---------- Header ---------- */
.topbar{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-bottom:20px;}
.brand h1{
  font-family:var(--font-display);
  font-weight:600;
  font-size:clamp(22px,3vw,30px);
  letter-spacing:-.01em;
  margin:0;
  text-wrap:balance;
}
.brand p{margin:4px 0 0;color:var(--ink-dim);font-size:12.5px;}
.topbar-controls{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.year-nav{display:flex;align-items:center;gap:8px;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:4px;}
.year-nav button{
  min-width:44px;height:44px;border-radius:9px;border:1px solid transparent;
  background:transparent;color:var(--ink);cursor:pointer;font-size:18px;line-height:1;
  display:flex;align-items:center;justify-content:center;
}
.year-nav button:hover{background:var(--surface-2);border-color:var(--line);}
.year-nav .year{font-family:var(--font-num);font-weight:600;font-size:15px;min-width:52px;text-align:center;}
.status-pill{
  display:inline-flex;align-items:center;gap:7px;min-height:36px;
  font-size:12px;font-weight:600;color:var(--ink-dim);
  padding:6px 13px;border:1px solid var(--line);border-radius:999px;background:var(--surface);
  max-width:100%;
}
.status-dot{width:7px;height:7px;flex:0 0 7px;border-radius:50%;background:var(--ink-faint);}
.status-pill[data-state="saving"]{color:var(--warning);border-color:color-mix(in srgb,var(--warning) 35%,transparent);}
.status-pill[data-state="saving"] .status-dot{background:var(--warning);box-shadow:0 0 8px var(--warning);animation:pulse 1.1s infinite;}
.status-pill[data-state="saved"]{color:var(--positive);}
.status-pill[data-state="saved"] .status-dot{background:var(--positive);}
.status-pill[data-state="error"]{color:var(--negative);border-color:color-mix(in srgb,var(--negative) 40%,transparent);}
.status-pill[data-state="error"] .status-dot{background:var(--negative);}
@keyframes pulse{50%{opacity:.35;}}

/* Toggle de tema */
.theme-toggle{
  width:44px;height:44px;border-radius:12px;border:1px solid var(--line);
  background:var(--surface);color:var(--ink-dim);cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;
}
.theme-toggle:hover{color:var(--ink);border-color:var(--line-strong);}
.theme-toggle svg{width:19px;height:19px;}
.theme-toggle .ico-sun{display:none;}
:root[data-theme="light"] .theme-toggle .ico-sun{display:block;}
:root[data-theme="light"] .theme-toggle .ico-moon{display:none;}

/* ---------- KPI strip (base compatible con render actual; hero en Fase 2) ---------- */
.kpi .lbl{font-size:10.5px;letter-spacing:.07em;text-transform:uppercase;color:var(--ink-dim);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

/* ---------- KPI hero (Fase 2) ---------- */
#kpiStrip{display:flex;flex-direction:column;}
.kpi.hero{
  background:linear-gradient(135deg,color-mix(in srgb,var(--accent-soft) 55%,var(--surface)),var(--surface) 70%);
  border:1px solid color-mix(in srgb,var(--accent) 28%,var(--line));
  border-radius:calc(var(--radius) + 4px);
  padding:20px 22px;box-shadow:var(--shadow);
}
.kpi.hero.negative{border-color:color-mix(in srgb,var(--negative) 35%,var(--line));}
.hero-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap;}
.kpi.hero .val{font-size:clamp(24px,4vw,32px);font-weight:600;font-family:var(--font-num);letter-spacing:-.02em;margin-top:8px;}
.kpi.hero.positive .val{color:var(--positive);}
.kpi.hero.negative .val{color:var(--negative);}
.delta-pill{
  font-size:12px;font-weight:700;padding:6px 12px;border-radius:999px;white-space:nowrap;margin-top:4px;
  border:1px solid transparent;
}
.delta-pill.pos{color:var(--positive);background:var(--positive-soft);border-color:color-mix(in srgb,var(--positive) 30%,transparent);}
.delta-pill.neg{color:var(--negative);background:var(--negative-soft);border-color:color-mix(in srgb,var(--negative) 30%,transparent);}
.hero-spark{margin-top:12px;}
.hero-spark svg{width:100%;height:52px;display:block;}
.kpi-row{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:12px;}
.kpi.mini .val{font-size:clamp(15px,2vw,19px);}
.minibar{height:5px;border-radius:99px;background:var(--surface-2);margin-top:10px;overflow:hidden;border:1px solid var(--line);}
.minibar span{display:block;height:100%;border-radius:99px;background:linear-gradient(90deg,var(--accent),var(--accent-strong));}
.kpi.mini:not(.positive) .minibar span{background:linear-gradient(90deg,var(--negative),var(--warning));}
@media (max-width:820px){
  .kpi-row{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;padding-bottom:4px;margin-left:-14px;margin-right:-14px;padding-left:14px;padding-right:14px;}
  .kpi.mini{flex:0 0 168px;scroll-snap-align:start;}
}

/* ---------- Gráfico anual (Fase 2) ---------- */
.chart-card{
  background:linear-gradient(180deg,color-mix(in srgb,var(--surface) 60%,transparent),var(--surface));
  border:1px solid var(--line);border-radius:calc(var(--radius) + 4px);
  box-shadow:var(--shadow);padding:14px 16px 8px;margin-bottom:20px;
}
.chart-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:6px;}
.chart-head h3{font-family:var(--font-display);font-size:17px;font-weight:600;margin:0;}
.chart-legend{display:flex;gap:14px;font-size:11.5px;color:var(--ink-dim);font-weight:600;}
.chart-legend .sw{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:5px;vertical-align:baseline;}
.sw-in{background:var(--positive);}
.sw-out{background:var(--negative);}
.chart-legend .sw-line{width:14px;height:0;background:transparent;border-radius:99px;border-top:3px solid var(--accent);vertical-align:middle;}
.chart-body svg{width:100%;height:auto;display:block;}
.ch-axis{fill:var(--ink-faint);font-size:9.5px;font-family:var(--font-num);}
.ch-axis.is-active{fill:var(--accent-strong);font-weight:700;}
.ch-zero{stroke:var(--line-strong);stroke-width:1;stroke-dasharray:3,4;}
.ch-in{fill:var(--positive);opacity:.85;}
.ch-out{fill:var(--negative);opacity:.8;}
.ch-active-bg{fill:var(--accent-soft);}
.ch-month{cursor:pointer;}
.ch-month:hover .ch-in{opacity:1;}
.ch-month:hover .ch-out{opacity:1;}
.ch-line{fill:none;stroke:var(--accent);stroke-width:2;stroke-linejoin:round;stroke-linecap:round;}
.ch-dot{fill:var(--surface);stroke:var(--accent);stroke-width:2;}
.ch-dot.neg{stroke:var(--negative);}
.ch-dot.is-active{stroke-width:3;}
.chart-hint{font-size:11.5px;color:var(--ink-faint);margin:6px 0 4px;}

/* ---------- Dots de actividad en month picker (Fase 2) ---------- */
.month-picker button{position:relative;}
.month-picker .mdot{
  position:absolute;left:50%;bottom:3px;transform:translateX(-50%);
  width:4px;height:4px;border-radius:50%;background:var(--accent);
}
.month-picker button[aria-pressed="true"] .mdot{background:var(--accent-strong);}
.month-picker{display:flex;gap:5px;overflow-x:auto;margin-bottom:16px;padding:4px 2px;scrollbar-width:thin;}
.month-picker button{
  flex:0 0 auto;min-height:38px;font-family:var(--font-num);font-size:12px;font-weight:600;
  padding:6px 12px;border-radius:10px;border:1px solid transparent;background:transparent;color:var(--ink-dim);cursor:pointer;
}
.month-picker button:hover{background:var(--surface-2);color:var(--ink);}
.month-picker button[aria-pressed="true"]{background:var(--accent-soft);color:var(--accent-strong);border-color:color-mix(in srgb,var(--accent) 30%,transparent);}
@media (pointer:coarse){.month-picker button{min-height:44px;padding:6px 14px;}}

/* ---------- Footer / export ---------- */
.footer-bar{display:flex;justify-content:space-between;align-items:center;margin-top:18px;flex-wrap:wrap;gap:10px;}
.footer-note{font-size:12px;color:var(--ink-faint);max-width:640px;}
.export-btn{
  display:inline-flex;align-items:center;gap:7px;min-height:44px;border:1px solid var(--line);background:var(--surface);
  color:var(--ink);font-size:13px;font-weight:600;padding:8px 15px;border-radius:11px;cursor:pointer;
}
.export-btn:hover{border-color:var(--accent);color:var(--accent-strong);}

/* ---------- Móvil: sidebar -> barra inferior fija ---------- */
@media (max-width:820px){
  .app-shell{flex-direction:column;}
  .sidebar{
    width:100%;flex:0 0 auto;min-height:0;position:fixed;left:0;right:0;bottom:0;top:auto;
    flex-direction:row;align-items:stretch;gap:0;
    padding:8px 8px calc(8px + env(safe-area-inset-bottom));
    border-right:none;border-top:1px solid var(--line);
    background:color-mix(in srgb,var(--surface) 92%,transparent);
    box-shadow:0 -8px 28px rgba(0,0,0,.35);
  }
  .sidebar-brand,.sidebar-foot{display:none;}
  .sidebar-nav{flex-direction:row;gap:2px;width:100%;overflow-x:auto;}
  .sidebar-nav button{
    flex:1 1 0;min-width:62px;min-height:56px;
    flex-direction:column;justify-content:center;gap:3px;
    font-size:10px;font-weight:600;text-align:center;padding:6px 4px;border-radius:11px;
  }
  .sidebar-nav button svg{width:21px;height:21px;}
  .nav-badge{
    font-size:9.5px;padding:0 6px;min-width:18px;
    position:absolute;top:5px;right:8px;margin-left:0;
  }
  .sidebar-nav button{position:relative;}
  .topbar{margin-bottom:14px;}
}
