/* ============================================================
   Portaflow Dashboard — MokkaHouse stylesheet (clean)
   Pantone 5415 C (#5B7F95) + Montserrat
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

:root {
  --pms-5415: #5B7F95;
  --pms-5415-dark: #3D5C71;
  --pms-5415-light: #7A98AB;
  --pms-5415-pale: #DCE5EB;
  --pms-5415-tint: #F0F4F7;

  --bg: #F4F1EC;
  --surface: #FFFFFF;
  --surface-2: #FAF8F4;
  --ink: #1A2329;
  --ink-muted: #5A6670;
  --ink-subtle: #8A949E;
  --border: rgba(91, 127, 149, 0.16);
  --border-strong: rgba(91, 127, 149, 0.32);

  --success: #4A7858;
  --warning: #C7913A;
  --danger: #B5443A;

  --font: 'Montserrat', sans-serif;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100vh; overflow: hidden; }

body {
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pms-5415); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ─── BRAND ─────────────────────────────────────────── */
.brand-mark {
  width: 38px; height: 38px;
  background: var(--pms-5415);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark::after {
  content: ''; display: block;
  width: 14px; height: 14px;
  border-radius: 50%; background: var(--surface);
}
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--ink); line-height: 1.1; }
.brand-sub { font-size: 0.65rem; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); margin-top: 2px; }

/* ─── AUTH PAGES ──────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg) 0%, var(--pms-5415-tint) 100%);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 48px 32px;
  box-shadow: 0 14px 40px rgba(26, 35, 41, 0.12);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.auth-title { font-size: 1.65rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.auth-sub { font-size: 0.88rem; color: var(--ink-muted); margin-bottom: 24px; }
.auth-error { background: rgba(181,68,58,0.08); border: 1px solid rgba(181,68,58,0.25); color: var(--danger); padding: 12px 16px; border-radius: var(--r-md); font-size: 0.85rem; margin-bottom: 16px; font-weight: 500; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 8px; }
.form-field label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.form-field input { font-family: var(--font); font-size: 0.95rem; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); }
.form-field input:focus { outline: none; border-color: var(--pms-5415); background: var(--surface); box-shadow: 0 0 0 3px rgba(91,127,149,0.12); }
.form-check { display: flex; font-size: 0.85rem; color: var(--ink-muted); }
.form-check label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type=checkbox] { accent-color: var(--pms-5415); width: 16px; height: 16px; }
.btn-primary { font-family: var(--font); background: var(--pms-5415); color: var(--surface); border: none; padding: 14px 24px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border-radius: var(--r-md); margin-top: 8px; box-shadow: 0 2px 8px rgba(91,127,149,0.25); }
.btn-primary:hover { background: var(--pms-5415-dark); }
body:has(.auth-page) { overflow: auto; height: auto; }

/* ─── TOPBAR — Pantone 5415C ──────────────────────── */
.topbar {
  background: var(--pms-5415);
  border-bottom: 1px solid var(--pms-5415-dark);
  padding: 10px 24px;
  display: flex; justify-content: space-between; align-items: center;
  height: 60px;
  flex-shrink: 0;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar .brand-mark { background: var(--surface); width: 36px; height: 36px; }
.topbar .brand-mark::after { background: var(--pms-5415); }
.topbar .brand-name { color: var(--surface); font-size: 1rem; }
.topbar .brand-sub { color: rgba(255,255,255,0.7); font-size: 0.6rem; }
.topbar-kpis { display: flex; gap: 24px; align-items: center; }
.kpi-pill { display: flex; flex-direction: column; gap: 1px; padding: 0 16px; border-left: 1px solid rgba(255,255,255,0.18); }
.kpi-pill:first-child { border-left: none; padding-left: 0; }
.kpi-label { font-size: 0.55rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.65); }
.kpi-value { font-size: 1rem; font-weight: 700; color: var(--surface); font-feature-settings: "tnum"; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.user-info { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.15; }
.user-info-name { color: var(--surface); font-weight: 600; font-size: 0.85rem; }
.user-role { font-size: 0.55rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255,255,255,0.7); }
.logout-link { font-size: 0.7rem; font-weight: 600; color: rgba(255,255,255,0.85); border: 1px solid rgba(255,255,255,0.25); padding: 6px 12px; border-radius: var(--r-md); }
.logout-link:hover { color: var(--pms-5415); background: var(--surface); border-color: var(--surface); }

