/* ============================================================
   AI Operations Platform - Design System v3
   Modern, Tabler-inspired. Clean, professional, ERP-ready.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --surface-alt: #F1F3F5;
    --surface-hover: #E9ECEF;
    --primary: #1864AB;
    --primary-dark: #0C4A8A;
    --primary-light: #DBEAFE;
    --accent: #0CA678;
    --accent-dark: #087F5B;

    --text: #212529;
    --text-muted: #6C757D;
    --text-light: #ADB5BD;

    --success: #2F9E44;
    --success-light: #EBFBEE;
    --warning: #E8590C;
    --warning-light: #FFF4E6;
    --danger: #E03131;
    --danger-light: #FFF5F5;
    --info: #1C7ED6;
    --info-light: #E7F5FF;

    --border: #DEE2E6;
    --border-dark: #CED4DA;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 3px rgba(0, 0, 0, .04);
    --shadow: 0 1px 3px rgba(0, 0, 0, .05), 0 4px 12px rgba(0, 0, 0, .06);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, .08), 0 16px 40px rgba(0, 0, 0, .12);

    --tap: 44px;
    --nav-h: 60px;
    --top-h: 56px;
    --sidebar-w: 240px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

    --transition: .15s ease;
}

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

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.55;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }

.subtitle { color: var(--text-muted); font-size: .875rem; margin-bottom: 1rem; }

[x-cloak] { display: none !important; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ---- Top-Bar ---- */
.topbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--top-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem;
}
.topbar__brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--primary); text-decoration: none; letter-spacing: -.02em; }
.topbar__brand:hover { text-decoration: none; }
.topbar__brand-icon { font-size: 1.3rem; }
.topbar__actions { display: flex; align-items: center; gap: .5rem; }
.topbar__user { font-size: .85rem; color: var(--text-muted); display: none; }
@media (min-width: 768px) { .topbar__user { display: inline; } }
.topbar__logout { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: .4rem .8rem; border-radius: var(--radius-sm); cursor: pointer; font-size: .85rem; font-family: var(--font); transition: all var(--transition); }
.topbar__logout:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border-dark); }

/* ---- Brand Logo ---- */
.brand-logo-img {
    height: 32px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    transition: transform var(--transition);
}
.brand-logo-img:hover {
    transform: scale(1.02);
}
.brand-logo-img--topbar {
    height: 26px;
}
.brand-logo-img--login {
    height: 96px;
    max-width: 240px;
    margin: 0 auto 1.25rem;
}

/* ---- Layout ---- */
.page {
    padding: 1rem;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}
@media (min-width: 768px) {
    .page {
        padding: 1.5rem 2rem;
        margin-left: var(--sidebar-w);
        width: calc(100% - var(--sidebar-w));
        max-width: calc(100vw - var(--sidebar-w));
        box-sizing: border-box;
    }
}
@media (min-width: 1400px) {
    .page {
        padding: 1.75rem 2.5rem;
        margin-left: var(--sidebar-w);
        width: calc(100% - var(--sidebar-w));
        max-width: 1680px;
    }
}
@media (min-width: 1920px) {
    .page {
        max-width: 1840px;
    }
}

/* Guard against double-nested .page shifting */
.page .page {
    padding: 0 !important;
    margin-left: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* ---- Bottom Nav (Mobile only) ---- */
.bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex; justify-content: space-around; align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.bottomnav__item,
.bottomnav__link {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    text-decoration: none; color: var(--text-light);
    font-size: .68rem; font-weight: 500; padding: .35rem .5rem;
    min-width: var(--tap); min-height: 44px;
    transition: color var(--transition); white-space: nowrap; position: relative;
    flex-shrink: 0;
}
.bottomnav__item.active,
.bottomnav__link.active { color: var(--primary); }
.bottomnav__icon { font-size: 1.25rem; }
.bottomnav__badge {
    position: absolute; top: 2px; right: 50%; transform: translateX(20px);
    background: var(--danger); color: #fff; font-size: .6rem; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
}
@media (min-width: 768px) {
    .bottomnav { display: none; }
    body { padding-bottom: 0; }
}
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 768px) { body { padding-bottom: 0; } }

