/* Medica – App-Styles (ergänzend zum DevExtreme-Light-Theme). */

:root {
    --brand: #b03a48;
    --brand-dark: #8f2c39;
    --brand-soft: #fbeef0;
    --accent: #2f6fb0;          /* zweite Linie im Diagramm (unterer Wert) */
    --bg: #f5f2f3;
    --card: #ffffff;
    --text: #23272f;
    --muted: #6b7280;
    --danger: #c0392b;
    --border: #e5e0e2;
    --ok: #2e7d4f;
    --tabbar-h: 62px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

h2 { font-size: 17px; margin: 0 0 12px; }

/* ── Boot-Hinweis ─────────────────────────────────────────────────────────── */
.boot {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
}
.btn-primary { color: #fff; background: var(--brand); border: none; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { color: var(--brand); background: #fff; border: 1px solid var(--brand); }
.btn-secondary:hover { background: var(--brand-soft); }
.btn-danger { color: #fff; background: var(--danger); border: none; }
button:disabled { opacity: 0.6; cursor: default; }

.btn-small {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}
.btn-small.primary { background: var(--brand); border-color: var(--brand); color: #fff; }

.link-btn {
    border: none;
    background: none;
    padding: 0;
    color: var(--brand);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ── Eingabefelder ───────────────────────────────────────────────────────── */
input[type=text], input[type=email], input[type=datetime-local] {
    width: 100%;
    padding: 11px 12px;
    font-size: 16px;            /* ≥16px verhindert iOS-Zoom beim Fokus */
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fdfcfc;
    min-height: 46px;
}
input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(176, 58, 72, 0.15);
}
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 12px 0 4px;
    color: var(--muted);
}
label i { font-weight: 400; }

/* ── Anmeldung ───────────────────────────────────────────────────────────── */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    padding-top: max(24px, env(safe-area-inset-top));
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border-radius: 18px;
    padding: 28px 22px 22px;
    box-shadow: 0 10px 40px rgba(70, 20, 30, 0.10);
}
.login-logo { display: block; margin: 0 auto; border-radius: 16px; }
.login-card h1 { margin: 10px 0 2px; text-align: center; font-size: 24px; }
.login-sub { margin: 0 0 20px; text-align: center; color: var(--muted); font-size: 14px; }
.login-hint { font-size: 13px; color: var(--muted); line-height: 1.45; margin: 14px 0 0; }
.login-switch { text-align: center; font-size: 14px; color: var(--muted); margin: 18px 0 0; }
.login-or {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0 4px;
    color: var(--muted);
    font-size: 13px;
}
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-msg {
    margin-top: 14px;
    min-height: 18px;
    font-size: 14px;
    color: var(--danger);
    text-align: center;
    line-height: 1.4;
}
.sent-icon { font-size: 44px; text-align: center; }
.sent-text { font-size: 15px; line-height: 1.5; text-align: center; }

/* ── App-Gerüst ──────────────────────────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.app-logo { border-radius: 7px; }
.app-title { font-weight: 700; font-size: 18px; color: var(--brand); }

.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.tab.active { background: var(--brand-soft); color: var(--brand); }

.app-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px;
}

/* Handy: Tabs als Leiste unten, gut mit dem Daumen erreichbar. */
@media (max-width: 640px) {
    .tabs {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 20;
        margin: 0;
        gap: 0;
        background: var(--card);
        border-top: 1px solid var(--border);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .tab {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        height: var(--tabbar-h);
        justify-content: center;
        border-radius: 0;
        font-size: 12px;
    }
    .tab .tab-icon { font-size: 20px; }
    .tab.active { background: none; }
    .tab.active span:last-child { color: var(--brand); }
    .tab:not(.active) .tab-icon { filter: grayscale(1); opacity: 0.6; }
    .app-main { padding: 12px 12px calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); }
}

/* ── Karten ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.card-head h2 { margin: 0; }
.hint { font-size: 14px; color: var(--muted); line-height: 1.45; margin: 0 0 10px; }

/* ── Erfassungsformular ──────────────────────────────────────────────────── */
.fields { display: flex; gap: 10px; flex-wrap: wrap; }
.field { position: relative; flex: 1 1 140px; min-width: 0; }
.field.grow { flex: 3 1 200px; }
.field.big input { font-size: 24px; font-weight: 600; padding-right: 56px; text-align: left; }
.field .unit {
    position: absolute;
    right: 12px;
    bottom: 14px;
    font-size: 13px;
    color: var(--muted);
    pointer-events: none;
}
.align-end { align-self: flex-end; height: 46px; }
.entry-form.editing { outline: 2px solid var(--brand); }
.entry-form { scroll-margin-top: 72px; }   /* nicht unter der festen Kopfzeile verschwinden */

@media (max-width: 640px) {
    .fields.three { flex-wrap: nowrap; gap: 8px; }
    .fields.three .field { flex: 1 1 0; }
    .field.big input { font-size: 22px; padding-right: 12px; padding-bottom: 22px; }
    .field.big .unit { bottom: 6px; left: 12px; right: auto; font-size: 11px; }
}

/* ── Zeitraum-Chips ──────────────────────────────────────────────────────── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Kennzahlen ──────────────────────────────────────────────────────────── */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin: 12px 0;
}
.stat {
    background: var(--bg);
    border-radius: 10px;
    padding: 10px 12px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 12px; font-weight: 500; color: var(--muted); }

.chart { height: 240px; margin: 4px -4px 8px; }
.chart.empty { height: auto; }

/* ── Einträge ────────────────────────────────────────────────────────────── */
.entries { border-top: 1px solid var(--border); }
.entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 2px;
    border-bottom: 1px solid var(--border);
}
.entry-main { flex: 1; min-width: 0; }
.entry-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.entry-meta { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.entry-actions { display: flex; gap: 2px; }
.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: none;
    font-size: 17px;
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
.empty-text { color: var(--muted); font-size: 14px; padding: 16px 2px; text-align: center; }
.more-btn { margin-top: 10px; }

/* ── Konto ───────────────────────────────────────────────────────────────── */
.kv { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 15px; }
.kv span { color: var(--muted); }
.kv b { overflow-wrap: anywhere; text-align: right; }
.passkey-list { margin-bottom: 4px; }
.passkey-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.passkey-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.passkey-label { font-weight: 600; overflow-wrap: anywhere; }
.passkey-meta { font-size: 13px; color: var(--muted); }
.danger-zone h2 { color: var(--danger); }

/* ── Passkey-Hinweis ─────────────────────────────────────────────────────── */
.nudge {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--brand-soft);
    border: 1px solid #f0cfd4;
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.45;
}
.nudge-text { flex: 1 1 240px; }
.nudge-actions { display: flex; gap: 8px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.app-toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 100;
    max-width: min(92vw, 520px);
    padding: 12px 16px;
    border-radius: 10px;
    background: #2b2f36;
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}
.app-toast.error { background: var(--danger); }
@media (max-width: 640px) {
    .app-toast { bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); }
}

.install-help ol { padding-left: 20px; line-height: 1.6; }
