/* ============================================================
   OFFTRACK CARE — Stylesheet
   Understated, engineered design system for the customer portal
   ============================================================ */

:root {
    /* Warm neutrals (stone) */
    --ink-950: #1C1917;
    --ink-900: #232019;
    --ink-800: #292524;
    --ink-700: #44403C;
    --ink-600: #57534E;
    --ink-500: #78716C;
    --ink-400: #A8A29E;
    --ink-300: #D6D3D1;
    --ink-200: #E7E5E4;
    --ink-100: #F0EFED;
    --ink-50:  #FAFAF9;

    /* Accent: burnt orange, used sparingly */
    --accent: #C2410C;
    --accent-dark: #9A3412;
    --accent-soft: #FDEEE3;

    --success: #15803D;
    --success-soft: #F0FDF4;
    --danger: #B91C1C;
    --danger-soft: #FEF2F2;

    --bg: #F5F5F4;
    --surface: #FFFFFF;
    --border: #E7E5E4;

    --radius: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
    --shadow-md: 0 2px 10px rgba(28, 25, 23, 0.07);
    --shadow-lg: 0 16px 48px rgba(28, 25, 23, 0.18);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink-800);
    background: var(--bg);
    min-height: 100vh;
}

a { color: var(--ink-900); text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 {
    color: var(--ink-950);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

/* Small uppercase micro-label, used across pages */
.overline {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-500);
}

/* ── Layout helpers ─────────────────────────────────────── */

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-main { flex: 1; }

/* ── Navbar ─────────────────────────────────────────────── */

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 60px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.nav-logo img { height: 24px; display: block; }

.nav-actions { display: flex; align-items: center; gap: 14px; }

.nav-user {
    font-size: 13px;
    color: var(--ink-500);
}

@media (max-width: 560px) {
    .nav-user { display: none; }
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    padding: 12px 22px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--ink-950); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ink-700); color: #fff; }

/* Light button for dark surfaces */
.btn-light { background: #fff; color: var(--ink-950); }
.btn-light:hover:not(:disabled) { background: var(--ink-200); color: var(--ink-950); }

.btn-outline {
    background: var(--surface);
    color: var(--ink-700);
    border-color: var(--ink-300);
}
.btn-outline:hover:not(:disabled) { border-color: var(--ink-600); color: var(--ink-950); }

.btn-ghost { background: transparent; color: var(--ink-500); }
.btn-ghost:hover:not(:disabled) { color: var(--ink-950); background: var(--ink-100); }

.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover:not(:disabled) { background: #991B1B; color: #fff; }

.btn-ghost-danger { background: transparent; color: var(--ink-400); }
.btn-ghost-danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }

.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ── Forms ──────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-700);
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    font-family: var(--font);
    font-size: 15px;
    color: var(--ink-950);
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--ink-300);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
    appearance: none;
    -webkit-appearance: none;
}

.form-select {
    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='%2378716C' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-input::placeholder { color: var(--ink-400); }

.form-input:focus, .form-select:focus {
    border-color: var(--ink-700);
    box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.08);
}

.form-hint { font-size: 12.5px; color: var(--ink-500); margin-top: 6px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ── Alerts ─────────────────────────────────────────────── */

.alert {
    font-size: 13.5px;
    padding: 11px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    line-height: 1.5;
}
.alert-error { background: var(--danger-soft); color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: var(--success-soft); color: #166534; border: 1px solid #BBF7D0; }
.alert-info { background: var(--ink-100); color: var(--ink-700); border: 1px solid var(--ink-200); }

/* ── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-pad { padding: 28px; }

/* ── Auth pages (login / set password) ──────────────────── */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
}

.auth-logo { margin-bottom: 36px; }
.auth-logo img { height: 28px; display: block; }

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 36px 34px;
}

.auth-title {
    font-size: 20px;
    margin-bottom: 6px;
}

.auth-sub {
    font-size: 13.5px;
    color: var(--ink-500);
    margin-bottom: 26px;
    line-height: 1.55;
}

.auth-footer-link {
    margin-top: 20px;
    font-size: 13px;
}
.auth-footer-link a { color: var(--ink-500); text-decoration: none; }
.auth-footer-link a:hover { color: var(--ink-950); }

.auth-below {
    margin-top: 28px;
    font-size: 12.5px;
    color: var(--ink-400);
    text-align: center;
    max-width: 340px;
    line-height: 1.55;
}

@media (max-width: 480px) {
    .auth-wrap { justify-content: flex-start; padding-top: 64px; }
    .auth-card { padding: 28px 22px; }
}

/* ── Landing (index) ────────────────────────────────────── */

.hero-dark {
    background: var(--ink-950);
    color: #fff;
    padding: 104px 0 112px;
}

.hero-dark .container { max-width: 880px; }

.hero-overline {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #D6BFA8;
    margin-bottom: 22px;
}

.hero-dark h1 {
    color: #fff;
    font-size: clamp(32px, 5.4vw, 52px);
    font-weight: 650;
    letter-spacing: -0.025em;
    line-height: 1.12;
    margin-bottom: 22px;
    max-width: 640px;
}

.hero-dark p {
    font-size: 16.5px;
    color: #B8B2AC;
    line-height: 1.65;
    max-width: 560px;
    margin-bottom: 40px;
}

.hero-actions { display: flex; gap: 14px; align-items: center; }

@media (max-width: 640px) {
    .hero-dark { padding: 72px 0 80px; }
}

/* "So funktioniert es" — editorial numbered steps, no cards */

.how {
    padding: 84px 0 104px;
}

.how .container { max-width: 880px; }

.how-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-500);
    margin-bottom: 36px;
}

.how-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
}

.how-step {
    border-top: 1px solid var(--ink-300);
    padding-top: 20px;
}