/* ---- Desktop Sidebar ---- */
.sidebar { display: none; }
@media (min-width: 768px) {
    .sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
        background: var(--surface); border-right: 1px solid var(--border);
        padding: 1.25rem 0;
        z-index: 90;
        overflow-x: hidden;
    }
    .sidebar__brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--primary); padding: 0 1.25rem; margin-bottom: 1.5rem; text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
    .sidebar__brand:hover { text-decoration: none; }
    .sidebar__nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .75rem; overflow-y: auto; overflow-x: hidden; flex: 1; }
    .sidebar__link { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--text-muted); padding: .55rem .85rem; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; transition: all var(--transition); white-space: nowrap; }
    .sidebar__link:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
    .sidebar__link.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
    .sidebar__icon { font-size: 1.15rem; flex-shrink: 0; }
    .sidebar__footer { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--border); overflow-x: hidden; }
    .sidebar__user { font-size: .85rem; color: var(--text-muted); margin-bottom: .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---- FAB ---- */
.fab {
    position: fixed; bottom: calc(var(--nav-h) + 1rem); right: 1rem;
    height: 48px; min-height: 48px; padding: 0 1.25rem;
    border-radius: var(--radius-full);
    background: var(--primary); color: #fff; border: none;
    font-size: .875rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; box-shadow: var(--shadow-lg);
    z-index: 50; display: inline-flex; align-items: center; justify-content: center;
    gap: .5rem; transition: all var(--transition);
    line-height: 1.2; white-space: nowrap;
}
.fab:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(24, 100, 171, .35); text-decoration: none; }
.fab:active { transform: translateY(0) scale(.97); }
.fab:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.fab__label { display: none; }
@media (min-width: 768px) {
    .fab { bottom: 1.5rem; right: 1.5rem; }
    .fab__label { display: inline; }
}
@media (min-width: 768px) {
    .fab { padding: 0 1.5rem; }
}

/* ---- Card (Tabler pattern) ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}
.card--accent { border-left: 3px solid var(--primary); }
.card--warning { border-left: 3px solid var(--warning); }
.card--success { border-left: 3px solid var(--success); }
.card--danger { border-left: 3px solid var(--danger); }
.card--clickable { cursor: pointer; text-decoration: none; color: inherit; display: block; }
.card--clickable:hover { box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }

/* Tabler card sub-components */
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: var(--radius) var(--radius) 0 0;
    margin: -1.25rem -1.25rem 1.25rem;
}
.card-body { padding: 0; }
.card-title { font-size: 1rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }

/* ---- KPI Grid ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow var(--transition), border-color var(--transition);
    box-shadow: var(--shadow-sm);
}
.kpi-card:hover { box-shadow: var(--shadow); text-decoration: none; border-color: var(--border-dark); }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.kpi-value--success { color: var(--success); }
.kpi-value--warning { color: var(--warning); }
.kpi-value--danger { color: var(--danger); }
.kpi-value--info { color: var(--info); }
.kpi-label { color: var(--text-muted); font-size: .75rem; margin-top: .15rem; font-weight: 500; }
.kpi-sub { color: var(--text-muted); font-size: .7rem; margin-top: .25rem; }
.kpi-sub--warning { color: var(--warning); }
.kpi-sub--danger { color: var(--danger); }

/* ---- Page Header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
    min-height: 0;
}
.workorder-edit-form {
    width: 100%;
    max-width: none;
    scroll-margin-top: 1rem;
}
/* Keep action labels visible even while Alpine hydrates x-text bindings. */
button[x-text*="Bedarf speichern"]:empty::after { content: "Bedarf speichern"; }
button[x-text*="Material buchen"]:empty::after { content: "Material buchen"; }
.page-header__title { flex: 1; min-width: 200px; }
.page-header__actions { display: flex; gap: .5rem; flex-shrink: 0; flex-wrap: wrap; }

/* ---- Action Bar ---- */
.action-bar {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
    flex: 1;
    min-width: 150px;
}
.filter-bar > input { min-width: 200px; }

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-btn, .tab {
    background: none;
    border: none;
    padding: .6rem 1rem;
    cursor: pointer;
    font-size: .875rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    font-family: var(--font);
    font-weight: 500;
    transition: color var(--transition), border-color var(--transition);
}
.tab-btn--active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover, .tab:hover { color: var(--text); }

