:root {
  /* Millentic brand tokens (dark) — brand green #00684A / #4DB894 */
  --bg: #191919;         /* background */
  --panel: #2d2d2c;      /* card */
  --panel-2: #40403e;    /* secondary */
  --text: #fafaf7;       /* foreground */
  --muted: #92928f;      /* muted-foreground */
  --line: #40403e;       /* border */
  --accent: #4DB894;     /* primary (dark) */
  --accent-strong: #00684A;
  --on-accent: #001F16;  /* primary-foreground */
  --good: #4DB894;
  --warn: #ffb020;
  --bad: #cd5247;        /* destructive */
  --radius: 14px;
  --gap: 20px;
  --header-h: 66px;
  --font-sans: "Inter Variable", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-heading: "Plus Jakarta Sans Variable", "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
}

.theme-light {
  --bg: #fafaf7;
  --panel: #efefeb;
  --panel-2: #e4e4df;
  --text: #191919;
  --muted: #656562;
  --line: #e4e4df;
  --accent: #00684A;
  --accent-strong: #005C42;
  --on-accent: #ffffff;
  --good: #00684A;
  --bad: #cd5247;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------- Branded header ---------- */
.app-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { height: 34px; width: 34px; display: block; }
.brand-word { font-family: var(--font-heading); font-size: 1.25rem; font-weight: 700; letter-spacing: 0.01em; color: var(--text); }
.brand-sub {
  color: var(--muted);
  font-size: 0.95rem;
  padding-left: 14px;
  margin-left: 4px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header-right { display: flex; align-items: center; gap: 16px; }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(170px, 1fr);
  gap: var(--gap);
  padding: var(--gap);
  flex: 1 1 auto;
  min-height: 0;
  width: 100vw;
  overflow: hidden;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.card-small  { grid-column: span 3; }
.card-medium { grid-column: span 4; }
.card-large  { grid-column: span 6; }
.card-wide   { grid-column: span 8; }
.card-full   { grid-column: span 12; }

@media (max-width: 900px) {
  .card-small, .card-medium { grid-column: span 6; }
  .card-large, .card-wide, .card-full { grid-column: span 12; }
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}
.card-body { flex: 1; min-height: 0; overflow: hidden; }

/* ---------- Clock ---------- */
.clock-time { font-family: var(--font-heading); font-size: clamp(2.5rem, 7vw, 6rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.clock-date { font-size: clamp(1rem, 2vw, 1.6rem); color: var(--muted); margin-top: 10px; }

/* ---------- Departures / lists ---------- */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.row:last-child { border-bottom: 0; }
.badge {
  min-width: 44px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 10px;
  font-weight: 700;
  background: var(--panel-2);
  color: var(--text);
}
.badge.metro { background: #1f6feb; color: #fff; }
.badge.bus  { background: #e2483d; color: #fff; }
.badge.train { background: #d6127f; color: #fff; }  /* pendeltåg pink */
.badge.tram { background: #f5a623; color: #101; }
.badge.ship { background: #00867c; color: #fff; }
.row .dest { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.row .when.soon { color: var(--good); }

/* ---------- Metric ---------- */
.metric-value { font-family: var(--font-heading); font-size: clamp(2.4rem, 6vw, 5rem); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.metric-unit { font-size: 1.4rem; color: var(--muted); margin-left: 8px; }

/* ---------- YouTube ---------- */
.yt-wrap { position: relative; width: 100%; height: 100%; border-radius: 12px; overflow: hidden; background: #000; }
.yt-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- States ---------- */
.muted { color: var(--muted); }
.err { color: var(--bad); font-size: 0.95rem; }
.loading { color: var(--muted); font-style: italic; }

/* ---------- Header controls ---------- */
.tb-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 0.95rem;
  cursor: pointer;
}
.tb-btn:hover { border-color: var(--accent); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); }
.status-dot.stale { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

/* ---------- Settings overlay ---------- */
.settings {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings.hidden { display: none; }
.settings-panel {
  background: var(--panel);
  width: min(720px, 92vw);
  max-height: 88vh;
  overflow: auto;
  border-radius: 20px;
  padding: 28px 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.settings h2 { margin: 0 0 6px; }
.settings .hint { color: var(--muted); margin: 0 0 18px; font-size: 0.95rem; }
.wlist { display: flex; flex-direction: column; gap: 10px; margin: 0 0 20px; }
.witem {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border-radius: 12px;
  padding: 12px 14px;
}
.witem .grip { cursor: grab; color: var(--muted); font-size: 1.2rem; }
.witem .name { flex: 1; font-weight: 600; }
.witem .type { color: var(--muted); font-size: 0.85rem; }
.witem input[type="checkbox"] { width: 20px; height: 20px; }
.witem .order-btns button {
  background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer;
}
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-actions button {
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 12px 18px; font-size: 1rem; cursor: pointer;
}
.settings-actions button.secondary { background: var(--panel-2); color: var(--text); }
.settings textarea {
  width: 100%; min-height: 120px; margin-top: 14px; border-radius: 12px;
  background: var(--bg); color: var(--text); border: 1px solid rgba(255,255,255,0.12);
  padding: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem;
}
