:root {
  color-scheme: light;
  --bg1: #f8fbff;
  --bg2: #eef4fa;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --panel-soft: rgba(248, 250, 252, 0.95);
  --border: rgba(148, 163, 184, 0.24);
  --divider: rgba(148, 163, 184, 0.26);
  --text: #0f172a;
  --muted: #64748b;
  --muted-strong: #475569;
  --blue: #2f86ff;
  --blue-soft: #eaf3ff;
  --orange: #ff7a1a;
  --orange-soft: #fff0e4;
  --gold: #f5b41b;
  --gold-soft: #fff5d9;
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.13);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
  --grid: rgba(148, 163, 184, 0.22);
  --radius: 24px;
}

html,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg1: #020817;
  --bg2: #081827;
  --panel: rgba(9, 24, 40, 0.88);
  --panel-strong: rgba(10, 26, 44, 0.96);
  --panel-soft: rgba(16, 35, 57, 0.88);
  --border: rgba(148, 163, 184, 0.18);
  --divider: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #a7b4c7;
  --muted-strong: #cbd5e1;
  --blue: #4aa0ff;
  --blue-soft: rgba(74, 160, 255, 0.15);
  --orange: #ff7a1a;
  --orange-soft: rgba(255, 122, 26, 0.14);
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.14);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.14);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
  --grid: rgba(148, 163, 184, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 0%, rgba(47, 134, 255, 0.12), transparent 26%),
    radial-gradient(circle at 90% 12%, rgba(255, 122, 26, 0.08), transparent 24%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 8%, rgba(47, 134, 255, 0.18), transparent 28%),
    radial-gradient(circle at 90% 10%, rgba(255, 122, 26, 0.10), transparent 24%),
    linear-gradient(rgba(2, 8, 23, 0.72), rgba(2, 8, 23, 0.84));
}

.app-shell {
  position: relative;
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: var(--blue);
  flex: 0 0 auto;
}

.brand-icon svg,
.mini-icon svg,
.chevron {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-icon svg {
  width: 42px;
  height: 42px;
  stroke-width: 2.1;
}

.brand h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted-strong);
  font-size: 16px;
}

.brand p span {
  margin: 0 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.week-pill,
.updated,
.status-pill,
.theme-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  padding: 8px 12px;
  white-space: nowrap;
}

.week-pill {
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid rgba(47, 134, 255, 0.30);
  font-weight: 750;
}

.updated {
  color: var(--muted-strong);
}

.status-pill {
  color: #86efac;
  background: var(--green-soft);
  border: 1px solid rgba(34, 197, 94, 0.25);
  font-weight: 750;
}

.status-pill.is-error {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.25);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

/* Tema-knappen är borttagen i mörk Synology-version */
.theme-row,
.theme-menu,
.theme-toggle,
.theme-popover {
  display: none !important;
}

.hero-card,
.quick-card,
.chart-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 410px;
  margin-bottom: 22px;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(8, 23, 40, 0.98) 0%, rgba(8, 23, 40, 0.86) 52%, rgba(8, 23, 40, 0.24) 100%),
    radial-gradient(circle at 78% 40%, rgba(49, 85, 132, 0.58), transparent 30%),
    linear-gradient(135deg, #071624 0%, #102542 48%, #2a2442 100%);
}

.hero-bg::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: 0;
  width: 50%;
  height: 100%;
  opacity: .55;
  background: repeating-linear-gradient(
    112deg,
    transparent 0 18px,
    rgba(0, 0, 0, 0.20) 18px 22px
  );
}

.hero-content {
  position: relative;
  padding: 34px 28px 28px;
}

.hero-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--blue);
  margin-bottom: 24px;
}

.hero-label h2 {
  margin: 0;
  font-size: 22px;
}

.mini-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.mini-icon svg {
  width: 25px;
  height: 25px;
  stroke-width: 2.0;
}

.mini-icon--blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.mini-icon--orange {
  background: var(--orange-soft);
  color: var(--orange);
}

.mini-icon--gold {
  background: var(--gold-soft);
  color: var(--gold);
}

