/* ===========================================================================
   Lehrerland Verwaltung – Design System
   Anmutung: Claude Code – warmes Papier-Beige, Schwarz, Weiss, Terrakotta-Orange
   Typografie: Fraunces (Display/Serif) + Hanken Grotesk (Body)
   =========================================================================== */

:root {
    /* Farbpalette */
    --paper:        #f6f1e9;   /* warmes Hintergrund-Beige */
    --paper-2:      #efe8dc;   /* etwas dunkler */
    --surface:      #fffdf9;   /* Kartenweiss, leicht warm */
    --surface-2:    #faf6ef;
    --ink:          #211c16;   /* fast schwarz, warm */
    --ink-soft:     #4f463b;
    --muted:        #8a7e6e;   /* gedaempfter Text */
    --line:         #e6ddcd;   /* Rahmen */
    --line-strong:  #d8ccb6;

    --accent:       #c96442;   /* Terrakotta-Orange (Claude) */
    --accent-soft:  #e8896a;
    --accent-weak:  #f6e4da;   /* sehr heller Akzent-Hintergrund */
    --accent-ink:   #9a472d;

    --green:        #4f7a52;
    --green-weak:   #e4eede;
    --amber:        #a9772a;
    --amber-weak:   #f5e9cf;
    --red:          #b2452f;
    --red-weak:     #f6e0d8;

    --radius:       14px;
    --radius-sm:    9px;
    --radius-lg:    20px;

    --shadow-sm:    0 1px 2px rgba(40, 30, 15, 0.05);
    --shadow:       0 4px 16px -6px rgba(50, 35, 15, 0.14), 0 1px 3px rgba(50, 35, 15, 0.06);
    --shadow-lg:    0 18px 48px -18px rgba(50, 35, 15, 0.30);

    --font-body:    'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-mono:    'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

    --sidebar-w:    264px;
}

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        radial-gradient(circle at 12% 0%, rgba(201, 100, 66, 0.05), transparent 42%),
        radial-gradient(circle at 100% 100%, rgba(160, 130, 80, 0.06), transparent 45%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 560; line-height: 1.15; letter-spacing: -0.01em; color: var(--ink); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === App-Layout =========================================================== */
.app { display: flex; min-height: 100vh; }

/* --- Sidebar ------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    border-right: 1px solid var(--line);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 100%);
    display: grid; place-items: center;
    color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 20px;
    box-shadow: var(--shadow-sm); flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; color: var(--ink); }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-label { font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; font-weight: 600; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; border-radius: var(--radius-sm);
    color: var(--ink-soft); font-weight: 500; font-size: 14.5px;
    transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--paper-2); text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--accent-weak); color: var(--accent-ink); font-weight: 600; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { color: var(--accent-ink); }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--ink); color: var(--paper);
    display: grid; place-items: center; font-weight: 600; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.user-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }

/* --- Hauptbereich -------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 20px 34px; border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 249, 0.7); backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 24px; }
.topbar-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 30px 34px 56px; max-width: 1240px; width: 100%; }

/* === Komponenten ========================================================== */

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font-body); font-weight: 600; font-size: 14px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; transition: all .15s ease; white-space: nowrap; line-height: 1.2;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-ink); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--paper-2); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #95381f; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Karten */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }
.card-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2, .card-head h3 { font-size: 17px; }
.card-title-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Statistik-Karten */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px 22px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::after { content: ''; position: absolute; right: -28px; top: -28px; width: 90px; height: 90px; border-radius: 50%; background: var(--accent-weak); opacity: .5; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-weak); color: var(--accent-ink); display: grid; place-items: center; margin-bottom: 14px; position: relative; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-value { font-family: var(--font-display); font-size: 34px; font-weight: 600; line-height: 1; color: var(--ink); position: relative; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 7px; position: relative; }

/* Grid-Helfer */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.between { justify-content: space-between; align-items: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; } .mt-3 { margin-top: 30px; }
.mb-2 { margin-bottom: 20px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }

/* Quick-Action-Karten */
.action-card {
    display: flex; align-items: flex-start; gap: 16px; padding: 20px 22px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); transition: all .15s ease;
}
.action-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.action-card .stat-icon { margin-bottom: 0; }
.action-title { font-family: var(--font-display); font-size: 17px; font-weight: 560; color: var(--ink); }
.action-desc { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* Tabellen */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--muted); padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
    white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface-2); }
