/* SchulMessenger Admin — editorial-refined, datenliebend.
   Design-System: warmes Off-White, dunkles Petrol als Akzent, Bernstein als Highlight.
   Typo: System-Stack (Display=Serif, Body=Sans, Mono für Zahlen).
*/

:root {
    --bg:               #f7f5ee;
    --surface:          #fdfcf7;
    --surface-elevated: #ffffff;
    --ink:              #1a1814;
    --ink-secondary:    #5a544a;
    --ink-muted:        #918a7c;
    --rule:             #e7e2d4;
    --rule-strong:      #d4cfbf;
    --accent:           #0f3d3e;          /* dunkles Petrol */
    --accent-deep:      #0a2a2b;
    --accent-warm:      #b25d2c;          /* Bernstein/Terra */
    --accent-warm-soft: #e9c8a7;
    --status-ok:        #3d6149;
    --status-warn:      #b8731f;
    --status-error:     #9c3a31;
    --status-neutral:   #6b665b;
    --shadow-soft:      0 1px 0 rgba(26,24,20,0.04);
    --shadow-card:      0 1px 2px rgba(26,24,20,0.04), 0 0 0 1px var(--rule);

    --font-display: ui-serif, "Iowan Old Style", "Apple Garamond", Baskerville, "Times New Roman", Georgia, serif;
    --font-body:    system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
    --font-mono:    ui-monospace, "SF Mono", "Menlo", "Cascadia Code", "Roboto Mono", monospace;

    --max-content: 1280px;
    --sidebar-w:   220px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
a:hover { border-bottom-color: var(--accent); }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.012em;
    color: var(--ink);
    margin: 0;
}
h1 { font-size: 2rem; line-height: 1.15; }
h2 { font-size: 1.25rem; line-height: 1.25; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; line-height: 1.3; }

/* ---------- Layout ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
    background: var(--accent-deep);
    color: #c9d4cf;
    padding: 1.5rem 0;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
    padding: 0 1.25rem 1.5rem;
    color: #f3eeda;
    font-family: var(--font-display);
    font-size: 1.05rem;
    line-height: 1.2;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand small {
    display: block;
    font-family: var(--font-body);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8a9893;
    margin-top: 0.25rem;
    font-weight: 500;
}
.sidebar nav { padding: 1rem 0; flex: 1; }
.sidebar nav a {
    display: flex; align-items: center;
    padding: 0.5rem 1.25rem;
    color: #c9d4cf;
    font-size: 0.92rem;
    border-bottom: 0;
    border-left: 2px solid transparent;
    text-transform: none;
    letter-spacing: 0;
}
.sidebar nav a:hover { color: #f3eeda; background: rgba(255,255,255,0.03); border-left-color: var(--accent-warm); }
.sidebar nav a.active { color: #f3eeda; background: rgba(255,255,255,0.05); border-left-color: var(--accent-warm); }
.sidebar nav .label {
    display: block;
    padding: 1rem 1.25rem 0.4rem;
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #6f7d78;
    font-weight: 600;
}
.sidebar .user-block {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.85rem;
}
.sidebar .user-block .user { color: #f3eeda; font-weight: 500; }
.sidebar .user-block .account-link {
    display: block;
    color: #8a9893;
    font-size: 0.78rem;
    text-decoration: none;
    border-bottom: 0;
    margin-top: 0.25rem;
}
.sidebar .user-block .account-link:hover { color: #f3eeda; border-bottom: 0; }
.sidebar .user-block form { margin-top: 0.6rem; }
.sidebar .user-block button {
    background: transparent;
    color: #b9a78c;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: var(--font-body);
    border-radius: 2px;
}
.sidebar .user-block button:hover { color: #f3eeda; border-color: var(--accent-warm); }

main {
    padding: 2.5rem 3rem;
    max-width: var(--max-content);
    width: 100%;
}

/* Section header (page top) */
.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--ink);
}
.section-head .eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-warm);
    font-weight: 600;
    margin-bottom: 0.4rem;
    display: block;
}
.section-head h1 { font-size: 2.25rem; }
.section-head p { color: var(--ink-secondary); margin: 0.4rem 0 0; max-width: 60ch; }
.section-head .actions { display: flex; gap: 0.5rem; align-items: center; }

/* Grid utilities */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    main { padding: 1.5rem; }
}