.how-num {
    display: block;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    margin-bottom: 14px;
}

.how-step h3 { font-size: 15.5px; margin-bottom: 8px; }
.how-step p { font-size: 13.5px; color: var(--ink-500); line-height: 1.6; }

@media (max-width: 680px) {
    .how { padding: 56px 0 72px; }
    .how-grid { grid-template-columns: 1fr; gap: 28px; }
}

/* ── Footer ─────────────────────────────────────────────── */

.footer {
    border-top: 1px solid var(--border);
    padding: 22px 0;
    background: var(--surface);
}

.footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.footer p, .footer a { font-size: 12.5px; color: var(--ink-400); }
.footer a:hover { color: var(--ink-700); }
.footer-links { display: flex; gap: 18px; }

/* ── Status page / timeline ─────────────────────────────── */

.status-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 52px 24px 88px;
}

.status-greeting { margin-bottom: 26px; }
.status-greeting h1 { font-size: 25px; letter-spacing: -0.02em; margin-bottom: 6px; }
.status-greeting p { color: var(--ink-500); font-size: 14.5px; }

.vehicle-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.vehicle-card-head {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.vehicle-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink-950);
}

.vehicle-year {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--ink-500);
}

.delivery-estimate {
    margin-top: 5px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-500);
}

.vehicle-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-400);
    margin-bottom: 4px;
}

.phase-badge {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent-dark);
    background: var(--accent-soft);
    padding: 6px 13px;
    border-radius: 100px;
}

.phase-badge.delivered { color: var(--success); background: var(--success-soft); }

/* Stepper — horizontal on desktop */

.stepper {
    display: flex;
    padding: 34px 32px 12px;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    text-align: center;
}

.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 15px;
    left: calc(50% + 24px);
    right: calc(-50% + 24px);
    height: 2px;
    background: var(--ink-200);
    border-radius: 2px;
}

.step.done:not(:last-child)::after { background: var(--ink-950); }

.step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    border: 2px solid var(--ink-300);
    color: var(--ink-400);
    margin-bottom: 10px;
    z-index: 1;
    flex-shrink: 0;
}

.step.done .step-dot {
    background: var(--ink-950);
    border-color: var(--ink-950);
    color: #fff;
}

.step.current .step-dot {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.step-title {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-400);
    line-height: 1.35;
    padding: 0 4px;
}

.step.done .step-title { color: var(--ink-600); }
.step.current .step-title { color: var(--ink-950); font-weight: 600; }

/* Compact progress (mobile only): segmented bar + label */

.progress-compact { display: none; }

.progress-dots {
    display: flex;
    gap: 5px;
    flex: 1;
}

.progress-dot {
    height: 6px;
    flex: 1;
    border-radius: 3px;
    background: var(--ink-200);
}
.progress-dot.done { background: var(--ink-950); }
.progress-dot.current { background: var(--accent); }

.progress-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-600);
    white-space: nowrap;
}

.phase-note {
    font-size: 12.5px;
    color: var(--ink-400);
    line-height: 1.55;
    margin-top: 12px;
}

/* Mobile: hide the full stepper, show the compact progress instead */

@media (max-width: 640px) {
    .stepper { display: none; }
    .phase-badge { display: none; }

    .progress-compact {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 20px 22px 2px;
    }

    .vehicle-card-head { padding: 20px 22px 16px; }
    .status-wrap { padding: 32px 18px 64px; }
}

.phase-info {
    padding: 20px 32px 30px;
    border-top: 1px solid var(--border);
    margin-top: 14px;
}

.phase-info h3 { font-size: 15.5px; margin-bottom: 6px; }
.phase-info p {
    font-size: 14px;
    color: var(--ink-500);
    line-height: 1.6;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;
    -webkit-hyphens: none;
}
.phase-copy {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
    -webkit-hyphens: none;
}
.phase-copy p + p { margin-top: 14px; }

@media (max-width: 640px) {
    .phase-info { padding: 18px 22px 26px; margin-top: 4px; }
}

/* ── Admin layout ───────────────────────────────────────── */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 232px;
    background: var(--ink-950);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
}

.admin-sidebar-head {
    padding: 24px 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.admin-sidebar-head img { height: 22px; display: block; filter: brightness(0) invert(1); }
.admin-sidebar-head span {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.42);
    margin-top: 10px;
}

.admin-nav { padding: 14px 12px; flex: 1; }

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.62);
    padding: 9px 12px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background 0.13s ease, color 0.13s ease;
}
.admin-nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.admin-nav-link.active { color: #fff; background: rgba(255, 255, 255, 0.11); }
.admin-nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.admin-sidebar-foot {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.admin-sidebar-foot .btn-outline {
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    border-color: rgba(255, 255, 255, 0.22);
}
.admin-sidebar-foot .btn-outline:hover:not(:disabled) {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-user-mail {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.65);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-main {
    flex: 1;
    margin-left: 232px;
    padding: 36px 40px 64px;
}

@media (max-width: 860px) {
    .admin-sidebar { display: none; }
    .admin-main { margin-left: 0; padding: 22px 16px 48px; }
    .admin-mobilebar { display: flex !important; }
}

.admin-mobilebar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 13px 18px;
    position: sticky;
    top: 0;
    z-index: 40;
}
.admin-mobilebar img { height: 21px; }

.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.admin-head h1 { font-size: 21px; letter-spacing: -0.02em; }
.admin-head p { font-size: 13.5px; color: var(--ink-500); margin-top: 3px; }

/* ── Table ──────────────────────────────────────────────── */

.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

/* Toolbar above the table: search + sort */
.admin-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.admin-toolbar .form-input {
    flex: 1 1 220px;
    max-width: 320px;
}
.sort-select {
    flex: 0 1 auto;
    width: auto;
    max-width: 300px;
    font-size: 13.5px;
    color: var(--ink-600);
}

.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-400);
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--ink-700);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--ink-50); }