.hero-value {
  font-size: clamp(68px, 10vw, 108px);
  line-height: .84;
  letter-spacing: -0.075em;
  font-weight: 760;
  color: var(--text);
  white-space: nowrap;
}

.hero-value::first-letter {
  letter-spacing: -0.08em;
}

.hero-subtitle {
  margin: 28px 0 30px;
  font-size: 16px;
  color: var(--muted-strong);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--divider);
}

.hero-metric {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding: 20px 18px 0;
}

.hero-metric + .hero-metric {
  border-left: 1px solid var(--divider);
}

.metric-icon {
  font-size: 22px;
  line-height: 1;
  color: var(--blue);
}

.metric-icon--orange {
  color: var(--orange);
}

.hero-metric span {
  display: block;
  color: var(--muted-strong);
  font-size: 14px;
  margin-bottom: 9px;
}

.hero-metric strong {
  display: block;
  font-size: 25px;
  line-height: 1.1;
  white-space: nowrap;
}

.hero-metric small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

/* Två rutor: större utetemperatur + solinformation */
.quick-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.quick-card {
  min-height: 205px;
  padding: 18px 20px;
}

.quick-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.quick-head h2 {
  margin: 0;
  font-size: 18px;
}

.quick-card--outdoor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 22px;
  align-items: center;
}

.quick-card--outdoor .quick-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.quick-value {
  white-space: nowrap;
}

.quick-card--outdoor .quick-value {
  font-size: clamp(50px, 6vw, 66px);
  line-height: 0.95;
  letter-spacing: -0.055em;
  margin: 0;
  align-self: center;
  white-space: nowrap;
}

.quick-card--outdoor .quick-row {
  font-size: 16px;
  padding: 10px 0;
}

.quick-card--outdoor .quick-row strong {
  font-size: 22px;
}

.quick-row,
.sun-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  color: var(--muted-strong);
  font-size: 15px;
}

.quick-row + .quick-row,
.sun-row + .sun-row {
  margin-top: 11px;
}

.quick-row strong,
.sun-row strong {
  color: var(--text);
  font-size: 18px;
  white-space: nowrap;
}

.quick-card--sun {
  min-height: 205px;
}

.legend-inline {
  display: flex;
  gap: 20px;
  align-items: center;
  color: var(--muted-strong);
}

.legend-inline span,
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot-blue,
.dot-orange {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: inline-block;
}

.dot-blue {
  background: var(--blue);
}

.dot-orange {
  background: var(--orange);
}

.chart-card {
  padding: 18px 20px 20px;
}

.chart-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chart-legend {
  display: flex;
  gap: 24px;
  color: var(--muted-strong);
  font-size: 15px;
}

.line-blue,
.line-orange {
  width: 26px;
  height: 3px;
  border-radius: 99px;
  display: inline-block;
}

.line-blue {
  background: var(--blue);
}

.line-orange {
  background: var(--orange);
}

.segmented {
  display: inline-flex;
  gap: 5px;
  padding: 5px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.segmented--view {
  margin-right: 2px;
}

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  border-radius: 10px;
  min-width: 58px;
  min-height: 36px;
  cursor: pointer;
}

.segmented button.active {
  background: rgba(47, 134, 255, 0.12);
  color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(47,134,255,.22);
}

.chart-wrap {
  height: 215px;
}

.stats-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}

.stats-group {
  display: grid;
  grid-template-columns: 1.1fr repeat(3, 1fr);
  gap: 10px;
  align-items: end;
}

.stats-group h3 {
  margin: 0;
  font-size: 14px;
}

.stats-group span {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-bottom: 4px;
}

.stats-group strong {
  font-size: 15px;
  white-space: nowrap;
}

.stats-group--blue strong {
  color: var(--blue);
}

.stats-group--orange strong {
  color: var(--orange);
}

