/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --red:       #c0392b;
    --red-dark:  #962d22;
    --red-light: #e74c3c;
    --aml1:      #c0392b;
    --aml2:      #7b2d8b;
    --green:     #27ae60;
    --yellow:    #f39c12;
    --gray-50:   #f8f9fa;
    --gray-100:  #f1f3f5;
    --gray-200:  #e9ecef;
    --gray-400:  #ced4da;
    --gray-600:  #6c757d;
    --gray-800:  #343a40;
    --text:      #212529;
    --header-h:  56px;
    --nav-h:     60px;
    --radius:    12px;
    --shadow:    0 2px 12px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.18);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--gray-50);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===== HEADER ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--red);
    color: #fff;
    height: var(--header-h);
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1rem;
    max-width: 900px;
    margin: 0 auto;
}
.logo {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}
.logo-cross { font-size: 1.4rem; font-weight: 900; }
.header-nav { display: flex; gap: .5rem; align-items: center; }
.nav-link {
    color: rgba(255,255,255,.85);
    font-size: .85rem;
    padding: .3rem .7rem;
    border-radius: 6px;
    text-decoration: none;
    transition: background .15s;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.2); color: #fff; }
.nav-logout { border: 1px solid rgba(255,255,255,.4); }

/* ===== MAIN ===== */
.app-main {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: calc(var(--nav-h) + 1rem);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    z-index: 100;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    display: flex;
    height: var(--nav-h);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--gray-600);
    text-decoration: none;
    font-size: .65rem;
    font-weight: 500;
    transition: color .15s;
}
.bottom-nav-item svg {
    width: 22px; height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.bottom-nav-item.active, .bottom-nav-item:hover { color: var(--red); }

/* ===== LOGIN ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #c0392b 0%, #7b2d8b 100%);
}
.login-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.install-box { max-width: 480px; }
.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}
.logo-cross-big {
    display: block;
    font-size: 3rem;
    font-weight: 900;
    color: var(--red);
    line-height: 1;
}
.login-logo h1 { font-size: 1.8rem; font-weight: 800; margin: .2rem 0 .1rem; }
.login-logo p { color: var(--gray-600); font-size: .85rem; }
.login-version { text-align: center; font-size: .75rem; color: var(--gray-600); margin-top: 1.5rem; }
.config-output {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 1rem;
    font-size: .75rem;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 1rem 0;
    max-height: 300px;
    overflow-y: auto;
}

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--gray-800); }
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-group input,
.form-group select,
.form-group textarea {
    padding: .6rem .8rem;
    border: 1.5px solid var(--gray-400);
    border-radius: 8px;
    font-size: .95rem;
    background: #fff;
    color: var(--text);
    transition: border-color .15s;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}
.login-form { display: flex; flex-direction: column; gap: .9rem; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .9rem;
    cursor: pointer;
}
.checkbox-item input[type=checkbox] {
    width: 16px; height: 16px;
    accent-color: var(--red);
    flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1.2rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-400); color: var(--gray-800); }
.btn-outline:hover { border-color: var(--red); color: var(--red); }
.btn-white { background: #fff; color: var(--red); }
.btn-white:hover { background: var(--gray-100); }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-full { width: 100%; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }

/* ===== ALERTS ===== */
.alert {
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-error { background: #fdecea; border: 1px solid #f5c6cb; color: #721c24; }
.alert-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.alert-warning { background: #fff3cd; border: 1px solid #ffeeba; color: #856404; }

/* ===== HOME PAGE ===== */
.check-banner {
    background: linear-gradient(135deg, var(--red) 0%, var(--aml2) 100%);
    color: #fff;
    padding: 1.5rem 1.25rem;
    margin: 0;
}
.check-banner h2 { font-size: 1.3rem; margin-bottom: .25rem; }
.check-banner p { font-size: .9rem; opacity: .9; margin-bottom: 1rem; }

.search-bar-wrap {
    padding: .75rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: var(--header-h);
    z-index: 50;
}
.search-bar {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: 10px;
    padding: .5rem .75rem;
    gap: .5rem;
}
.search-icon {
    width: 18px; height: 18px;
    stroke: var(--gray-600);
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
}
#searchInput {
    border: none;
    background: transparent;
    flex: 1;
    font-size: .95rem;
    outline: none;
    color: var(--text);
}
.search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    font-size: .9rem;
    padding: 0 .2rem;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
    gap: 1rem;
}
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.aml-section { padding: 1rem 1rem 0; }
.aml-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: .75rem;
    color: #fff;
}
.aml-header.aml1 { background: var(--aml1); }
.aml-header.aml2 { background: var(--aml2); }
.aml-badge {
    background: rgba(255,255,255,.25);
    padding: .2rem .6rem;
    border-radius: 6px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .05em;
}
.aml-header h2 { font-size: 1rem; font-weight: 700; flex: 1; }
.aml-header p { font-size: .8rem; opacity: .85; }

.kb-grid {
    display: grid;
    gap: .6rem;
    margin-bottom: 1rem;
}
.kb-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .9rem 1rem;
    cursor: pointer;
    border-left: 4px solid transparent;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.kb-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kb-card.aml1 { border-left-color: var(--aml1); }
.kb-card.aml2 { border-left-color: var(--aml2); }
.kb-card-body { flex: 1; min-width: 0; }
.kb-card-name { font-weight: 600; font-size: .95rem; }
.kb-card-meds { font-size: .78rem; color: var(--gray-600); margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-card-arrow { color: var(--gray-400); font-size: 1.1rem; }
.kb-skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: var(--radius);
    height: 64px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== SEARCH RESULTS ===== */
.search-results { padding: .5rem 1rem; }
.search-results .kb-card { margin-bottom: .5rem; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
@media (min-width: 600px) {
    .modal-overlay { align-items: center; }
}
.modal {
    background: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
    position: relative;
    -webkit-overflow-scrolling: touch;
}
@media (min-width: 600px) {
    .modal { border-radius: var(--radius); }
}
.modal-close {
    position: absolute;
    top: .9rem; right: .9rem;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    width: 32px; height: 32px;
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--gray-800);
}
.modal-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem; padding-right: 2rem; }

/* KB Detail in Modal */
.kb-detail-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: .75rem;
    padding-right: 2rem;
}
.aml-tag {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 700;
    margin-bottom: .5rem;
    color: #fff;
}
.aml-tag.aml1 { background: var(--aml1); }
.aml-tag.aml2 { background: var(--aml2); }

