/* mobile.css — separate mobile-first stylesheet (loaded only when viewport <768px) */

html.mobile, body.mobile{
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.m-app{
  min-height: 100vh;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(91,168,255,.06), transparent 60%),
    radial-gradient(600px 500px at -10% 100%, rgba(157,123,255,.05), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
  padding-bottom: 32px;
}

/* ── Top bar ────────────────────────────────────────────────────────── */
.m-topbar{
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: rgba(10,15,24,.86);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.m-topbar .logo{
  width: 36px; height: 36px; border-radius: 50%;
  overflow: hidden; flex: none;
  border: 1px solid rgba(255,255,255,.08);
}
.m-topbar .logo img{ width: 100%; height: 100%; object-fit: contain; }
.m-topbar .title{ flex: 1; min-width: 0; }
.m-topbar .title .name{
  font-size: 15px; font-weight: 600; letter-spacing: -.005em;
  line-height: 1.1;
}
.m-topbar .title .status{
  font-size: 11px; color: var(--ink-3);
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.m-topbar .title .status .dot{
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-sell);
}

/* ── Tab bar ────────────────────────────────────────────────────────── */
.m-tabs{
  position: sticky; top: 60px; z-index: 28;
  display: flex;
  gap: 0;
  background: rgba(10,15,24,.86);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--line);
  padding: 0 4px;
}
.m-tabs button{
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font: inherit;
  font-size: 13px; font-weight: 500;
  padding: 12px 4px 11px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.m-tabs button.is-active{
  color: var(--ink);
  border-bottom-color: var(--blue);
}

/* ── Main content ───────────────────────────────────────────────────── */
.m-main{
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
/* Desktop cards reused in the mobile column — full width, never force min-width */
.m-main .card{ width: 100%; max-width: 100%; }

/* Linear charts (forecast + linear schema) scroll horizontally at a readable
   size on mobile instead of squashing 48h into ~360px. Radial charts (clock,
   flow) stay fit-to-width since scrolling a circle makes no sense.
   Padding-bottom ger en bred touch-yta UNDER SVG där användaren kan dra
   horisontellt utan att fastna i SVG:ns drag-tooltip-handlers. */
.m-main .forecast-wrap,
.m-main .schema-wrap{
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 44px;
  touch-action: pan-x;
}
.m-main .forecast-svg,
.m-main .schema-svg{
  min-width: 920px;
  width: 920px;
  max-width: none;
  height: 240px;
}
.m-main .forecast-wrap::-webkit-scrollbar,
.m-main .schema-wrap::-webkit-scrollbar{ height: 14px; }
.m-main .forecast-wrap::-webkit-scrollbar-track,
.m-main .schema-wrap::-webkit-scrollbar-track{
  background: rgba(180,200,240,.06); border-radius: 7px; margin: 0 22px;
}
.m-main .forecast-wrap::-webkit-scrollbar-thumb,
.m-main .schema-wrap::-webkit-scrollbar-thumb{
  background: rgba(180,200,240,.45); border-radius: 7px;
  border: 2px solid transparent; background-clip: padding-box;
}
.m-main .forecast-wrap::-webkit-scrollbar-thumb:active,
.m-main .schema-wrap::-webkit-scrollbar-thumb:active{
  background: rgba(180,200,240,.75); background-clip: padding-box;
}

/* (1) Forecast readout — sticky info-panel above the scroll-container. Stays
   visible while the user scrolls the wide 48h SVG horizontally so the tap
   detail is never hidden behind the imorgon-edge of the chart. */
.m-main .forecast-readout{
  margin: 10px 14px 0;
  padding: 9px 11px;
  border-radius: 11px;
  min-height: 52px;
}
.m-main .forecast-readout .rows{
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
}
.m-main .forecast-readout .hint{
  font-size: 11.5px;
}

/* (2) Drop redundant titles on mobile — the visualisation says it itself.
   Keep the right-side tag (24h / current action). */
.m-main .schema-clock .schema-head h3,
.m-main .schema-clock .schema-head .sub,
.m-main .flow .head h3 .dim,
.m-main .flow .head .sub{ display: none; }
.m-main .schema-clock .schema-head,
.m-main .flow .head{ padding-top: 12px; padding-bottom: 12px; }
.m-main .flow .head h3{ font-size: 13px; }

/* (4) Forecast stat tiles — horizontal scroll with snap + right padding so the
   last tile is never clipped */
.m-main .forecast-stats{
  display: flex !important;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-right: 20px;
  -webkit-overflow-scrolling: touch;
}
.m-main .forecast-stats .forecast-stat{
  flex: 0 0 62%;
  scroll-snap-align: start;
}
.m-main .forecast-stats .forecast-stat:last-child{ flex-basis: 70%; }

/* ── Card ───────────────────────────────────────────────────────────── */
.m-card{
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 22px rgba(0,0,0,.18);
}
.m-card-head{
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.m-card-head h2{
  margin: 0; font-size: 14px; font-weight: 600;
  letter-spacing: -.005em;
}
.m-card-head .ic{ flex: none; }
.m-card-head .tag{
  margin-left: auto;
  font-size: 11px; color: var(--ink-2);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px;
}

/* ── Big KPI tile ───────────────────────────────────────────────────── */
.m-kpi{
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 22px rgba(0,0,0,.18);
}
.m-kpi .l{
  font-size: 11px; letter-spacing: .10em; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase;
}
.m-kpi .v{
  margin-top: 8px;
  font-size: 36px; line-height: 1; font-weight: 600;
  font-family: "Geist Mono", monospace;
  letter-spacing: -.02em;
  display: flex; align-items: baseline; gap: 6px;
}
.m-kpi .v small{
  font-size: 14px; color: var(--ink-2); font-weight: 500;
}
.m-kpi .d{
  margin-top: 8px;
  font-size: 12.5px; color: var(--ink-2);
  display: flex; align-items: center; gap: 6px;
}
.m-kpi.action .v{ font-size: 20px; }
.m-kpi.action .v .dot{
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 8px; vertical-align: middle;
}

/* ── Flow list (vertical, no SVG) ───────────────────────────────────── */
.m-flow-row{
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.m-flow-row:first-child{ border-top: 0; padding-top: 4px; }
.m-flow-row .ic{
  width: 38px; height: 38px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.m-flow-row .body{ flex: 1; min-width: 0; }
.m-flow-row .body .name{ font-size: 13.5px; font-weight: 600; color: var(--ink); }
.m-flow-row .body .sub{ font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.m-flow-row .v{
  font-family: "Geist Mono", monospace;
  font-size: 17px; font-weight: 600;
  letter-spacing: -.02em;
  text-align: right;
}
.m-flow-row .v small{ font-size: 11px; color: var(--ink-2); font-weight: 500; }

.m-flow-action{
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.025);
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
}
.m-flow-action .dot{ width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ── Schema as upcoming-list ────────────────────────────────────────── */
.m-schema-now{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(91,168,255,.06), transparent);
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 12px;
}
.m-schema-now .ico{
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.m-schema-now .ico .dot{ width: 14px; height: 14px; border-radius: 50%; }
.m-schema-now .lbl{ font-size: 10px; letter-spacing: .12em; font-weight: 600; color: var(--ink-3); }
.m-schema-now .action{ font-size: 15px; font-weight: 600; margin-top: 2px; }
.m-schema-now .rem{ margin-left: auto; font-size: 11.5px; color: var(--ink-3); font-family: "Geist Mono", monospace; }

.m-plan-item{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  border-top: 1px solid var(--line);
}
.m-plan-item:first-of-type{ border-top: 0; }
.m-plan-item .bullet{ width: 9px; height: 9px; border-radius: 50%; flex: none; }
.m-plan-item .body{ flex: 1; min-width: 0; }
.m-plan-item .body .name{ font-size: 13.5px; font-weight: 500; }
.m-plan-item .body .range{ font-size: 11.5px; color: var(--ink-3); font-family: "Geist Mono", monospace; margin-top: 2px; }
.m-plan-item .rem{ font-size: 11.5px; color: var(--ink-2); font-family: "Geist Mono", monospace; }

/* ── Forecast graph — horizontal scroll, natural width ──────────────── */
.m-forecast-scroll{
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px; padding: 0 16px 6px;
}
.m-forecast-scroll svg{
  display: block;
  height: 220px;
  min-width: 1200px;
}
.m-forecast-legend{
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px;
}
.m-forecast-legend .m-chip{
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(255,255,255,.02);
  color: var(--ink-1); font: inherit; font-size: 11.5px; font-weight: 500;
  cursor: pointer;
}
.m-forecast-legend .m-chip .dot{ width: 8px; height: 8px; border-radius: 2px; }
.m-forecast-legend .m-chip.off{ color: var(--ink-3); opacity: .55; }
.m-forecast-legend .m-chip.off .dot{ filter: grayscale(.6); opacity: .4; }
.m-forecast-legend .m-chip.on{ background: rgba(91,168,255,.06); border-color: rgba(91,168,255,.20); }

/* ── Battery card ───────────────────────────────────────────────────── */
.m-batt-soc{
  display: flex; align-items: center; gap: 14px;
}
.m-batt-soc svg{ flex: none; width: 110px; height: 110px; }
.m-batt-soc .info{ flex: 1; min-width: 0; }
.m-batt-soc .info .v{
  font-size: 32px; font-weight: 600;
  font-family: "Geist Mono", monospace;
  letter-spacing: -.02em;
}
.m-batt-soc .info .v small{ font-size: 14px; color: var(--ink-2); font-weight: 500; }
.m-batt-soc .info .pwr{
  font-size: 13px; margin-top: 4px;
}
.m-batt-row{
  display: flex; justify-content: space-between;
  padding: 8px 0; border-top: 1px solid var(--line);
  font-size: 12.5px;
}
.m-batt-row:first-of-type{ margin-top: 12px; }
.m-batt-row .k{ color: var(--ink-3); }
.m-batt-row .v{ color: var(--ink); font-family: "Geist Mono", monospace; font-weight: 500; }

/* ── Peak shaving card ─────────────────────────────────────────────── */
.m-peak-bar{
  position: relative; height: 14px; border-radius: 7px;
  background: rgba(180,200,240,.06);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-top: 12px;
}
.m-peak-bar .fill{
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--c-sell), #6fd9a8);
  transition: width .4s;
}
.m-peak-bar.warn .fill{ background: linear-gradient(90deg, var(--c-sell), var(--c-unchanged)); }
.m-peak-bar.over .fill{ background: linear-gradient(90deg, var(--c-cover), var(--c-peak)); }
.m-peak-bar .limit-mark{
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: rgba(230,236,247,.85);
  transform: translateX(-2px);
}

/* ── Mer / Settings list ────────────────────────────────────────────── */
.m-list-link{
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
}
.m-list-link + .m-list-link{ margin-top: 10px; }
.m-list-link .ic{
  width: 38px; height: 38px; border-radius: 11px;
  background: rgba(91,168,255,.10);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.m-list-link .body{ flex: 1; min-width: 0; }
.m-list-link .body .name{ font-size: 14px; font-weight: 600; }
.m-list-link .body .sub{ font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.m-list-link .chev{ color: var(--ink-3); }

/* ── Activity log on Mer page ──────────────────────────────────────── */
.m-act-row{
  display: flex; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}
.m-act-row:first-of-type{ border-top: 0; }
.m-act-row .t{ font-family: "Geist Mono", monospace; color: var(--ink-3); min-width: 38px; }
.m-act-row .body{ color: var(--ink-1); line-height: 1.4; }

/* ── Empty / loading state ─────────────────────────────────────────── */
.m-empty{
  padding: 36px 18px; text-align: center;
  color: var(--ink-3); font-size: 13px;
  line-height: 1.55;
}


/* — Allvarlig systemvarning (batteriet pausat m.m.) — */
.m-sysbanner{
  border-radius:14px;padding:14px 16px;margin-bottom:14px;
  font-size:14px;line-height:1.45;
  display:flex;flex-direction:column;gap:10px;
}
.m-sysbanner .msg{font-weight:500}
.m-sysbanner.err{
  background:linear-gradient(180deg, rgba(255,90,101,.16), rgba(255,90,101,.07));
  border:1px solid rgba(255,90,101,.45);
  color:#ffd0d3;
}
.m-sysbanner.warn{
  background:rgba(255,158,69,.10);
  border:1px solid rgba(255,158,69,.34);
  color:#ffd9af;
}
.m-sysbanner .m-sysbtn{
  text-decoration:none;text-align:center;
  font-size:14px;font-weight:600;
  padding:11px 16px;border-radius:11px;
  background:var(--c-peak);color:#fff;
}


/* — Per-batteri rekommenderad effekt i HEMS-status-kortet — */
.m-perbatt{ margin-top:12px; padding-top:10px; border-top:1px solid var(--line); }
.m-perbatt-h{ font-size:10.5px; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-3); margin-bottom:6px; }
.m-perbatt-row{ display:flex; justify-content:space-between; gap:12px; font-size:13px; padding:3px 0; color:var(--ink-1); font-family:"Geist Mono",monospace; }


/* ── EV-/lastband i prognosgrafen (mobil-fix 2026-06-12) ─────────────────
   SVG:n tvingas till 920px i scroll-containern; .fc-lanes (HTML-banden
   under) måste få EXAKT samma bredd, annars löses bandens %-positioner mot
   den synliga ~360px-bredden och hamnar på fel klockslag. Ändras SVG-
   bredden ovan MÅSTE denna följa med. */
.m-main .forecast-wrap .fc-lanes{ width: 920px; }
.m-main .forecast-wrap .fc-loadrows{ padding-left: 16px; padding-right: 16px; }

/* ── Läsbarhet under grafen på mobil (2026-06-18) ────────────────────────
   Last-rader, legend-chips och insikts-raden ärvde desktopens 11–11.5px och
   blev knappt läsbara på telefon. Bumpa till ~13.5px och ge raderna lite mer
   luft. Endast mobil (.m-main), rör inte desktop. */
.m-main .forecast .fc-loadrows{ gap: 9px; }
.m-main .forecast .fc-loadrow{ font-size: 13.5px; gap: 8px; }
.m-main .forecast .fc-loadrow .w,
.m-main .forecast .fc-loadrow .p,
.m-main .forecast .fc-loadrow .st,
.m-main .forecast .fc-loadrow .ev-unmet{ font-size: 12.5px; }

.m-main .forecast .forecast-legend{ gap: 8px; }
.m-main .forecast .forecast-legend .cs-toggle,
.m-main .forecast .forecast-legend .cs-line{ font-size: 13px; }
.m-main .forecast .forecast-legend .cs-toggle{ padding: 6px 11px; }

.m-main .forecast .forecast-foot{ font-size: 13.5px; gap: 14px 18px; }
.m-main .forecast .forecast-foot .np-wait{ font-size: 12.5px; }

/* ══ Standardläge-översikt (2026-06-18) ═══════════════════════════════════
   Lennie: det absolut nödvändigaste STORT och luftigt, specifik info på klick.
   Nördläge slås på i toppbaren och bygger på SAMMA bas — desktopkomponenterna
   (flow, klocka, prognos, livechart) renderas då under standardvyn. */

/* Nördläge-toggle i toppbaren */
.m-nerd{
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: var(--ink-3);
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.m-nerd .track{
  position: relative; width: 26px; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,.10); transition: background .15s; flex: none;
}
.m-nerd .knob{
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink-3); transition: transform .18s, background .15s;
}
.m-nerd.on{
  color: var(--ink); border-color: rgba(91,168,255,.40);
  background: rgba(91,168,255,.10);
}
.m-nerd.on .track{ background: var(--blue); }
.m-nerd.on .knob{ transform: translateX(10px); background: #fff; }

/* Hero — vad HEMS gör just nu, stort */
.m-hero{
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 20px 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 22px rgba(0,0,0,.18);
}
.m-hero .l{
  font-size: 11px; letter-spacing: .12em; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase;
}
.m-hero .big{
  margin-top: 10px;
  font-size: 30px; line-height: 1.05; font-weight: 600;
  letter-spacing: -.02em;
  display: flex; align-items: center; gap: 12px;
}
.m-hero .big .dot{ width: 13px; height: 13px; border-radius: 50%; flex: none; }
.m-hero .why{
  margin-top: 10px;
  font-size: 14px; line-height: 1.5; color: var(--ink-2);
}
.m-hero-toggle{
  margin-top: 14px;
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 0; padding: 4px 0;
  color: var(--ink-3); font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.m-hero-toggle .chev{ transition: transform .18s; }
.m-hero-toggle .chev.open{ transform: rotate(90deg); }
.m-hero .m-perbatt{ margin-top: 14px; }

/* Stora brickor — 2×2, omöjliga att missa */
.m-tilegrid{
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.m-tile{
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 16px 18px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 22px rgba(0,0,0,.18);
}
.m-tile .l{
  font-size: 11px; letter-spacing: .08em; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase;
}
.m-tile .v{
  margin-top: 10px;
  font-size: 34px; line-height: 1; font-weight: 600;
  font-family: "Geist Mono", monospace; letter-spacing: -.02em;
  display: flex; align-items: baseline; gap: 5px;
}
.m-tile .v small{ font-size: 13px; color: var(--ink-2); font-weight: 500; }

/* Härnäst-remsa */
.m-next{
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.m-next .ic{
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(91,168,255,.10); color: var(--blue);
}
.m-next .body{ min-width: 0; }
.m-next .k{
  font-size: 10.5px; letter-spacing: .10em; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase;
}
.m-next .val{ font-size: 15px; font-weight: 600; color: var(--ink); margin-top: 2px; }

/* Vägen till nya designen. Ligger i topbaren eftersom mobilstacken saknar
   sidopanel — och utan den fanns ingen väg tillbaka från gammal design. */
/* --blue är mobilstackens egen blå. Ett första utkast använde --c-buy (finns
   inte i projektet) med en Tailwind-sky fallback — kollegans palett hör inte
   hemma i gamla designens stilmall. Etiketten är kort ("Ny") eftersom
   topbaren är trång vid 360 px: logo + chip + Avancerat lämnar ~90 px till
   husnamnet. */
.m-design{
  flex: none; display: inline-flex; align-items: center;
  min-height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  font-size: 11px; font-weight: 600; color: var(--blue);
  text-decoration: none; white-space: nowrap;
}
.m-design:hover{ color: var(--blue); text-decoration: none; }
/* Husnamn och status kortas i stället för att radbryta — topbaren ska hålla
   sin höjd när chippet tar plats. */
.m-topbar .title .name,.m-topbar .title .status{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.m-topbar .title .status{display:block}
.m-topbar .title .status .dot{display:inline-block;margin-right:5px;vertical-align:1px}