.table-empty {
    text-align: center;
    padding: 48px 20px !important;
    color: var(--ink-400);
}

.cell-strong { font-weight: 600; color: var(--ink-950); }
.cell-muted { color: var(--ink-400); }
.cell-sub { font-size: 12px; color: var(--ink-400); margin-top: 2px; }

/* Compact desktop table cells */
.cell-ellipsis {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-vehicle { white-space: nowrap; }
.cell-nr {
    width: 1%;
    white-space: nowrap;
    font-weight: 600;
    color: var(--ink-700);
    font-variant-numeric: tabular-nums;
    vertical-align: top;
}
.cell-phase { min-width: 210px; width: 25%; vertical-align: top; }
.cell-estimate { min-width: 185px; width: 21%; vertical-align: top; }
.cell-customer { min-width: 170px; vertical-align: top; }
.cell-actions {
    text-align: right;
    white-space: nowrap;
    width: 1%;
    vertical-align: top;
}

.customers-table td { padding-top: 16px; padding-bottom: 16px; }

/* Kunde cell: name + Nr. primary, contact quieter below */
.cust-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}
.cust-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-950);
    line-height: 1.35;
}
.cust-line { font-size: 12.5px; color: var(--ink-500); line-height: 1.5; }
.cust-line.quiet { font-size: 12px; color: var(--ink-400); }

/* Fahrzeug cell: base + model on two lines */
.veh-base { font-size: 13px; font-weight: 600; color: var(--ink-800); line-height: 1.4; }
.veh-model { font-size: 12.5px; color: var(--ink-500); line-height: 1.4; }

/* Row action buttons: icon + label, real hit targets */
.row-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.row-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-600);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 10px;
    cursor: pointer;
    transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.row-action svg { width: 14px; height: 14px; flex-shrink: 0; }
.row-action:hover {
    border-color: var(--ink-400);
    color: var(--ink-950);
    background: var(--ink-50);
}
.row-action.danger:hover {
    border-color: #FECACA;
    color: var(--danger);
    background: var(--danger-soft);
}

/* Action labels only where they truly fit; below that icon + tooltip */
@media (min-width: 901px) and (max-width: 1600px) {
    .row-action span { display: none; }
    .row-action { padding: 8px; }
}

/* Tighter table on narrow desktop (sidebar still visible) */
@media (min-width: 901px) and (max-width: 1440px) {
    .data-table td, .data-table th { padding: 12px 12px; }
    .cell-ellipsis { max-width: 170px; }
    .cell-phase { min-width: 185px; }
    .cell-estimate { min-width: 150px; }
    .admin-main { padding: 28px 24px 56px; }
    .estimate-chip-action { display: none; }
}

.btn-icon { padding: 7px; }
.btn-busy { opacity: 0.5; pointer-events: none; }

/* Staleness: quiet "seit … · vor x Tagen" normally, loud amber badge when stale */
.stale-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    padding: 3px 9px;
    border-radius: 100px;
    background: var(--ink-100);
    color: var(--ink-500);
    white-space: nowrap;
}
.stale-badge.warn { background: #FEF3C7; color: #92400E; }
.stale-badge.warn svg { flex-shrink: 0; }

.phase-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 0;
}
.phase-meta .phase-date { margin-top: 0; }

/* Mobile / narrow: tables become stacked cards (no horizontal scrolling) */

@media (max-width: 900px) {
    .data-table { min-width: 0; }
    .data-table thead { display: none; }

    .data-table tbody tr {
        display: block;
        padding: 16px 18px;
        border-bottom: 1px solid var(--border);
    }
    .data-table tbody tr:last-child { border-bottom: none; }
    .data-table tbody tr:hover { background: transparent; }

    .data-table tbody td {
        display: block;
        padding: 0 0 12px;
        border-bottom: none;
    }
    .data-table tbody td:last-child { padding-bottom: 0; }

    /* Micro-labels above secondary cells (customer table) */
    #customersTableBody td:nth-child(2)::before,
    #customersTableBody td:nth-child(3)::before,
    #customersTableBody td:nth-child(4)::before {
        display: block;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--ink-400);
        margin-bottom: 5px;
    }
    #customersTableBody td:nth-child(2)::before { content: 'Fahrzeug'; }
    #customersTableBody td:nth-child(3)::before { content: 'Bauphase'; }
    #customersTableBody td:nth-child(4)::before { content: 'Übergabe'; }

    /* Same treatment for the appointments table. The date stays unlabelled —
       it is the headline of the card. */
    #appointmentsTableBody td:nth-child(2)::before,
    #pickupsTableBody td:nth-child(2)::before {
        display: block;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--ink-400);
        margin-bottom: 5px;
        content: 'Kunde & Fahrzeug';
    }
    #appointmentsTableBody td.table-empty::before,
    #pickupsTableBody td.table-empty::before { content: none !important; }
    #appointmentsTableBody td.cell-actions {
        text-align: left !important;
        width: auto;
        padding-top: 6px;
        display: flex;
        gap: 6px;
    }
    #appointmentsTableBody td.cell-actions .row-action { flex: 1 1 auto; justify-content: center; }
    /* Needs the extra specificity: the base .appt-note rule sits ~1000 lines
       further down, and a media query adds no specificity of its own — the
       later selector would simply win at every width. */
    #appointmentsTableBody td.appt-note { max-width: none; }

    /* No truncation needed in stacked cards */
    .cell-ellipsis { max-width: none; white-space: normal; }
    .cell-phase, .cell-estimate { min-width: 0; width: auto; }
    .cell-vehicle { white-space: normal; }
    .phase-select { max-width: none; }
    .estimate-chip { width: 100%; max-width: none; }
    .estimate-empty { width: 100%; justify-content: space-between; }

    /* Vehicle base + model on one line in the card */
    .veh-base, .veh-model { display: inline; }
    .veh-model { margin-left: 5px; font-size: 13px; }

    /* Action buttons: full-width row with visible labels */
    #customersTableBody td.cell-actions {
        text-align: left !important;
        width: auto;
        padding-top: 6px;
    }
    .row-actions { display: flex; width: 100%; }
    .row-action { flex: 1 1 auto; justify-content: center; padding: 9px 10px; }
    .row-action span { display: inline; }

    /* No labels for empty/expanded rows */
    #customersTableBody tr.history-row td::before,
    #customersTableBody td.table-empty::before { content: none !important; }

    .history-label { min-width: 0; flex: 1; }

    /* Activity log stacks naturally */
    #activityLogBody td { font-size: 13px; }
    #activityLogBody td:first-child { font-size: 11.5px; }

    /* The import preview stays a real table: the columns are short and the
       stacked-card layout would hide which row belongs to which customer. */
    .excel-preview-table { min-width: 640px; }
    .excel-preview-table thead { display: table-header-group; }
    .excel-preview-table tbody tr { display: table-row; padding: 0; }
    .excel-preview-table tbody td {
        display: table-cell;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }
    .excel-import-preview { overflow-x: auto; }
}

