/* Theme: dunkel ist der Standard; hell über Betriebssystem (System) oder data-theme am <html>-Element. */
:root {
    --bg: #1f2229;
    --surface: #2a2e37;
    --surface-2: #343945;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    --border: #444a57;
    --accent: #4c8dff;
    --accent-text: #ffffff;
    --error: #ff6b6b;
    --notice-bg: #3a3320;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --bg: #f4f5f7;
        --surface: #ffffff;
        --surface-2: #eceef2;
        --text: #1d2025;
        --muted: #5b6270;
        --border: #cfd3db;
        --accent: #1b6ec2;
        --error: #c0392b;
        --notice-bg: #fff6d6;
        color-scheme: light;
    }
}

:root[data-theme="light"] {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #eceef2;
    --text: #1d2025;
    --muted: #5b6270;
    --border: #cfd3db;
    --accent: #1b6ec2;
    --error: #c0392b;
    --notice-bg: #fff6d6;
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
}

h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h1:focus { outline: none; }

a { color: var(--accent); }

.muted { color: var(--muted); margin: 0 0 1rem; }

.center-note { text-align: center; margin-top: 20vh; color: var(--muted); }

/* Kopfzeile mit Benutzermenü (oben links wie in Tempo) */
.app-header {
    display: flex;
    align-items: center;
    padding: .5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.user-menu { display: flex; align-items: center; gap: .75rem; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
    font-size: .9rem;
}

.user-name { font-size: 1.1rem; }

.app-content { padding: 1rem; }

/* Karten, Formulare */
.login-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.card {
    width: 100%;
    max-width: 24rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .5rem;
}

.card.narrow { max-width: 28rem; }

form { display: flex; flex-direction: column; gap: .25rem; }

label { margin-top: .75rem; font-size: .9rem; color: var(--muted); }

input {
    min-height: 2.75rem; /* Tippfläche für Touch */
    padding: .5rem .75rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: .375rem;
    font-size: 1rem;
}

input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
    min-height: 2.75rem;
    padding: .5rem 1rem;
    border-radius: .375rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
}

button.primary {
    margin-top: 1.25rem;
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

button:disabled { opacity: .6; cursor: not-allowed; }

button.link-button {
    min-height: 0;
    padding: .25rem .5rem;
    background: none;
    border: none;
    color: var(--accent);
}

.error { color: var(--error); margin: .75rem 0 0; padding-left: 0; list-style: none; }

.notice { padding: .5rem .75rem; background: var(--notice-bg); border-radius: .375rem; }

/* Blazor: Fehleranzeige und Ladebalken */
#blazor-error-ui {
    color-scheme: light only;
    background: #ffffe0;
    color: #000;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Es ist ein Fehler aufgetreten."; }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--surface-2);
    stroke-width: .6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto .2rem;
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Lade …"); }

/* Navigation und Tabellen */
.app-header { gap: 1.5rem; flex-wrap: wrap; }
.main-nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.main-nav a { padding: .5rem .75rem; border-radius: .375rem; text-decoration: none; color: var(--text); min-height: 2.75rem; display: inline-flex; align-items: center; }
.main-nav a.active { background: var(--surface-2); font-weight: 600; }

h2 { font-size: 1.15rem; margin: 0 0 .25rem; }

.table-wrap { overflow-x: auto; margin: .75rem 0; }

.data-table { border-collapse: collapse; width: 100%; min-width: 44rem; }
.data-table th, .data-table td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.data-table input[type="date"], .data-table input[type="time"], .data-table input[type="text"] { width: 100%; min-width: 6rem; }
.entry-row { background: var(--surface-2); }
.actions { white-space: nowrap; }
.actions button { min-height: 2.25rem; padding: .25rem .6rem; margin-right: .25rem; }

.nowrap { white-space: nowrap; }

.swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 50%; border: 1px solid var(--border); vertical-align: middle; margin-right: .35rem; }

.button-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.button-row button.primary { margin-top: 0; }
.day-nav input[type="date"] { min-width: 11rem; }

.inline-check { display: flex; align-items: center; gap: .5rem; color: var(--text); margin-top: .5rem; }
.inline-check input { min-height: 0; width: 1.1rem; height: 1.1rem; }

.card.wide { max-width: 32rem; margin-top: 1.5rem; }
input[type="color"] { padding: .15rem; width: 4rem; }

.summary { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: .75rem 0; }
.summary div { display: flex; flex-direction: column; }
.summary span { color: var(--muted); font-size: .85rem; }
.summary strong { font-size: 1.1rem; }

.warning { padding: .5rem .75rem; background: var(--notice-bg); border-left: 4px solid #e6a700; border-radius: .25rem; }

.button-link { display: inline-block; padding: .6rem 1rem; background: var(--accent); color: var(--accent-text); border-radius: .375rem; text-decoration: none; }

/* Smartphone: Tabellen als Karten (Spaltenbeschriftung über aria/Reihenfolge), große Tippflächen */
@media (max-width: 599px) {
    .data-table { min-width: 0; }
    .data-table thead { display: none; }
    .data-table tr { display: block; border: 1px solid var(--border); border-radius: .5rem; margin-bottom: .75rem; padding: .25rem; }
    .data-table td { display: block; border: none; padding: .25rem .5rem; }
    .data-table td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .75rem; }
    .actions button { min-height: 2.75rem; }
}