td .primary-cell { font-weight: 600; color: var(--ink); }
td .sub-cell { font-size: 12.5px; color: var(--muted); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.col-check { width: 38px; }
.col-actions { text-align: right; white-space: nowrap; }
.col-address { min-width: 260px; }

/* Sticky-Tabellenkopf: Spaltenüberschriften bleiben beim Scrollen sichtbar.
   Die Liste scrollt innerhalb des Rahmens (max-height wird per JS gesetzt),
   sodass Filter- und Auswahlleiste darüber ebenfalls sichtbar bleiben. */
.table-wrap[data-sticky-scroll] { overflow: auto; }
.table-wrap[data-sticky-scroll] thead th {
    position: sticky; top: 0; z-index: 5;
    box-shadow: inset 0 -1px 0 var(--line-strong);
}

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
    border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4;
    background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line-strong);
}
.badge-accent { background: var(--accent-weak); color: var(--accent-ink); border-color: transparent; }
.badge-green { background: var(--green-weak); color: var(--green); border-color: transparent; }
.badge-amber { background: var(--amber-weak); color: var(--amber); border-color: transparent; }
.badge-red { background: var(--red-weak); color: var(--red); border-color: transparent; }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Formulare */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field .req { color: var(--accent); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=search], select, textarea {
    font-family: var(--font-body); font-size: 14.5px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    padding: 10px 13px; width: 100%; transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.15);
}
input::placeholder { color: #b7ac9a; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a7e6e' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Checkbox */
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

/* Toolbar / Filter */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.toolbar .field { flex: 1; min-width: 160px; gap: 5px; }
.toolbar .grow { flex: 2; min-width: 220px; }

/* Flash-Nachrichten */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.flash {
    display: flex; align-items: flex-start; gap: 11px; padding: 13px 16px;
    border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
    border: 1px solid; box-shadow: var(--shadow-sm); animation: slideIn .3s ease;
}
.flash svg { width: 19px; height: 19px; flex-shrink: 0; margin-top: 1px; }
.flash-success { background: var(--green-weak); color: #2f5733; border-color: #c5dcc0; }
.flash-error { background: var(--red-weak); color: #8d3320; border-color: #e8c3b8; }
.flash-info { background: var(--accent-weak); color: var(--accent-ink); border-color: #eccdc0; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* Empty State */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--paper-2); color: var(--muted); display: inline-grid; place-items: center; margin-bottom: 16px; }
.empty-icon svg { width: 28px; height: 28px; }
.empty h3 { font-size: 19px; color: var(--ink-soft); margin-bottom: 6px; }

/* Pagination */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 24px; }
.pagination a, .pagination span {
    min-width: 36px; height: 36px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
    font-size: 14px; font-weight: 500; color: var(--ink-soft);
}
.pagination a:hover { background: var(--paper-2); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* Steps (Import) */
.steps { display: flex; gap: 10px; margin-bottom: 26px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; font-weight: 500; color: var(--muted); }
.step.active { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-weak); }
.step.done { color: var(--green); border-color: #c5dcc0; background: var(--green-weak); }
.step-num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--paper-2); color: var(--muted); }
.step.active .step-num { background: var(--accent); color: #fff; }
.step.done .step-num { background: var(--green); color: #fff; }

/* Definition list (Detailansicht) */
.dl { display: grid; grid-template-columns: 200px 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dl dt { background: var(--surface-2); padding: 13px 18px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.dl dd { background: var(--surface); padding: 13px 18px; font-size: 14.5px; }

/* Dropzone */
.dropzone {
    border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 44px 24px;
    text-align: center; background: var(--surface-2); transition: all .18s ease; cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-weak); }
.dropzone.error { border-color: var(--red); background: var(--red-weak); }
.dropzone.error .dz-file { color: var(--red); }
.dropzone svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 12px; }
.dropzone .dz-title { font-family: var(--font-display); font-size: 18px; color: var(--ink); }
.dropzone .dz-sub { font-size: 13px; color: var(--muted); margin-top: 5px; }
.dropzone .dz-file { margin-top: 14px; font-weight: 600; color: var(--accent-ink); }

/* Inline-Code / Pfade */
code, .mono { font-family: var(--font-mono); font-size: 0.86em; background: var(--paper-2); padding: 2px 6px; border-radius: 5px; color: var(--accent-ink); }

/* Auth-Layout */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; }
.auth-card { width: 100%; max-width: 430px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-brand .brand-mark { width: 54px; height: 54px; font-size: 27px; border-radius: 15px; }
.auth-brand h1 { font-size: 26px; }
.auth-brand p { color: var(--muted); font-size: 14px; }
.auth-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); }
.auth-foot { text-align: center; margin-top: 22px; font-size: 12.5px; color: var(--muted); }

/* Hilfsbanner */
.note { display: flex; gap: 12px; padding: 15px 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-soft); align-items: flex-start; }
.note svg { width: 19px; height: 19px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.note-accent { background: var(--accent-weak); border-color: #eccec1; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); z-index: 60; transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-flex !important; }
    .content { padding: 22px 18px 48px; }
    .topbar { padding: 16px 18px; }
    .form-grid { grid-template-columns: 1fr; }
    .dl { grid-template-columns: 1fr; }
    .dl dt { padding-bottom: 4px; }
    .scrim.open { display: block; }
}
.menu-toggle { display: none; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(33,28,22,.4); z-index: 55; }

/* AJAX-Ladezustand */
[data-results] { transition: opacity .15s ease; }
[data-results].is-loading { opacity: .5; pointer-events: none; }

/* Druckstatus (rechtsklickbar) */
.print-status.is-printed { cursor: context-menu; }

/* "Adresse geprüft"-Umschalter (Fragezeichen -> grünes Häkchen) */
.verify-toggle { background: none; border: none; cursor: pointer; padding: 5px; border-radius: 8px; line-height: 0; transition: background .12s ease; }
.verify-toggle svg { width: 22px; height: 22px; }
.verify-toggle .ic-q { color: var(--muted); }
.verify-toggle .ic-check { display: none; color: var(--green); }
.verify-toggle.is-verified .ic-q { display: none; }
.verify-toggle.is-verified .ic-check { display: inline-block; }
.verify-toggle:hover { background: var(--paper-2); }
.verify-toggle:hover .ic-q { color: var(--accent); }
.verify-toggle:disabled { opacity: .5; cursor: wait; }

/* "Werbung"-Umschalter mit drei Zuständen:
   ? (neutral) -> rotes Häkchen (Werbung) -> X (ausgeblendet) */
.mark-toggle { background: none; border: none; cursor: pointer; padding: 5px; border-radius: 8px; line-height: 0; transition: background .12s ease; }
.mark-toggle svg { width: 22px; height: 22px; }
.mark-toggle .ic-q { color: var(--muted); }
.mark-toggle .ic-check { display: none; color: var(--red); }
.mark-toggle .ic-x { display: none; color: var(--ink); }
.mark-toggle.is-werbung .ic-q { display: none; }
.mark-toggle.is-werbung .ic-check { display: inline-block; }
.mark-toggle.is-excluded .ic-q { display: none; }
.mark-toggle.is-excluded .ic-x { display: inline-block; }
.mark-toggle:hover { background: var(--paper-2); }
.mark-toggle:disabled { opacity: .5; cursor: wait; }

/* Werbung markiert: rote Schrift in der Zeile */
tr.is-werbung td,
tr.is-werbung .primary-cell,
tr.is-werbung a.primary-cell,
tr.is-werbung .sub-cell { color: var(--red); }

/* Ausgeblendet: graue Zeile (hat Vorrang vor der Werbe-Markierung) */
tr.is-excluded td { background: var(--paper-2); }
tr.is-excluded td,
tr.is-excluded .primary-cell,
tr.is-excluded a.primary-cell,
tr.is-excluded .sub-cell { color: var(--muted); }
tr.is-excluded .badge { opacity: .6; }

/* Konflikt (mögliches Duplikat): dezenter gelber Hinweisstreifen */
tr.is-conflict td { box-shadow: inset 3px 0 0 var(--amber); }

/* Kontextmenue */
.ctx-menu {
    position: absolute; z-index: 200; min-width: 230px;
    background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 5px;
    animation: slideIn .12s ease;
}
.ctx-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 11px; border: none; background: transparent; cursor: pointer;
    font-family: var(--font-body); font-size: 14px; font-weight: 500; color: var(--ink);
    border-radius: 7px; text-align: left;
}
.ctx-menu button:hover { background: var(--accent-weak); color: var(--accent-ink); }
.ctx-menu button svg { width: 17px; height: 17px; color: var(--muted); }
.ctx-menu button:hover svg { color: var(--accent-ink); }
