/* Flax Kontroll – felles palett (dark er standard) */
:root, [data-theme="dark"] {
  --bg: #0f171e;
  --bg-glow-a: #1a2d3a;
  --bg-glow-b: #152029;
  --panel: #17232d;
  --panel-soft: #1c2a36;
  --ink: #e8eef3;
  --muted: #8fa0b0;
  --accent: #3db4d8;
  --accent-ink: #0a1520;
  --line: #2a3d4d;
  --input: #111c26;
  --ok: #3dbe74;
  --bad: #e85d5d;
  --warn: #d4a017;
  --quiet: #6a7d8d;
  --theme-color: #3db4d8;
}

[data-theme="light"] {
  --bg: #e7eef4;
  --bg-glow-a: #c9dcea;
  --bg-glow-b: #dfe8f0;
  --panel: #ffffff;
  --panel-soft: #f2f6fa;
  --ink: #14202b;
  --muted: #5a6a7a;
  --accent: #0a6d8f;
  --accent-ink: #ffffff;
  --line: #c3ced9;
  --input: #f4f8fb;
  --ok: #1a7a48;
  --bad: #c0392b;
  --warn: #9a6b00;
  --quiet: #8b98a6;
  --theme-color: #0a6d8f;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse at 15% 0%, var(--bg-glow-a) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, var(--bg-glow-b) 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
}

a { color: var(--accent); }
.red { color: var(--bad); font-weight: 700; }
.yellow { color: var(--warn); font-weight: 700; }
.ok { color: var(--ok); font-weight: 600; }
.muted { color: var(--quiet); }

/* Desktop: Title | Store | Actions — one baseline */
.dash-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "brand store actions";
  align-items: center;
  column-gap: 0.55rem;
  row-gap: 0.4rem;
  margin-bottom: 1rem;
}
.dash-brand {
  grid-area: brand;
  min-width: 0;
}
.dash-brand h1 { font-size: 1.25rem; margin: 0; color: var(--accent); line-height: 1.2; }
.dash-brand .meta { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }

.dash-nav-actions {
  grid-area: actions;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  height: 2.25rem;
  min-width: 0;
}

.dash-nav-actions .icon-btn,
.dash-nav-actions .theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; min-width: 2.25rem; padding: 0 !important;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); cursor: pointer;
  text-decoration: none; flex: 0 0 auto; box-sizing: border-box;
  border-radius: 0;
}
.dash-nav-actions .icon-btn svg,
.dash-nav-actions .theme-toggle svg { width: 1.15rem; height: 1.15rem; }
.dash-nav-actions .theme-toggle .icon-sun { display: none; }
.dash-nav-actions .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .dash-nav-actions .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .dash-nav-actions .theme-toggle .icon-moon { display: none; }
.dash-nav-actions .settings-btn { color: var(--muted); }
.dash-nav-actions .settings-btn.on,
.dash-nav-actions .settings-btn:hover { color: var(--accent); border-color: var(--accent); }
.dash-nav-actions .live-check-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  height: 2.25rem; padding: 0 0.55rem 0 0.4rem;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line));
  background: color-mix(in srgb, var(--bad) 8%, var(--panel));
  color: var(--bad); text-decoration: none; flex: 0 0 auto;
  box-sizing: border-box; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.01em; white-space: nowrap;
}
.dash-nav-actions .live-check-chip.on,
.dash-nav-actions .live-check-chip:hover {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, var(--panel));
}
.dash-nav-actions .live-check-chip .ekg-svg {
  width: 1.55rem; height: 0.7rem; display: block; overflow: visible;
}
.dash-nav-actions .live-check-chip .ekg-line {
  stroke-dasharray: 56;
  stroke-dashoffset: 56;
  animation: ekg-draw 2.2s ease-in-out infinite;
}
@keyframes ekg-draw {
  0% { stroke-dashoffset: 56; opacity: 0.55; }
  35% { stroke-dashoffset: 0; opacity: 1; }
  70% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: -56; opacity: 0.45; }
}
.dash-nav-actions .kv-hub-chip {
  display: inline-flex; align-items: center;
  height: 2.25rem; padding: 0 0.7rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted); text-decoration: none; flex: 0 0 auto;
  box-sizing: border-box; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.01em; white-space: nowrap;
}
.dash-nav-actions .kv-hub-chip:hover {
  color: var(--accent); border-color: var(--accent);
}
.dash-nav-actions .logout-form {
  display: inline-flex; align-items: center; margin: 0; height: 2.25rem;
}
.dash-nav-actions .logout-form button {
  color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  padding: 0 0.7rem; font: inherit; font-size: 0.9rem; cursor: pointer;
  height: 2.25rem; box-sizing: border-box; white-space: nowrap;
  width: auto; min-width: 0; line-height: 1; margin: 0;
}