/* View tabs – shown only on mobile where the sidebar is hidden */
.admin-tabs {
    display: none;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--ink-200);
    border-radius: var(--radius);
    padding: 3px;
    width: fit-content;
}
.admin-tab {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-500);
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 7px 16px;
    cursor: pointer;
}
.admin-tab.active { background: var(--surface); color: var(--ink-950); box-shadow: var(--shadow-sm); }

@media (max-width: 860px) {
    .admin-tabs { display: flex; }
}

/* Phase select in table */

.phase-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: 300px;
}

.phase-control { display: flex; align-items: center; gap: 6px; width: 100%; }

.phase-select {
    font-family: var(--font);
    font-size: 13px;
    color: var(--ink-800);
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 8px 30px 8px 10px;
    border: 1px solid var(--ink-300);
    border-radius: var(--radius);
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
}
.phase-select:focus { border-color: var(--ink-700); }
.phase-select:disabled { background-color: var(--ink-100); color: var(--ink-400); cursor: not-allowed; }
.phase-select option:disabled { color: var(--ink-300); }

.phase-date {
    font-size: 11.5px;
    color: var(--ink-400);
    margin-top: 0;
}

.phone-row { display: flex; gap: 8px; }
.phone-prefix { width: 106px; flex-shrink: 0; }

.form-row-plz { display: grid; grid-template-columns: 110px 1fr; gap: 14px; }

/* Straße | PLZ | Ort | Land (one row on the wide modal) */
.form-row-addr { display: grid; grid-template-columns: 1.9fr 0.55fr 1fr 1.1fr; gap: 14px; }

/* IBAN | Reisepass | Ausweis */
.form-row-docs { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; }

/* Basis | Modell | Preis */
.form-row-3 { display: grid; grid-template-columns: 1.1fr 1.1fr 0.8fr; gap: 14px; }

@media (max-width: 640px) {
    .form-row-addr, .form-row-docs, .form-row-3 { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 480px) {
    .form-row-plz { grid-template-columns: 100px 1fr; }
}

.history-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-400);
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}
.history-toggle:hover { color: var(--accent); }
.history-toggle svg { transition: transform 0.15s ease; }
.history-toggle.open svg { transform: rotate(180deg); }

/* Delivery estimate chip — own column, easy to scan/edit */
.estimate-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 260px;
    text-align: left;
    font-family: var(--font);
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--ink-50);
    color: var(--ink-700);
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.estimate-chip:hover {
    border-color: var(--ink-400);
    background: var(--surface);
}
.estimate-chip.has-value {
    border-color: #FDBA74;
    background: var(--accent-soft);
    color: var(--ink-900);
}
.estimate-chip.has-value:hover {
    border-color: var(--accent);
}
.estimate-chip svg { flex-shrink: 0; color: var(--ink-500); }
.estimate-chip.has-value svg { color: var(--accent-dark); }
.estimate-chip-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}
.estimate-chip-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-400);
}
.estimate-chip.has-value .estimate-chip-label { color: var(--accent-dark); }
.estimate-chip-value {
    font-size: 13px;
    font-weight: 600;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.estimate-chip-action {
    flex-shrink: 0;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-500);
}
.estimate-chip.has-value .estimate-chip-action { color: var(--accent-dark); }

/* Übergabe: explicit empty state — muted text + clear button */
.estimate-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.estimate-empty-text {
    font-size: 12.5px;
    color: var(--ink-400);
    white-space: nowrap;
}
.estimate-set-btn {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-800);
    background: var(--surface);
    border: 1px solid var(--ink-300);
    border-radius: var(--radius);
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.estimate-set-btn:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: var(--accent-soft);
}

/* Übergabe: vehicle already delivered */
.estimate-done {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--success);
    white-space: nowrap;
}
.estimate-done svg { flex-shrink: 0; }

/* Legacy class kept for safety if referenced elsewhere */
.estimate-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-500);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}
.estimate-toggle:hover { color: var(--accent); }

/* Estimate modal: date/quarter toggle */
.estimate-type-toggle { display: flex; gap: 8px; }

.estimate-type-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-600);
    cursor: pointer;
    user-select: none;
}
.estimate-type-option:has(input:checked) {
    border-color: var(--ink-950);
    color: var(--ink-950);
    background: var(--ink-50);
    font-weight: 600;
}
.estimate-type-option input { accent-color: var(--ink-950); margin: 0; }

.estimate-pflicht {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 4px;
    vertical-align: middle;
}