/* ---- Grid Layouts ---- */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 768px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Form ---- */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: .8rem; font-weight: 500; margin-bottom: .3rem; color: var(--text-muted); }
input, select, textarea {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 100, 171, .12);
}
input:disabled { opacity: .6; background: var(--surface-alt); cursor: not-allowed; }
textarea { resize: vertical; min-height: 2.5rem; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid--4 { grid-template-columns: repeat(4, 1fr); }
.form-grid > .full { grid-column: 1 / -1; }
@media (max-width: 600px) {
    .form-grid, .form-grid--3, .form-grid--4 { grid-template-columns: 1fr 1fr; }
    .form-grid > .full { grid-column: 1 / -1; }
}

.form-section {
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
}
.form-section--first { margin-top: 0; padding-top: 0; border-top: none; }
.form-section h4 { margin-bottom: .5rem; }

.form-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.checkbox-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .25rem;
}
.checkbox-row input[type="checkbox"] { width: auto; }
.checkbox-row label { margin: 0; }

/* Modal form helpers */
.crud-form-panel {
    display: block;
    width: 100%;
    margin: 0 0 1.25rem;
    padding: 0;
}
.crud-form-card {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: .6rem;
    box-shadow: 0 1px 3px rgba(15,23,42,.06);
    overflow: hidden;
}
.crud-form-card--lg,
.crud-form-card--sm { max-width: none !important; }
.crud-form-panel .modal__header,
.crud-form-panel .modal__footer { padding: 1rem 1.25rem; }
.crud-form-panel .modal__body { padding: 1.25rem; max-height: none; overflow: visible; }
.crud-form-panel .modal__header,
.crud-form-panel .crud-form-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.crud-form-back { margin-right: auto; }
.detail-breadcrumb {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin: 0 0 .75rem;
    color: var(--text-muted);
    font-size: .85rem;
}
.detail-breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.detail-breadcrumb a:hover { text-decoration: underline; }

/* Legacy CRUD dialogs are rendered in the page flow.  The class names remain
   as a compatibility layer for Alpine handlers, but no overlay or viewport
   trapping is used anywhere in the ERP. */
.modal-overlay {
    position: static !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    background: transparent !important;
    padding: 0 !important;
}
.modal-overlay > .modal {
    width: 100%;
    max-width: none !important;
    max-height: none !important;
    margin: 0 auto !important;
    border-radius: .6rem;
}
.modal-overlay > .modal .modal__body {
    max-height: none !important;
    overflow: visible !important;
}
.crud-form-panel > .modal {
    width: 100%;
    max-width: none !important;
    max-height: none !important;
    margin: 0 auto !important;
    border-radius: .6rem;
}
.crud-form-panel > .modal .modal__body {
    max-height: none !important;
    overflow: visible !important;
}
.modal-backdrop {
    position: static !important;
    background: transparent !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
}
.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
.modal-form-grid > .full { grid-column: 1 / -1; }
.modal-form-section {
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
}
.modal-form-section--first { margin-top: 0; padding-top: 0; border-top: none; }
.modal-form-section h4 { margin-bottom: .5rem; }
@media (max-width: 600px) {
    .modal-form-grid { grid-template-columns: 1fr 1fr; }
    .modal-form-grid > .full { grid-column: 1 / -1; }
}

/* ---- Button ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .5rem 1rem; border: 1px solid transparent; border-radius: var(--radius-sm);
    font-size: .875rem; font-weight: 600; cursor: pointer;
    font-family: var(--font); text-decoration: none;
    min-height: var(--tap); transition: all var(--transition);
    line-height: 1.2; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-dark); text-decoration: none; }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: #25703a; text-decoration: none; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #c02a2a; text-decoration: none; }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-alt); border-color: var(--border-dark); text-decoration: none; }
.btn--outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn--outline:hover { background: var(--primary-light); text-decoration: none; }
.btn--block { width: 100%; }
.btn--sm { padding: .35rem .75rem; font-size: .8rem; min-height: 34px; font-weight: 500; }
.btn--xs { padding: .2rem .5rem; font-size: .75rem; min-height: 28px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ---- Badge ---- */
.badge {
    display: inline-flex; align-items: center;
    padding: .15rem .5rem; border-radius: var(--radius-full);
    font-size: .75rem; font-weight: 600;
    background: var(--surface-alt); color: var(--text-muted);
    white-space: nowrap; line-height: 1.4;
}
.badge--new { background: var(--surface-alt); color: var(--text-muted); }
.badge--processing { background: var(--info-light); color: var(--info); }
.badge--needs_review, .badge--open, .badge--draft, .badge--scheduled { background: var(--warning-light); color: var(--warning); }
.badge--approved, .badge--active, .badge--completed, .badge--success { background: var(--success-light); color: var(--success); }
.badge--rejected, .badge--failed, .badge--cancelled, .badge--danger, .badge--overdue { background: var(--danger-light); color: var(--danger); }
.badge--info { background: var(--info-light); color: var(--info); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--sm { font-size: .68rem; padding: .1rem .4rem; }

/* ---- Status indicators (Tabler-style dots) ---- */
.status {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .8rem; font-weight: 500;
}
.status::before {
    content: ""; display: inline-block;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-light); flex-shrink: 0;
}
.status-green::before { background: var(--success); }
.status-yellow::before { background: var(--warning); }
.status-red::before { background: var(--danger); }

