/* The platform shell (sidebar, User Panel, panel frames) and what every panel shares: loading circles and charts. */

/* -- loading inside a panel ------------------------------------------------------------------------------ */
.qq-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px 12px; font-size: 13px; color: var(--muted); }
button .qq-loading { padding: 0; gap: 6px; font-size: inherit; color: inherit; }
.qq-spin { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid rgba(127, 127, 127, 0.3); border-top-color: var(--accent); animation: qq-spin 0.8s linear infinite; }
@keyframes qq-spin { to { transform: rotate(360deg); } }
.qq-loading.with-log { flex-direction: column; gap: 8px; }
.qq-cloud { width: 100px; height: 100px; flex: none; overflow: visible; }
.qq-cloud-fill { fill: var(--accent); }
.qq-cloud-puff { animation: qq-cloud-drift 2s linear infinite; }
.qq-cloud-puff:nth-child(2) { animation-delay: -0.667s; }
.qq-cloud-puff:nth-child(3) { animation-delay: -1.333s; }
.qq-cloud-line { stroke-width: 5; transform-box: view-box; transform-origin: 50px 50px; rotate: -65deg;
  animation: qq-cloud-lines 0.75s linear infinite; }
.qq-cloud-arrows { fill: #b8ffd6; transform-box: view-box; transform-origin: 50px 58px;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.85)); animation: qq-spin 1s linear infinite; }
@keyframes qq-cloud-drift {
  0% { cx: 20px; cy: 60px; r: 15px; }
  50% { cx: 50px; cy: 45px; r: 20px; }
  100% { cx: 80px; cy: 60px; r: 15px; }
}
@keyframes qq-cloud-lines { from { transform: translateY(-10px); } to { transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  .qq-cloud-puff, .qq-cloud-line, .qq-cloud-arrows { animation: none; }
}
.qq-loading-log { display: grid; justify-content: center; gap: 4px; margin: 6px 0 0; padding: 0; list-style: none; font: 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.02em; }
.qq-loading-log li { color: var(--accent); animation: qq-log-in 0.35s ease-out; }
.qq-loading-log li::before { content: "\203A  "; }
.qq-loading-log li:not(.done)::after { content: " \2026"; animation: qq-log-wait 1s steps(2) infinite; }
.qq-loading-log li.done { color: var(--muted); }
.qq-loading-log li.done::before { content: "\2713  "; }
@keyframes qq-log-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes qq-log-wait { 50% { opacity: 0; } }

/* -- charts ---------------------------------------------------------------------------------------------- */
.linechart { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 132px auto; column-gap: 6px; font-size: 10.5px; color: var(--muted); overflow: visible; }
.linechart svg { width: 100%; height: 120px; overflow: visible; background: var(--deep); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.linechart .line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.linechart .line.dashed { stroke-dasharray: 4 3; stroke-width: 1.2; opacity: 0.8; }
.linechart .axis-y { display: flex; flex-direction: column; justify-content: space-between; text-align: right; }
.linechart .axis-x { grid-column: 2; display: flex; justify-content: space-between; }
.linechart .legend { grid-column: 2; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 3px; }
.linechart .legend .swatch { display: inline-block; width: 10px; height: 3px; margin-right: 4px; vertical-align: middle; }
.linechart circle.marked { stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

/* -- the shell ------------------------------------------------------------------------------------------- */
body.platform { overflow: hidden; }
.platform-shell { display: flex; height: 100vh; background: var(--paper); }
.sidebar { flex: none; width: 196px; display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; border-right: 1px solid var(--line); background: var(--paper); transition: width 160ms ease; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 4px 14px; }
.sidebar-brand { margin: 0; color: var(--accent); font-weight: 650; font-size: 15px; letter-spacing: 0.04em; }
.sidebar-toggle { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none; border-radius: var(--radius); color: var(--muted); }
.sidebar-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-toggle:hover { background: var(--raised); color: var(--ink); }
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .side-item span,
.sidebar.collapsed .sidebar-foot .meta { display: none; }
.sidebar.collapsed .sidebar-top { justify-content: center; margin-bottom: 10px; }
.sidebar.collapsed .sidebar-toggle svg { transform: scaleX(-1); }
.sidebar.collapsed .side-item { justify-content: center; padding-left: 8px; padding-right: 8px; }
.side-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--radius); color: var(--muted); text-align: left;
  transition: background 140ms ease, color 140ms ease; }
.side-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-item:hover { background: var(--raised); color: var(--ink); }
.side-item[aria-current="page"] { background: var(--hit); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .meta { margin: 8px 10px; }
.platform-main { position: relative; flex: 1; min-width: 0; }
.panel-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--paper); animation: panel-in 160ms ease-out; }
@keyframes panel-in { from { opacity: 0.6; } to { opacity: 1; } }

/* -- Home and Monitor ---------------------------------------------------------------------------------------- */
.home { position: absolute; inset: 0; overflow: auto; padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 14px; animation: panel-in 160ms ease-out; }
.home > .kicker { margin: 0; }
.page-head { max-width: 760px; }
.page-title { margin: 0; font-size: 20px; font-weight: 650; }
.page-head .meta { margin: 4px 0 0; line-height: 1.5; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--hit); color: var(--accent); font-size: 12px; font-weight: 600; }
.warn { margin: 0; color: var(--warn); font-size: 12.5px; }