/* Benutzermenü */
.user-menu-wrap { position: relative; }
.user-menu-toggle { display: inline-flex; align-items: center; gap: .6rem; background: none; border: none; color: var(--text); padding: .25rem .5rem; min-height: 2.75rem; }
.avatar { position: relative; overflow: hidden; }
.avatar-photo { position: absolute; inset: 0; background-size: cover; background-position: center; }
.menu-backdrop { position: fixed; inset: 0; background: transparent; border: none; cursor: default; z-index: 40; min-height: 0; }
.user-menu-panel { position: absolute; top: calc(100% + .25rem); left: 0; z-index: 50; min-width: 15rem; padding: .35rem; background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); display: flex; flex-direction: column; }
.user-menu-panel button { text-align: left; background: none; border: none; min-height: 2.5rem; padding: .35rem .75rem; border-radius: .375rem; }
.user-menu-panel button:hover { background: var(--surface-2); }
.menu-sep { height: 1px; background: var(--border); margin: .35rem 0; }
.menu-label { color: var(--muted); font-size: .75rem; padding: .2rem .75rem; text-transform: uppercase; letter-spacing: .04em; }
.check { display: inline-block; width: 1.25rem; }

/* Dialog */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 60; }
.modal { position: fixed; z-index: 61; top: 4vh; left: 50%; transform: translateX(-50%); width: min(70rem, 96vw); max-height: 92vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: .6rem; padding: 1rem 1.25rem; outline: none; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.modal-header h2 { margin: 0; font-size: 1.25rem; }
.modal .close { min-width: 2.75rem; }
.modal h3 { font-size: 1rem; margin: .5rem 0 .25rem; }
.modal hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.modal form { max-width: 34rem; }

/* Monatsraster */
.month-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1.5rem; margin-bottom: .5rem; }
.month-nav h1 { margin: 0 .5rem; min-width: 11rem; text-align: center; font-size: 1.35rem; }
.month-totals { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; color: var(--muted); }
.month-totals strong { color: var(--text); }
.badge { background: var(--surface-2); border: 1px solid var(--border); border-radius: 1rem; padding: .1rem .6rem; }

.grid-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--border); border-radius: .5rem; }
.grid { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; text-align: center; font-weight: 400; white-space: nowrap; }
.grid thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); }
.grid .row-head { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: .35rem .6rem; min-width: 14rem; max-width: 20rem; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.grid thead .row-head { z-index: 4; }
.grid .sum-col { position: sticky; left: 14rem; z-index: 2; background: var(--surface); min-width: 4.5rem; padding: .35rem .5rem; font-weight: 600; }
.grid thead .sum-col { z-index: 4; }
.grid tfoot th, .grid tfoot td { position: sticky; bottom: 0; background: var(--surface); z-index: 3; border-top: 2px solid var(--border); }
.grid td { min-width: 4.4rem; }
.grid .weekend { background: var(--surface-2); }
.grid .holiday { background: color-mix(in srgb, #b23a48 35%, var(--surface)); }
.grid thead th.weekend, .grid thead th.holiday { z-index: 3; }
.grid .today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }

.head-btn, .cell { width: 100%; min-height: 2.25rem; padding: .2rem .3rem; background: none; border: none; color: inherit; border-radius: 0; }
.head-btn { display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-height: 3.2rem; }
.head-btn .dn { font-weight: 700; }
.head-btn .wd { font-size: .7rem; color: var(--muted); }
.head-btn .marks { font-size: .7rem; display: flex; gap: .2rem; min-height: .9rem; color: #e6a700; }
.cell:hover, .head-btn:hover { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.cell.total { font-weight: 600; }
.display-cell { display: inline-block; margin: .2rem; padding: .15rem .4rem; border-radius: .25rem; color: #fff; font-size: .85rem; }
.display-row .row-head { font-style: italic; }
.empty-note { text-align: left !important; padding: 1rem !important; white-space: normal !important; }

.day-list { display: none; list-style: none; margin: 0; padding: 0; }
.day-card { width: 100%; display: grid; grid-template-columns: 7rem 1fr auto; gap: .25rem .75rem; text-align: left; align-items: center; margin-bottom: .4rem; }
.day-card.weekend { background: var(--surface-2); }
.day-card.holiday { background: color-mix(in srgb, #b23a48 35%, var(--surface)); }
.day-card.today { outline: 2px solid var(--accent); }
.dc-flags { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.dc-flags:empty { display: none; }

select { min-height: 2.75rem; padding: .5rem .75rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: .375rem; font-size: 1rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .15rem 0 0; }

@media (max-width: 599px) {
    .grid-wrap { display: none; }
    .day-list { display: block; }
    .month-nav h1 { min-width: 0; font-size: 1.1rem; }
    .modal { top: 0; left: 0; transform: none; width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
}

/* Monatsabschluss */
.figures { min-width: 0; max-width: 34rem; }
.figures th { color: var(--muted); font-weight: 500; font-size: .95rem; width: 55%; }
.figures td { font-weight: 600; text-align: right; }
.warning-list { margin: .5rem 0 0; padding-left: 0; list-style: none; color: #e6a700; }

/* Administration */
.log-controls label { color: var(--muted); }
.log-controls input[type="text"] { min-width: 14rem; }
.log-view { background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; padding: .75rem; overflow: auto; max-height: 65vh; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .8rem; line-height: 1.35; word-break: break-word; margin: .5rem 0; }
.log-view .log-entry { white-space: pre-wrap; }
.log-view .lvl-err { color: var(--error); }
.log-view .lvl-wrn { color: #e6a700; }
code { background: var(--surface-2); padding: .1rem .4rem; border-radius: .25rem; user-select: all; }