.admin-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.admin-head-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.admin-head-actions .btn svg { flex-shrink: 0; }

@media (max-width: 720px) {
    .admin-head { align-items: flex-start; }
    .admin-head-actions { width: 100%; }
    .admin-head-actions .btn { flex: 1 1 auto; justify-content: center; }
    .admin-toolbar .form-input { max-width: none; }
    .sort-select { width: 100%; max-width: none; }
}

.excel-import-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 14px;
}
.excel-stat {
    font-size: 13px;
    color: var(--ink-600);
    background: var(--ink-50);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
}
.excel-stat.update { border-color: #BBF7D0; background: var(--success-soft); color: var(--success); }
.excel-stat.unknown { border-color: #FECACA; background: var(--danger-soft); color: var(--danger); }

.excel-import-preview {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.excel-preview-table { margin: 0; }
.excel-preview-table th { position: sticky; top: 0; z-index: 1; }

/* Excel-Import: Schritte, Modus, Mailzähler, Fortschritt */
.excel-step { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); }
.excel-step:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
.excel-step-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-900);
    margin-bottom: 10px;
}
.excel-step-nr {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: var(--ink-900);
    color: #fff;
    font-size: 12px;
    flex-shrink: 0;
}

.excel-mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.excel-mode {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.excel-mode:hover { border-color: var(--ink-300); }
.excel-mode input { margin-top: 3px; flex-shrink: 0; }
.excel-mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.excel-mode-body { display: flex; flex-direction: column; gap: 4px; }
.excel-mode-title { font-size: 13.5px; font-weight: 600; color: var(--ink-900); }
.excel-mode-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 11px;
    font-weight: 600;
    vertical-align: 1px;
}
.excel-mode-text { font-size: 12.5px; line-height: 1.45; color: var(--ink-500); }

.excel-option {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink-600);
    cursor: pointer;
}
.excel-option input { margin-top: 2px; flex-shrink: 0; }

.excel-file-note {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--ink-50);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--ink-600);
}
.excel-note-warn, .excel-note-resume { color: var(--danger); }

.excel-mail-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    margin-bottom: 14px;
    border: 2px solid var(--danger);
    border-radius: var(--radius);
    background: var(--danger-soft);
}
.excel-mail-panel.none { border-color: #BBF7D0; background: var(--success-soft); }
.excel-mail-panel.many { box-shadow: 0 0 0 4px rgba(185, 28, 28, .12); }
.excel-mail-count {
    font-size: 40px;
    line-height: 1;
    font-weight: 700;
    color: var(--danger);
    min-width: 54px;
    text-align: center;
}
.excel-mail-panel.none .excel-mail-count { color: #166534; }
.excel-mail-title { font-size: 15px; font-weight: 600; color: var(--ink-900); }
.excel-mail-sub { font-size: 13px; color: var(--ink-600); margin-top: 3px; }
.excel-mail-mode { font-size: 12.5px; color: var(--ink-500); margin-top: 5px; }

.excel-warnings {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid #FECACA;
    border-radius: var(--radius);
    background: var(--danger-soft);
}
.excel-warnings-head { font-size: 13px; font-weight: 600; color: var(--danger); margin-bottom: 8px; }
.excel-warn-group + .excel-warn-group { margin-top: 10px; }
.excel-warn-title { font-size: 12.5px; font-weight: 600; color: var(--ink-900); }
.excel-warn-rows { font-size: 12px; line-height: 1.6; color: var(--ink-600); margin-top: 3px; }

.excel-row-action td { background: #F0FDF4; }
.excel-row-warn td { background: var(--danger-soft); }
.excel-row-quiet td, .excel-row-info td { color: var(--ink-500); }
.excel-row-note td {
    padding-top: 0 !important;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--ink-500);
    border-top: 0;
}
.excel-row-note.warn td { color: var(--danger); }
.excel-date-fix {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}
.excel-date-fix-label {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-900);
}
.excel-date-input {
    width: auto;
    min-width: 10.5rem;
    padding: 4px 8px;
    font-size: 13px;
}
.excel-mail-missing-dates,
.excel-missing-dates-head { color: var(--danger); }
.excel-mail-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 11.5px;
    white-space: nowrap;
}
.excel-confirm-count { max-width: 140px; font-weight: 600; }

.excel-progress {
    margin: 14px 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--ink-50);
}
.excel-progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
.excel-progress-track span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--ink-900);
    transition: width .2s;
}
.excel-progress-text { font-size: 13px; color: var(--ink-600); margin: 9px 0; }

@media (max-width: 720px) {
    .excel-mode-grid { grid-template-columns: 1fr; }
    .excel-mail-panel { align-items: flex-start; gap: 12px; padding: 14px; }
    .excel-mail-count { font-size: 32px; min-width: 42px; }
    .excel-import-preview { max-height: 300px; }
}

/* Zweites Fahrzeug desselben Kunden in der Kundentabelle */
.veh-count { font-size: 11px; color: var(--ink-500); margin-top: 3px; }
.veh-extra-row > td { background: var(--ink-50); }
.veh-extra-row:hover > td { background: var(--ink-100) !important; }

/* Fahrzeugwechsel im Kundenportal */
.vehicle-switch {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.vehicle-switch-btn {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink-600);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.vehicle-switch-btn:hover { border-color: var(--ink-500); color: var(--ink-900); }
.vehicle-switch-btn.active {
    border-color: var(--ink-900);
    background: var(--ink-900);
    color: #fff;
}
.vehicle-switch-sub { font-size: 11.5px; font-weight: 500; opacity: .75; }

@media (max-width: 560px) {
    .vehicle-switch { flex-direction: column; }
    .vehicle-switch-btn { width: 100%; }
}

.history-row td {
    background: var(--ink-50);
    padding: 14px 18px !important;
}
.history-row:hover td { background: var(--ink-50) !important; }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ink-950);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-label { font-weight: 500; color: var(--ink-800); min-width: 200px; flex: 1; }
.history-date { color: var(--ink-400); font-size: 12.5px; }
.history-by { color: var(--ink-500); font-size: 12.5px; font-weight: 500; }