/* The account scorecard: one flat card; identity and balance side by side, then the prices. */
.scorecard {
  --sc-surface: #0a222d; --sc-surface-2: #0f2b37; --sc-border: #2b4550; --sc-ink: #edf5f6; --sc-muted: #91a9b1;
  --sc-emerald: #25db9c; --sc-slate: #426d75; --sc-amber: #dcb078;
  max-width: 980px; padding: 22px 24px; border: 1px solid var(--sc-border); border-radius: 14px; background: var(--sc-surface); color: var(--sc-ink);
  font-variant-numeric: tabular-nums;
}
.scorecard .meta { color: var(--sc-muted); }
.scorecard .kicker { margin: 0 0 10px; }
.score-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.score-name { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.score-head .meta { margin: 3px 0 0; }
.score-status { display: inline-flex; align-items: center; gap: 7px; margin: 4px 0 0; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.score-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.score-status.on { color: var(--sc-emerald); }
.score-status.on::before { box-shadow: 0 0 8px rgba(37, 219, 156, 0.7); }
.score-status.off { color: var(--sc-amber); }
.score-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; margin-top: 20px; }
.score-facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; align-content: start; margin: 0; font-size: 13.5px; }
.score-facts dt { color: var(--sc-muted); font-size: 12px; padding-top: 2px; }
.score-facts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.services { display: flex; gap: 8px; flex-wrap: wrap; }
.service { display: flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid var(--sc-border); border-radius: 8px; background: transparent; color: var(--sc-ink); font-size: 12.5px; font-weight: 600;
  transition: border-color 140ms ease, background 140ms ease; }
