/* Datei: /assets/css/app.css */

:root {
    --bg: #f5f2ed;
    --panel: #fffaf3;
    --panel-strong: #f0e5d7;
    --text: #2f251d;
    --muted: #76685c;
    --line: #dacdbe;
    --accent: #0f8d5a;
    --accent-strong: #0b7047;
    --danger: #b42318;
    --warn: #a15c00;
    --ok: #147a43;
    --shadow: 0 12px 28px rgba(49, 39, 30, .09);
    --radius: 16px;
}

* { box-sizing: border-box; }

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

body { font-size: 14px; }

.topbar {
    max-width: 1480px;
    margin: 18px auto 0;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar h1, .login-box h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -.02em;
}

.topbar p { margin: 3px 0 0; color: var(--muted); }

.wrap {
    max-width: 1480px;
    margin: 0 auto 40px;
    padding: 0 18px 30px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin: 16px 0;
}

.panel h2 { margin: 0 0 10px; font-size: 18px; }
.panel.success { border-color: rgba(20, 122, 67, .3); }
.panel.error { border-color: rgba(180, 35, 24, .35); }

.muted { color: var(--muted); }

.btn {
    appearance: none;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 8px 12px;
    min-height: 36px;
    background: var(--panel-strong);
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn:hover { filter: brightness(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; }

.alert {
    border-radius: 12px;
    padding: 10px 12px;
    margin: 10px 0;
    border: 1px solid var(--line);
}
.alert-error { background: #fff0ee; color: var(--danger); border-color: #efb5ad; }
.alert-warn { background: #fff5e5; color: var(--warn); border-color: #f1c37e; }

.upload-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.upload-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-radius: 14px;
    border: 1px dashed #bea98f;
    background: #fffdf9;
}

.upload-card.required { border-style: solid; border-color: var(--accent); }
.upload-title { font-weight: 700; }
.upload-sub { color: var(--muted); font-size: 13px; }
.upload-card input { width: 100%; }
.upload-form .btn { justify-self: start; grid-column: 1 / -1; }

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.stat {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px;
    background: #fffdf9;
}
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); }

.table-wrap {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fffdf9;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 8px 9px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

th {
    background: var(--panel-strong);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

tr:last-child td { border-bottom: none; }

.small-table { max-width: 850px; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eee4d7;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.status-new { background: #e4f5eb; color: var(--ok); }
.status-exists { background: #ece7df; color: #61564b; }
.status-change { background: #fff0cc; color: #805300; }
.status-duplicate { background: #ffe3d6; color: #974000; }
.status-conflict { background: #ffe9e7; color: var(--danger); }
.status-skipped { background: #ececec; color: #777; }
.badge.full { background: #ffe9e7; color: var(--danger); }
.badge.ok { background: #e4f5eb; color: var(--ok); }

.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar input,
.toolbar select,
.field input {
    min-height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 7px 10px;
    background: #fff;
    color: var(--text);
}

.export-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px;
    background: #fffdf9;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 10px;
}

.contacts-table-wrap { max-height: 72vh; }
.contacts-table th { position: sticky; top: 0; z-index: 2; }
.contacts-table td small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
    white-space: normal;
    max-width: 520px;
}
.contacts-table td:nth-child(9) { white-space: normal; min-width: 320px; }
.contacts-table tr.hidden { display: none; }

.downloads {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.download-card {
    display: grid;
    gap: 4px;
    padding: 13px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fffdf9;
    color: var(--text);
    text-decoration: none;
}
.download-card span { color: var(--muted); font-size: 13px; }
.download-card:hover { border-color: var(--accent); }

.login-page {
    display: grid;
    place-items: center;
    padding: 20px;
}
.login-box {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 22px;
}
.field { display: grid; gap: 6px; margin: 14px 0; }
.field span { font-weight: 700; }
.field input { width: 100%; }

@media (max-width: 900px) {
    .upload-form, .stats-grid, .downloads { grid-template-columns: 1fr; }
    .section-head { flex-direction: column; }
    .topbar { align-items: flex-start; }
}

/* Kompakte Kontaktvorschau ohne horizontalen Scroll */
.contacts-table-wrap {
    overflow-x: hidden;
    max-height: 72vh;
}

.contacts-table {
    table-layout: fixed;
    width: 100%;
}

.contacts-table th,
.contacts-table td {
    padding: 5px 6px;
    line-height: 1.18;
    font-size: 13px;
    vertical-align: middle;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contacts-table th {
    font-size: 11px;
    letter-spacing: .025em;
}

.contacts-table th:nth-child(1),
.contacts-table td:nth-child(1) {
    width: 34px;
    text-align: center;
}

.contacts-table th:nth-child(2),
.contacts-table td:nth-child(2) {
    width: 102px;
}

.contacts-table th:nth-child(3),
.contacts-table td:nth-child(3) {
    width: 100px;
}

.contacts-table th:nth-child(4),
.contacts-table td:nth-child(4),
.contacts-table th:nth-child(5),
.contacts-table td:nth-child(5) {
    width: 13%;
}

.contacts-table th:nth-child(6),
.contacts-table td:nth-child(6) {
    width: 118px;
    white-space: nowrap;
}

.contacts-table th:nth-child(7),
.contacts-table td:nth-child(7) {
    width: 104px;
    white-space: nowrap;
}

.contacts-table th:nth-child(8),
.contacts-table td:nth-child(8) {
    width: 21%;
    white-space: nowrap;
}

.contacts-table th:nth-child(9),
.contacts-table td:nth-child(9) {
    width: auto;
    min-width: 0;
    white-space: normal;
}

.contacts-table td:nth-child(9) small {
    display: block;
    max-width: none;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contacts-table .badge {
    min-height: 20px;
    padding: 1px 7px;
    font-size: 11px;
}

.contacts-table input[type="checkbox"] {
    width: 15px;
    height: 15px;
}

@media (max-width: 1100px) {
    .contacts-table th,
    .contacts-table td {
        font-size: 12px;
        padding: 4px 5px;
    }

    .contacts-table th {
        font-size: 10px;
    }

    .contacts-table th:nth-child(2),
    .contacts-table td:nth-child(2) {
        width: 92px;
    }

    .contacts-table th:nth-child(3),
    .contacts-table td:nth-child(3) {
        width: 82px;
    }

    .contacts-table th:nth-child(6),
    .contacts-table td:nth-child(6) {
        width: 105px;
    }

    .contacts-table th:nth-child(7),
    .contacts-table td:nth-child(7) {
        width: 90px;
    }
}