/*
 * tio-dashboard, im Stil von Kickertool V3.
 * Tokens aus tio-app/projects/tio-components/src/styles/_vars.scss (light :root, dark .tio-dark).
 */

@font-face { font-family: 'Roboto'; font-weight: 400; font-display: swap; src: url(fonts/roboto-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 500; font-display: swap; src: url(fonts/roboto-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 700; font-display: swap; src: url(fonts/roboto-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Roboto Condensed'; font-weight: 700; font-display: swap; src: url(fonts/roboto-condensed-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Material Symbols Rounded'; font-display: block; src: url(fonts/material-symbols-rounded-subset.woff2) format('woff2'); }

:root {
  --font-default: 'Roboto', 'Helvetica', sans-serif;
  --font-headline: 'Roboto Condensed', 'Roboto', sans-serif;

  --accent-primary-rgb: 141, 189, 107;
  --accent-primary: rgb(var(--accent-primary-rgb));
  --accent-primary-light: rgba(var(--accent-primary-rgb), 0.16);
  --accent-primary-dark: #3c6a1d;
  --accent-secondary-rgb: 225, 111, 61;
  --accent-secondary: rgb(var(--accent-secondary-rgb));
  --accent-secondary-light: rgba(var(--accent-secondary-rgb), 0.16);
  --accent-secondary-dark: rgb(161, 64, 16);

  --bg-header: #ffffff;
  --bg-default: #f4f4f4;
  --bg-hover: #f6f6f6;
  --bg-cards: #ffffff;
  --bg-on-cards: #f1f1f1;
  --bg-nav-drawer: #1b1b1b;
  --bg-inverted: #272727;

  --fg-default: #202020;
  --fg-muted: #6f6f6f;
  --fg-on-nav-drawer: #9b9b9a;
  --fg-lines: #f1f1f1;
  --fg-lines-outer: #f1f1f1;

  --modi-yellow-rgb: 255, 161, 27;
  --modi-red-rgb: 229, 56, 52;
  --modi-orange-rgb: 254, 87, 33;
  --modi-turquise-rgb: 0, 184, 212;
  --modi-petrol-rgb: 40, 165, 154;
  --modi-green-rgb: 142, 187, 93;
  --modi-blue-rgb: 67, 164, 245;
  --modi-lila-rgb: 156, 39, 176;
  --modi-grey-rgb: 69, 90, 100;
  --error-red-rgb: 176, 0, 32;

  --spark: rgba(var(--accent-primary-rgb), 0.28);
  --spark-last: var(--accent-primary);
  color-scheme: light;
}

.tio-dark {
  --accent-primary-dark: #8dbd6b;
  --bg-header: #1f1f1f;
  --bg-default: #121212;
  --bg-hover: #252525;
  --bg-cards: #1e1e1e;
  --bg-on-cards: #2d2d2d;
  --bg-inverted: #2d2d2d;
  --fg-default: #e5e5e5;
  --fg-muted: #969696;
  --fg-lines: #272727;
  --fg-lines-outer: #1f1f1f;
  --spark: rgba(var(--accent-primary-rgb), 0.22);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font-default);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--fg-default);
  background: var(--bg-default);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.icon {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
  font-variation-settings: 'FILL' 0;
  user-select: none;
}
.icon.filled { font-variation-settings: 'FILL' 1; }

/* --- Sidebar (V3: immer dunkel, 56px, orange Pill für die Gruppe) -------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 56px;
  background: var(--bg-nav-drawer);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 12px;
  z-index: 10;
}
.sidebar .logo { width: 30px; height: 36px; display: block; margin-bottom: 24px; }
.sidebar .logo img { width: 100%; height: 100%; }
.sidebar nav {
  margin-top: auto;
  margin-bottom: auto;
  background: var(--accent-secondary);
  border-radius: 24px;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  width: 40px;
  align-items: center;
}
.sidebar nav a {
  width: 40px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.72);
  position: relative;
}
.sidebar nav a:hover { color: #fff; text-decoration: none; }
.sidebar nav a.active { color: #fff; }
.sidebar nav a.active .icon { font-variation-settings: 'FILL' 1; }
.sidebar nav a .icon { font-size: 22px; }
.sidebar nav .sep { width: 18px; height: 2px; background: rgba(255, 255, 255, 0.72); border-radius: 1px; margin: 4px 0; }
.sidebar .bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sidebar button {
  width: 40px; height: 40px;
  border: 0; background: none; cursor: pointer;
  color: var(--fg-on-nav-drawer);
  border-radius: 8px;
}
.sidebar button:hover { color: var(--accent-primary); }

/* --- Header --------------------------------------------------------------- */

.page { margin-left: 56px; min-height: 100vh; }

header.top {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 56px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--fg-lines);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}
header.top h1 {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 21px;
  margin: 0;
  white-space: nowrap;
}
header.top .date { color: var(--fg-muted); font-size: 16px; white-space: nowrap; }
header.top .spacer { flex: 1; }
header.top .stamp { color: var(--fg-muted); font-size: 13px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
header.top .stamp.stale { color: var(--accent-secondary); }

/* --- Layout --------------------------------------------------------------- */

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}
.grid { display: grid; gap: 24px; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
@media (max-width: 1100px) {
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
}

section { scroll-margin-top: 72px; min-width: 0; }
.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 8px 10px;
}
.section-title h2 {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 18px;
  margin: 0;
}
.section-title .meta { color: var(--fg-muted); font-size: 13px; }
.section-title .meta a { color: var(--accent-primary-dark); }
.section-title .right { margin-left: auto; color: var(--fg-muted); font-size: 13px; }

.card {
  min-width: 0;
  overflow-wrap: anywhere;
  background: var(--bg-cards);
  border: 1px solid var(--fg-lines-outer);
  border-radius: 8px;
  padding: 8px;
}
.card + .section-title { margin-top: 24px; }
.stack > * + * { margin-top: 24px; }

/* Grauer Streifen wie „Round 1" / Tabellenkopf in V3 */
.strip {
  background: var(--bg-on-cards);
  border-radius: 4px;
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted);
  font-size: 14px;
}
.strip.label { text-transform: uppercase; font-size: 12px; letter-spacing: 0; }
.strip .count { margin-left: auto; }

