:root {
  --bg: #0b0f14; --panel: #111821; --panel2: #16202b; --line: #1f2b38; --text: #e6edf3; --muted: #8b9bb0; --dim: #5d6d80;
  --accent: #3fb6ff; --hi: #ff4d5e; --mid: #ffb020; --lo: #4b5b6e; --ok: #2ecc71; --flash: rgba(63,182,255,.18);
  --r-us: #5aa9ff; --r-eu: #a78bfa; --r-nordic: #facc15; --r-asia: #f87171; --r-mideast: #fb923c; --r-em: #34d399; --r-global: #94a3b8;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f7fa; --panel: #fff; --panel2: #eef2f6; --line: #dde3ea; --text: #111a24; --muted: #566577; --dim: #8796a8; --lo: #b8c3cf; --flash: rgba(0,120,255,.12); color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
small { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); font-size: 13px; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--accent); white-space: nowrap; }
.brand span { color: var(--text); }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mid); }
.status.live .dot { background: var(--ok); box-shadow: 0 0 0 0 rgba(46,204,113,.6); animation: pulse 2s infinite; }
.status.down .dot { background: var(--hi); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(46,204,113,0); } 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); } }
.clocks { display: flex; gap: 12px; margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.clocks b { color: var(--text); font-weight: 600; }
.clocks .open b { color: var(--ok); }
.actions { display: flex; gap: 6px; }
.icon, .primary, .ghost { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 10px; }
.primary { background: var(--accent); border-color: var(--accent); color: #001523; font-weight: 600; }
.primary.on { background: var(--ok); border-color: var(--ok); }
.ghost:hover, .icon:hover { background: var(--panel2); }

/* Filter */
.filters { padding: 8px 16px 6px; border-bottom: 1px solid var(--line); background: var(--panel); }
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 4px 11px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--panel2)); color: var(--text); }
.chip .n { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.tools { flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel2); padding: 5px 11px; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #001523; font-weight: 600; }
.seg.small button { padding: 3px 9px; font-size: 12px; }
#search { flex: 1; min-width: 160px; max-width: 380px; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; font: inherit; }
.count { color: var(--dim); font-size: 12px; margin-left: auto; }

/* Layout */
.tabs { display: none; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0; }
.feed { position: relative; min-width: 0; border-right: 1px solid var(--line); }
.cal { padding: 12px 14px; position: sticky; top: 52px; align-self: start; max-height: calc(100vh - 52px); overflow: auto; }
.cal h2 { font-size: 14px; margin: 0 0 8px; }

/* Nyhetslista */
.news { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: 118px minmax(0, 1fr); column-gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.item.i3 { border-left-color: var(--hi); }
.item.i2 { border-left-color: var(--mid); }
.item.fresh { animation: flash 6s ease-out; }
@keyframes flash { 0% { background: var(--flash); } 100% { background: transparent; } }
.meta { grid-row: span 2; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.meta time { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; font-size: 13px; }
.meta time small { font-weight: 400; margin-left: 4px; }
.imp { font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.i3 .imp { color: var(--hi); } .i2 .imp { color: var(--mid); } .i1 .imp { color: var(--dim); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 10.5px; padding: 0 6px; border-radius: 4px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.tag.r { color: var(--bg); border: 0; font-weight: 700; }
.title { text-decoration: none; font-size: 15px; font-weight: 500; }
.i3 .title { font-weight: 700; }
.i1 .title { color: color-mix(in srgb, var(--text) 82%, var(--muted)); }
.title:hover { color: var(--accent); }
.title mark { background: color-mix(in srgb, var(--mid) 45%, transparent); color: inherit; border-radius: 2px; }
.sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.src { color: var(--accent); font-weight: 600; }
.also a { color: var(--muted); }
.lag { color: var(--dim); }
.newpill { position: sticky; top: 60px; z-index: 5; display: block; margin: 8px auto -36px; background: var(--accent); color: #001523; border: 0; border-radius: 999px; padding: 6px 16px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Kalender */
.events { list-style: none; margin: 10px 0 0; padding: 0; }
.day { font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; text-transform: capitalize; }
.ev { display: grid; grid-template-columns: 44px 38px 1fr; gap: 6px; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: baseline; }
.ev.past { opacity: .5; }
.ev.soon { background: color-mix(in srgb, var(--hi) 14%, transparent); border-radius: 6px; }
.ev .tm { font-variant-numeric: tabular-nums; color: var(--muted); }
.ev .cur { font-weight: 700; font-size: 12px; }
.ev .e3 { color: var(--hi); } .ev .e2 { color: var(--mid); } .ev .e1 { color: var(--dim); }
.ev .nums { grid-column: 3; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.ev .nums b { color: var(--text); }
.ev .cd { color: var(--hi); font-weight: 700; font-size: 11.5px; }

/* Dialoger */
dialog { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg { padding: 18px 20px; position: relative; }
.dlg.wide { width: auto; }
#dlgSources { width: min(760px, calc(100vw - 24px)); }
.dlg h2 { margin: 0 0 6px; font-size: 18px; }
.dlg fieldset { border: 0; padding: 0; margin: 14px 0 0; }
.dlg legend { font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.dlg input[type=text] { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; }
.btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.close { position: absolute; top: 10px; right: 10px; border: 0; background: none; font-size: 18px; color: var(--muted); }
.tablewrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.okc { color: var(--ok); } .errc { color: var(--hi); }

/* Mobil */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .feed { border-right: 0; }
  .tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel); }
  .tabs button { flex: 1; border: 0; background: none; padding: 9px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
  .tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
  body[data-tab=news] .cal { display: none; }
  body[data-tab=cal] .feed { display: none; }
  .cal { position: static; max-height: none; }
  .clocks { display: none; }
}
@media (max-width: 600px) {
  .top { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .brand span, .actions .lbl { display: none; }
  .status { margin-right: auto; }
  .filters { padding: 8px 12px 4px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .chips::-webkit-scrollbar { display: none; }
  .item { grid-template-columns: 1fr; padding: 9px 12px; }
  .meta { grid-row: auto; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
  .title { font-size: 15px; }
  #search { max-width: none; }
  .count { display: none; }
}
.newpill[hidden] { display: none; }