.service svg { width: 15px; height: 15px; fill: none; stroke: var(--sc-emerald); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.service:hover { border-color: var(--sc-emerald); background: rgba(37, 219, 156, 0.08); }
.score-balance { padding-left: 28px; border-left: 1px solid var(--sc-border); }
.score-figure { margin: 0; font-size: 40px; line-height: 1.05; font-weight: 650; letter-spacing: -0.02em; color: var(--sc-ink); }
.score-figure.available { color: var(--sc-emerald); text-shadow: 0 0 18px rgba(37, 219, 156, 0.22); }
.score-figure.low { color: var(--sc-ink); }
.score-figure.exhausted { color: var(--sc-amber); }
.score-of { font-size: 18px; font-weight: 500; color: var(--sc-muted); }
.score-used { display: flex; justify-content: space-between; gap: 12px; margin: 10px 0 8px; font-size: 12.5px; color: var(--sc-muted); }
.score-level { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.score-level.available { color: var(--sc-emerald); }
.score-level.low, .score-level.exhausted { color: var(--sc-amber); }
.score-balance > .score-level { margin: 8px 0; }
.score-bar { height: 4px; border-radius: 4px; background: var(--sc-surface-2); overflow: hidden; }
.score-bar span { display: block; height: 100%; border-radius: 4px; background: var(--sc-slate); transition: width 300ms ease; }
.score-balance .warn, .score-balance > .meta { margin-top: 10px; font-size: 12px; }
.score-quant { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--sc-border); }
.score-quant .warn, .score-quant .meta { margin: 8px 0 0; font-size: 12px; }
.score-quant .warn { color: var(--sc-amber); }
.score-days { margin: 0 0 10px; font-size: 26px; line-height: 1.1; font-weight: 650; color: var(--sc-ink); }
.score-days.available { color: var(--sc-emerald); }
.score-days.low, .score-days.exhausted { color: var(--sc-amber); }
.score-bar.days span { background: var(--sc-emerald); }
.score-balance .warn { color: var(--sc-amber); }
.score-rule { margin: 24px 0 20px; border: 0; border-top: 1px solid var(--sc-border); }
.price-rows { margin-bottom: 22px; }
.price-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 0; padding: 10px 2px; border-bottom: 1px solid var(--sc-border); font-size: 13.5px; }
.price-row:last-child { border-bottom: 0; }
.price-row strong { font-weight: 600; }
.price-row .meta { margin-left: 10px; font-size: 12px; }
.price-row-head { padding-top: 0; color: var(--sc-muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.price-cost { font-size: 15px; font-weight: 650; }
.ops { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.op { padding: 16px 18px; border: 1px solid var(--sc-border); border-radius: 12px; background: var(--sc-surface-2); }
.op-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.op-name { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.op-head .meta { margin: 3px 0 0; font-size: 12px; }
.op-total { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.op-stages { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 12px; }
.op-stage { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--sc-border); }
.op-stage.plan { border-color: rgba(37, 219, 156, 0.35); background: rgba(37, 219, 156, 0.06); }
.op-stage.run { background: rgba(66, 109, 117, 0.18); }
.op-stage-label { margin: 0; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sc-muted); }
.op-stage.plan .op-stage-label { color: var(--sc-emerald); }
.op-stage-cost { margin: 6px 0 2px; font-size: 18px; font-weight: 650; }
.op-stage .meta { margin: 0; font-size: 11.5px; }
.op-split { display: flex; gap: 3px; height: 5px; }
.op-split span { border-radius: 3px; }
.op-split .plan { background: var(--sc-emerald); }
.op-split .run { background: var(--sc-slate); }
.op-split-labels { display: flex; gap: 3px; margin-top: 5px; font-size: 10.5px; letter-spacing: 0.04em; color: var(--sc-muted); }
.op-split-labels span { text-align: center; }
.score-note { margin: 16px 0 0; font-size: 12px; }
@media (max-width: 760px) {
  .home { padding: 18px 14px 32px; }
  .scorecard { padding: 18px 16px; }
  .score-top { grid-template-columns: 1fr; gap: 20px; }
  .score-balance { padding: 18px 0 0; border-left: 0; border-top: 1px solid var(--sc-border); }
  .price-row .meta { display: block; margin: 2px 0 0; }
  .op-stages { grid-template-columns: 1fr; }
}

.monitor { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); animation: panel-in 200ms ease-out; }
.monitor-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.monitor-title { margin: 0; font-size: 15px; font-weight: 650; }
.monitor-head .meta { margin: 2px 0 0; }
.monitor-prices { display: flex; gap: 22px; }
.monitor-latest { text-align: right; }
.monitor-latest .kicker { margin: 0 0 2px; }
.monitor-price { margin: 0; font-size: 22px; font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.driver-charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.driver-chart { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.driver-chart figcaption { margin-bottom: 6px; font-weight: 600; font-size: 12.5px; }
.table-wrap { overflow: auto; max-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); }
.price-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.price-table th, .price-table td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.price-table th:first-child, .price-table td:first-child, .price-table th:nth-child(3), .price-table td:nth-child(3) { text-align: left; }
.price-table thead th { position: sticky; top: 0; background: var(--raised); color: var(--muted); font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.monitor-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.monitor-actions button { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); }
.monitor-actions button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.what-if-ask { display: flex; gap: 6px; }
.what-if-ask input { width: 200px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--deep); }
.what-if ul { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; }
.what-if p { margin: 0; }