.abcd-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.abcd-table td { padding: .4rem .5rem; vertical-align: top; font-size: .85rem; border-bottom: 1px solid var(--gray-100); }
.abcd-table td:first-child { font-weight: 800; width: 24px; color: var(--red); }

.section-title {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gray-600);
    margin: 1rem 0 .4rem;
}

.ki-box {
    background: #fdecea;
    border: 1.5px solid var(--red);
    border-radius: 8px;
    padding: .6rem .8rem;
    margin-bottom: .5rem;
}
.ki-box-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--red);
    margin-bottom: .3rem;
}
.ki-item { font-size: .85rem; display: flex; align-items: flex-start; gap: .4rem; }
.ki-item::before { content: '⚠'; font-size: .9rem; flex-shrink: 0; }

.dosis-gruppe { margin-bottom: 1rem; }
.dosis-gruppe-title {
    font-size: .75rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .35rem;
}
.dosis-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: .6rem .8rem;
    margin-bottom: .35rem;
}
.dosis-card-label {
    display: inline-block;
    background: var(--gray-200);
    color: var(--gray-800);
    font-size: .7rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 4px;
    margin-bottom: .3rem;
}
.dosis-card-main { font-size: 1rem; font-weight: 700; color: var(--text); }
.dosis-card-wirkstoff { font-size: .8rem; color: var(--gray-600); margin-bottom: .2rem; }
.dosis-card-hint { font-size: .8rem; color: var(--gray-600); font-style: italic; margin-top: .2rem; }
.dosis-card-wdh {
    font-size: .78rem;
    color: var(--green);
    font-weight: 600;
    margin-top: .3rem;
    display: flex;
    align-items: flex-start;
    gap: .3rem;
}
.dosis-card-wdh::before { content: '↺'; }

.hinweis-box {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: .6rem .8rem;
    font-size: .85rem;
    margin-top: .5rem;
}
.hinweis-item { margin-bottom: .25rem; }
.hinweis-item:last-child { margin-bottom: 0; }

/* ===== KI-CHECK ===== */
.modal-check { padding-bottom: 2rem; }
.check-form { display: flex; flex-direction: column; gap: .9rem; }
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem .75rem;
}
.check-result { margin-top: 1.25rem; }
.check-safe {
    background: #d4edda;
    border: 1.5px solid #28a745;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    color: #155724;
    font-weight: 700;
}
.check-warn {
    background: #fdecea;
    border: 1.5px solid var(--red);
    border-radius: 8px;
    padding: 1rem;
}
.check-warn-title { font-weight: 800; color: var(--red); margin-bottom: .5rem; }
.check-warn-item { font-size: .88rem; margin-bottom: .3rem; display: flex; gap: .4rem; }
.check-warn-item::before { content: '⚠'; flex-shrink: 0; }

/* ===== ADMIN ===== */
.admin-page {
    padding: 1rem;
    max-width: 1000px;
    margin: 0 auto;
}
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.admin-header h1 { font-size: 1.4rem; font-weight: 800; }
.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    align-items: center;
}
.stat-num { font-size: 2rem; font-weight: 800; color: var(--red); }
.stat-label { font-size: .85rem; color: var(--gray-600); }
.admin-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.admin-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.admin-form { display: flex; flex-direction: column; gap: .75rem; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th { text-align: left; padding: .5rem .75rem; background: var(--gray-100); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.admin-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-info { background: #fff8e1; border: 1px solid #ffe082; border-radius: var(--radius); padding: 1rem 1.25rem; }
.admin-info h3 { margin-bottom: .5rem; font-size: .95rem; }
.admin-info ul { padding-left: 1.2rem; font-size: .88rem; display: flex; flex-direction: column; gap: .3rem; }
.abcd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; }
.add-form-details { margin-top: .5rem; }
.add-form-details summary { cursor: pointer; }
.add-form-details[open] summary { margin-bottom: .5rem; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-nfs { background: #cce5ff; color: #004085; }
.badge-admin { background: #f8d7da; color: #721c24; }
.badge-ok { background: #d4edda; color: #155724; }
.badge-off { background: var(--gray-200); color: var(--gray-600); }
.badge-ki { background: #fdecea; color: var(--red); }

/* ===== ERROR PAGE ===== */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}
.error-page h1 { font-size: 5rem; font-weight: 900; color: var(--gray-200); }
.error-page p { color: var(--gray-600); margin: .5rem 0 1.5rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .admin-stats { grid-template-columns: repeat(3, 1fr); }
    .stat-num { font-size: 1.5rem; }
    .form-row { flex-direction: column; }
    .checkbox-grid { grid-template-columns: 1fr; }
    .admin-header h1 { font-size: 1.15rem; }
}

/* ===== CHECK PAGE ===== */
.check-page {
    padding: 1rem;
    max-width: 620px;
    margin: 0 auto;
}
.check-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.check-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
}
.check-subtitle {
    font-size: .88rem;
    color: var(--gray-600);
    margin-top: -.5rem;
}
.check-result {
    margin-top: .5rem;
}