.phase-confirm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    border: none;
    background: var(--success);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}
.phase-confirm:hover { background: #166534; }

/* ── Modal ──────────────────────────────────────────────── */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.55);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal.active { display: flex; }

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#estimateModal .modal-card,
#excelImportModal .modal-card {
    max-height: min(860px, calc(100vh - 64px));
}
#estimateModal .modal-body,
#excelImportModal .modal-body {
    overflow-y: auto;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 26px;
    border-bottom: 1px solid var(--border);
}

.modal-head h3 { font-size: 16px; }

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--ink-400);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius);
}
.modal-close:hover { color: var(--ink-950); background: var(--ink-100); }

.modal-body { padding: 26px; }

/* Wider variant for data-heavy forms (desktop) — visually compact so it
   fits a laptop screen without scrolling. The card is capped at the
   viewport height and scrolls internally as a safety net. */
.modal-card.modal-wide {
    max-width: 780px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
}

.modal-wide .modal-head { padding: 16px 26px; flex-shrink: 0; }
.modal-wide .modal-body { padding: 18px 26px 22px; overflow-y: auto; }
.modal-wide .form-group { margin-bottom: 11px; }
.modal-wide .form-input, .modal-wide .form-select { padding: 8px 12px; font-size: 14px; }
.modal-wide .form-label { margin-bottom: 4px; font-size: 12.5px; }
.modal-wide .form-section { margin-bottom: 4px; }
.modal-wide .form-section:not(:first-child) { padding-top: 12px; margin-top: 12px; }
.modal-wide .form-section-title { margin-bottom: 9px; }
.modal-wide .form-hint { font-size: 12px; margin-top: 4px; }

@media (min-width: 561px) {
    .modal { padding: 24px 20px; }
}

/* Labeled form sections inside modals */
.form-section { margin-bottom: 10px; }
.form-section:not(:first-child) {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 20px;
}
.form-section-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-400);
    margin-bottom: 14px;
}

@media (max-width: 560px) {
    .modal { padding: 0; align-items: stretch; }
    /* Full-screen card: fixed header, internally scrolling body. The card is
       pinned to the (dynamic) viewport height so the body can scroll on touch
       devices — with align-items:stretch the card can never exceed the
       viewport, so overflow must live on .modal-body, not the card. */
    .modal-card,
    .modal-card.modal-wide,
    #estimateModal .modal-card,
    #excelImportModal .modal-card {
        max-width: none;
        border-radius: 0;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        max-height: none;
        display: flex;
        flex-direction: column;
    }
    .modal-head {
        flex-shrink: 0;
        position: sticky;
        top: 0;
        background: var(--surface);
        z-index: 5;
    }
    .modal-body,
    .modal-wide .modal-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 20px 18px 40px;
    }
}

/* ── Toast ──────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    left: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--ink-950);
    color: #fff;
    font-size: 13.5px;
    padding: 12px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    animation: toast-in 0.22s ease;
}

.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Admin: Schadensmeldungen inbox ─────────────────────── */

.nav-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    border-radius: 100px;
    padding: 1px 7px;
    line-height: 1.5;
}

.reports-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.reports-empty {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 34px 20px;
    text-align: center;
    font-size: 13.5px;
    color: var(--ink-400);
}

.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px 22px;
}

.report-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.report-title h3 { font-size: 15.5px; margin-bottom: 3px; }
.report-sub { font-size: 12.5px; color: var(--ink-400); }

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

.urgency-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 100px;
    padding: 4px 10px;
    white-space: nowrap;
}
.urgency-badge.u1 { color: var(--ink-600); background: var(--ink-100); }
.urgency-badge.u2 { color: #92400E; background: #FEF3C7; }
.urgency-badge.u3 { color: var(--danger); background: var(--danger-soft); }

.report-status-select {
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 100px;
    border: 1px solid var(--border);
    padding: 5px 28px 5px 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='3'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.report-status-select.st-pending { color: #92400E; background-color: #FEF3C7; border-color: #FDE68A; }
.report-status-select.st-in_progress { color: #1D4ED8; background-color: #DBEAFE; border-color: #BFDBFE; }
.report-status-select.st-completed { color: var(--success); background-color: var(--success-soft); border-color: #BBF7D0; }
.report-status-select.st-cancelled { color: var(--ink-500); background-color: var(--ink-100); border-color: var(--ink-200); }

.report-meta {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr 1fr 1.2fr;
    gap: 16px;
    padding: 14px 16px;
    background: var(--ink-50);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
}
@media (max-width: 1100px) { .report-meta { grid-template-columns: 1fr 1fr; gap: 12px 16px; } }
@media (max-width: 760px) { .report-meta { grid-template-columns: 1fr; gap: 12px; } }

.report-field > span {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-400);
    margin-bottom: 3px;
}
.report-field strong { font-size: 13.5px; color: var(--ink-900); }
.report-field-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 1px; }
.report-field-sub a { color: var(--ink-600); text-decoration: underline; text-underline-offset: 2px; }
.report-field-sub a:hover { color: var(--accent-dark); }

.report-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.report-chip {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-700);
    background: var(--surface);
    border: 1px solid var(--ink-300);
    border-radius: 100px;
    padding: 2px 9px;
    white-space: nowrap;
}

.report-desc {
    font-size: 13.5px;
    color: var(--ink-700);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 14px;
}

.report-files-label {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-400);
    margin-bottom: 8px;
}

.report-files-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rfile-photo {
    display: block;
    width: 92px;
    height: 92px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--ink-100);
}
.rfile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rfile-photo:hover { border-color: var(--accent); }