/* --- Tabellen --------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; table-layout: fixed; }
td { overflow-wrap: anywhere; }
thead th {
  background: var(--bg-on-cards);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  text-align: left;
  height: 40px;
  padding: 0 12px;
  white-space: nowrap;
}
thead th:first-child { border-radius: 4px 0 0 4px; }
thead th:last-child { border-radius: 0 4px 4px 0; }
tbody td {
  padding: 13px 12px;
  border-top: 2px solid var(--fg-lines);
  vertical-align: top;
}
tbody tr:first-child td { border-top: 0; }
tbody tr.hover:hover td { background: var(--bg-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.muted, .muted { color: var(--fg-muted); }
td.nowrap { white-space: nowrap; }
.sub { display: block; color: var(--fg-muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.mono { font-variant-numeric: tabular-nums; }

/* --- Tags (Modi-Farbe mit 16 % Alpha) -------------------------------------- */

.tag {
  --c: var(--modi-grey-rgb);
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  color: rgb(var(--c));
  background: rgba(var(--c), 0.16);
  white-space: nowrap;
  vertical-align: 1px;
}
.tio-dark .tag { --c-boost: 1; }
.tag.red { --c: var(--modi-red-rgb); }
.tag.orange { --c: var(--accent-secondary-rgb); }
.tag.yellow { --c: var(--modi-yellow-rgb); }
.tag.green { --c: 94, 145, 60; }
.tio-dark .tag.green { --c: var(--accent-primary-rgb); }
.tag.blue { --c: var(--modi-blue-rgb); }
.tag.turquise { --c: var(--modi-turquise-rgb); }
.tag.petrol { --c: var(--modi-petrol-rgb); }
.tag.lila { --c: var(--modi-lila-rgb); }
.tio-dark .tag.lila { --c: 206, 110, 222; }
.tio-dark .tag.grey { --c: 150, 150, 150; }
.tag.solid { color: #fff; background: rgb(var(--c)); }
.tag.solid.darkred { --c: var(--error-red-rgb); }

.badge {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 13px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-secondary-light);
  color: var(--accent-secondary);
}

/* --- Briefing --------------------------------------------------------------- */

.briefing { padding: 16px 20px 18px; }
.briefing .headline {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.3;
  margin: 0 0 12px;
}
.briefing p { margin: 0 0 10px; font-weight: 400; font-size: 15px; line-height: 1.55; max-width: 72ch; }
.briefing p:last-child { margin-bottom: 0; }
.briefing .foot { margin-top: 14px; color: var(--fg-muted); font-size: 12px; font-weight: 400; }