/* ---- List ---- */
.list { display: flex; flex-direction: column; gap: .5rem; }
.list-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none; color: inherit;
    transition: box-shadow var(--transition), border-color var(--transition);
    box-shadow: var(--shadow-sm);
}
.list-item:hover { box-shadow: var(--shadow); border-color: var(--border-dark); text-decoration: none; }
.list-item--static { cursor: default; }
.list-item--static:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
.list-item__icon { font-size: 1.5rem; flex-shrink: 0; width: 32px; text-align: center; }
.list-item__main { flex: 1; min-width: 0; }
.list-item__title { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__meta { color: var(--text-muted); font-size: .8rem; margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__actions { display: flex; gap: .25rem; flex-shrink: 0; }
.list-item__amount { font-weight: 700; font-size: .9rem; flex-shrink: 0; white-space: nowrap; }

/* ---- Empty State ---- */
.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty__icon { font-size: 3rem; margin-bottom: .5rem; opacity: .5; }
.empty__text { font-size: .875rem; line-height: 1.6; }

/* ---- Breadcrumb ---- */
.breadcrumb { margin-bottom: 1rem; }
.breadcrumb a { text-decoration: none; color: var(--text-muted); font-size: .85rem; transition: color var(--transition); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }

/* ---- Key-Value Rows ---- */
.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.kv-row:last-child { border-bottom: none; }
.kv-label { color: var(--text-muted); font-size: .8rem; flex-shrink: 0; min-width: 120px; }
.kv-value { font-weight: 600; text-align: right; word-break: break-word; font-size: .875rem; }
.kv-value--left { text-align: left; }

/* ---- Datagrid (Tabler-style key-value display) ---- */
.datagrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.datagrid__item {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.datagrid__item:nth-last-child(-n+1) { border-bottom: none; }
.datagrid__title { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: .2rem; }
.datagrid__content { font-size: .875rem; font-weight: 600; }

/* Work-order details follow the portal's flat detail layout; information is
   grouped by rows without the legacy nested card container. */
.workorder-stammdaten { max-width: 960px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; }
.workorder-stammdaten .kv-row { border-bottom: 1px solid var(--border); padding: .7rem 0; min-width: 0; }
.workorder-stammdaten .kv-value { overflow-wrap: anywhere; }
@media (max-width: 700px) { .workorder-stammdaten { grid-template-columns: 1fr; } }

/* ---- Detail Header ---- */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.detail-header__title { flex: 1; min-width: 200px; }
.detail-header__badges { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.detail-header h1 { margin: 0; }
.detail-header__sub { color: var(--text-muted); margin-top: .25rem; font-size: .85rem; }

/* ---- Capture Area ---- */
.capture {
    border: 2px dashed var(--border-dark); border-radius: var(--radius-lg);
    padding: 2rem 1rem; text-align: center; margin-bottom: 1rem;
    background: var(--surface-alt);
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
}
.capture:hover { border-color: var(--primary); background: var(--primary-light); }
.capture--active, .capture--drag { border-color: var(--primary); background: var(--primary-light); }
.capture__icon { font-size: 2.5rem; margin-bottom: .5rem; }
.capture__title { font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.capture__hint { font-size: .8rem; color: var(--text-muted); }
.capture__file { margin-top: .5rem; font-size: .85rem; color: var(--text-muted); }

/* ---- Inbox Items ---- */
.inbox-item { cursor: pointer; }
.inbox-item--processing { border-left: 3px solid var(--info); }
.inbox-item--needs_review { border-left: 3px solid var(--warning); }
.inbox-item--completed { border-left: 3px solid var(--success); }
.inbox-item--failed { border-left: 3px solid var(--danger); }

/* ---- Review ---- */
.review { margin-bottom: 1rem; }
.review__question { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.review__meta { color: var(--text-muted); font-size: .8rem; margin-bottom: .75rem; }
.review__proposal { font-size: .85rem; color: var(--text-muted); margin-bottom: .75rem; padding: .5rem .75rem; background: var(--surface-alt); border-radius: var(--radius-sm); }
.review__buttons { display: flex; gap: .5rem; margin-top: 1rem; }
.review__buttons .btn { flex: 1; }

/* ---- Login ---- */
.login {
    display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - 2rem);
    padding: 1rem;
}
.login__card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    max-width: 400px; width: 100%;
    text-align: center;
}
.login__logo { font-size: 3rem; margin-bottom: .5rem; }
.login__title { margin-bottom: .25rem; }
.login__subtitle { color: var(--text-muted); font-size: .85rem; margin-bottom: 1.5rem; }
.login__demo { margin-top: 1.5rem; padding: .75rem; background: var(--surface-alt); border-radius: var(--radius-sm); font-size: .8rem; color: var(--text-muted); text-align: left; }

/* ---- Search ---- */
.search-bar {
    display: flex; gap: .5rem; align-items: center;
}
.search-bar input { flex: 1; }
.search-results { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.search-hit {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.search-hit:hover { box-shadow: var(--shadow); }
.search-hit__type { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); margin-bottom: .15rem; }
.search-hit__title { font-weight: 600; font-size: .9rem; }
.search-hit__snippet { color: var(--text-muted); font-size: .8rem; margin-top: .25rem; }

/* ---- Command Bar ---- */
.command-bar {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .5rem 1rem;
}
.command-input {
    flex: 1;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.command-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24, 100, 171, .12); }
.command-result {
    margin-top: .5rem;
    padding: .75rem;
    border-radius: var(--radius);
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

/* ---- Spinner ---- */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border-dark);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Animations ---- */
.fade-in { animation: fadeIn .3s ease; }
.slide-out { animation: slideOut .3s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(100px); } }

/* ---- Flash/Toast ---- */
.flash {
    padding: .65rem 1rem; border-radius: var(--radius-sm);
    font-size: .85rem; font-weight: 500; margin-bottom: 1rem;
    border: 1px solid transparent;
}
.flash--success { background: var(--success-light); color: var(--success); border-color: rgba(47, 158, 68, .2); }
.flash--error { background: var(--danger-light); color: var(--danger); border-color: rgba(224, 49, 49, .2); }

/* ============================================================ MODAL SYSTEM
 * Zentrale Modal-Klassen fuer Desktop + Mobile.
 * [x-cloak] { display: none !important; } verhindert Aufblitzen.
 */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(33, 37, 41, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: scroll;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-overflow-scrolling: touch;
}
.modal-overlay::-webkit-scrollbar {
    width: 8px;
}
.modal-overlay::-webkit-scrollbar-track {
    background: transparent;
}
.modal-overlay::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4rem);
    overflow: hidden;
}

.modal--lg { max-width: 760px; }
.modal--sm { max-width: 420px; }

/* CRUD forms are full-width page sections, never constrained like dialogs. */
.crud-form-panel,
.crud-form-panel > .modal,
.crud-form-panel > .modal.modal--lg,
.crud-form-panel > .modal.modal--sm,
.crud-form-panel > .crud-form-card {
    width: 100% !important;
    max-width: none !important;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal__title { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.modal__close {
    background: none; border: none; font-size: 1.5rem; line-height: 1;
    color: var(--text-muted); cursor: pointer; padding: .25rem .5rem;
    border-radius: var(--radius-sm); transition: all var(--transition);
}
.modal__close:hover { background: var(--surface-alt); color: var(--text); }

.modal__body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    scrollbar-gutter: stable;
    flex: 1 1 auto;
    min-height: 0;  /* critical for flex children to allow scrolling */
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--surface-alt);
    -webkit-overflow-scrolling: touch;
}

/* When a <form> wraps modal__body + modal__footer, the form must
   participate in the modal's flex column layout, otherwise the body
   grows beyond the modal and content gets clipped without a scrollbar. */
.modal > form,
.modal > div > form {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Webkit scrollbar styling - always visible rails */
.modal__body::-webkit-scrollbar {
    width: 12px !important;
}
.modal__body::-webkit-scrollbar-track {
    background: #e9ecef !important;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}
.modal__body::-webkit-scrollbar-thumb {
    background: #6c757d !important;
    border-radius: 6px;
    border: 2px solid #e9ecef;
}
.modal__body::-webkit-scrollbar-thumb:hover {
    background: #495057 !important;
}
/* Firefox */
.modal__body {
    scrollbar-width: auto !important;
    scrollbar-color: #6c757d #e9ecef !important;
}

.modal__footer {
    padding: .75rem 1.5rem 1.25rem;
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .modal-overlay { padding: 3rem 2rem; }
    .modal { margin: 1rem auto; }
}
@media (max-width: 767px) {
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal { margin: 0; max-height: 100vh; max-width: 100%; border-radius: 0; }
    .modal--sm, .modal--lg { max-width: 100%; }
    .modal__body { padding: 1rem; }
    .modal__header, .modal__footer { padding: .75rem 1rem; }
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 1rem; right: 1rem;
    padding: .75rem 1.25rem;
    background: var(--text); color: white;
    border-radius: var(--radius); z-index: 2000;
    box-shadow: var(--shadow-lg);
    font-size: .85rem; font-weight: 500;
    max-width: 320px;
    animation: fadeIn .3s ease;
}
@media (max-width: 767px) {
    .toast { bottom: calc(var(--nav-h) + 1rem); left: 1rem; right: 1rem; max-width: none; }
}

/* ---- Avatar (Tabler-style initials) ---- */
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-light); color: var(--primary-dark);
    font-size: .85rem; font-weight: 600;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.avatar--sm { width: 28px; height: 28px; font-size: .7rem; }

/* ---- Table (Tabler-style) ---- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.table > thead > tr {
    border-bottom: 1px solid var(--border);
}
.table > thead > tr > th {
    padding: .6rem .75rem;
    font-size: .7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted);
    text-align: left;
    white-space: nowrap;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}
.table > tbody > tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.table > tbody > tr:hover {
    background: var(--surface-alt);
}
.table > tbody > tr:last-child {
    border-bottom: none;
}
.table > tbody > tr > td {
    padding: .65rem .75rem;
    vertical-align: middle;
}
.table-vcenter > tbody > tr > td {
    vertical-align: middle;
}
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ---- Helpers ---- */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }

/* ---- Responsive Helpers ---- */
@media (max-width: 767px) {
    .form-grid, .form-grid--3, .form-grid--4 { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    h1 { font-size: 1.25rem; }
    .datagrid { grid-template-columns: 1fr; }
    .datagrid__item { border-right: none; }
}

@media (max-width: 390px) {
    .form-grid, .form-grid--3, .form-grid--4,
    .modal-form-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Print ---- */
@media print {
    .sidebar, .bottomnav, .fab, .topbar__logout { display: none; }
    .page { max-width: 100%; margin: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ============================================================
   Lager & Materialwirtschaft - Dedicated ERP Design System
   ============================================================ */

.inventory-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Header & Actions Toolbar */
.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    width: 100%;
}
.inventory-header__title {
    flex: 1;
    min-width: 260px;
}
.inventory-header__title h1 {
    margin: 0 0 0.25rem 0;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.inventory-header__title p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.inventory-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.inventory-toolbar .btn {
    min-height: 36px;
    padding: 0.4rem 0.85rem;
    font-size: 0.825rem;
    font-weight: 600;
}

/* KPI Grid: Exactly 6 symmetrical cards */
.inventory-kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    width: 100%;
}
@media (max-width: 1200px) {
    .inventory-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 640px) {
    .inventory-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

.inventory-kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 0.75rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all var(--transition);
}
.inventory-kpi-card:hover {
    border-color: var(--border-dark);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.inventory-kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}
.inventory-kpi-card .kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Modern Segmented Tab Bar */
.inventory-tabs-container {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.35rem;
    box-shadow: var(--shadow-sm);
}
.inventory-tabs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.inventory-tabs::-webkit-scrollbar {
    display: none;
}
.inventory-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    flex: 1 1 0;
    text-align: center;
    font-family: var(--font);
}
.inventory-tab:hover {
    background: var(--surface-alt);
    color: var(--text);
}
.inventory-tab.active {
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(24, 100, 171, 0.25);
}
.inventory-tab.active .badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-color: transparent;
}
@media (max-width: 992px) {
    .inventory-tab {
        flex: 0 0 auto;
        padding: 0.5rem 0.85rem;
    }
}

/* Card & Table Layout */
.inventory-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    width: 100%;
}
.inventory-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.25rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}
.inventory-card__header-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.inventory-card__header-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.inventory-card__table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.inventory-card__table-wrap .table {
    margin-bottom: 0;
    width: 100%;
}
.inventory-card__table-wrap .table th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 2-Column Responsive Grid */
.bridge-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    width: 100%;
}
@media (max-width: 992px) {
    .bridge-grid-2 {
        grid-template-columns: 1fr;
    }
}