.rfile-video, .rfile-broken {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-700);
    background: var(--surface);
    border: 1px solid var(--ink-300);
    border-radius: var(--radius);
    padding: 8px 12px;
    max-width: 240px;
}
.rfile-video span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rfile-video:hover { border-color: var(--accent); color: var(--accent-dark); }
.rfile-broken { color: var(--ink-400); border-style: dashed; }

.rfile-wrap { position: relative; display: inline-flex; }
.rfile-del {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid var(--ink-300);
    background: var(--surface);
    color: var(--ink-500);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.rfile-del:hover { color: var(--danger); border-color: var(--danger); }

/* Internal part of a damage report: notes, files, log. Team only. */
.report-internal {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--ink-300);
}
@media (max-width: 900px) { .report-internal { grid-template-columns: 1fr; } }
.report-internal-col { min-width: 0; }
.report-internal .report-files-label em {
    font-style: normal;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink-400);
    margin-left: 6px;
}
.report-note { width: 100%; min-height: 76px; resize: vertical; font-size: 13.5px; line-height: 1.5; }
.report-note-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}
.report-note-meta { font-size: 12px; color: var(--ink-400); }
.report-upload-btn { margin-top: 10px; cursor: pointer; }
.report-upload-btn.is-busy { opacity: 0.6; pointer-events: none; }

.report-log {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}
.report-log li { position: relative; padding: 0 0 12px 20px; }
.report-log li::before {
    content: '';
    position: absolute;
    left: 1px;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink-300);
    z-index: 1;
}
.report-log li::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 9px;
    bottom: -5px;
    width: 2px;
    background: var(--ink-200);
}
.report-log li:last-child::after { display: none; }
.report-log li:first-child::before { background: var(--accent); }
.report-log-what { font-size: 13px; color: var(--ink-800); }
.report-log-who { font-size: 12px; color: var(--ink-400); margin-top: 1px; }
.report-log-quote {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--ink-500);
    white-space: pre-wrap;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Termine im Adminbereich ────────────────────────────── */
/* The view reuses .data-table, .row-action and .cell-actions from the customer
   and activity views; only the status pill and the note column are new. */

.appt-when { font-weight: 600; color: var(--ink-950); }

.appt-status {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    padding: 3px 10px;
    border-radius: 100px;
    white-space: nowrap;
}
.appt-status-angefragt { color: #92400E; background: #FEF3C7; }
.appt-status-bestaetigt { color: var(--success); background: var(--success-soft); }
.appt-status-abgesagt { color: var(--ink-500); background: var(--ink-100); }

/* Ausbaubesprechungen left, Übergaben right; stacked once the halves get
   too narrow for the action buttons. */
.termine-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
@media (max-width: 1200px) {
    .termine-split { grid-template-columns: minmax(0, 1fr); }
}
.termine-col-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    margin-bottom: 4px;
}
.termine-col-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.termine-col-head .btn { white-space: nowrap; }
.termine-nowrap { white-space: nowrap; }
.termine-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-600);
    background: var(--ink-100);
    border-radius: 100px;
    padding: 2px 9px;
}
.termine-count:empty { display: none; }
.termine-col-hint { margin: 0 0 14px; line-height: 1.5; min-height: 3em; }
.termine-col .admin-toolbar { margin-bottom: 14px; flex-wrap: nowrap; }
.termine-col .admin-toolbar .form-input { flex: 1 1 auto; min-width: 0; }
.termine-col .admin-toolbar .form-select { flex: 0 0 auto; }
.termine-table td { vertical-align: top; }
.termine-name { font-weight: 600; color: var(--ink-950); }
.termine-vehicle { margin-top: 4px; }
.termine-status { margin-top: 6px; }
.termine-note { margin-top: 6px; max-width: none; }
.termine-actions {
    display: inline-grid;
    grid-template-columns: repeat(2, auto);
    gap: 6px;
    justify-content: end;
}
.termine-actions .row-action { justify-content: center; }

/* Past and cancelled rows stay readable but step back, so the eye lands on
   what still needs a decision. */
.appt-row-muted td { color: var(--ink-400); }
.appt-row-muted .appt-when { color: var(--ink-500); }

.appt-note {
    max-width: 240px;
    font-size: 12.5px;
    color: var(--ink-600);
}

/* Cancelled and past rows are muted via .appt-row-muted td, but `a { color:
   var(--ink-900) }` targets the anchor directly and beats inheritance — the
   e-mail address ended up the most prominent thing in a cancelled row. */
.appt-row-muted td a { color: var(--ink-500); }

/* ── Terminbuchung Ausbaubesprechung (Kundenportal) ─────── */
/* Same shell as .vehicle-card so the panel reads as part of the page rather
   than as a widget bolted on underneath it. */

.booking-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-top: 18px;
}

.booking-head {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.booking-title { font-size: 17px; letter-spacing: -0.015em; }
.booking-body { padding: 22px 32px 26px; }

.booking-intro { font-size: 14.5px; color: var(--ink-700); }
.booking-hint { margin-top: 10px; font-size: 13px; color: var(--ink-500); }
.booking-loading { font-size: 13.5px; color: var(--ink-500); padding: 6px 0; }

/* Uses the existing .alert / .alert-error and .alert-info components; these
   two rules only place them inside the card. */
.booking-error { margin: 0 0 14px; font-size: 13.5px; }
.booking-note { margin: 14px 0 0; font-size: 13.5px; }

/* The booked appointment — the one thing a returning customer looks for, so
   it sits at the top and is the largest text in the card. */
.booking-current {
    padding: 16px 18px;
    background: var(--ink-50);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.booking-current-date { font-size: 16px; font-weight: 600; color: var(--ink-950); }
.booking-current-time { margin-top: 2px; font-size: 14px; color: var(--ink-600); }

.booking-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.booking-confirm {
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--danger-soft);
    border: 1px solid #FECACA;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-900);
}
.booking-confirm .booking-actions { margin-top: 10px; }

/* Week navigation */
.booking-weeknav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 14px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.booking-weeklabel {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-900);
    text-align: center;
    flex: 1;
}
/* Focus lands here when the control that had it comes back disabled. */
.booking-weeklabel:focus { outline: none; }

