/* STARKAST Trainer Platform 2.07, Fas 2. Svart/grafit, varm ljus text, EN röd accent. Systemtypsnitt (inga externa typsnitt/CDN). Desktop/surfplatta först, användbar på mobil. */
:root {
  --bg: #0a0a0b; --panel: #121214; --panel-2: #18181b; --line: #25252a; --line-2: #34343b;
  --text: #efe9d6; --dim: #a39f94; --faint: #6e6b63;
  --red: #e5391d; --red-dim: rgba(229, 57, 29, .14);
  --ok: #4fae7f; --warn: #d9a13b; --bad: #e5391d; --info: #7fa2d6;
  --r: 10px; --f: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --m: ui-monospace, "SF Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body { margin: 0; font: 14px/1.45 var(--f); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---- toppfält ---- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: rgba(10, 10, 11, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { height: 28px; width: auto; display: block; border-radius: 4px; }
.brand b { letter-spacing: .14em; font-size: 13px; }
.top nav { display: flex; gap: 4px; margin-left: 8px; }
.top nav a { padding: 6px 12px; border-radius: 8px; color: var(--dim); text-decoration: none; font-weight: 600; }
.top nav a.on { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--red); }
.grow { flex: 1; }
.tbtn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; color: var(--text); font-weight: 600; font-size: 13px; text-decoration: none; }
.tbtn:hover { border-color: var(--faint); }
.tbtn.on { border-color: var(--red); background: var(--red-dim); }
.tbtn svg { width: 16px; height: 16px; }

/* ---- layout ---- */
main { max-width: 1180px; margin: 0 auto; padding: 18px 20px 60px; }
h1 { font-size: 22px; margin: 4px 0 14px; letter-spacing: .01em; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); margin: 26px 0 10px; font-weight: 700; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.pad { padding: 14px 16px; }
.muted { color: var(--dim); } .faint { color: var(--faint); } .mono { font-family: var(--m); font-variant-numeric: tabular-nums; }
.empty { padding: 28px 16px; text-align: center; color: var(--dim); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); font-weight: 600; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .5; cursor: default; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--dim); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.chip.warn i { background: var(--warn); } .chip.bad i { background: var(--bad); } .chip.info i { background: var(--info); } .chip.ok i { background: var(--ok); }
.chip.warn { color: var(--warn); border-color: rgba(217, 161, 59, .35); } .chip.bad { color: #ff7a63; border-color: rgba(229, 57, 29, .45); } .chip.info { color: var(--info); border-color: rgba(127, 162, 214, .35); } .chip.ok { color: var(--ok); border-color: rgba(79, 174, 127, .35); }
input[type=text], input[type=search], input[type=number], select, textarea { background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--red); outline: none; }