/* Stat-Card mit großer Display-Zahl */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: 1.25rem 1.25rem 1.5rem;
    position: relative;
}
.stat-card .stat-label {
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-secondary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    line-height: 1;
    color: var(--ink);
    font-variant-numeric: tabular-nums oldstyle-nums;
    font-weight: 500;
}
.stat-card .stat-meta {
    font-size: 0.78rem;
    color: var(--ink-muted);
    margin-top: 0.5rem;
    font-variant-numeric: tabular-nums;
}
.stat-card .stat-spark {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    color: var(--accent);
    width: 70px; height: 24px;
}
.stat-card.is-warning .stat-value { color: var(--status-warn); }
.stat-card.is-warning { border-color: var(--accent-warm-soft); background: linear-gradient(180deg, var(--surface) 0%, #fbf0e0 100%); }
.stat-card-link { display: block; text-decoration: none; border-bottom: 1px solid var(--rule); transition: transform 0.1s, box-shadow 0.1s; cursor: pointer; }
.stat-card-link:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(26,24,20,0.06); border-bottom: 1px solid var(--rule); }
.stat-card.is-accent { background: var(--accent-deep); color: #f3eeda; border-color: var(--accent-deep); }
.stat-card.is-accent .stat-label { color: #b9a78c; }
.stat-card.is-accent .stat-value { color: #f3eeda; }
.stat-card.is-accent .stat-meta { color: #8a9893; }
.stat-card.is-accent .stat-spark { color: #e9c8a7; }

/* Card */
.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.card-head h2 { font-family: var(--font-display); font-size: 1.1rem; margin: 0; font-weight: 600; }
.card-head .meta { color: var(--ink-muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* Tables (data-zentriert, editorial) */
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
table.data th {
    text-align: left;
    padding: 0.5rem 0.875rem 0.5rem 0;
    border-bottom: 2px solid var(--ink);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-secondary);
    font-weight: 600;
}
table.data th.right, table.data td.right { text-align: right; }
table.data td {
    padding: 0.7rem 0.875rem 0.7rem 0;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
    color: var(--ink);
}
table.data td.right, table.data td.num { font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: rgba(15, 61, 62, 0.03); }
table.data tr.expired td { color: var(--status-warn); }
table.data .empty {
    text-align: center;
    color: var(--ink-muted);
    padding: 3rem 1rem;
    font-style: italic;
}
table.data code {
    color: var(--ink-secondary);
    font-size: 0.82rem;
}

/* Sparkline-Zelle */
.sparkline-cell {
    display: inline-block;
    color: var(--accent);
    width: 120px;
    height: 26px;
    vertical-align: middle;
}
.sparkline { display: block; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    font-weight: 600;
    text-transform: uppercase;
    font-family: var(--font-body);
    background: var(--rule);
    color: var(--ink-secondary);
}
.badge-ok      { background: #e2ebe5; color: var(--status-ok); }
.badge-warn    { background: #f4e3ce; color: var(--status-warn); }
.badge-error   { background: #f3dad6; color: var(--status-error); }
.badge-off     { background: var(--rule); color: var(--ink-muted); }
.badge.cat-bug      { background: #f3dad6; color: var(--status-error); }
.badge.cat-feature  { background: #d9e2ed; color: #355682; }
.badge.cat-ux       { background: #ece1f0; color: #6b3a7a; }
.badge.cat-other    { background: var(--rule); color: var(--ink-secondary); }
.badge.status-new         { background: #f4e3ce; color: var(--status-warn); }
.badge.status-triaged     { background: #d9e2ed; color: #355682; }
.badge.status-in_progress { background: #d6dde9; color: #2c4366; }
.badge.status-resolved    { background: #e2ebe5; color: var(--status-ok); }
.badge.status-closed      { background: var(--rule); color: var(--ink-muted); }

/* Buttons */
.btn-primary {
    background: var(--accent-deep);
    color: #f3eeda;
    border: 0;
    padding: 0.55rem 1.1rem;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    border-radius: 2px;
    transition: background .15s;
    border-bottom: 0;
}
.btn-primary:hover { background: var(--accent); border-bottom: 0; }
.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--rule-strong);
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: var(--font-body);
    border-radius: 2px;
    text-decoration: none;
    display: inline-block;
}
.btn-secondary:hover { border-color: var(--accent); border-bottom: 1px solid var(--accent); }
.link-button {
    background: none; border: 0;
    color: var(--status-error); cursor: pointer;
    text-decoration: underline; font-size: 0.85rem;
    font-family: var(--font-body); padding: 0;
}

/* Search + Filter */
.toolbar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: end;
    flex-wrap: wrap;
}
.toolbar label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--ink-secondary); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.toolbar input, .toolbar select {
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--rule-strong);
    background: var(--surface-elevated);
    border-radius: 2px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--ink);
}
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.toolbar input[type="search"] { min-width: 280px; }
.toolbar .quick {
    display: flex; gap: 0.75rem; align-items: center;
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--ink-muted);
}
.toolbar .quick a { font-size: 0.85rem; }

/* Forms */
.form-stack { display: flex; flex-direction: column; gap: 1rem; max-width: 520px; }
.form-stack label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-secondary); }
.form-stack input, .form-stack select, .form-stack textarea {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--rule-strong);
    background: var(--surface-elevated);
    border-radius: 2px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--ink);
}
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
.form-stack small { color: var(--ink-muted); font-size: 0.78rem; }
.form-stack .req { color: var(--accent-warm); }
.form-stack label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }
.form-stack .actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.5rem; }

/* Charts */
.chart-host { width: 100%; }
.chart-host svg.line-chart, .chart-host svg.bar-chart { display: block; }
.axis-label, .bar-label, .bar-value { font-family: var(--font-body); font-size: 11px; fill: var(--ink-muted); }
.bar-value { fill: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }
.donut { display: block; margin: 0 auto; }
.donut-center-value { font-family: var(--font-display); font-size: 22px; fill: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }
.donut-center-label { font-family: var(--font-body); font-size: 9px; fill: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
@keyframes chartDraw {
    to { stroke-dashoffset: 0; }
}

/* Chart-Tooltip (Hover-Crosshair) */
.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--ink);
    color: #f3eeda;
    padding: 0.55rem 0.7rem;
    border-radius: 3px;
    font-size: 0.78rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(26,24,20,0.18);
    transform: translate(-50%, calc(-100% - 10px));
    opacity: 0;
    transition: opacity 0.1s, transform 0.1s;
    z-index: 5;
    white-space: nowrap;
    min-width: 140px;
}
.chart-tooltip.is-visible { opacity: 1; }
.chart-tooltip.flip-left  { transform: translate(calc(-100% - 12px), -50%); }
.chart-tooltip.flip-right { transform: translate(12px, -50%); }
.chart-tooltip .tt-date {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: #f3eeda;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    padding-bottom: 0.3rem;
    margin-bottom: 0.35rem;
    font-variant-numeric: tabular-nums;
}
.chart-tooltip .tt-row {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.1rem 0;
}
.chart-tooltip .tt-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    display: inline-block;
}
.chart-tooltip .tt-lbl { color: #c9d4cf; }
.chart-tooltip .tt-val { font-variant-numeric: tabular-nums; font-weight: 500; color: #f3eeda; }
.chart-tooltip .tt-total {
    border-top: 1px solid rgba(255,255,255,0.12);
    padding-top: 0.3rem;
    margin-top: 0.3rem;
    grid-template-columns: 1fr auto;
}
.chart-tooltip .tt-total .tt-lbl { color: #b9a78c; font-weight: 600; }
.chart-tooltip .tt-total .tt-val { color: #f3eeda; font-weight: 600; }

/* MAU-Hero */
.mau-hero {
    background: linear-gradient(135deg, #fdfcf7 0%, #f4eddc 100%);
    border-color: var(--accent-warm-soft);
}
.mau-hero-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: center;
}
@media (max-width: 720px) { .mau-hero-grid { grid-template-columns: 1fr; } }
.mau-eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent-warm);
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.mau-value {
    font-family: var(--font-display);
    font-size: 3rem;
    line-height: 1;
    color: var(--accent-deep);
    font-variant-numeric: tabular-nums oldstyle-nums;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.mau-current-label {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--ink-secondary);
    letter-spacing: 0.04em;
    font-weight: 500;
}
.mau-meta {
    margin-top: 0.5rem;
    color: var(--ink-secondary);
    font-size: 0.92rem;
}
.mau-meta em { color: var(--ink-muted); font-style: italic; }
.mau-delta { font-weight: 600; padding: 0.1rem 0.4rem; border-radius: 2px; font-size: 0.85rem; }
.mau-delta-up   { background: #e2ebe5; color: var(--status-ok); }
.mau-delta-down { background: #f3dad6; color: var(--status-error); }
.mau-delta-flat { background: var(--rule); color: var(--ink-secondary); }
.mau-explanation {
    margin-top: 1rem;
    color: var(--ink-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
    max-width: 60ch;
}
.mau-spark-host { color: var(--accent); width: 180px; height: 40px; }
.mau-spark-label {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--ink-muted);
    text-align: right;
    letter-spacing: 0.06em;
}

/* Period-Tab-Bar */
.period-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.4rem 0;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--rule-strong);
}
.period-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    overflow: hidden;
    background: var(--surface);
}
.period-tabs .period-tab {
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    color: var(--ink-secondary);
    border: 0;
    border-bottom: 0;
    border-right: 1px solid var(--rule);
    background: transparent;
    transition: background 0.1s;
}
.period-tabs .period-tab:hover { background: rgba(15, 61, 62, 0.05); border-bottom: 0; }
.period-tabs .period-tab:last-child { border-right: 0; }
.period-tabs .period-tab.is-active {
    background: var(--accent-deep);
    color: #f3eeda;
    font-weight: 500;
    cursor: default;
    border-bottom: 0;
}
.period-tabs .period-tab.is-active:hover { background: var(--accent-deep); }

.period-nav {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.period-nav .period-label {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--ink);
    min-width: 11rem;
    text-align: center;
    font-variant-numeric: oldstyle-nums;
}
.period-nav .nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem; height: 2rem;
    border: 1px solid var(--rule-strong);
    background: var(--surface);
    color: var(--ink-secondary);
    text-decoration: none;
    border-radius: 2px;
    border-bottom: 1px solid var(--rule-strong);
    font-size: 0.9rem;
    transition: background 0.1s, color 0.1s;
}
.period-nav .nav-btn:hover {
    background: var(--accent-deep);
    color: #f3eeda;
    border-color: var(--accent-deep);
    border-bottom-color: var(--accent-deep);
}
.period-nav .nav-btn-disabled { color: var(--ink-muted); cursor: default; opacity: 0.4; }
.period-nav .nav-btn-disabled:hover { background: var(--surface); color: var(--ink-muted); border-color: var(--rule-strong); }
.period-nav .nav-btn-today {
    width: auto;
    padding: 0 0.7rem;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

/* Loading-State der Period-Bar (Vor/Zurueck via fetch) */
.push-period-bar { position: relative; }
.push-period-bar::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-warm) 30%, var(--accent-warm) 70%, transparent);
    background-size: 200% 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
.push-period-bar.is-loading::after {
    opacity: 1;
    animation: periodBarLoading 1s linear infinite;
}
.push-period-bar.is-loading {
    pointer-events: none;
    opacity: 0.85;
}
@keyframes periodBarLoading {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Metric-Card mit Tooltip + Delta */
.metric-card { position: relative; }
.metric-tip {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--rule-strong);
    color: var(--surface);
    font-size: 9px;
    font-weight: 700;
    margin-left: 0.4rem;
    cursor: help;
    vertical-align: 1px;
}
.metric-tip:hover { background: var(--accent-deep); }
.metric-delta {
    font-weight: 600;
    padding: 0.05rem 0.35rem;
    border-radius: 2px;
    font-size: 0.78rem;
    margin-right: 0.3rem;
}
.metric-delta-up   { background: #e2ebe5; color: var(--status-ok); }
.metric-delta-down { background: #f3dad6; color: var(--status-error); }
.metric-delta-flat { background: var(--rule); color: var(--ink-secondary); }

.metric-switch-hint {
    margin: 0.5rem 0 0.75rem;
    font-size: 0.78rem;
    color: var(--ink-muted);
    letter-spacing: 0.04em;
}
.metric-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s, border-color 0.15s;
}
.metric-card-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(26,24,20,0.06);
    border-bottom: 1px solid var(--rule);
}
.metric-card-link.is-selected {
    box-shadow: 0 0 0 2px var(--accent-deep), 0 4px 12px rgba(26,24,20,0.08);
    border-bottom: 1px solid var(--accent-deep);
}
.metric-active-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    background: var(--accent-deep);
    color: #f3eeda;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 2px;
    vertical-align: 1px;
}

/* Granularity-Buttons im Chart-Header */
.time-range-buttons {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    overflow: hidden;
    background: var(--surface);
}
.time-range-buttons .time-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    color: var(--ink-secondary);
    border: 0;
    border-right: 1px solid var(--rule);
    background: transparent;
    text-decoration: none;
    transition: background 0.1s;
}
.time-range-buttons .time-btn:hover { background: rgba(15, 61, 62, 0.05); border-bottom: 0; }
.time-range-buttons .time-btn:last-child { border-right: 0; }
.time-range-buttons .time-btn.is-active {
    background: var(--accent-deep);
    color: #f3eeda;
    font-weight: 500;
}