/* ─── DASHBOARD CONTAINER ─────────────────────────── */
.dashboard {
  height: calc(100vh - 60px);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: none;
}
.dashboard-header { display: flex; justify-content: space-between; align-items: baseline; flex-shrink: 0; }
.dashboard-title { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.dashboard-meta { font-size: 0.7rem; color: var(--ink-subtle); }
.dashboard-meta .live-dot { display: inline-block; width: 7px; height: 7px; background: var(--success); border-radius: 50%; margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── GRID: 3 rows × 2 cols ──────────────────────── */
/* Row 1: MokkaHouse (fuld bredde)                    */
/* Row 2: Telemetri (col 1) + Kunder (col 2)          */
/* Row 3: Portaflow (fuld bredde)                     */
.grid.grid-2 {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 10px;
}
.grid.grid-2 > section:nth-child(1) { grid-column: 1; grid-row: 2; }
.grid.grid-2 > section:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
.grid.grid-2 > section:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
.grid.grid-2 > section:nth-child(4) { grid-column: 2; grid-row: 2; }

/* ─── CARDS ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.card-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.card-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--pms-5415); }
.card-title-sub { font-size: 0.62rem; color: var(--ink-subtle); font-weight: 500; }
.card-body { padding: 12px 14px; flex: 1; min-height: 0; overflow: auto; }
.card-empty { text-align: center; padding: 24px 16px; color: var(--ink-subtle); font-size: 0.82rem; display: flex; flex-direction: column; justify-content: center; height: 100%; }
.card-empty-title { color: var(--ink-muted); font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }

/* ============================================================
   TELEMETRI — flex column med FAST HØJDE på stats-rækken
   så den ALDRIG kan kollapse til 0.
   ============================================================ */
.grid.grid-2 > section:nth-child(1) > .card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 14px;
  overflow: hidden;
}

/* Chart-rækken: tager den plads der er tilbage */
.tele-row-chart {
  flex: 1 1 auto;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tele-row-chart h3,
.tele-row-stats h3 {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.tele-row-chart .chart-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  width: 100%;
}
.tele-row-chart .chart-wrap canvas {
  max-height: 100% !important;
  max-width: 100% !important;
}

/* STATS-RÆKKEN: FAST 150px HØJDE, kan ikke kollapse */
.tele-row-stats {
  flex: 0 0 150px;
  height: 150px;
  min-height: 150px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  overflow: visible;
}

/* Stat-blokke */
.stat-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.stat-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

/* Distribution-blok */
.dist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.dist-cell { text-align: center; }
.dist-label { font-size: 0.55rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-subtle); margin-bottom: 3px; }
.dist-value { font-size: 1.4rem; font-weight: 700; color: var(--pms-5415); font-feature-settings: "tnum"; line-height: 1; }
.dist-cell-alt .dist-value { color: var(--pms-5415-light); }
.dist-sub { font-size: 0.6rem; color: var(--ink-muted); margin-top: 3px; font-feature-settings: "tnum"; }
.dist-bar { grid-column: 1 / -1; height: 5px; background: var(--pms-5415-light); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.dist-bar-fill { height: 100%; background: var(--pms-5415); transition: width 0.4s ease; }

/* Top-variant-blok */
.top-variant { width: 100%; text-align: center; }
.top-variant-name { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.top-variant-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.top-variant-stat { text-align: center; }
.top-variant-num { font-size: 1.2rem; font-weight: 700; color: var(--pms-5415); font-feature-settings: "tnum"; line-height: 1; }
.top-variant-label { font-size: 0.55rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-subtle); margin-top: 4px; }

/* Skjul gammel popular-list helt */
.tele-row-list, .popular-list { display: none !important; }

/* ─── SALES SECTIONS ───────────────────────────── */
.sales-headline { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sales-amount { font-size: 1.5rem; font-weight: 700; color: var(--ink); font-feature-settings: "tnum"; }
.sales-amount-sub { font-size: 0.72rem; color: var(--ink-muted); font-weight: 500; }
.yoy-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.45rem; border-radius: var(--r-md); }
.yoy-up { background: rgba(74,120,88,0.12); color: var(--success); }
.yoy-down { background: rgba(181,68,58,0.12); color: var(--danger); }
.yoy-flat { background: var(--pms-5415-tint); color: var(--ink-muted); }
.breakdown-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.breakdown-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--border); font-size: 0.78rem; }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { font-weight: 500; color: var(--ink); }
.breakdown-value { font-weight: 600; color: var(--ink); font-feature-settings: "tnum"; }

