/* Stunden — iOS-Dark-Design, mobile-first */

:root {
    --bg: #000000;
    --card: #1c1c1e;
    --card2: #2c2c2e;
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --sep: rgba(84, 84, 88, 0.5);
    --label: #ffffff;
    --label2: rgba(235, 235, 245, 0.72);
    /* Bewusst kräftiger als in iOS üblich: die App wird bei Sonnenlicht
       im Traktor gelesen, 0.32 war dort faktisch unsichtbar. */
    --label3: rgba(235, 235, 245, 0.55);
    --green: #30d158;
    --green-deep: #1ea94a;
    --blue: #0a84ff;
    --orange: #ff9f0a;
    --red: #ff453a;
    --radius: 14px;
    --pad: 16px;
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Muss die Layout-Regeln unten schlagen (z. B. .form-row { display: flex }),
   sonst bleibt ein per JS gesetztes hidden wirkungslos. */
[hidden] { display: none !important; }

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

body {
    background: var(--bg);
    color: var(--label);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
    min-height: 100dvh;
}

.page {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 var(--pad);
}

/* ————— Header ————— */

.nav-header { padding-top: calc(var(--sat) + 10px); }

.nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
}

.nav-back {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    color: var(--green);
    text-decoration: none;
    font-size: 17px;
    margin-left: -12px;
    padding: 11px 12px;   /* 44px Trefferfläche */
}

.nav-action {
    background: var(--card);
    color: var(--green);
    border: none;
    font-size: 26px;
    font-weight: 500;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding-bottom: 3px;
    margin-left: auto;
}

.large-title {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: 0.2px;
    margin-top: 2px;
}

.header-sub {
    color: var(--label2);
    font-size: 15px;
    margin-top: 1px;
}

/* ————— Content / Tabbar ————— */

.content {
    padding: 14px 0 calc(84px + var(--sab));
}

body.no-tabbar .content { padding-bottom: 40px; }

.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: space-around;
    padding: 6px 8px calc(6px + var(--sab));
    background: rgba(22, 22, 24, 0.82);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    border-top: 0.5px solid var(--sep);
    z-index: 40;
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--label3);
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 500;
    min-width: 64px;
    padding: 2px 0;
}

.tab.active { color: var(--green); }

/* ————— Cards & Listen ————— */

.card {
    background: var(--card);
    border-radius: var(--radius);
    margin-bottom: 14px;
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 14px 7px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--label2);
}

.section-header-detail {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--label3);
}

.section-header-detail.warn { color: var(--orange); }

.list-card { padding: 0; }

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: none;
    color: var(--label);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    position: relative;
}

.list-row + .list-row::before,
.list-row-form .list-row::before {
    content: "";
    position: absolute;
    left: 14px; right: 0; top: 0;
    border-top: 0.5px solid var(--sep);
}

.list-row:active { background: var(--card2); }

.list-row .icn:last-child { color: var(--label3); flex: none; }

.list-empty {
    padding: 22px 16px;
    color: var(--label2);
    font-size: 15px;
    text-align: center;
}

.row-inactive { opacity: 0.45; }

.entry-icon {
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card2);
    border-radius: 10px;
    flex: none;
}