/* Hinweisbanner wie „Changing the mode …" */
.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-secondary-light);
  border: 1px solid var(--accent-secondary);
  border-radius: 4px;
  padding: 9px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.notice .icon { color: var(--accent-secondary); }

.actions { list-style: none; margin: 0; padding: 0; }
.actions li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 12px 8px;
  border-top: 2px solid var(--fg-lines);
}
.actions li:first-child { border-top: 0; }
.actions li .icon { color: var(--fg-muted); margin-top: -1px; }
.actions li.heute .icon { color: var(--accent-secondary); }
.actions .empty { color: var(--fg-muted); padding: 12px 8px; }

/* --- Kennzahlen (Kacheln wie „32/32 MATCHES") --------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--bg-on-cards);
  border-radius: 4px;
  padding: 12px 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.kpi .value {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 2px;
}
.kpi .delta { font-size: 12px; color: var(--fg-muted); margin-top: 6px; font-weight: 400; }
.kpi .delta.up { color: var(--accent-primary-dark); }
.kpi .delta.down { color: var(--accent-secondary); }
.kpi svg { display: block; width: 100%; height: 34px; margin-top: 8px; }
.kpi svg { cursor: crosshair; touch-action: none; }
.kpi svg rect.hit { fill: transparent; }
.kpi svg rect.val { fill: var(--spark); transition: fill 120ms; }
.kpi svg g.last rect.val { fill: var(--spark-last); }
.kpi svg g.today rect.val { fill: none; stroke: var(--spark-last); stroke-width: 1; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.kpi svg g.hover rect.val { fill: var(--accent-secondary); }
.kpi svg g.today.hover rect.val { fill: var(--accent-secondary-light); stroke: var(--accent-secondary); }

/* Tooltip wie der dunkle Toast in V3 („Result saved") */
.tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: #272727;
  color: #fff;
  border-radius: 4px;
  padding: 8px 12px;
  box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  text-align: left;
}
.tio-dark .tip { background: #3a3a3a; }
.tip-value { font-family: var(--font-headline); font-weight: 700; font-size: 18px; line-height: 1.1; }
.tip-label { font-size: 11px; text-transform: uppercase; color: #a8a8a8; margin-top: 2px; }
.tip-range { font-size: 12px; font-weight: 400; color: #d6d6d6; margin-top: 4px; }

/* --- Status ----------------------------------------------------------------- */

.status-line { display: flex; align-items: center; gap: 12px; padding: 10px 8px; }
.status-line .big { font-family: var(--font-headline); font-weight: 700; font-size: 21px; }
.status-line .icon { font-size: 28px; }
.ok { color: var(--accent-primary-dark); }
.warn { color: var(--accent-secondary); }
.bad { color: rgb(var(--modi-red-rgb)); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0; }
.kv > div { padding: 10px 8px; border-top: 2px solid var(--fg-lines); }
.kv > div:nth-child(-n+2) { border-top: 0; }
.kv > div:nth-child(odd) { color: var(--fg-muted); padding-right: 24px; white-space: nowrap; }

/* --- Updates-Details ------------------------------------------------------------ */

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary .chev { transition: transform 200ms cubic-bezier(0.645, 0.045, 0.355, 1); color: var(--fg-muted); }
details[open] summary .chev { transform: rotate(180deg); }
.release-detail { padding: 4px 0 2px; font-weight: 400; font-size: 13px; }
.release-detail h4 { font-size: 12px; text-transform: uppercase; color: var(--fg-muted); font-weight: 500; margin: 10px 0 4px; }
.release-detail ul { margin: 0; padding-left: 18px; }
.release-detail li { margin: 2px 0; }

.error-text { color: rgb(var(--modi-red-rgb)); font-size: 13px; font-weight: 400; }
.empty-row { color: var(--fg-muted); padding: 14px 12px; font-weight: 400; }

footer { color: var(--fg-muted); font-size: 12px; font-weight: 400; text-align: center; padding: 8px 0 24px; }

.more-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  height: 40px;
  border: 0;
  border-radius: 4px;
  background: var(--bg-on-cards);
  color: var(--fg-muted);
  font: inherit;
  cursor: pointer;
}
.more-btn:hover { color: var(--fg-default); }

/* --- Login ------------------------------------------------------------------ */

.login { max-width: 380px; margin: 12vh auto 0; }
.login .card { padding: 24px; }
.login h2 { font-family: var(--font-headline); font-weight: 700; font-size: 21px; margin: 0 0 4px; }
.login p { margin: 0 0 20px; font-weight: 400; font-size: 13px; }
.login label { display: block; color: var(--fg-muted); font-size: 12px; margin-bottom: 6px; }
.login input[type=password] {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 4px;
  background: var(--bg-on-cards);
  color: var(--fg-default);
  font: inherit;
  padding: 0 12px;
  margin-bottom: 14px;
  outline: none;
}
.login input[type=password]:focus { box-shadow: inset 0 0 0 2px var(--accent-secondary-light); }
.login label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--fg-default); margin-bottom: 20px; cursor: pointer; }
.login label.check input { accent-color: var(--accent-primary); width: 16px; height: 16px; margin: 0; }
.login .error-text { margin: -6px 0 14px; }