.store-switch {
  grid-area: store;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  height: 2.25rem;
  box-sizing: border-box;
}
.store-switch-label {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.store-switch-select {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  font: inherit; font-size: 0.82rem; font-weight: 600;
  height: 2.25rem;
  width: 10.5rem;
  margin: 0;
  padding: 0 1.7rem 0 0.55rem;
  border: 1px solid var(--line);
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.25L6 7.75L9.5 4.25' stroke='%238fa0b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
  background-size: 0.7rem 0.7rem;
  color: var(--ink);
  cursor: pointer;
  box-sizing: border-box;
  line-height: normal;
}
[data-theme="light"] .store-switch-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.25L6 7.75L9.5 4.25' stroke='%235a6a7a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.store-switch-select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.store-switch-select:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.tabs {
  display: flex; gap: 0.15rem 0.25rem; margin-bottom: 1.25rem;
  flex-wrap: wrap; align-items: flex-end;
}
.tabs a {
  color: var(--muted); text-decoration: none;
  padding: 0.4rem 0.55rem;
  border-bottom: 2px solid transparent;
  font-size: 0.9rem;
  white-space: nowrap;
}
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

.hist-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  box-sizing: border-box;
}
.hist-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.hist-toggle.on {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary, .btn-secondary, .btn-danger {
  font: inherit;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mobile: Title + actions on row 1; store full width under Live check→Logg ut */
@media (max-width: 640px) {
  .dash-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "store store";
    align-items: center;
    column-gap: 0.35rem;
    row-gap: 0.4rem;
  }
  .dash-brand h1 {
    font-size: 1.05rem;
    line-height: 2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dash-nav-actions {
    gap: 0.28rem;
    height: 2rem;
    justify-content: flex-end;
  }
  .dash-nav-actions .icon-btn,
  .dash-nav-actions .theme-toggle {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
  }
  .dash-nav-actions .icon-btn svg,
  .dash-nav-actions .theme-toggle svg {
    width: 1.05rem;
    height: 1.05rem;
  }
  .dash-nav-actions .live-check-chip {
    height: 2rem;
    padding: 0 0.4rem 0 0.3rem;
    font-size: 0.68rem;
    gap: 0.25rem;
  }
  .dash-nav-actions .live-check-chip .ekg-svg {
    width: 1.25rem; height: 0.58rem;
  }
  .dash-nav-actions .logout-form { height: 2rem; }
  .dash-nav-actions .logout-form button {
    height: 2rem;
    padding: 0 0.45rem;
    font-size: 0.72rem;
  }
  .store-switch {
    height: 2rem;
    width: 100%;
  }
  .store-switch-select {
    width: 100%;
    height: 2rem;
    font-size: 0.8rem;
    padding: 0 1.55rem 0 0.5rem;
    background-position: right 0.4rem center;
  }
  .tabs {
    gap: 0.1rem 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0;
  }
  .tabs a {
    flex: 1 1 auto;
    text-align: center;
    padding: 0.45rem 0.35rem;
    font-size: 0.78rem;
  }
}
