/* stats.a-dur.at – Dashboard im A-DUR-Design. Schriften liegen lokal unter assets/fonts, nichts kommt von fremden Servern. */

@font-face {
  font-family: "Garamond A-DUR";
  src: url("fonts/CormorantGaramond-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Amulya";
  src: url("fonts/Amulya-Variable.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-serif: "Garamond A-DUR", "Cormorant Garamond", Garamond, Georgia, serif;
  --font-sans: "Amulya", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bg: #ffffff;
  --band: #f1f1d2;
  --surface: #ffffff;
  --surface-2: #fafae9;
  --border: #e3e4c4;
  --border-strong: #d6d7ab;
  --text: #111111;
  --muted: #5c5d4a;
  --accent: #acaf56;
  --accent-strong: #7d802f;
  --accent-text: #5f6224;
  --accent-soft: rgba(172, 175, 86, 0.22);
  --on-accent: #111111;
  --prev: #a3a48c;
  --up: #4f7a28;
  --down: #a33a2a;
  --danger: #a33a2a;
  --bar: rgba(172, 175, 86, 0.20);
  --shadow: none;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12130d;
    --band: #1e2014;
    --surface: #191a12;
    --surface-2: #212318;
    --border: #2f3122;
    --border-strong: #45482f;
    --text: #f2f2e8;
    --muted: #a6a790;
    --accent: #c5c870;
    --accent-strong: #d3d585;
    --accent-text: #d3d585;
    --accent-soft: rgba(197, 200, 112, 0.16);
    --on-accent: #12130d;
    --prev: #6d6e5a;
    --up: #9cc66b;
    --down: #e88b78;
    --danger: #e88b78;
    --bar: rgba(197, 200, 112, 0.14);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12130d;
  --band: #1e2014;
  --surface: #191a12;
  --surface-2: #212318;
  --border: #2f3122;
  --border-strong: #45482f;
  --text: #f2f2e8;
  --muted: #a6a790;
  --accent: #c5c870;
  --accent-strong: #d3d585;
  --accent-text: #d3d585;
  --accent-soft: rgba(197, 200, 112, 0.16);
  --on-accent: #12130d;
  --prev: #6d6e5a;
  --up: #9cc66b;
  --down: #e88b78;
  --danger: #e88b78;
  --bar: rgba(197, 200, 112, 0.14);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  /* Sanfter Verlauf wie im Kopfbereich von a-dur.at */
  background: linear-gradient(180deg, var(--bg) 0, var(--band) 240px, var(--bg) 560px) no-repeat, var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font-sans);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2 { font-family: var(--font-serif); font-weight: 400; letter-spacing: 0; }
h1 { font-size: 2.4rem; line-height: 1.15; margin: 0; }
h2 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 0.75rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 0.85em; }
small, .small { font-size: 0.82rem; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 32px; padding-bottom: 32px; }
.footer { color: var(--muted); font-size: 0.8rem; padding-bottom: 32px; }

/* Kopfzeile */
.topbar { background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 28px; min-height: 76px; flex-wrap: wrap; }
.brand { color: var(--text); display: grid; justify-items: center; line-height: 1; font-family: var(--font-serif); }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 1.9rem; letter-spacing: 0.14em; padding-left: 0.14em; }
.brand-sub { font-size: 0.9rem; letter-spacing: 0.16em; padding: 5px 0 0 0.16em; margin-top: 4px; border-top: 1px solid var(--border-strong); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; font-family: var(--font-serif); font-size: 1.2rem; }
.nav a { color: var(--text); padding: 4px 10px; border-radius: 4px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Bausteine */
.card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card.narrow { max-width: 440px; margin: 40px auto; }
.card.narrow-left { max-width: 480px; }
.card.highlight { border-color: var(--accent-strong); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.crumbs { margin: 0 0 4px; color: var(--muted); font-size: 0.85rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
.align-start { align-items: start; }
.note { font-size: 0.85rem; margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: 4px;
  padding: 8px 18px; font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 0.85rem; }
.btn-ghost, :root .btn.btn-ghost { background: transparent; color: var(--text); border-color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger, :root .btn.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--bg); }
.icon-btn { background: transparent; border: 1px solid var(--border-strong); color: var(--text); border-radius: 4px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; }
.icon-btn:hover { background: var(--surface-2); }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--surface); }
.flash-ok { border-color: var(--accent-strong); background: var(--accent-soft); }
.flash-error { border-color: var(--danger); color: var(--danger); background: transparent; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 500; font-size: 0.92rem; }
.form label small { font-weight: 400; }
.form-inline { grid-template-columns: 1fr auto; align-items: end; }
input[type="text"], input[type="password"], input[type="date"], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 8px 10px;
}
input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 1px; }
input[readonly] { opacity: 0.7; }
.danger-zone { border-color: var(--danger); }