.btn {
  height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn.primary { background: var(--accent-secondary); color: #fff; width: 100%; }
.btn.primary:hover { background: var(--accent-secondary-dark); }
.btn[disabled] { opacity: 0.3; cursor: default; }
.sidebar nav:empty { display: none; }

/* --- Mobil (≤ 700 px) ----------------------------------------------------------
 * Tabellen werden zu gestapelten Zeilen: erste Spalte als Kopf, der Rest darunter.
 * Die Sidebar wird zur Leiste am unteren Rand, wie ein Tab-Bar.
 */
@media (max-width: 700px) {
  body { font-size: 14px; }
  .page { margin-left: 0; padding-bottom: 64px; }

  .sidebar {
    inset: auto 0 0 0;
    width: auto;
    height: 56px;
    flex-direction: row;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: content-box;
  }
  .sidebar .logo { display: none; }
  .sidebar nav {
    margin: 0 auto 0 0;
    flex-direction: row;
    width: auto;
    height: 40px;
    padding: 0 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar nav a { width: 34px; height: 40px; flex: none; }
  .sidebar nav a .icon { font-size: 21px; }
  .sidebar button { width: 36px; }
  .sidebar nav .sep { width: 2px; height: 18px; margin: 0 2px; flex: none; }
  .strip { padding: 8px 12px; }
  .sidebar .bottom { flex-direction: row; }

  header.top { padding: 0 12px; gap: 10px; }
  header.top .date { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  header.top .stamp .icon { display: none; }

  main { padding: 16px 10px 32px; }
  .grid { gap: 16px; }
  .grid + .grid, .grid[style] { margin-top: 16px !important; }
  .section-title { flex-wrap: wrap; row-gap: 2px; margin: 0 4px 8px; }
  .section-title .right { margin-left: 0; flex-basis: 100%; }
  .card + .section-title { margin-top: 16px; }

  .briefing { padding: 14px 14px 16px; }
  .briefing .headline { font-size: 18px; }
  .briefing p { font-size: 14px; }

  /* Tabellen stapeln */
  table, tbody, tr, td { display: block; width: 100%; }
  table { table-layout: auto; }
  colgroup, thead { display: none; }
  tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    padding: 12px 6px;
    border-top: 2px solid var(--fg-lines);
  }
  tbody tr:first-child { border-top: 0; }
  tbody tr[hidden] { display: none; }
  tbody td { padding: 0; border-top: 0; width: auto; flex: 0 1 auto; }
  tbody td:empty { display: none; }
  /* Die Hauptzelle (Titel, Betreff, Image …) bekommt eine eigene Zeile */
  tbody td.main { flex-basis: 100%; }
  td.num, th.num { text-align: left; }
  td.nowrap { white-space: normal; }
  tbody tr.hover:hover td { background: none; }
  .empty-row { padding: 12px 6px; }

  /* Updates: Details-Zeile ohne Einzug, Pfeil rechts oben */
  tr.upd td:last-child { margin-left: auto; }
  tr.detail { padding-top: 0; border-top: 0; }

  /* Sicherheitslücken: Zahlen als kleine Beschriftungen */
  .cve-num::before { content: attr(data-label) ' '; color: var(--fg-muted); font-size: 12px; }

  .kpis { gap: 6px; }
  .kpi { padding: 10px 8px 8px; }
  .kpi .delta { font-size: 11px; }

  .kv { grid-template-columns: 1fr; }
  .kv > div:nth-child(odd) { padding-bottom: 0; }
  .kv > div:nth-child(even) { border-top: 0; padding-top: 2px; }

  .login { margin-top: 6vh; }
  .tip { white-space: normal; max-width: 70vw; }
}