/* ============================================================
   Voice Command - Unified input group with inline mic button
   ============================================================ */
.voice-command {
    margin-bottom: 1rem;
}

/* Input group: text field + mic + send button in one row */
.voice-input-group {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    overflow: hidden;
}
.voice-input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 100, 171, .12);
}
.voice-input-group--listening {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(192, 42, 42, .12);
}

/* Text input - fills available space, no own border */
.voice-input {
    flex: 1;
    padding: .5rem .75rem;
    border: none;
    background: transparent;
    font-size: .875rem;
    font-family: var(--font);
    color: var(--text);
    outline: none;
    min-height: var(--tap);
}
.voice-input:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}
.voice-input::placeholder {
    color: var(--text-muted);
}

/* Mic button - inside the input, right side, before send */
.voice-mic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: auto;
    height: 40px;
    border: none;
    border-left: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0 .65rem;
    gap: .35rem;
    white-space: nowrap;
}
.voice-button-label {
    font-size: .75rem;
    font-weight: 600;
}
.voice-mic-btn:hover:not(:disabled) {
    background: var(--surface-alt);
    color: var(--primary);
}
.voice-mic-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}
.voice-mic-btn--active {
    background: var(--danger);
    color: #fff;
    border-left-color: var(--danger);
}
.voice-mic-btn--active:hover {
    background: #c02a2a;
    color: #fff;
}
.voice-mic-btn--pulse {
    animation: voice-pulse-anim 1.2s ease-in-out infinite;
}
@keyframes voice-pulse-anim {
    0%, 100% { box-shadow: 0 0 0 0 rgba(192, 42, 42, .4); }
    50% { box-shadow: 0 0 0 6px rgba(192, 42, 42, 0); }
}