/* ---- klientlista ---- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 340px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel); border: 0; padding: 7px 12px; color: var(--dim); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--red-dim); color: var(--text); box-shadow: inset 0 -2px 0 var(--red); }
.clist { list-style: none; margin: 0; padding: 0; }
.crow { display: grid; grid-template-columns: 44px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.crow:last-child { border-bottom: 0; }
.crow:hover { background: var(--panel-2); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--dim); }
.cname { font-weight: 700; font-size: 15px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.go { color: var(--faint); font-size: 20px; }

/* ---- klientsidan ---- */
.chead { position: sticky; top: 49px; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 20px 0; }
.chead-in { max-width: 1180px; margin: 0 auto; }
.chead .line1 { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.chead .avatar { width: 46px; height: 46px; font-size: 15px; }
.chead .nm { font-size: 22px; font-weight: 800; line-height: 1.1; }
.chead .sub { color: var(--dim); font-size: 13px; margin-top: 2px; }
.navbtns { display: flex; gap: 6px; margin-left: auto; }
.navbtns .tbtn { padding: 6px 10px; }
.alerts { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; min-height: 0; }
.tabs { display: flex; gap: 2px; margin-top: 12px; }
.tabs button { background: none; border: 0; padding: 10px 18px; font-weight: 700; font-size: 14px; color: var(--dim); border-bottom: 3px solid transparent; position: relative; }
.tabs button.on { color: var(--text); border-bottom-color: var(--red); }
.tabs .dot { position: absolute; top: 6px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.pane[hidden] { display: none; }

/* ---- training ---- */
.review { border-left: 3px solid var(--warn); }
.sess { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sess:last-child { border-bottom: 0; }
.sess .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.exline { display: flex; gap: 10px; padding: 3px 0; font-size: 13.5px; }
.exline b { min-width: 170px; max-width: 220px; font-weight: 600; }
.exline span { color: var(--dim); font-family: var(--m); font-size: 12.5px; }
.days { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.day { border: 1px solid var(--line-2); background: var(--panel); border-radius: 10px; padding: 10px 14px; min-width: 150px; text-align: left; }
.day.on { border-color: var(--red); background: var(--red-dim); }
.day small { display: block; color: var(--dim); margin-top: 2px; }
.day.done small { color: var(--ok); } .day.pending_review small { color: var(--warn); }
.ex-table { width: 100%; border-collapse: collapse; }
.ex-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ex-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ex-table tr:last-child td { border-bottom: 0; }
.ex-table input { padding: 6px 8px; }
.saved { font-size: 12px; color: var(--ok); min-width: 70px; display: inline-block; }
.saved.err { color: var(--bad); }
details.hist { border-bottom: 1px solid var(--line); }
details.hist:last-child { border-bottom: 0; }
details.hist summary { padding: 12px 16px; cursor: pointer; display: flex; gap: 12px; align-items: center; list-style: none; }
details.hist summary::-webkit-details-marker { display: none; }
details.hist summary::before { content: "▸"; color: var(--faint); }
details.hist[open] summary::before { content: "▾"; }
details.hist .body { padding: 0 16px 12px 36px; }

/* ---- progress ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.kpi { padding: 12px 14px; }
.kpi b { display: block; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--dim); font-size: 12.5px; }
.trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.trend { padding: 12px 14px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.trend.on { border-color: var(--red); }
.trend .t1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.up { color: var(--ok); } .down { color: var(--bad); } .flat { color: var(--dim); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--faint); font-size: 11px; font-family: var(--f); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--red); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--red-dim); stroke: none; }
.chart .pt { fill: var(--bg); stroke: var(--red); stroke-width: 2; }
.chart .pb { fill: var(--red); stroke: var(--text); stroke-width: 1.5; }
.chart .bar { fill: var(--line-2); } .chart .bar.f { fill: var(--red); } .chart .bar.p { fill: var(--panel-2); stroke: var(--line-2); }
.tip { position: absolute; pointer-events: none; z-index: 5; background: #000; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; max-width: 260px; box-shadow: 0 8px 24px rgba(0, 0, 0, .6); }
.chartbox { position: relative; padding: 10px 12px 6px; }
.pbtable { width: 100%; border-collapse: collapse; }
.pbtable td, .pbtable th { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.pbtable th { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); }
.pbtable tr:last-child td { border-bottom: 0; }

/* ---- messages ---- */
.thread { height: min(58vh, 560px); overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.bub { max-width: 72%; padding: 9px 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line-2); white-space: pre-wrap; word-wrap: break-word; }
.bub.me { align-self: flex-end; background: var(--red-dim); border-color: rgba(229, 57, 29, .45); }
.bub small { display: block; color: var(--faint); margin-top: 4px; font-size: 11.5px; }
.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.composer textarea { resize: none; height: 46px; }

/* ---- modal (bara QR) ---- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .72); display: grid; place-items: center; z-index: 100; }
.sheet { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; padding: 20px; width: min(420px, 92vw); text-align: center; }
.sheet .qr { background: #fff; border-radius: 12px; padding: 10px; margin: 12px auto; width: min(320px, 80vw); }
.sheet .qr svg { width: 100%; height: auto; display: block; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #000; border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; z-index: 120; }

@media (max-width: 820px) {
  .crow { grid-template-columns: 38px minmax(0, 1fr) 14px; } .crow .c3, .crow .c4 { grid-column: 2 / 3; }
  .top { padding: 8px 12px; flex-wrap: wrap; } main { padding: 14px 12px 50px; } .chead { padding: 10px 12px 0; top: 0; position: static; }
  .exline b { min-width: 120px; } .bub { max-width: 88%; } .navbtns { margin-left: 0; }
}

@media (max-width: 640px) {
  .ex-table, .ex-table tbody, .ex-table tr, .ex-table td { display: block; width: 100% !important; }
  .ex-table thead { display: none; }
  .ex-table tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .ex-table td { border: 0; padding: 3px 0; }
  .ex-table input { width: 100%; }
  .exline { flex-wrap: wrap; } .exline b { min-width: 0; }
  .kpis, .trends { grid-template-columns: minmax(0, 1fr); }
  .toolbar { flex-wrap: wrap; } main, .card { min-width: 0; max-width: 100%; }
}

/* ---- Fas 3: Idag ---- */
.dash-kpis { margin-bottom: 4px; }
a.kpi { text-decoration: none; display: block; } a.kpi:hover { border-color: var(--faint); }
a.kpi.hot { border-color: rgba(229, 57, 29, .5); background: var(--red-dim); } a.kpi.hot b { color: #ff7a63; }
.kpi small { font-size: 14px; font-weight: 600; color: var(--dim); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.crow.task { grid-template-columns: 44px minmax(0, 1fr) auto; } .crow.rec { grid-template-columns: minmax(0, 1fr) auto; padding: 9px 16px; }
.reason { font-size: 13px; display: flex; gap: 7px; align-items: baseline; } .reason i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; transform: translateY(-1px); }
.reason.warn i { background: var(--warn); } .reason.bad i { background: var(--bad); } .reason.info i { background: var(--info); }
.prev { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .when { font-size: 12px; white-space: nowrap; }
.crow .act { pointer-events: none; }
.st { font-size: 12px; color: var(--dim); } .st.pending_review { color: var(--warn); } .st.blocked { color: var(--bad); }
.quick { white-space: nowrap; }
@media (max-width: 820px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .crow.task { grid-template-columns: 38px minmax(0, 1fr) auto; } .crow.task .act { padding: 8px 10px; }
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .crow:not(.task):not(.rec) { grid-template-columns: 38px minmax(0, 1fr); }
  .crow:not(.task):not(.rec) .quick { grid-column: 2 / 3; justify-self: start; } .crow:not(.task):not(.rec) .go { display: none; }
}

/* ---- Fas 4: Program Builder V2 ---- */
.bmain { max-width: 1280px; }
.bhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pname-in { font-size: 20px; font-weight: 800; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; min-width: 120px; width: min(360px, 100%); color: var(--text); }
.pname-in:hover, .pname-in:focus { border-color: var(--line-2); background: var(--panel); }
.big { padding: 12px 22px; font-size: 16px; }
.pad { padding: 16px; }
.confirm { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--warn); }
.bbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.wtabs, .dtabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.wtab, .dtab { background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 14px; color: var(--dim); font-weight: 700; }
.wtab.on, .dtab.on { background: var(--red-dim); color: var(--text); border-color: var(--red); }
.wtab.lock { color: var(--ok); } .wtab.act, .dtab.add { border-style: dashed; font-weight: 600; background: transparent; }
.wtab.act:hover, .dtab.add:hover { color: var(--text); border-color: var(--faint); }
.dtabs { margin-bottom: 10px; } .dtab { padding: 9px 18px; font-size: 15px; }
.dtab-in { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--red); background: var(--panel); font-weight: 700; width: 160px; }
.lockbar { background: rgba(79, 174, 127, .1); border: 1px solid rgba(79, 174, 127, .35); color: var(--ok); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.gtable { width: 100%; border-collapse: collapse; }
.gtable th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.gtable td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.gtable td.nm b { font-size: 15px; } .gtable td.nx { font-size: 12.5px; white-space: nowrap; } .gtable td.ac, .gtable td.mv { white-space: nowrap; }
.gtable input { width: 100%; padding: 7px 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
.gtable input:hover { border-color: var(--line-2); } .gtable input:focus { border-color: var(--red); outline: none; }
.gtable input.num { width: 64px; text-align: center; font-family: var(--m); } .gtable input.bad { border-color: var(--bad); background: var(--red-dim); }
.gtable input:disabled { opacity: .55; background: transparent; }
.ib { background: transparent; border: 1px solid transparent; color: var(--dim); border-radius: 6px; padding: 5px 8px; font-size: 14px; } .ib:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); } .ib:disabled { opacity: .25; cursor: default; }
.addrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px; border-top: 1px solid var(--line); }
.acwrap { position: relative; flex: 1 1 300px; } .acwrap input { width: 100%; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); font-size: 15px; } .acwrap input:focus { border-color: var(--red); outline: none; }
.ac { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 40; list-style: none; margin: 0; padding: 4px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .55); max-height: 300px; overflow: auto; }
.ac li { padding: 9px 10px; border-radius: 7px; cursor: pointer; } .ac li.on, .ac li:hover { background: var(--red-dim); }
.bstatus { position: fixed; right: 18px; bottom: 18px; z-index: 110; padding: 9px 14px; border-radius: 10px; background: #000; border: 1px solid var(--line-2); font-weight: 600; }
.bstatus.ok { color: var(--ok); } .bstatus.err { border-color: var(--bad); color: #ff7a63; } .bstatus.busy { color: var(--dim); }
.undo { position: fixed; left: 50%; transform: translateX(-50%); bottom: 64px; z-index: 115; padding: 9px 14px; border-radius: 10px; background: #000; border: 1px solid var(--line-2); display: flex; gap: 12px; align-items: center; }
.prow { grid-template-columns: minmax(0, 1fr) auto auto auto; } .pname { text-decoration: none; display: block; min-width: 0; }
@media (max-width: 900px) { .gtable td.nx, .gtable th:nth-child(8) { display: none; } }
@media (max-width: 640px) {
  .gtable thead { display: none; } .gtable, .gtable tbody, .gtable tr, .gtable td { display: block; width: 100%; }
  .gtable tr[data-ex] { padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; align-items: end; }
  .gtable td { border: 0; padding: 0; } .gtable td.mv { grid-column: 1 / 2; grid-row: 1; } .gtable td.nm { grid-column: 1 / -1; grid-row: 1; padding-left: 70px; } .gtable td.mv { z-index: 1; }
  .gtable td[colspan] { grid-column: 1 / -1; } .gtable td[data-l]::before { content: attr(data-l); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
  .gtable td.nm::before { display: none; } .gtable td.nx, .gtable td.ac { grid-column: 1 / -1; } .gtable input.num { width: 100%; }
  .gtable td[data-l="Anteckning"] { grid-column: 1 / -1; } .gtable td[data-l="Startvikt kg"] { grid-column: 1 / 2; }
  .bbar { flex-direction: column; align-items: stretch; } .bstatus { right: 8px; left: 8px; text-align: center; }
}
.scopecap { font-size: 12.5px; }
