/* Audit & Wartungsmanagement — Grunddesign (Etappe 1) */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --danger: #b91c1c;
    --warn-bg: #fef3c7;
    --sidebar: #0f172a;
    --sidebar-text: #cbd5e1;
    --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Layout ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1rem 0.75rem;
}
.brand {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.4rem 0.6rem 1.2rem;
    color: #fff; font-weight: 600;
}
.brand-mark {
    display: inline-grid; place-items: center;
    width: 34px; height: 34px; border-radius: 8px;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 0.85rem;
}
.brand-name { font-size: 0.95rem; line-height: 1.25; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
    display: flex; justify-content: space-between; align-items: center;
    color: var(--sidebar-text); text-decoration: none;
    padding: 0.55rem 0.7rem; border-radius: 8px; font-size: 0.92rem;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .phase {
    font-size: 0.68rem; padding: 1px 7px; border-radius: 99px;
    background: rgba(255, 255, 255, 0.12); color: #e2e8f0;
}
.logout-form { margin: 0.5rem 0.4rem 0; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 0.8rem; }
.btn-link {
    background: none; border: 0; color: var(--sidebar-text); cursor: pointer;
    font-size: 0.85rem; padding: 0.3rem 0.3rem; text-align: left;
}
.btn-link:hover { color: #fff; }

.content { margin-left: 240px; padding: 1.6rem 2rem 3rem; }
.content h1 { margin: 0.2rem 0 0.4rem; font-size: 1.5rem; }
.content h2 { font-size: 1.05rem; margin: 0 0 0.6rem; }

/* ---------- Kennzahlen ---------- */
.cards {
    display: grid; gap: 0.9rem; margin: 1.2rem 0;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.1rem;
}
.card.warn { border-color: #f59e0b; background: var(--warn-bg); }
.metric { font-size: 1.9rem; font-weight: 700; }
.metric-label { color: var(--muted); font-size: 0.82rem; margin-top: 0.15rem; }

/* ---------- Panels / Tabellen ---------- */
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 1.2rem 0;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
tbody tr:hover { background: #f8fafc; }

.hint {
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius);
    padding: 0.9rem 1.1rem; margin: 1.2rem 0; font-size: 0.9rem;
}

/* ---------- Formulare / Meldungen ---------- */
.flash { border-radius: var(--radius); padding: 0.7rem 1rem; margin: 0 0 1rem; font-size: 0.9rem; }
.flash-error { background: #fee2e2; border: 1px solid #fca5a5; color: var(--danger); }
.flash-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.empty { font-style: italic; }

.btn {
    display: inline-block; border: 0; border-radius: 8px; cursor: pointer;
    padding: 0.55rem 1.1rem; font-size: 0.9rem; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }

/* ---------- Anmeldung ---------- */
.login-body {
    display: grid; place-items: center; min-height: 100vh;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #1d4ed8 140%);
}
.login-card {
    width: min(380px, 92vw); background: var(--surface);
    border-radius: 14px; padding: 2rem; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.login-brand { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.2rem; }
.login-brand h1 { font-size: 1.05rem; margin: 0; }
.login-card label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.8rem 0 0.3rem; }
.login-card input {
    width: 100%; padding: 0.55rem 0.7rem; font-size: 0.95rem;
    border: 1px solid var(--border); border-radius: 8px;
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.login-card .btn { margin-top: 1.1rem; }

/* ---------- Mobil / Tablet ---------- */
@media (max-width: 900px) {
    .sidebar {
        position: static; width: auto; flex-direction: column; padding: 0.6rem;
    }
    .sidebar nav { flex-direction: row; overflow-x: auto; gap: 0.2rem; }
    .sidebar nav a { white-space: nowrap; }
    .brand-name { display: none; }
    .content { margin-left: 0; padding: 1rem; }
}

/* ---------- Etappe 2: Kundenverwaltung & Bestandsdaten ---------- */

.page-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 0.6rem; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.35rem; }
.crumb { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.crumb:hover { color: var(--primary); }

.tabs {
    display: flex; flex-wrap: wrap; gap: 0.25rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.4rem; margin: 0.8rem 0 1.2rem;
}
.tabs a, .tab-disabled {
    padding: 0.45rem 0.8rem; border-radius: 7px; font-size: 0.88rem;
    text-decoration: none; color: var(--text);
}
.tabs a:hover { background: #eef2ff; }
.tabs a.active { background: var(--primary); color: #fff; }
.tab-disabled { color: var(--muted); }
.badge {
    display: inline-block; padding: 1px 8px; border-radius: 99px;
    background: #eef2ff; color: var(--primary-dark); font-size: 0.72rem; font-weight: 600;
}
.muted-badge { background: #f1f5f9; color: var(--muted); font-weight: 500; }
.phase { font-size: 0.68rem; background: #f1f5f9; color: var(--muted); padding: 1px 7px; border-radius: 99px; }

.filter-bar {
    display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.7rem 0.9rem; margin-bottom: 1rem;
}
.filter-bar input[type="text"] { flex: 1 1 220px; }

table.kv th, table.kv td { border-bottom: 1px solid var(--border); }
table.kv th { width: 190px; font-weight: 600; color: var(--muted); font-size: 0.82rem; vertical-align: top; }
table.list a { color: var(--primary-dark); text-decoration: none; }
table.list a:hover { text-decoration: underline; }

details.panel > summary {
    cursor: pointer; padding: 0.2rem 0; user-select: none;
}
details.panel[open] > summary { margin-bottom: 0.6rem; }
.edit-body { padding: 0.3rem 0.2rem 0.4rem; }
.add-panel { background: #f8fafc; }

.form-grid fieldset {
    border: 1px solid var(--border); border-radius: 8px;
    margin: 0 0 1rem; padding: 0.8rem 1rem;
}
.form-grid legend { font-size: 0.82rem; font-weight: 700; color: var(--muted); padding: 0 0.4rem; }
.form-row { display: grid; grid-template-columns: 220px 1fr; gap: 0.5rem; align-items: center; margin: 0.4rem 0; }
.form-row label { font-size: 0.85rem; color: var(--text); }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 0.45rem 0.6rem; font-size: 0.9rem;
    border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: 2px solid var(--primary); border-color: var(--primary);
}
.req { color: var(--danger); }
.form-actions { margin-top: 0.8rem; display: flex; gap: 0.6rem; }
.sub-list { margin-top: 0.8rem; }
.sub-list .small { margin: 0.4rem 0 0; }
.triple-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: 0.5rem; margin: 0.35rem 0; align-items: center; }
.quad-row { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1.4fr; gap: 0.5rem; margin: 0.35rem 0; }
.triple-row input, .quad-row input {
    padding: 0.4rem 0.55rem; font-size: 0.85rem;
    border: 1px solid var(--border); border-radius: 7px;
}
.inline-grid { display: flex; flex-direction: column; gap: 0.2rem; }

.entity-card h2 { font-size: 1.02rem; margin: 0 0 0.5rem; }
.entity-card h2.small-h { font-size: 0.95rem; }
.entity-head { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.link-list { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.9rem; }
.link-list li { margin: 0.15rem 0; }
.link-list .inactive a { color: var(--muted); text-decoration: line-through; }
.url-cell { max-width: 340px; overflow-wrap: anywhere; font-size: 0.82rem; }
.row-inactive td { color: var(--muted); }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.inline { display: inline; }
.check { display: flex; gap: 0.4rem; align-items: center; font-size: 0.88rem; }

.danger-zone { border-color: #fecaca; background: #fff5f5; }
.danger-zone > summary { color: var(--danger); }
.warn-text { background: #fee2e2; border: 1px solid #fca5a5; border-radius: 7px; padding: 0.6rem 0.8rem; font-size: 0.88rem; }

@media (max-width: 700px) {
    .form-row { grid-template-columns: 1fr; gap: 0.15rem; }
    .triple-row, .quad-row { grid-template-columns: 1fr; }
    table.kv th { width: auto; display: block; }
    table.kv th, table.kv td { display: block; width: 100%; }
}

/* ---------- Etappe 3: Audit-System ---------- */

.progress {
    width: 140px; height: 9px; background: #e2e8f0;
    border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle;
}
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.3s; }
.progress-bar.done { background: #16a34a; }
.progress-row { display: flex; align-items: center; gap: 0.8rem; margin: 0.6rem 0 0.2rem; flex-wrap: wrap; }
.progress-row .progress { width: 240px; }

.audit-meta { display: flex; gap: 1.4rem; flex-wrap: wrap; font-size: 0.9rem; }

.result-block {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 0.7rem 0.9rem; margin: 0.6rem 0; background: #fff;
}
.result-block.rb-warn { border-color: #f59e0b; background: #fffbeb; }
.result-block.rb-ok { border-color: #86efac; }
.result-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 1rem; margin-top: 0.5rem; }
.result-grid .form-row { grid-template-columns: 150px 1fr; }
.form-row-wide { grid-column: 1 / -1; }
.result-grid textarea { min-height: 38px; }
table.compact th, table.compact td { padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.status-cell { font-size: 0.8rem; }
.status-cell.ok { color: #166534; }
.status-cell.warn { color: #92400e; font-weight: 700; }
.small-h { font-size: 0.92rem; margin: 0.8rem 0 0.3rem; }
.sticky-actions {
    position: sticky; bottom: 0; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.8rem 1rem; align-items: center; gap: 1rem;
}
.edit-details > summary { cursor: pointer; color: var(--primary-dark); font-size: 0.85rem; user-select: none; }
.edit-details[open] > summary { margin-bottom: 0.5rem; }
.edit-row td { padding-top: 0.1rem; }

/* ---------- Etappe 4: Wartungsplan-System ---------- */
.plan-module {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 0.7rem 0.9rem; margin: 0.5rem 0; background: #fff;
}
.plan-module.selected { border-color: var(--primary); background: #f8faff; }
.pm-head { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.pm-select { gap: 0.5rem; }
.pm-price { font-size: 0.9rem; font-weight: 600; }
.pm-desc { margin: 0.2rem 0 0; }
.pm-config { margin-top: 0.6rem; border-top: 1px dashed var(--border); padding-top: 0.5rem; }
.pm-config.hidden { display: none; }
.variant-radios { display: flex; gap: 1rem; flex-wrap: wrap; }
.totals-row {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    border-top: 2px solid var(--primary); margin-top: 1rem; padding-top: 0.8rem;
    font-size: 1rem;
}
.tfoot .muted, tfoot .muted { background: #f8fafc; }