/* Zeitraum */
.period { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 2px; flex-wrap: wrap; }
.segmented a { color: var(--muted); padding: 5px 12px; border-radius: 4px; font-size: 0.9rem; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: var(--accent); color: var(--on-accent); font-weight: 500; }
.custom-range { position: relative; }
.custom-range summary { list-style: none; cursor: pointer; padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 0.88rem; }
.custom-range summary::-webkit-details-marker { display: none; }
.custom-range summary.active { color: var(--text); font-weight: 500; border-color: var(--accent-strong); }
.range-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; display: flex; gap: 8px; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); flex-wrap: wrap; width: max-content; max-width: calc(100vw - 32px); }
.range-form label { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.period-label { width: 100%; text-align: right; margin: 0; font-size: 0.8rem; }

/* Live-Aktualisierung */
.live-status { display: flex; align-items: center; gap: 8px; margin: -8px 0 14px; font-size: 0.82rem; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 0 var(--accent-soft); animation: live-pulse 2s infinite; }
.live-error .live-dot { background: var(--danger); animation: none; }
.live-error { color: var(--danger); }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 var(--accent-soft); } 70% { box-shadow: 0 0 0 8px rgba(0,0,0,0); } 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Favicons der Websites */
.favicon { width: 20px; height: 20px; border-radius: 4px; object-fit: contain; flex: none; }
.site-link { display: inline-flex; align-items: center; gap: 10px; vertical-align: middle; }
.site-title { display: flex; align-items: center; gap: 14px; }
.site-title .favicon { width: 32px; height: 32px; border-radius: 6px; }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 18px 22px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 0.85rem; }
.kpi-value { font-family: var(--font-serif); font-size: 2.6rem; font-weight: 400; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.kpi-prev { color: var(--muted); font-size: 0.8rem; }
.delta { font-size: 0.85rem; font-weight: 500; }
.delta-up { color: var(--up); }
.delta-down { color: var(--down); }
.delta-none { color: var(--muted); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.table-card { padding: 14px 10px; }
.table-card h2 { padding: 0 8px; }
.table-scroll { overflow-x: auto; }
.empty { color: var(--muted); padding: 8px; margin: 0; }
table.bars { table-layout: fixed; }
table.bars th:first-child { width: auto; }
table.bars th.num { width: 6.5rem; }
table.bars td.label { position: relative; overflow: hidden; }
table.bars .bar { position: absolute; left: 0; top: 3px; bottom: 3px; background: var(--bar); border-radius: 4px; }
table.bars .text { position: relative; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 400; }
tr.revoked td { color: var(--muted); }
.sites-table td { white-space: nowrap; }
.spark-col { width: 140px; }
.spark { width: 120px; height: 28px; color: var(--accent-strong); display: block; }

/* Diagramm */
.chart-card { padding-bottom: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.chart-head h2 { margin: 0; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 0.85rem; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.legend-item.active { color: var(--text); border-color: var(--border-strong); background: var(--accent-soft); }
.legend-static { cursor: default; }
.swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch-a { background: var(--accent-strong); }
.swatch-prev { background: repeating-linear-gradient(90deg, var(--prev) 0 4px, transparent 4px 7px); }
.chart { position: relative; height: 260px; margin-top: 12px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--border); }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font-sans); }
.chart .line-cur { fill: none; stroke: var(--accent-strong); stroke-width: 2; }
.chart .area-cur { fill: var(--accent-soft); stroke: none; }
.chart .line-prev { fill: none; stroke: var(--prev); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .hover-line { stroke: var(--muted); stroke-width: 1; }
.chart .hover-dot { fill: var(--accent-strong); stroke: var(--surface); stroke-width: 2; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 0.8rem; box-shadow: 0 6px 16px rgba(0,0,0,0.12); white-space: nowrap; z-index: 2; }
.chart-tip strong { display: block; margin-bottom: 2px; }
.chart-table { margin-top: 10px; font-size: 0.85rem; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table table { margin-top: 8px; }

/* Code und Tabs */
.code-wrap { position: relative; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 0 0 8px; white-space: pre; }
.copy-btn { position: absolute; top: 8px; right: 8px; }
.tab-list { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.tab { font: inherit; background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent-strong); font-weight: 500; }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .kpi { grid-template-columns: 1fr auto; align-items: baseline; }
  .kpi-value { font-size: 2rem; }
  .period-label { text-align: left; }
  .range-form { left: 0; right: auto; }
  .chart { height: 200px; }
}
@media (max-width: 560px) {
  h1 { font-size: 1.9rem; }
  .brand-name { font-size: 1.5rem; }
  .nav { font-size: 1.05rem; }
  .topbar-inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .nav { order: 3; width: 100%; }
  .spark-col { display: none; }
  .form-inline { grid-template-columns: 1fr; }
}