/* Select im Card-Header */
.meta-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--rule-strong);
    background: var(--surface);
    color: var(--ink-secondary);
    border-radius: 2px;
    font-family: var(--font-body);
    font-size: 0.85rem;
}

/* Plattform-Doppel-Donut + Legende-Tabelle */
.platform-donut-host { display: flex; justify-content: center; padding: 0.5rem 0; }
.platform-legend-table {
    width: 100%;
    margin-top: 0.75rem;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.platform-legend-table th {
    text-align: left;
    padding: 0.4rem 0.5rem 0.4rem 0;
    border-bottom: 2px solid var(--ink);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-secondary);
    font-weight: 600;
}
.platform-legend-table th.pl-current,
.platform-legend-table th.pl-previous,
.platform-legend-table td.pl-current,
.platform-legend-table td.pl-previous {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.platform-legend-table th.pl-current { color: var(--ink); }
.platform-legend-table th.pl-previous { color: var(--ink-muted); }
.platform-legend-table td {
    padding: 0.45rem 0.5rem 0.45rem 0;
    border-bottom: 1px solid var(--rule);
}
.platform-legend-table td.pl-platform .swatch {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 1px;
    margin-right: 0.5rem;
    vertical-align: 1px;
}
.platform-legend-table td.pl-previous { color: var(--ink-muted); }
.platform-legend-table td .pct {
    color: var(--ink-muted);
    font-size: 0.82rem;
    margin-left: 0.2rem;
}
.platform-legend-table .pl-total td {
    border-bottom: 0;
    border-top: 1px solid var(--rule);
    padding-top: 0.6rem;
    font-weight: 500;
    color: var(--ink);
}
.platform-legend-table .pl-total td.pl-platform { font-variant-numeric: tabular-nums; }
.platform-legend-table .pl-current { padding-left: 1.5rem !important; }
.platform-legend-table .pl-previous { padding-left: 1.5rem !important; border-left: 1px solid var(--rule); }

/* Heatmap */
.heatmap-host { overflow-x: auto; padding: 0.5rem 0; }
svg.heatmap text.heatmap-label {
    font-family: var(--font-body);
    font-size: 10px;
    fill: var(--ink-muted);
    letter-spacing: 0.04em;
}

/* Donut-Legend */
.legend {
    display: flex; flex-direction: column; gap: 0.5rem;
    font-size: 0.85rem;
    margin-top: 1rem;
}
.legend .item { display: flex; align-items: center; gap: 0.6rem; }
.legend .swatch { width: 12px; height: 12px; flex-shrink: 0; border-radius: 1px; }
.legend .name { flex: 1; color: var(--ink-secondary); }
.legend .value { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }

/* Login + Setup pages */
.auth-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    background: var(--bg);
}
.auth-aside {
    background: var(--accent-deep);
    color: #f3eeda;
    padding: 3rem;
    display: flex; flex-direction: column; justify-content: space-between;
    background-image:
        radial-gradient(at 20% 30%, rgba(178, 93, 44, 0.12) 0px, transparent 50%),
        radial-gradient(at 80% 70%, rgba(15, 61, 62, 0.5) 0px, transparent 50%);
}
.auth-aside .brand { font-family: var(--font-display); font-size: 1.5rem; }
.auth-aside .brand small { display: block; font-family: var(--font-body); font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: #8a9893; margin-top: 0.25rem; font-weight: 500; }
.auth-aside .pitch { max-width: 30ch; }
.auth-aside .pitch h1 { font-size: 2.5rem; color: #f3eeda; line-height: 1.1; margin-bottom: 1rem; }
.auth-aside .pitch p { color: #c9d4cf; line-height: 1.6; }
.auth-aside .footnote { font-size: 0.78rem; color: #8a9893; }
.auth-main {
    display: flex; align-items: center; justify-content: center;
    padding: 3rem;
}
.auth-card {
    background: var(--surface-elevated);
    border: 1px solid var(--rule);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}
.auth-card .eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-warm);
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.auth-card h1 { font-size: 1.75rem; margin-bottom: 1.5rem; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-secondary); }
.auth-card input {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--rule-strong);
    background: var(--surface);
    border-radius: 2px;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ink);
    transition: border-color .15s;
}
.auth-card input[name="code"] {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    text-align: center;
    letter-spacing: 0.4em;
    padding: 0.8rem;
}
.auth-card input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
.auth-card button[type="submit"] {
    background: var(--accent-deep);
    color: #f3eeda;
    border: 0;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 500;
    border-radius: 2px;
    margin-top: 0.5rem;
    transition: background .15s;
}
.auth-card button[type="submit"]:hover { background: var(--accent); }
.auth-card .hint {
    font-size: 0.85rem;
    color: var(--ink-muted);
    margin-top: 1rem;
    line-height: 1.6;
}
.auth-card .hint a { color: var(--accent); }
.auth-card .error {
    background: #f3dad6;
    color: var(--status-error);
    padding: 0.65rem 0.85rem;
    border-radius: 2px;
    font-size: 0.88rem;
    border-left: 3px solid var(--status-error);
}
@media (max-width: 880px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { padding: 2rem 1.5rem; }
    .auth-aside .pitch h1 { font-size: 1.75rem; }
}