/* Mobil: komprimerad topp så huvudkortet kommer högre upp */
@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 640px);
    padding: 14px 0 28px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand {
    gap: 12px;
    align-items: flex-start;
  }

  .brand-icon {
    width: 46px;
    height: 46px;
    margin-top: 2px;
  }

  .brand-icon svg {
    width: 34px;
    height: 34px;
  }

  .brand h1 {
    font-size: 31px;
    line-height: 1;
    letter-spacing: -0.055em;
  }

  .brand p {
    margin-top: 5px;
    font-size: 15px;
    line-height: 1.22;
  }

  .brand p span {
    margin: 0 6px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 10px;
    align-items: center;
    justify-content: start;
  }

  .week-pill,
  .updated,
  .status-pill {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 15px;
    border-radius: 13px;
  }

  .updated {
    justify-self: start;
  }

  .status-pill {
    grid-column: 1 / -1;
    width: fit-content;
  }

  .hero-card {
    min-height: auto;
    margin-top: 4px;
    margin-bottom: 18px;
  }

  .hero-content {
    padding: 24px 20px 20px;
  }

  .hero-label {
    margin-bottom: 18px;
  }

  .hero-label h2 {
    font-size: 20px;
  }

  .hero-value {
    font-size: clamp(72px, 19vw, 86px);
  }

  .hero-subtitle {
    margin: 22px 0 24px;
    font-size: 15px;
  }

  .hero-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .hero-metric {
    padding: 16px 12px 0;
  }

  .hero-metric:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--divider);
  }

  .hero-metric:nth-child(4) {
    border-top: 1px solid var(--divider);
  }

  .hero-metric span {
    font-size: 13px;
  }

  .hero-metric strong {
    font-size: 23px;
  }

  .hero-metric small {
    font-size: 13px;
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }

  .quick-card {
    min-height: auto;
  }

  .quick-card--outdoor {
    grid-template-columns: 1fr;
  }

  .quick-card--outdoor .quick-value {
    font-size: clamp(44px, 12vw, 58px);
    margin-bottom: 12px;
  }

  .chart-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-controls {
    width: 100%;
    justify-content: stretch;
  }

  .segmented {
    width: 100%;
  }

  .chart-controls .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }

  .stats-group {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-group h3 {
    grid-column: 1 / -1;
  }
}

/* iPhone landscape / låg höjd */
@media (max-width: 932px) and (max-height: 500px) and (orientation: landscape) {
  .app-shell {
    width: min(100% - 16px, 920px);
    padding: 12px 0 18px;
  }

  .brand-icon {
    width: 44px;
    height: 44px;
  }

  .brand-icon svg {
    width: 32px;
    height: 32px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .brand p {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar {
    margin-bottom: 10px;
  }

  .top-actions {
    gap: 8px;
  }

  .week-pill,
  .updated,
  .status-pill {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .hero-card {
    min-height: 0;
    margin-bottom: 12px;
  }

  .hero-content {
    padding: 18px 18px 16px;
  }

  .hero-label {
    margin-bottom: 12px;
  }

  .mini-icon {
    width: 42px;
    height: 42px;
  }

  .hero-value {
    font-size: 64px;
  }

  .hero-subtitle {
    margin: 14px 0 16px;
    font-size: 13px;
  }

  .hero-metrics {
    grid-template-columns: repeat(4, 1fr);
  }

  .hero-metric {
    padding: 12px 10px 0;
    gap: 6px;
  }

  .hero-metric span {
    font-size: 11px;
    margin-bottom: 5px;
  }

  .hero-metric strong {
    font-size: 17px;
  }

  .hero-metric small {
    font-size: 11px;
    margin-top: 4px;
  }

  .quick-grid {
    grid-template-columns: 1.25fr 1fr;
    gap: 10px;
  }

  .quick-card {
    min-height: auto;
    padding: 12px;
  }

  .quick-card--outdoor {
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
  }

  .quick-card--outdoor .quick-value {
    font-size: 36px;
  }

  .quick-head h2 {
    font-size: 14px;
  }

  .quick-row,
  .sun-row {
    font-size: 12px;
  }

  .quick-row strong,
  .sun-row strong,
  .quick-card--outdoor .quick-row strong {
    font-size: 14px;
  }

  .chart-controls {
    gap: 8px;
  }

  .chart-card {
    padding: 12px;
  }

  .chart-wrap {
    height: 180px;
  }
}