/* Send button - rightmost, primary color */
.voice-send-btn {
    flex-shrink: 0;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--primary-dark);
    min-height: var(--tap);
}

/* Listening bar - appears below input when recording */
.voice-listening-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .5rem;
    padding: .4rem .75rem;
    background: rgba(192, 42, 42, .06);
    border-radius: var(--radius-sm);
    font-size: .85rem;
    color: var(--danger);
}
.voice-listening-text {
    font-weight: 600;
}
.voice-interim {
    color: var(--text-muted);
    font-style: italic;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.voice-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
    animation: voice-dot-pulse 1s ease-in-out infinite;
}
@keyframes voice-dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .4; transform: scale(.8); }
}

/* Result panel */
.voice-result {
    margin-top: .75rem;
    padding: .75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-alt);
}
.voice-result--success {
    border-color: var(--success);
    background: rgba(43, 156, 70, .04);
}
.voice-result--warning {
    border-color: var(--warning);
    background: rgba(233, 164, 4, .04);
}
.voice-result__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
}
.voice-result__info {
    flex: 1;
    min-width: 0;
}
.voice-result__agent,
.voice-result__confidence,
.voice-result__hint {
    margin-left: .5rem;
    color: var(--text-muted);
    font-size: .8rem;
}
.voice-result__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: .15rem .35rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    flex-shrink: 0;
}
.voice-result__close:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.voice-result__desc {
    margin: .25rem 0 0;
    color: var(--text-muted);
    font-size: .85rem;
}
.voice-result__target {
    margin-top: .5rem;
    padding: .5rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
}
.voice-result__target-status {
    font-size: .85rem;
}
.voice-result__target-msg {
    font-size: .85rem;
    margin-top: .25rem;
    color: var(--text-muted);
}
.voice-result__target-action {
    margin-top: .5rem;
}