/* ─── CUSTOMERS ─────────────────────────────────── */
.customer-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-md); border: 1px solid var(--border); margin-bottom: 6px; align-items: center; }
.customer-name { font-weight: 600; font-size: 0.82rem; color: var(--ink); }
.customer-meta { font-size: 0.62rem; color: var(--ink-muted); margin-top: 2px; }
.customer-stat { text-align: right; font-feature-settings: "tnum"; }
.customer-stat-num { font-weight: 700; color: var(--ink); font-size: 0.85rem; }
.customer-stat-label { font-size: 0.55rem; color: var(--ink-subtle); letter-spacing: 0.05em; text-transform: uppercase; }

/* ─── LOADING ───────────────────────────────────── */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--pms-5415); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--ink-subtle); font-size: 0.82rem; text-align: center; padding: 24px 12px; }
/* ============================================================
   TELEMETRI v3 — ren tekstbaseret metric-grid (ingen chart)
   3 rows × 2 cols, hver celle har fast min-height
   ============================================================ */

.tele-body, .grid.grid-2 > section:nth-child(1) > .card-body {
  display: flex !important;
  flex-direction: column !important;
  padding: 12px 14px;
  overflow: auto;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.metric-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 56px;
  overflow: hidden;
}
.metric-cell-wide {
  grid-column: 1 / -1;
}

.metric-label {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--pms-5415);
  font-feature-settings: "tnum";
  letter-spacing: -0.02em;
  line-height: 1;
}

.metric-empty {
  font-size: 0.75rem;
  color: var(--ink-subtle);
  font-style: italic;
}