.entry-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.entry-title {
    font-weight: 600;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-sub {
    color: var(--label2);
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-hours {
    font-weight: 700;
    font-size: 16px;
    color: var(--green);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.muted { color: var(--label3); font-weight: 400; }

.row-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex: none;
}

.icon-blue { background: var(--blue); }
.icon-green { background: var(--green-deep); }
.icon-orange { background: var(--orange); }
.icon-red { background: var(--red); }
.icon-gray { background: #636366; }

.row-detail { color: var(--label2); font-size: 16px; }

.list-row-form { display: contents; }
.list-row-danger .entry-title { color: var(--red); }

/* ————— Tages-Karte ————— */

.day-card { padding: 16px; }

.day-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.day-hours {
    font-size: 44px;
    font-weight: 800;
    color: var(--green);
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.day-hours .unit {
    font-size: 20px;
    font-weight: 600;
    color: var(--label2);
    margin-left: 6px;
}

.day-times { color: var(--label2); font-size: 15px; margin-top: 4px; }

.day-note {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 0.5px solid var(--sep);
    color: var(--label2);
    font-size: 14.5px;
}

.btn-icon {
    background: var(--card2);
    border: none;
    color: var(--green);
    width: 44px; height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: none;
}

/* ————— Datum-Navigation ————— */

.date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.date-nav-btn {
    width: 46px; height: 46px;
    border-radius: 12px;
    background: var(--card);
    color: var(--green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex: none;
}

.date-nav-btn:active { background: var(--card2); }

.date-nav-current {
    flex: 1;
    height: 46px;
    background: var(--card);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    position: relative;
    cursor: pointer;
}

.date-nav-current input[type="date"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    border: none;
    font-size: 16px;   /* sonst zoomt iOS beim Fokus */
    -webkit-appearance: none;
}

/* ————— Statistik-Chips ————— */

.stat-chips {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.stat-chip {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 8px 10px;
    text-align: center;
}

.stat-chip strong {
    display: block;
    font-size: 24px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.stat-chip.accent strong { color: var(--green); }

.stat-chip span {
    color: var(--label2);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ————— Monat: Tageszeile ————— */

.day-date {
    width: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: none;
    background: var(--card2);
    border-radius: 10px;
    padding: 5px 0 4px;
}

.day-date strong { font-size: 18px; line-height: 1.1; }
.day-date span { font-size: 11px; color: var(--label2); }

/* ————— Bericht ————— */

.user-select-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border-radius: 12px;
    padding: 4px 14px;
    margin-bottom: 14px;
    color: var(--label2);
}

.user-select-wrap select {
    flex: 1;
    background: none;
    border: none;
    color: var(--label);
    font: inherit;
    font-weight: 600;
    padding: 10px 0;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.report-row { cursor: default; }

.report-bar {
    display: block;
    height: 4px;
    background: var(--fill);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.report-bar i {
    display: block;
    height: 100%;
    background: var(--green);
    border-radius: 2px;
}


.report-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}

/* ————— Buttons ————— */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font: inherit;
    font-size: 17px;
    font-weight: 600;
    padding: 14px 22px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.06s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.975); opacity: 0.85; }

.btn-primary { background: var(--green); color: #003310; }
.btn-secondary { background: var(--card); color: var(--green); }
.btn-block { width: 100%; margin-bottom: 10px; }

.btn-danger-plain {
    background: none;
    color: var(--red);
    width: 100%;
    padding: 13px;
    font-size: 16px;
    /* Deutlicher Abstand zu „Speichern" — sonst ist der Vertipper teuer */
    margin-top: 14px;
}

/* Zweizeiliger Button: Titel + kleine Erläuterung */
.btn-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.btn-stack small {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--label2);
}

/* ————— Formulare ————— */

.form-card {
    background: var(--card);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    min-height: 50px;
    position: relative;
}

.form-row + .form-row::before,
.form-row + .calc-row::before {
    content: "";
    position: absolute;
    left: 14px; right: 0; top: 0;
    border-top: 0.5px solid var(--sep);
}

.form-row > span:first-child { color: var(--label); font-size: 16px; flex: none; }

.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row input[type="time"],
.form-row select {
    background: none;
    border: none;
    color: var(--label);
    font: inherit;
    font-size: 16px;
    text-align: right;
    flex: 1;
    min-width: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-row input::placeholder { color: var(--label3); }

.form-row input[type="time"] {
    flex: none;
    background: var(--fill);
    border-radius: 8px;
    padding: 6px 10px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color-scheme: dark;
}

.form-row select { color-scheme: dark; }

.form-row-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
}

.form-row-stack > span:first-child { font-size: 13px; color: var(--label2); }
/* Muss `.form-row input[type=...]` (rechtsbündig) überstimmen — daher gleich spezifisch */
.form-row.form-row-stack input { text-align: left; }

.row-input-suffix {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: flex-end;
}

.row-input-suffix input { text-align: right; max-width: 110px; }
.row-input-suffix em { font-style: normal; color: var(--label2); font-size: 15px; }

.input-narrow { max-width: 80px; }

/* Inline-Anlage eines neuen Kunden im Einsatz-Sheet */
.new-cust-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row .new-cust-fields input {
    background: var(--fill);
    border: none;
    border-radius: 8px;
    color: var(--label);
    font: inherit;
    font-size: 16px;
    text-align: left;
    padding: 10px 12px;
    outline: none;
    width: 100%;
}

.new-cust-fields input::placeholder { color: var(--label3); }

.calc-row strong { color: var(--green); font-size: 17px; font-variant-numeric: tabular-nums; }

/* Segmented Control */

.seg-control {
    display: flex;
    background: var(--fill);
    border-radius: 10px;
    padding: 2px;
    margin-bottom: 12px;
}

.seg {
    flex: 1;
    border: none;
    background: none;
    color: var(--label2);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 4px;
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
}

/* Aktiver Zustand muss auch bei Sonne eindeutig sein — nicht Grau auf Grau */
.seg.active {
    background: var(--green);
    color: #003310;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* iOS Switch */

.switch { position: relative; display: inline-block; flex: none; }

.switch input {
    position: absolute;
    opacity: 0;
    width: 100%; height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}

.switch i {
    display: block;
    width: 51px; height: 31px;
    background: var(--fill-strong);
    border-radius: 16px;
    transition: background 0.18s ease;
    position: relative;
}

.switch i::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 27px; height: 27px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: transform 0.18s ease;
}

.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ————— Sheets (Bottom-Modals) ————— */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 60;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
    background: #161618;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    border-radius: 18px 18px 0 0;
    padding: 8px 16px calc(20px + var(--sab));
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    overscroll-behavior: contain;
}

.sheet-backdrop.open .sheet { transform: translateY(0); }

.sheet-handle {
    width: 38px; height: 5px;
    background: var(--fill-strong);
    border-radius: 3px;
    margin: 4px auto 10px;
}

/* Titelzeile mit Schließen-Knopf: der Backdrop allein ist auf dem iPhone
   oft verdeckt (Tastatur, Zeit-Rad) und damit kein verlässlicher Ausweg. */
.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.sheet-title {
    font-size: 20px;
    font-weight: 700;
}

.sheet-close {
    flex: none;
    width: 44px; height: 44px;
    margin-right: -10px;
    border: none;
    background: none;
    color: var(--label2);
    font: inherit;
    font-size: 17px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sheet .form-card { background: var(--card2); }
.sheet .form-row input[type="time"] { background: var(--fill-strong); }

/* ————— Empty State ————— */

.empty-state {
    text-align: center;
    padding: 46px 20px 30px;
}

.empty-icon {
    color: var(--label3);
    margin-bottom: 14px;
}

.empty-state h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }

.empty-state p { color: var(--label2); font-size: 15px; margin-bottom: 20px; }

/* ————— Toast ————— */

.toast {
    position: fixed;
    top: calc(var(--sat) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--card2);
    color: var(--label);
    font-size: 15px;
    font-weight: 600;
    padding: 11px 20px;
    border-radius: 22px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
    max-width: calc(100vw - 32px);
    text-align: center;
    animation: toast-in 0.3s ease;
}

/* Fehler müssen auch bei Sonne auffallen — gefüllt statt nur farbiger Text */
.toast-error { background: var(--red); color: #fff; }
.toast-success { color: var(--green); }

/* Dauerhafter Hinweis, solange kein Netz da ist.
   pointer-events:none, damit das Banner keine Taps auf den Header schluckt;
   .is-offline schiebt den Seiteninhalt entsprechend nach unten. */
.offline-bar {
    position: fixed;
    left: 0; right: 0; top: 0;
    padding: calc(var(--sat) + 7px) 16px 7px;
    background: var(--orange);
    color: #3a2400;
    font-size: 13.5px;
    font-weight: 700;
    text-align: center;
    z-index: 110;
    pointer-events: none;
}

.is-offline .nav-header,
.is-offline .login-wrap { padding-top: 34px; }
.is-offline .toast { top: calc(var(--sat) + 46px); }

.toast.hide { opacity: 0; transition: opacity 0.4s ease; }

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, -12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ————— Avatare / Hinweise ————— */

.avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green) 0%, #0f8f3c 100%);
    color: #00280c;
    font-size: 21px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.avatar-sm { width: 36px; height: 36px; font-size: 16px; }

.profile-card .list-row { cursor: default; padding: 14px; }

.hint-box {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    color: var(--label2);
    font-size: 13.5px;
    padding: 12px 14px;
    background: var(--card);
    border-radius: 12px;
    margin-top: 14px;
}

.hint-box .icn { flex: none; margin-top: 1px; }
.hint-box a { color: var(--green); }

.app-footer {
    text-align: center;
    color: var(--label3);
    font-size: 12.5px;
    margin-top: 22px;
    line-height: 1.6;
}

/* ————— Login ————— */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
}

.login-wrap {
    width: 100%;
    max-width: 360px;
    text-align: center;
    padding-bottom: 8vh;
}

.login-logo img {
    border-radius: 22px;
    box-shadow: 0 10px 40px rgba(48, 209, 88, 0.25);
}

.login-title {
    font-size: 30px;
    font-weight: 800;
    margin-top: 16px;
}

.login-sub {
    color: var(--label2);
    font-size: 15px;
    margin-bottom: 28px;
}

.login-error {
    background: rgba(255, 69, 58, 0.14);
    color: var(--red);
    font-size: 14.5px;
    font-weight: 600;
    padding: 11px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.input-group {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 14px;
    text-align: left;
}

.input-group input {
    width: 100%;
    background: none;
    border: none;
    color: var(--label);
    font: inherit;
    font-size: 17px;
    padding: 15px 16px;
    outline: none;
}

.input-group input + input { border-top: 0.5px solid var(--sep); }

.input-group input::placeholder { color: var(--label3); }

.login-hint {
    color: var(--label3);
    font-size: 13px;
    margin-top: 22px;
    line-height: 1.6;
}

/* ————— Desktop-Feinschliff ————— */

@media (min-width: 700px) {
    .tabbar {
        max-width: 560px;
        margin: 0 auto;
        border-radius: 18px 18px 0 0;
        border-left: 0.5px solid var(--sep);
        border-right: 0.5px solid var(--sep);
    }
}