/* Setup-2FA */
.setup-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2.5rem;
    align-items: start;
    margin-top: 1.5rem;
}
@media (max-width: 720px) { .setup-grid { grid-template-columns: 1fr; } }
.qr-frame {
    background: #fff;
    padding: 1.25rem;
    border: 1px solid var(--rule-strong);
    display: flex; align-items: center; justify-content: center;
}
.qr-frame canvas, .qr-frame img { display: block; }
.setup-steps ol {
    margin: 0; padding-left: 1.25rem;
    counter-reset: step;
    list-style: none;
}
.setup-steps li {
    margin-bottom: 1.25rem;
    padding-left: 0.5rem;
    position: relative;
    counter-increment: step;
}
.setup-steps li::before {
    content: counter(step);
    position: absolute;
    left: -1.5rem;
    top: -2px;
    background: var(--accent-deep);
    color: #f3eeda;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: oldstyle-nums;
}
.setup-steps li code {
    background: var(--rule);
    padding: 0.15rem 0.4rem;
    border-radius: 2px;
    font-size: 0.92em;
    color: var(--ink);
}
.setup-key {
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    word-break: break-all;
    color: var(--accent-deep);
}
.setup-confirm {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
}
.setup-confirm label { font-weight: 600; color: var(--ink); }
.setup-confirm input {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.45em;
    padding: 0.75rem;
    width: 200px;
    border: 1px solid var(--rule-strong);
    border-radius: 2px;
    margin-top: 0.5rem;
}