/* Mest populære variant */
.metric-variant .variant-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 4px;
}
.metric-variant .variant-sub {
  font-size: 0.78rem;
  color: var(--ink-muted);
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.variant-num {
  font-weight: 700;
  color: var(--pms-5415);
  font-feature-settings: "tnum";
}
.variant-pct {
  font-size: 0.72rem;
  color: var(--ink-subtle);
  font-feature-settings: "tnum";
}

/* Fordeling */
.metric-dist .dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.dist-tag {
  background: var(--pms-5415);
  color: var(--surface);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dist-tag-alt {
  background: var(--pms-5415-light);
}
.dist-pct {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--pms-5415);
  font-feature-settings: "tnum";
}
.dist-pct-alt {
  color: var(--pms-5415-light);
}
.dist-bar {
  height: 6px;
  background: var(--pms-5415-light);
  border-radius: 3px;
  overflow: hidden;
}
.dist-bar-fill {
  height: 100%;
  background: var(--pms-5415);
  transition: width 0.4s ease;
}

/* Reset gamle telemetri-stilarter der ikke længere bruges */
.tele-row, .tele-row-chart, .tele-row-stats, .tele-row-list,
.stat-block, .chart-wrap, .popular-list { display: none !important; }
/* ============================================================
   STEP 9 — Telemetri rubrik-layout (horisontal, større tekst)
   ============================================================ */

/* De 4 metric-cells (i dag/måned/i alt/kg): label venstre, tal højre */
.metric-cell {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 14px 18px !important;
  gap: 16px !important;
  min-height: 56px !important;
}

.metric-cell .metric-label {
  font-size: 0.92rem !important;
  font-weight: 500 !important;
  color: var(--ink) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  margin: 0 !important;
  flex: 1;
}

.metric-cell .metric-value {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  color: var(--pms-5415) !important;
  font-feature-settings: "tnum" !important;
  letter-spacing: -0.02em !important;
  white-space: nowrap;
  text-align: right;
}

/* metric-cell-wide (Mest populære + Fordeling) — beholder stacked layout */
.metric-cell.metric-cell-wide {
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
}
.metric-cell.metric-cell-wide .metric-label {
  font-size: 0.6rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: var(--ink-subtle) !important;
  margin-bottom: 6px !important;
}

/* ─── Topbar uden KPI-pills ─────────────────────────────── */
.topbar-kpis { display: none !important; }

/* ============================================================
   TELEMETRI KOMPAKT — alle 6 rubrikker i 3x2 grid
   ============================================================ */

/* "Mest populære variant" og "Fordeling" får halv bredde */
.metric-cell.metric-cell-wide {
  grid-column: auto !important;
}

/* Mere kompakte rubrikker */
.metric-cell {
  padding: 10px 14px !important;
  min-height: 48px !important;
}
.metric-cell .metric-label {
  font-size: 0.82rem !important;
}
.metric-cell .metric-value {
  font-size: 1.3rem !important;
}

/* Mest populære variant - kompakt */
.metric-cell.metric-cell-wide .metric-label {
  font-size: 0.55rem !important;
  margin-bottom: 4px !important;
}
.metric-variant .variant-name {
  font-size: 0.92rem;
  margin-bottom: 3px;
}
.metric-variant .variant-sub {
  font-size: 0.7rem;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
}
.variant-pct {
  font-size: 0.66rem;
}

/* Fordeling - kompakt */
.metric-dist .dist-row {
  font-size: 0.7rem;
  margin-bottom: 4px;
  gap: 5px;
}
.dist-tag {
  padding: 1px 6px;
  font-size: 0.55rem;
}
.dist-pct {
  font-size: 0.82rem;
}
.dist-bar {
  height: 4px;
}
/* ============================================================
   STEP 10 — Tab navigation + tab-grid
   ============================================================ */

/* TAB BAR */
.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  flex-shrink: 0;
  align-items: stretch;
  height: 44px;
}

.tab {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 0 16px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color 0.15s ease;
  border-bottom: 2px solid transparent;
  letter-spacing: 0.01em;
}

.tab:hover {
  color: var(--pms-5415);
}

.tab.active {
  color: var(--pms-5415);
  font-weight: 600;
  border-bottom-color: var(--pms-5415);
}

/* TAB PANES — kun en synlig ad gangen */
.tab-pane { display: none; flex: 1; min-height: 0; }
.tab-pane.active { display: flex; flex-direction: column; }

/* TAB-CARD (single card der fylder hele tab-paneet) */
.tab-card {
  flex: 1;
  min-height: 0;
}

/* TAB METRIC-GRID — fler kolonner end Oversigt for tæthed */
.metric-grid-tab {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  flex: 1;
  min-height: 0;
}

@media (min-width: 1100px) {
  .metric-grid-tab { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1500px) {
  .metric-grid-tab { grid-template-columns: repeat(4, 1fr); }
}

/* Mock-tag */
.metric-source-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(199, 145, 58, 0.15);
  color: var(--warning);
  border-radius: 8px;
  vertical-align: middle;
}

/* Justeret dashboard højde fordi tabs tager 44px */
.dashboard {
  height: calc(100vh - 60px - 44px);
}

/* Skjul H1 dashboard-title - er dublet af aktiv fane */
.dashboard-title { display: none; }
.dashboard-header {
  margin-bottom: 0;
  justify-content: flex-end;
}
#sales-portaflow-body .sales-headline{margin-bottom:8px;gap:8px}#sales-portaflow-body .sales-amount{font-size:1.3rem}#sales-portaflow-body .breakdown-list{gap:2px}#sales-portaflow-body .breakdown-row{padding:2px 0;font-size:0.74rem}