/* Suggestions list */
.voice-suggestions {
    margin-top: .5rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.voice-suggestion {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.voice-suggestion:hover {
    background: var(--surface-hover);
}
.voice-suggestion__arrow {
    color: var(--text-muted);
    flex-shrink: 0;
}
.voice-suggestion__main {
    flex: 1;
    min-width: 0;
}
.voice-suggestion__title {
    font-size: .85rem;
    font-weight: 500;
}
.voice-suggestion__desc {
    font-size: .8rem;
    color: var(--text-muted);
}

/* Mobile: keep input group compact */
@media (max-width: 768px) {
    .voice-input-group {
        flex-wrap: nowrap;
    }
    .voice-mic-btn {
        width: 44px;
        height: 44px;
    }
    .voice-send-btn {
        padding: .35rem .75rem;
    }
}

/* ============================================================
   Agent Quick Actions Bar (KI-Schnellbefehle)
   ============================================================ */
.agent-quick-section {
    background: var(--surface-alt, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius, 8px);
    padding: 0.65rem 0.9rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
.agent-quick-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.agent-quick-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main, #1e293b);
}
.agent-quick-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(11, 48, 86, 0.1);
    color: var(--primary, #0B3056);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.agent-quick-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    font-weight: normal;
}
.agent-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}
.agent-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface, #ffffff);
    border: 1px solid var(--border, #cbd5e1);
    color: var(--text-main, #1e293b);
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    text-decoration: none;
    user-select: none;
}
.agent-quick-chip:hover {
    background: #f1f5f9;
    border-color: var(--primary, #0B3056);
    color: var(--primary, #0B3056);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
}
.agent-quick-chip:active {
    transform: translateY(0);
}
.agent-quick-chip:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.agent-quick-chip--loading {
    border-color: var(--primary, #0B3056);
    background: rgba(11, 48, 86, 0.04);
}
.agent-quick-chip__icon {
    font-size: 0.95rem;
    line-height: 1;
}
.agent-quick-chip__label {
    white-space: nowrap;
}
.agent-quick-feedback {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(11, 48, 86, 0.06);
    color: var(--primary, #0B3056);
}
.agent-quick-feedback--success {
    background: rgba(43, 156, 70, 0.1);
    color: var(--success, #2b9c46);
}
.agent-quick-feedback--error {
    background: rgba(192, 42, 42, 0.1);
    color: var(--danger, #c02a2a);
}

/* ============================================================
   Scrollable Panels - Fixed-height scrollable lists & tables
   Usage: <div class="scroll-panel"> <div class="list">...</div> </div>
   Or:    <div class="scroll-panel scroll-panel--table"> <table>...</table> </div>
   ============================================================ */
.scroll-panel {
    max-height: 480px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: .5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) transparent;
}
.scroll-panel::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.scroll-panel::-webkit-scrollbar-track {
    background: transparent;
}
.scroll-panel::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}
.scroll-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* When wrapping a .list, remove outer border (panel provides it) */
.scroll-panel > .list {
    gap: .35rem;
}

/* Table variant: sticky header */
.scroll-panel--table {
    padding: 0;
    overflow: auto;
}
.scroll-panel--table > .table,
.scroll-panel--table > .table-responsive {
    margin: 0;
    border: none;
    border-radius: 0;
}
.scroll-panel--table > .table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface-alt);
}

/* Compact variant for smaller panels */
.scroll-panel--sm {
    max-height: 320px;
}

/* Tall variant for full-page lists */
.scroll-panel--lg {
    max-height: 65vh;
}

/* Cockpit: 4 panels in 2x2 grid, each independently scrollable */
.cockpit-panels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}
@media (max-width: 992px) {
    .cockpit-panels {
        grid-template-columns: 1fr;
    }
}
.cockpit-panel__title {
    font-size: 1rem;
    margin-bottom: .5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cockpit-panel__count {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 500;
}