/* Detail-Pages */
.breadcrumb {
    color: var(--ink-muted);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    font-weight: 600;
}
.breadcrumb a { color: var(--ink-muted); }
.breadcrumb a:hover { color: var(--accent); }

dl.meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    margin: 1rem 0 2rem;
    font-size: 0.92rem;
}
dl.meta dt {
    color: var(--ink-secondary);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    align-self: center;
}
dl.meta dd { margin: 0; align-self: center; color: var(--ink); }
dl.meta dd code { color: var(--ink-secondary); }

/* Feedback message-Block */
.message-block {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--accent-warm);
    padding: 1.25rem 1.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--ink);
    max-height: 400px;
    overflow-y: auto;
}

.attachments { list-style: none; padding: 0; margin: 0; }
.attachments li {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--rule);
    display: flex; align-items: center; gap: 0.75rem;
}
.attachments li:last-child { border-bottom: 0; }
.attachments small { color: var(--ink-muted); margin-left: auto; font-variant-numeric: tabular-nums; }

.pagination {
    display: flex; justify-content: center; align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    font-size: 0.88rem;
    color: var(--ink-muted);
}
.pagination span { font-variant-numeric: tabular-nums; }

/* Subtle page-load animation */
main > * { animation: fadeUp 0.5s cubic-bezier(0.2, 0.6, 0.2, 1) backwards; }
main > *:nth-child(1) { animation-delay: 0.05s; }
main > *:nth-child(2) { animation-delay: 0.12s; }
main > *:nth-child(3) { animation-delay: 0.18s; }
main > *:nth-child(4) { animation-delay: 0.24s; }
main > *:nth-child(5) { animation-delay: 0.3s; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* === Inline-Style-Migration 2026-05-11 ============================ */
/* Utility-Klassen die heute noch inline waren — fuer CSP strict     */

.text-muted   { color: var(--ink-muted); }
.text-secondary { color: var(--ink-secondary); }
.text-error   { color: var(--status-error); }
.text-small   { font-size: 0.85rem; }
.text-xsmall  { font-size: 0.7rem; }
.text-tabular { font-variant-numeric: tabular-nums; }
.text-nowrap  { white-space: nowrap; }
.opacity-low  { opacity: 0.7; }
.no-margin    { margin: 0; }
.margin-top-1 { margin-top: 1rem; }
.margin-top-half { margin-top: 0.5rem; }
.inline-flex  { display: inline; }
.row-flex     { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

/* error-card mit border */
.card.is-error { border-color: var(--status-error); background: #fbe9e6; }
.card.is-error p { margin: 0; color: var(--status-error); }

/* Accent borders fuer Stat-Cards (Palette-Konstanten) */
.stat-card.accent-petrol { border-top: 3px solid #1f5e60; }
.stat-card.accent-rust   { border-top: 3px solid #b25d2c; }
.stat-card.accent-olive  { border-top: 3px solid #7a6b48; }

/* Dynamische Palette-Farben fuer Swatches (donut-Legenden, chart-paletten) */
.swatch-accent { background: var(--accent); }
.swatch-warm   { background: var(--accent-warm); }
.swatch-muted  { background: var(--ink-muted); }
.swatch-rule   { background: var(--rule-strong); }

/* Highlight-Tooltip-Marker (kleiner ?-circle hover) */
.tooltip-marker { font-size: 0.7rem; opacity: 0.7; cursor: help; }

/* form-error block (verwendet in school_form.phtml) */
.form-error {
    background: #f3dad6;
    color: var(--status-error);
    padding: 0.65rem 0.85rem;
    border-left: 3px solid var(--status-error);
    margin-bottom: 1rem;
}

/* feedback-table cells */
.cell-code { font-size: 0.82rem; }
.cell-note { font-size: 0.88rem; color: var(--ink-secondary); }
.cell-date { white-space: nowrap; }

/* school-suffix small */
.school-suffix { color: var(--ink-muted); font-size: 0.6em; }

/* 2fa wide auth-card */
.auth-card.is-wide { max-width: 640px; }

/* otpauth-link below QR */
.otpauth-link { margin: 0.4rem 0 0; }

/* Warn-/Inactive-Markers */
.text-warn { color: var(--status-warn); }
.card.is-warning-border { border-left: 3px solid var(--status-warn); }
.card.is-warning-border h2 { color: var(--status-warn); }
.row-inactive { background: rgba(184,115,31,0.04); }
.badge-spaced { margin-left: 0.4rem; }
.em-muted { color: var(--ink-muted); }

/* Status-Farben für stat-values */
.text-ok { color: var(--status-ok); }

/* Card-Varianten */
.card.max-560 { max-width: 560px; }
.card.is-dashed { background: transparent; border-style: dashed; }

/* Alert-Boxen (success/error) */
.alert-success {
    background: #e2ebe5;
    color: var(--status-ok);
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--status-ok);
    margin: 0 0 1.25rem;
}
.alert-error {
    background: #f3dad6;
    color: var(--status-error);
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--status-error);
    margin: 0 0 1.25rem;
}
.alert-error.is-compact { padding: 0.65rem 0.85rem; margin-bottom: 1rem; }

/* Diverse Pattern */
.h-tight { font-size: 0.92rem; margin-bottom: 0.5rem; }
.h-spaced { margin-top: 1.5rem; }
.text-secondary-small { color: var(--ink-secondary); font-size: 0.88rem; margin: 0; }
.form-inline { display: inline; }
.badge.is-large { font-size: 0.85rem; padding: 0.4rem 0.75rem; }
.feedback-timestamp { color: var(--ink-muted); font-size: 0.88rem; margin-top: 0.4rem; }
.meta-inline { font-size: 0.85rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

/* Standort-Karte (home.phtml) — schoenes Designobjekt, kein Pan/Zoom */
.map-card {
    position: relative;  /* Anker fuer Tooltip oben-rechts */
}
.map-card .map-canvas {
    padding: 0.5rem 0 1rem;
    text-align: center;  /* SVG-Inline-Block zentriert */
}
.germany-map {
    width: 100%;
    max-width: 320px;
    height: auto;
    display: inline-block;
    overflow: visible;
    vertical-align: top;
}
.germany-map .country-outline {
    fill: var(--rule);
    fill-opacity: 0.55;
    stroke: var(--rule-strong);
    stroke-width: 0.6;
    stroke-linejoin: round;
}
.germany-map .marker {
    transition: r 0.12s ease, fill 0.12s ease, filter 0.12s ease;
    cursor: pointer;
}
.germany-map .marker.is-customer {
    fill: var(--accent);
    stroke: var(--surface);
    stroke-width: 1.2;
}
.germany-map .marker.is-test {
    fill: var(--accent-warm);
    fill-opacity: 0.85;
    stroke: var(--surface);
    stroke-width: 1.2;
}
.germany-map .marker-link:hover .marker,
.germany-map .marker-link:focus .marker {
    r: 6;
    filter: drop-shadow(0 1px 3px rgba(15, 61, 62, 0.35));
}
.germany-map .marker-link { outline: none; }
.map-legend {
    flex-direction: row;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--rule);
    padding-top: 0.85rem;
}
.map-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid var(--surface);
}
.map-dot-customer { background: var(--accent); }
.map-dot-test     { background: var(--accent-warm); opacity: 0.85; }

/* Lizenzen — Filter-Toolbar + sortierbare Spalten-Headers */
.toolbar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: flex-end;
}
.toolbar-filters label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: var(--ink-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.toolbar-filters input[type="search"],
.toolbar-filters select {
    font: inherit;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--rule-strong);
    background: var(--surface);
    color: var(--ink);
    border-radius: 2px;
    text-transform: none;
    letter-spacing: 0;
    min-width: 9rem;
}
.toolbar-filters input[type="search"] { min-width: 14rem; }
.toolbar-filters .quick {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.sortable-table th.sortable {
    padding: 0;
}
.sortable-table th.sortable a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.75rem 0.6rem;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}
.sortable-table th.sortable.right a { flex-direction: row-reverse; }
.sortable-table th.sortable a:hover { background: var(--bg); }
.sortable-table th.is-sorted a {
    color: var(--accent);
    background: rgba(15, 61, 62, 0.05);
}
.sortable-table .sort-icon {
    font-size: 0.7em;
    opacity: 0.35;
    font-variant-numeric: tabular-nums;
}
.sortable-table .sort-icon.is-active {
    opacity: 1;
    color: var(--accent);
}

/* Map-Tooltip — feste Position oben-rechts in der Karten-Card, statt ueber dem
   Marker. So stoert das Overlay die Karten-Uebersicht nicht. */
.map-tooltip {
    position: absolute;
    top: 5rem;       /* unter dem card-head (Titel + Meta-Zeile) */
    right: 1.5rem;
    background: var(--accent-deep);
    color: #f1ebd9;
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(10, 42, 43, 0.28), 0 1px 2px rgba(10, 42, 43, 0.18);
    pointer-events: none;
    opacity: 0;
    z-index: 10;
    min-width: 180px;
    max-width: 280px;
    line-height: 1.35;
    font-size: 0.85rem;
}
.map-tooltip.is-visible { opacity: 1; }
.map-tooltip .tt-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.92rem;
    color: #fefcf5;
    line-height: 1.25;
}
.map-tooltip .tt-city {
    font-weight: 400;
    color: rgba(241, 235, 217, 0.7);
}
.map-tooltip .tt-sub {
    margin-top: 0.2rem;
    font-size: 0.78rem;
    color: rgba(241, 235, 217, 0.78);
    font-variant-numeric: tabular-nums;
}
.map-tooltip .tt-status {
    font-weight: 500;
}
.map-tooltip .tt-status.is-customer { color: #b7e0e2; }
.map-tooltip .tt-status.is-test     { color: #f0c79f; }

/* Marker-Fokus (Keyboard-Nav) */
.germany-map .marker:focus {
    outline: none;
    r: 6;
    filter: drop-shadow(0 1px 3px rgba(15, 61, 62, 0.5));
}