.booking-weekbtn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink-700);
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.booking-weekbtn svg { width: 18px; height: 18px; }
.booking-weekbtn:hover:not(:disabled) { border-color: var(--ink-600); color: var(--ink-950); }
.booking-weekbtn:disabled { opacity: .35; cursor: not-allowed; }

/* One row per working day: label on the left, times wrapping on the right.
   The same layout works at 320px and on a desktop, so there is no second
   grid to keep in sync and nothing scrolls sideways on a phone. */
.booking-week { display: flex; flex-direction: column; gap: 4px; }
.booking-week.is-loading { opacity: .45; pointer-events: none; }

.booking-day {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 7px 0;
    border-top: 1px solid var(--ink-100);
}
.booking-day:first-child { border-top: none; }
/* Deliberately not `opacity: .5` on the whole row: that multiplied with the
   already-muted slot colour and left the times at roughly 1.5:1, i.e.
   invisible. Only the label is dimmed; the times below carry the information
   the customer needs in order to choose. */
.booking-day.is-empty .booking-day-name,
.booking-day.is-empty .booking-day-date { color: var(--ink-400); }

.booking-day-label {
    flex: 0 0 62px;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.booking-day-name { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.booking-day-date { font-size: 11.5px; color: var(--ink-500); }
.booking-day-none { font-size: 12.5px; color: var(--ink-400); }

.booking-slots { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }

.booking-slot {
    min-width: 72px;
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink-800);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.booking-slot:hover:not(:disabled) { border-color: var(--ink-900); color: var(--ink-950); }
.booking-slot.is-selected {
    border-color: var(--ink-900);
    background: var(--ink-900);
    color: #fff;
}
/* Taken and out-of-window slots stay visible instead of disappearing: an
   empty row reads as "broken", a struck-through time reads as "gone". */
/* --ink-400 on --ink-50 is 2.41:1. These are disabled controls, which are
   formally exempt from the contrast requirement, but they carry the very
   information the customer needs in order to choose — so the exemption does
   not really apply. --ink-600 reads as clearly secondary at 7.3:1. */
.booking-slot.is-full,
.booking-slot.is-blocked {
    color: var(--ink-600);
    background: var(--ink-50);
    border-color: var(--ink-200);
    cursor: not-allowed;
}
.booking-slot.is-full { text-decoration: line-through; }

/* The customer's own appointment while they are moving it — otherwise their
   own booking shows up as "taken" and struck through. */
.booking-slot.is-current {
    border-color: var(--ink-900);
    border-style: dashed;
    color: var(--ink-900);
    background: #fff;
    text-decoration: none;
    cursor: default;
}

.booking-slot:focus-visible,
.booking-weekbtn:focus-visible { outline: 2px solid var(--ink-950); outline-offset: 2px; }
/* A dark ring on a near-black selected chip is close to invisible. */
.booking-slot.is-selected:focus-visible { outline-color: var(--accent); }

.booking-submit { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.booking-selected { font-size: 13.5px; color: var(--ink-700); margin-bottom: 12px; }
.booking-selected-empty { color: var(--ink-600); }

/* The handover note in phases 5/6 is text only and should not compete with
   the booking card above it. */
.booking-card-note { background: var(--ink-50); box-shadow: none; }

@media (max-width: 560px) {
    .booking-head { padding: 18px 20px; }
    .booking-body { padding: 18px 20px 22px; }
    .booking-day { align-items: flex-start; flex-direction: column; gap: 7px; }
    .booking-day-label { flex: none; flex-direction: row; gap: 6px; align-items: baseline; }
    .booking-slots { width: 100%; }
    .booking-slot { flex: 1 1 calc(50% - 4px); min-height: 44px; }
}

/* Visually hidden but readable by assistive technology. Used for the booking
   live region and for the reason a slot is unavailable, which `title` alone
   conveys neither on touch nor to a screen reader. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Misc ───────────────────────────────────────────────── */

.spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--ink-200);
    border-top-color: var(--ink-950);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Automatik, Übergabe, Verkäufer (Adminbereich) ── */

.phase-next {
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-500, #78716C);
}

.cust-seller { font-size: 12px; }

.seller-filter { max-width: 220px; }

.admin-subhead {
    margin: 28px 0 8px;
    font-size: 17px;
    font-weight: 600;
}

.row-muted td { opacity: 0.6; }

.actor-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--ink-100, #F5F5F4);
    color: var(--ink-700, #44403C);
    margin-right: 4px;
}
.actor-chip.actor-seller { background: #E0F2FE; color: #075985; }
.actor-chip.actor-customer { background: var(--success-soft); color: var(--success); }
.actor-chip.actor-import { background: #EDE9FE; color: #5B21B6; }
.actor-chip.actor-system { background: var(--accent-soft); color: var(--accent-dark); }

.automatik-status { margin-bottom: 16px; }

.automatik-preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auto-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.auto-day-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    font-weight: 600;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.auto-day-head .cell-muted { font-weight: 400; font-size: 13px; }

.auto-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.auto-item:last-child { border-bottom: 0; }
.auto-item.held { background: #FFFBEB; }
.auto-step { margin-top: 2px; }
.auto-mails { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }

.auto-empty {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--ink-500, #78716C);
}
