/* ============================================================
   Zeitio v3 — Design-System (EINE Datei für alle Kontexte)
   Mobile-first; Desktop ab 640px. Tokens → Komponenten → Utilities.
   ============================================================ */

:root {
    --c-primary: #2563eb;
    --c-primary-dark: #1d4ed8;
    --c-success: #16a34a;
    --c-warn: #d97706;
    --c-danger: #dc2626;
    --c-bg: #f4f6fb;
    --c-surface: #ffffff;
    --c-text: #1e2433;
    --c-muted: #6b7280;
    --c-border: #e5e9f2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgb(16 24 40 / .08);
    --shadow-lg: 0 8px 30px rgb(16 24 40 / .12);
    --touch: 52px;
    --font: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px 32px; }
.main.landing { max-width: 520px; padding-top: 7vh; }

.footer { text-align: center; color: var(--c-muted); font-size: .85em; padding: 12px; }

/* ---------------- Navbar ---------------- */
.navbar {
    background: #1e2433;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
}
.navbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; gap: 12px;
}
.navbar-brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05em; white-space: nowrap; }
.nav-links { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; overflow-x: auto; flex: 1; }
.nav-links a { color: #cbd5e1; text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); white-space: nowrap; }
.nav-links a:hover, .nav-links a:focus { background: #2c3547; color: #fff; }
.navbar-form { margin-left: auto; }

/* ---------------- Cards / KPI ---------------- */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}
.card-title { margin: 0 0 14px; font-size: 1.15em; }
.page-title { font-size: 1.5em; margin: 8px 0 12px; }
.muted { color: var(--c-muted); font-size: .93em; }

.kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 20px; }
.kpi {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; text-align: center;
}
.kpi-value { font-size: 1.9em; font-weight: 700; color: var(--c-primary); }
.kpi-warn .kpi-value { color: var(--c-warn); }
.kpi-info .kpi-value { color: #0ea5e9; }
.kpi-label { color: var(--c-muted); font-size: .9em; }

/* ---------------- Forms ---------------- */
.form { display: flex; flex-direction: column; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 2px; }
.form-label { font-weight: 600; margin: 12px 0 6px; font-size: .95em; }
.input {
    width: 100%; padding: 14px 14px; font-size: 1em; font-family: var(--font);
    border: 1px solid #c9d3e2; border-radius: var(--radius-sm);
    background: #f8fafc; color: var(--c-text); min-height: var(--touch);
}
.input:focus { outline: 2px solid var(--c-primary); outline-offset: -1px; border-color: var(--c-primary); background: #fff; }
select.input { height: var(--touch); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.input-suffix {
    display: flex; align-items: center; padding: 0 12px;
    background: #eef2f9; border: 1px solid #c9d3e2; border-left: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--c-muted); font-size: .95em; white-space: nowrap;
}
.form-field-submit { margin-top: 16px; }
.form-field-submit .btn { width: 100%; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--touch); padding: 12px 22px; font-size: 1em; font-family: var(--font);
    font-weight: 600; border: none; border-radius: var(--radius-sm); cursor: pointer;
    background: #e9edf5; color: var(--c-text); text-decoration: none;
    transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-success { background: var(--c-success); color: #fff; }
.btn-warn { background: var(--c-warn); color: #fff; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--c-border); color: inherit; }
.navbar .btn-ghost { color: #cbd5e1; border-color: #3a455c; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .9em; }
.btn-block { width: 100%; margin-top: 18px; }
.btn-stempel { width: 100%; font-size: 1.2em; padding: 18px; }

.inline-form { display: inline-block; }
.action-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .95em; }
.table th {
    text-align: left; padding: 10px 12px; background: #eef2f9;
    border-bottom: 2px solid var(--c-border); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tr:hover td { background: #f8fafc; }
.table-actions { white-space: nowrap; }
.card > .table-wrap { margin: -6px -6px -6px; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .82em; font-weight: 600; background: #e9edf5; color: var(--c-text);
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-cancel { background: #fee2e2; color: #991b1b; }

/* ---------------- Flash / Logs / Misc ---------------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin: 14px 0; font-weight: 500; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { padding: 8px 0; border-bottom: 1px solid var(--c-border); font-size: .95em; }
.log-list li:last-child { border-bottom: none; }

.empty-state { text-align: center; color: var(--c-muted); padding: 24px 8px; }
.link { color: var(--c-primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

.center-box { max-width: 460px; margin: 6vh auto 0; }
.login-card { padding: 28px; }

.onetime-box { word-break: break-all; }
.onetime-code { display: block; margin-top: 6px; font-size: .95em; word-break: break-all; }

/* ---------------- Landing ---------------- */
.landing-hero { display: flex; flex-direction: column; }
.landing-card { padding: 28px 22px; }
.landing-title { font-size: 1.9em; margin: 0; text-align: center; }
.landing-sub { text-align: center; color: var(--c-muted); margin: 6px 0 18px; }
.landing-note { margin-top: 18px; font-size: .88em; color: var(--c-muted); text-align: center; }

/* ---------------- Stempeluhr ---------------- */
.stempel-card { padding: 24px; }
.stempel-status { font-size: 1.15em; font-weight: 600; margin: 12px 0 18px; }
.stempel-active { color: var(--c-success); }
.stempel-form { margin-bottom: 14px; }
.stempel-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.timer {
    font-size: 2.6em; font-weight: 700; text-align: center;
    color: var(--c-primary); letter-spacing: 2px; margin: 6px 0 14px;
    font-variant-numeric: tabular-nums;
}
.restzeit {
    background: #fef9c3; border: 1px solid #fde68a; color: #854d0e;
    border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: .95em;
}
.restzeit-kritisch { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.pause-hint { color: var(--c-warn); font-weight: 600; margin: 10px 0 14px; }

/* ---------------- Zeiten-Liste ---------------- */
.filter-bar { display: flex; gap: 8px; margin: 14px 0; align-items: center; }
.input-inline { width: auto; min-width: 110px; padding: 10px; min-height: 44px; }
.summe-bar {
    background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
    border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 0;
}
.zeit-card { padding: 16px; }
.zeit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.zeit-datum { font-weight: 700; color: #1e3a8a; }
.zeit-zeit { color: var(--c-muted); margin-left: 8px; }
.zeit-body { margin-top: 6px; font-size: .95em; }
.zeit-approved { border-left: 5px solid var(--c-success); }
.zeit-rejected { border-left: 5px solid var(--c-danger); }

.pagination { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 18px 0; }
.pause-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.pause-row .input { width: 110px; padding: 10px; min-height: 44px; }

/* ---------------- Mitteilungen ---------------- */
.msg-card { padding: 16px; border-left: 5px solid var(--c-warn); }
.msg-card[data-typ="stunden"] { border-left-color: var(--c-primary); }
.msg-card[data-typ="urlaub"] { border-left-color: var(--c-success); }
.msg-read { opacity: .65; background: #f9fafb; }
.msg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.msg-body { margin-bottom: 10px; }

/* ---------------- Phase 3: Formulare/Karte ---------------- */
.check { display: flex; align-items: center; gap: 8px; font-size: .95em; padding: 4px 0; min-height: 44px; }
.check input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--c-primary); }
.check-grid { display: grid; grid-template-columns: 1fr; gap: 2px; margin: 10px 0; }
.form-inline-fields { display: flex; gap: 8px; }
.geo-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.geo-row .geo-lat, .geo-row .geo-lng { width: 130px; min-height: 44px; }
.map-picker { height: 260px; border-radius: var(--radius-sm); border: 1px solid var(--c-border); margin-top: 8px; z-index: 1; }
.input-color { height: var(--touch); padding: 4px; width: 90px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: #eef2f9; border: 1px solid var(--c-border); border-radius: 999px; padding: 4px 10px; font-size: .85em; }

.plus { color: var(--c-success); }
.minus { color: var(--c-danger); }

/* ---------------- Phase 4: Kalender-Legende ---------------- */
.legende { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: .88em; color: var(--c-muted); align-items: center; }
.legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------------- Toast (JS) ---------------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: #1e2433; color: #fff; padding: 12px 20px; border-radius: 999px;
    box-shadow: var(--shadow-lg); z-index: 100; font-size: .95em; max-width: 90vw;
}
.toast-error { background: var(--c-danger); }
.toast-success { background: var(--c-success); }

.offline-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    background: var(--c-warn); color: #fff; text-align: center;
    padding: 10px; font-weight: 600; display: none;
}
body.is-offline .offline-banner { display: block; }

/* ---------------- Modal (Confirm) ---------------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgb(16 24 40 / .45); z-index: 90;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
    background: var(--c-surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 22px; max-width: 380px; width: 100%; text-align: center;
}
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ---------------- Desktop ---------------- */
@media (min-width: 640px) {
    .kpi-row { grid-template-columns: repeat(4, 1fr); }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid .form-field:nth-last-child(2) { grid-column: span 1; }
    .stempel-actions { flex-direction: row; }
    .btn-stempel { width: auto; min-width: 220px; }
    .card > .table-wrap { margin: 0; }
}
