@font-face {
    font-family: 'Source Code Pro';
    src: url('fonts/SourceCodePro-Variable.ttf') format('truetype');
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Source Code Pro';
    src: url('fonts/SourceCodePro-Italic-Variable.ttf') format('truetype');
    font-weight: 200 900;
    font-style: italic;
    font-display: swap;
}

:root {
    --primary: #b1d641;
    --primary-dark: #96b835;
    --primary-light: #c2e25a;
    --secondary: #027ABB;
    --bg-dark: #18181B;
    --bg-card: #1F1F32;
    --bg-sidebar: #111118;
    --bg-main: #0f0f14;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0b0;
    --text-muted: #666680;
    --border-color: #2a2a3d;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --font-mono: 'Source Code Pro', monospace;
    --sidebar-width: 260px;
    --header-height: 60px;
    --radius: 8px;
    --transition: all 0.2s ease;
}

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

/* Prevent min-content blow-out in flex/grid children (images, pre, long words) */
*, *::before, *::after {
    min-width: 0;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    /* iOS safe-area support */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Media & embeds never overflow their container */
img, svg, video, canvas, iframe {
    max-width: 100%;
    height: auto;
}

/* Break overly long tokens (URLs, IDs) instead of pushing layout wider */
p, h1, h2, h3, h4, h5, h6, td, th, li, dd, dt, a, span, div.breakable {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Inputs must not exceed container */
input, select, textarea {
    max-width: 100%;
    box-sizing: border-box;
}

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

a:hover {
    color: var(--primary-light);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.2s ease;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--header-height);
}

.sidebar-header img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    transition: var(--transition);
    margin: 1px 0;
}

.nav-item:hover {
    background: rgba(177, 214, 65, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary);
    color: #1a1a2e;
}

.nav-item .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-footer .user-info:hover {
    background: rgba(255,255,255,0.05);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a2e;
    font-weight: 600;
    font-size: 13px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.2s ease;
}

/* Sidebar-Collapse-Toggle (Desktop/Tablet). Standard sichtbar, auf echten
   Phones (<=640 px) ausgeblendet – dort übernimmt der Burger/Overlay. */
.sidebar-collapse-toggle {
    display: inline-flex;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
    flex: 0 0 auto;
}
.sidebar-collapse-toggle:hover,
.sidebar-collapse-toggle:active {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--primary);
}
@media (max-width: 640px) {
    .sidebar-collapse-toggle { display: none; }
}

/* Eingeklappter Zustand: nur Icons sichtbar */
html.sidebar-collapsed .sidebar {
    width: 64px;
}
html.sidebar-collapsed .sidebar-header h1,
html.sidebar-collapsed .nav-section-title,
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .sidebar-footer .user-info > div:not(.user-avatar) {
    display: none;
}
html.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 16px 8px;
}
html.sidebar-collapsed .sidebar-header img {
    margin: 0 auto;
}
html.sidebar-collapsed .nav-section {
    padding: 0 6px;
}
html.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px 6px;
    gap: 0;
}
html.sidebar-collapsed .nav-item .nav-icon {
    width: auto;
    font-size: 16px;
}
html.sidebar-collapsed .sidebar-footer {
    padding: 10px 6px;
}
html.sidebar-collapsed .sidebar-footer .user-info {
    justify-content: center;
    padding: 4px;
}
@media (min-width: 641px) {
    html.sidebar-collapsed .main-content {
        margin-left: 64px;
    }
}

.content-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
}

.content-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.content-body {
    flex: 1;
    padding: 24px;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #1a1a2e;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #1a1a2e;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(177, 214, 65, 0.2);
}

select.form-control {
    appearance: none;
    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='%23a0a0b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

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

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

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

/* Tabellenzellen dürfen NICHT pro Zeichen umbrechen – das täte die globale
   overflow-wrap:anywhere-Regel sonst, sobald Spalten eng werden. Wörter
   bleiben ganz; ist die Tabelle insgesamt zu breit, scrollt der
   .table-responsive-Container horizontal statt die Spalten zu zerquetschen. */
.table th,
.table td {
    overflow-wrap: normal;
    word-break: normal;
}

.table th,
.table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0,0,0,0.2);
}

.table tr:hover td {
    background: rgba(177, 214, 65, 0.05);
}

.table-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-primary { background: rgba(2, 122, 187, 0.2); color: var(--secondary); }
.badge-success { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-secondary { background: rgba(160, 160, 176, 0.2); color: var(--text-secondary); }
.badge-info { background: rgba(59, 130, 246, 0.2); color: var(--info); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
a.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
a.stat-card.is-active-filter {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-card));
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-icon.green-primary { background: rgba(177, 214, 65, 0.15); color: var(--primary); }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.stat-icon.blue { background: rgba(2, 122, 187, 0.15); color: var(--secondary); }
.stat-icon.green { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.stat-icon.yellow { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.stat-info h4 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 12px;
    color: var(--text-muted);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: rgba(34, 197, 94, 0.15); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3); }
.alert-error { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.alert-info { background: rgba(59, 130, 246, 0.15); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.3); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Grid layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 20px;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 16px 0;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.pagination a:hover {
    background: rgba(177, 214, 65, 0.1);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--primary);
    color: #1a1a2e;
    border-color: var(--primary);
}

/* Search */
.search-bar {
    position: relative;
}

.search-bar input {
    padding-left: 36px;
}

.search-bar::before {
    content: '⌕';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    gap: 0;
}

.tab {
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Item list */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: var(--transition);
}

.item-row:hover {
    border-color: var(--primary);
}

/* Login Page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.login-card h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-day-header {
    padding: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    background: var(--bg-card);
}

.calendar-day {
    min-height: 100px;
    padding: 8px;
    background: var(--bg-card);
    font-size: 12px;
}

.calendar-day.today {
    background: rgba(177, 214, 65, 0.08);
}

.calendar-day.other-month {
    opacity: 0.3;
}

.calendar-day .day-number {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 13px;
}

.calendar-day.today .day-number {
    color: var(--primary);
}

.calendar-event {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    margin-bottom: 2px;
    background: var(--primary);
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.calendar-nav h3 {
    font-size: 18px;
    min-width: 200px;
    text-align: center;
}

/* Time tracking */
.timer-display {
    font-size: 36px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
    text-align: center;
    padding: 20px;
}

.timer-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

/* Invoice/Offer items */
.line-items {
    margin: 20px 0;
}

.line-item {
    display: grid;
    grid-template-columns: 50px 1fr 80px 70px 100px 100px 40px;
    gap: 8px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.line-item-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.line-item-row .article-search-wrap .article-search-input {
    font-size: 11px !important;
    padding: 3px 6px 3px 24px !important;
    background: var(--bg-sidebar);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.line-item-row .article-search-wrap .article-search-input:focus {
    border-color: var(--primary);
}

/* Item type variants (optional / alternative) */
.line-item-row.item-type-optional {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    border-left: 3px solid var(--primary);
    padding-left: 6px;
}
.line-item-row.item-type-optional .item-desc,
.line-item-row.item-type-optional .item-total {
    font-style: italic;
    opacity: 0.85;
}
.line-item-row.item-type-alternative {
    background: rgba(245, 158, 11, 0.07);
    border-left: 3px solid #f59e0b;
    padding-left: 6px;
}
.line-item-row.item-type-alternative .item-desc,
.line-item-row.item-type-alternative .item-total {
    font-style: italic;
    opacity: 0.85;
}

/* --- Positionen per Drag & Drop umordnen --- */
.line-item-row .li-handle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: grab;
}
.line-item-row .li-handle:active { cursor: grabbing; }
.line-item-row .li-handle .li-grip {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}
/* Positions-Nummer schmaler, damit Grip + Zahl in die Spalte passen */
.line-item-row .li-handle input[readonly] {
    width: 24px !important;
    padding-left: 2px !important;
    padding-right: 2px !important;
}
.line-item-row.li-dragging {
    opacity: 0.5;
    background: rgba(127, 127, 127, 0.10);
}
.line-item-row.item-type-optional .item-type-select {
    border-color: var(--primary);
    color: var(--primary);
}
.line-item-row.item-type-alternative .item-type-select {
    border-color: #f59e0b;
    color: #b45309;
}

.article-dropdown-item:hover {
    background: var(--bg-sidebar) !important;
}

/* Priority indicators */
.priority-low { color: var(--info); }
.priority-normal { color: var(--text-secondary); }
.priority-high { color: var(--warning); }
.priority-urgent { color: var(--danger); }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Filter pills */
.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    font-family: var(--font-mono);
}

.filter-pill:hover, .filter-pill.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(177, 214, 65, 0.1);
}

/* Totals section */
.totals-section {
    max-width: 300px;
    margin-left: auto;
    margin-top: 20px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.totals-row.total {
    font-weight: 700;
    font-size: 16px;
    border-top: 2px solid var(--border-color);
    padding-top: 12px;
    margin-top: 8px;
}

/* Tag / Chip */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(177, 214, 65, 0.15);
    color: var(--primary-light);
}

/* Responsive */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .line-item { grid-template-columns: 30px 1fr 70px 70px 90px 40px; }
    .line-item .line-total { display: none; }
}

/* Sidebar als Overlay nur auf echten Phone-Breiten. iPad (inkl. Mini Portrait,
   744 px) hat die Seitenleiste fest sichtbar und nutzt den Collapse-Toggle. */
@media (max-width: 640px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: block;
    }
}

@media (max-width: 768px) {
    .content-body {
        padding: 16px;
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .line-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }

    .table th, .table td {
        padding: 8px 10px;
    }
}

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

    .content-header h2 {
        font-size: 15px;
    }

    .login-card {
        padding: 24px;
    }
}

/* ===== Mobile Responsiveness Enhancements ===== */
@media (max-width: 768px) {
    /* Header stacking + touch targets */
    .content-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
    }
    .content-header h2 { font-size: 16px; }
    .header-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .header-actions .btn,
    .btn {
        min-height: 40px;
    }
    .btn-icon {
        min-width: 40px;
        min-height: 40px;
    }

    /* Card paddings smaller */
    .card { padding: 12px; }
    .card-header, .card-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-footer .btn { flex: 1 1 auto; }

    /* Tables: horizontal scroll with min-width */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table { min-width: 560px; }
    .table-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    .table-actions .btn {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* Toolbar / filter pills scrollable */
    .filter-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .filter-pills > * { flex: 0 0 auto; }

    /* Modals */
    .modal {
        width: calc(100% - 16px) !important;
        max-width: calc(100% - 16px) !important;
        max-height: calc(100vh - 16px);
        overflow-y: auto;
        margin: 8px;
    }
    .modal-body { padding: 12px; }
    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    .modal-footer .btn { flex: 1 1 auto; }

    /* Line items editor */
    .line-item input,
    .line-item select,
    .line-item textarea {
        width: 100%;
        font-size: 14px;
    }
    .line-item-row { padding: 8px; }

    /* Forms */
    input, select, textarea {
        font-size: 16px; /* prevents iOS zoom */
    }

    /* Kanban: horizontal scroll */
    .kanban-board {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .kanban-column { min-width: 240px; }

    /* Portal */
    .portal-card { padding: 14px; }
    .portal-stats { grid-template-columns: 1fr 1fr; }
    .portal-page-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .portal-btn { min-height: 40px; }
    .portal-table { min-width: 520px; }

    /* Gantt fallback */
    .gantt-chart { overflow-x: auto; }
}

@media (max-width: 480px) {
    .content-body { padding: 12px; }
    .content-header { padding: 10px 12px; }
    .content-header h2 { font-size: 14px; }

    .card { padding: 10px; }
    .card-header h3 { font-size: 14px; }

    .btn {
        padding: 8px 10px;
        font-size: 13px;
    }
    .btn-sm {
        padding: 6px 8px;
        font-size: 12px;
    }

    .login-card { padding: 16px; }
    .login-card h1 { font-size: 20px; }

    .table th, .table td {
        padding: 6px 8px;
        font-size: 12px;
    }

    .portal-stats { grid-template-columns: 1fr; }

    .stat-card {
        padding: 12px;
    }
    .stat-value { font-size: 20px; }

    .modal-header h3 { font-size: 15px; }

    /* Stack action columns */
    .table-actions { flex-direction: column; align-items: stretch; }
    .table-actions .btn { width: 100%; }
}

@media (max-width: 360px) {
    .content-body { padding: 8px; }
    .card { padding: 8px; }
    .btn { font-size: 12px; padding: 8px; }
}

/* ===== Stage 1: Global mobile overflow guards (fix "zoomed-in" iPhone view) =====
   These rules target the most common causes of horizontal overflow on small screens. */
@media (max-width: 768px) {
    /* Main content must never be wider than viewport */
    .main-content,
    .content-body,
    .content-header,
    .card,
    .card-body {
        max-width: 100%;
        min-width: 0;
    }

    /* Any table not yet wrapped in .table-responsive becomes scrollable container */
    .content-body > table,
    .card > table,
    .card-body > table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Force common wide grids into single column on phones */
    .euer-compact,
    .grid-4,
    .stats-grid-4 {
        grid-template-columns: 1fr !important;
    }

    /* Pre / code blocks scroll instead of blowing layout */
    pre, code {
        max-width: 100%;
        overflow-x: auto;
        white-space: pre-wrap;
        word-break: break-word;
    }

    /* Toolbars wrap and never push wider than viewport */
    .toolbar, .filter-bar, .btn-group {
        max-width: 100%;
        flex-wrap: wrap;
    }

    /* Long labels in form groups wrap */
    .form-group label { word-break: break-word; }

    /* Safe-area padding for notch (left/right is handled on body; here bottom for fixed bars) */
    .content-body {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    /* Modals respect safe-area */
    .modal {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Sidebar also respects safe-area on iPhone */
    .sidebar {
        padding-top: env(safe-area-inset-top);
    }

    /* Content-Header: Dynamic-Island-Abstand + dynamische Höhe, damit umbrochene
       Action-Buttons nicht hinter den Kacheln im Body verschwinden */
    .content-header {
        height: auto;
        min-height: var(--header-height);
        padding-top: calc(10px + env(safe-area-inset-top));
        padding-bottom: 10px;
        row-gap: 8px;
    }
    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    /* Zentrales "Gerdware"-Branding auf Mobile ausblenden — kollidiert sonst mit
       den umbrechenden Action-Buttons */
    .content-header > div[style*="left:50%"],
    .content-header .header-brand-center {
        display: none !important;
    }
}

/* Auf Tablets/kleinen Desktops ebenfalls ausblenden, sobald der Header knapp
   wird und das zentrale "Gerdware"-Label hinter den rechten Buttons landet. */
@media (max-width: 1100px) {
    .content-header .header-brand-center {
        display: none !important;
    }
}

/* ===== Tabs & Alerts: lesbar auf Mobile ===== */
@media (max-width: 768px) {
    /* Einstellungs-Reiter: horizontale Scroll-Leiste statt Zusammenquetschen */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .tabs .tab {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 10px 14px;
    }
    /* Info-/Hinweis-Boxen: Icon oben verankern, Text darf umbrechen */
    .alert {
        align-items: flex-start;
        flex-wrap: wrap;
        word-break: break-word;
        line-height: 1.5;
    }
    .alert > i.fas,
    .alert > i.far,
    .alert > i.fab {
        flex: 0 0 auto;
        margin-top: 2px;
    }
    .alert code {
        display: inline-block;
        max-width: 100%;
        white-space: pre-wrap;
        word-break: break-all;
    }
}

/* ===== Stage 2: Mobile UX improvements ===== */
@media (max-width: 640px) {
    /* --- Fullscreen-Modals auf Phones (angenehmer als Mini-Fenster) --- */
    .modal-overlay { padding: 0; }
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex;
        flex-direction: column;
    }
    .modal-header {
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 2;
        padding-top: calc(16px + env(safe-area-inset-top));
    }
    .modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    /* --- Sticky Content-Header auf Mobile, damit Primäraktion immer erreichbar --- */
    .content-header {
        position: sticky;
        top: 0;
        z-index: 50;
    }

    /* --- Tabellen als Karten rendern (Opt-in via .table-mobile-cards) ---
       Jede <tr> wird zur Karte, jede <td> zeigt sein Label links (data-label).
       Nutzung im Template:
         <table class="table table-mobile-cards">
           <tr><td data-label="Name">…</td> …
    */
    .table-mobile-cards {
        display: block !important;
        min-width: 0 !important;
        width: 100%;
    }
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards tbody,
    .table-mobile-cards tr {
        display: block;
        width: 100%;
    }
    .table-mobile-cards tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 6px 0 !important;
        border: none !important;
        text-align: right;
    }
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-align: left;
        flex: 0 0 auto;
        max-width: 45%;
    }
    .table-mobile-cards td:empty { display: none; }
    .table-mobile-cards td[data-label=""]::before { content: ""; display: none; }
    .table-mobile-cards td .table-actions,
    .table-mobile-cards td.actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 6px;
    }
    .table-mobile-cards td .table-actions .btn {
        width: auto;
        flex: 0 0 auto;
    }

    /* --- Toolbar: Suchfeld nimmt volle Breite, Filter scrollen horizontal --- */
    .toolbar input[type="search"],
    .toolbar input[type="text"].search-input {
        width: 100%;
    }

    /* --- Stat-Cards etwas kompakter auf sehr schmalen Handys --- */
    .stats-grid { gap: 10px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }

    /* --- Detail-Ansichten mit inline-style grid-template-columns:2fr 1fr u.ä. ---
       Auf Mobile in eine Spalte brechen (überschreibt inline styles). */
    div[style*="grid-template-columns:2fr 1fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns:1fr 2fr"],
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns:3fr 1fr"],
    div[style*="grid-template-columns: 3fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* --- Key-Value-Tabellen (inv-meta-table u.ä.) auf Mobile stapeln ---
       th wird zum "Label oben", td direkt darunter */
    .inv-meta-table,
    table.meta-table,
    table.kv-table {
        display: block;
        width: 100%;
    }
    .inv-meta-table tbody,
    table.meta-table tbody,
    table.kv-table tbody { display: block; }
    .inv-meta-table tr,
    table.meta-table tr,
    table.kv-table tr {
        display: block;
        padding: 6px 0;
        border-bottom: 1px solid var(--border-color);
    }
    .inv-meta-table tr:last-child,
    table.meta-table tr:last-child,
    table.kv-table tr:last-child { border-bottom: none; }
    .inv-meta-table th,
    table.meta-table th,
    table.kv-table th {
        display: block;
        width: auto !important;
        padding: 0 0 2px 0 !important;
        text-align: left;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: var(--text-muted);
        font-weight: 600;
        border: none;
    }
    .inv-meta-table td,
    table.meta-table td,
    table.kv-table td {
        display: block;
        padding: 0 !important;
        border: none;
    }

    /* --- Empty states kompakter auf Mobile --- */
    .empty-state {
        padding: 24px 12px !important;
    }
    .empty-state .empty-icon,
    .empty-icon {
        font-size: 40px !important;
    }
    .empty-state h3 { font-size: 15px; }
    .empty-state p { font-size: 13px; }

    /* --- Filter-Pills Scrollbar ausblenden --- */
    .filter-pills::-webkit-scrollbar { display: none; }
    .filter-pills { scrollbar-width: none; }

    /* --- Opt-in: Sticky Form-Action-Bar am unteren Rand ---
       Template kann <div class="form-sticky-actions">…Buttons…</div> nutzen,
       und auf Mobile schwebt die Leiste immer unten mit Safe-Area-Padding. */
    .form-sticky-actions {
        position: sticky;
        bottom: 0;
        z-index: 20;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        margin: 16px -12px -12px;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    .form-sticky-actions .btn {
        flex: 1 1 auto;
        min-height: 44px;
    }

    /* --- Labels & Links in Cards auf Mobile lesbarer --- */
    .card-body .form-group label {
        font-size: 13px;
        margin-bottom: 4px;
    }

    /* --- Chips brechen um statt Liste zu sprengen --- */
    .chip {
        white-space: normal;
        word-break: break-word;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* WICHTIG: KEIN animation-fill-mode:forwards. Mit 'forwards' behielte das Element
   den animierten Transform-Endwert (Identitäts-Matrix) dauerhaft – ein Transform
   ≠ none macht das Element zum Containing-Block für position:fixed. Dadurch würden
   Modale (.modal-overlay) relativ zur langen .content-body statt zum Viewport
   zentriert und bei gescrollter Seite außerhalb des Sichtfelds erscheinen.
   Ohne 'forwards' fällt der Transform nach der Animation auf 'none' zurück. */
.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --bg-dark: #f5f5f7;
    --bg-card: #ffffff;
    --bg-sidebar: #f0f0f2;
    --bg-main: #f5f5f7;
    --text-primary: #1a1a2e;
    --text-secondary: #555570;
    --text-muted: #8888a0;
    --border-color: #d8d8e0;
}

[data-theme="light"] .table th {
    background: rgba(0,0,0,0.04);
}

[data-theme="light"] .table tr:hover td {
    background: rgba(177, 214, 65, 0.04);
}

[data-theme="light"] .nav-item:hover {
    background: rgba(177, 214, 65, 0.06);
}

[data-theme="light"] .sidebar-footer .user-info:hover {
    background: rgba(0,0,0,0.04);
}

[data-theme="light"] .btn-secondary {
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="light"] .btn-secondary:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-primary);
}

[data-theme="light"] .modal-overlay {
    background: rgba(0,0,0,0.4);
}

[data-theme="light"] .sidebar-overlay {
    background: rgba(0,0,0,0.3);
}

[data-theme="light"] select.form-control {
    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='%23555570' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="light"] .calendar-day.today {
    background: rgba(177, 214, 65, 0.05);
}

[data-theme="light"] .stat-icon.red { background: rgba(177, 214, 65, 0.1); }
[data-theme="light"] .stat-icon.blue { background: rgba(2, 122, 187, 0.1); }
[data-theme="light"] .stat-icon.green { background: rgba(34, 197, 94, 0.1); }
[data-theme="light"] .stat-icon.yellow { background: rgba(245, 158, 11, 0.1); }

[data-theme="light"] .chip {
    background: rgba(177, 214, 65, 0.1);
}

[data-theme="light"] .filter-pill:hover,
[data-theme="light"] .filter-pill.active {
    background: rgba(177, 214, 65, 0.06);
}

[data-theme="light"] .pagination a:hover {
    background: rgba(177, 214, 65, 0.06);
}

[data-theme="light"] .item-row {
    background: var(--bg-card);
}

[data-theme="light"] .doc-card {
    background: var(--bg-card);
}

[data-theme="light"] .doc-icon {
    background: rgba(177, 214, 65, 0.08);
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Document list */
.doc-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-main);
    transition: var(--transition);
}

.doc-card:hover {
    border-color: var(--primary);
}

.doc-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: rgba(177, 214, 65, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.doc-info h4 {
    font-size: 14px;
    margin-bottom: 4px;
}

.doc-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

/* ===== Inventory Module Styles ===== */

/* Inventory Status Badges */
.badge-available { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-in_custody { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-checked_out { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-maintenance { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-retired { background: rgba(107,114,128,0.15); color: var(--text-muted); }

/* Booking Status Badges */
.badge-reserved { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-returned { background: rgba(107,114,128,0.15); color: var(--text-muted); }
.badge-overdue { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-cancelled { background: rgba(107,114,128,0.25); color: var(--text-muted); }
.badge-lending { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-rental { background: rgba(168,85,247,0.15); color: #a855f7; }

/* Request Priority Badges */
.badge-low { background: rgba(107,114,128,0.15); color: var(--text-muted); }
.badge-normal { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-high { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-urgent { background: rgba(239,68,68,0.15); color: var(--danger); font-weight: 600; }

/* Color Dot */
.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* Inventory Detail Layout */
.inv-detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-top: 16px;
}
@media (max-width: 900px) {
    .inv-detail-grid { grid-template-columns: 1fr; }
}

/* Asset Image */
.inv-asset-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--bg-dark);
}

/* QR Code Container */
.inv-qr-container {
    background: #ffffff;
    padding: 12px;
    border-radius: var(--radius);
    display: inline-block;
}

/* Stats Grid */
.inv-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

/* Metadata Table */
.inv-meta-table {
    width: 100%;
    border-collapse: collapse;
}
.inv-meta-table td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    font-size: 13px;
}
.inv-meta-table td:first-child {
    color: var(--text-muted);
    width: 140px;
}

/* Bulk Action Bar */
.inv-bulk-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 13px;
}
.inv-bulk-bar.visible { display: flex; }

/* Inv Tabs */
.inv-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}
.inv-tab {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    text-decoration: none;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    font-family: inherit;
}
.inv-tab:hover { color: var(--text-primary); }
.inv-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Activity List */
.inv-activity-list { list-style: none; padding: 0; }
.inv-activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.inv-activity-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bg-dark);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: var(--text-muted); font-size: 12px;
}

/* Table Thumbnail */
.inv-table-thumb {
    width: 36px; height: 36px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-dark);
}
.inv-table-thumb-placeholder {
    width: 36px; height: 36px;
    border-radius: 6px;
    background: var(--bg-dark);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 14px;
}

/* Tag Chips */
.inv-tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin: 1px 2px;
}

/* Filter Bar */
.inv-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 4px;
}
.inv-filters .form-control {
    width: auto;
    min-width: 140px;
    font-size: 13px;
    padding: 6px 10px;
}

/* Entity Cards Grid */
.inv-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.inv-entity-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.inv-entity-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.inv-entity-card-color { height: 4px; }
.inv-entity-card-body { padding: 16px; }
.inv-entity-card-body h4 { font-size: 14px; margin-bottom: 4px; }
.inv-entity-card-actions {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

/* ===== Searchable Select Component ===== */
.ss-wrap { position: relative; display: inline-block; }
.ss-wrap:not(.ss-inline) { width: 100%; }
.ss-wrap:not(.ss-inline) .ss-input { width: 100%; }
.ss-dd {
    position: absolute; left: 0; top: 100%; margin-top: 2px; width: 100%; min-width: 260px;
    max-height: 240px; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 200; display: none;
}
.ss-dd .ss-opt {
    display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 13px;
    color: var(--text-primary); cursor: pointer;
}
.ss-dd .ss-opt:hover { background: var(--bg-hover); }
.ss-dd .ss-opt.ss-new { color: var(--primary); font-weight: 500; border-top: 1px solid var(--border-color); }
.ss-dd .ss-none { padding: 10px 12px; font-size: 12px; color: var(--text-muted); }
.ss-input.ss-active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, transparent); }
/* Edit/open pencil button — shown when a selection is active, links to the full edit page */
.ss-wrap .ss-edit {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    z-index: 3;
    transition: color 0.15s, background 0.15s;
}
.ss-wrap .ss-edit:hover { color: var(--primary); background: var(--bg-hover); }
.ss-wrap .ss-edit:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* Reserve space in input so the selected text doesn't run under the pencil */
.ss-wrap .ss-input.ss-active { padding-right: 36px; }

/* ===== Collapsible Sidebar Sections ===== */
.nav-section-title {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.nav-section-title .nav-toggle {
    font-size: 10px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}
.nav-section.collapsed .nav-toggle {
    transform: rotate(-90deg);
}
.nav-section-items {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.25s ease;
}
.nav-section.collapsed .nav-section-items {
    max-height: 0;
}

/* ===== Page Section Accent Separators ===== */
.content-header h2 {
    font-weight: 700;
}
.card-header h3 {
    font-weight: 700;
}
.section-accent {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
}
.card-header {
    border-left: 3px solid var(--primary);
}

/* ===== Accessibility Modes ===== */

/* High Contrast */
[data-a11y-contrast="high"] {
    --bg-dark: #000000;
    --bg-card: #111111;
    --bg-sidebar: #000000;
    --bg-main: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #aaaaaa;
    --border-color: #555555;
}
[data-a11y-contrast="high"][data-theme="light"] {
    --bg-dark: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #f0f0f0;
    --bg-main: #ffffff;
    --text-primary: #000000;
    --text-secondary: #222222;
    --text-muted: #444444;
    --border-color: #333333;
}
[data-a11y-contrast="high"] .nav-item.active {
    outline: 2px solid var(--primary);
}
[data-a11y-contrast="high"] .btn {
    border-width: 2px;
}

/* Colorblind Mode — replaces red/green with blue/orange */
[data-a11y-colorblind="on"] {
    --success: #2196f3;
    --danger: #ff9800;
    --warning: #e040fb;
}
[data-a11y-colorblind="on"] .badge-success { background: rgba(33, 150, 243, 0.2); color: var(--success); }
[data-a11y-colorblind="on"] .badge-danger { background: rgba(255, 152, 0, 0.2); color: var(--danger); }
[data-a11y-colorblind="on"] .badge-warning { background: rgba(224, 64, 251, 0.2); color: var(--warning); }
[data-a11y-colorblind="on"] .alert-success { background: rgba(33, 150, 243, 0.15); color: var(--success); border-color: rgba(33, 150, 243, 0.3); }
[data-a11y-colorblind="on"] .alert-error { background: rgba(255, 152, 0, 0.15); color: var(--danger); border-color: rgba(255, 152, 0, 0.3); }

/* Large Font Mode */
[data-a11y-fontsize="large"] {
    font-size: 17px;
}
[data-a11y-fontsize="large"] .nav-item { font-size: 15px; padding: 11px 12px; }
[data-a11y-fontsize="large"] .nav-section-title { font-size: 12px; }
[data-a11y-fontsize="large"] .content-header h2 { font-size: 22px; }
[data-a11y-fontsize="large"] .card-header h3 { font-size: 18px; }
[data-a11y-fontsize="large"] .table th, [data-a11y-fontsize="large"] .table td { font-size: 15px; }
[data-a11y-fontsize="large"] .btn { font-size: 15px; }
[data-a11y-fontsize="large"] .form-control { font-size: 15px; }
[data-a11y-fontsize="large"] .badge { font-size: 13px; }

/* ADHS / Bionic Reading Mode */
[data-a11y-bionic="on"] .bionic-b {
    font-weight: 800;
}

/* ===== Module Toggle Styles ===== */
.module-toggle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: var(--transition);
}
.module-toggle-card:hover { border-color: var(--primary); }
.module-toggle-info { display: flex; align-items: center; gap: 12px; }
.module-toggle-icon {
    width: 38px; height: 38px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; background: rgba(177,214,65,0.1); color: var(--primary);
}
.module-toggle-label h4 { font-size: 14px; font-weight: 600; }
.module-toggle-label p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
/* Toggle switch */
.toggle-switch {
    position: relative; width: 44px; height: 24px; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border-color);
    border-radius: 12px; transition: 0.2s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px; background: var(--text-primary);
    border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: #1a1a2e; }

/* A11y settings toggle group */
.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    flex-shrink: 0;
    margin: 0 4px;
}
.header-action-btn {
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.a11y-toggles {
    display: flex;
    gap: 4px;
    align-items: center;
}
.a11y-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px; height: 34px;
    border-radius: 6px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: var(--transition);
    position: relative;
}
.a11y-btn:hover { border-color: var(--primary); color: var(--primary); }
.a11y-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(177,214,65,0.1); }

/* Label Print Styles */
@media print {
    .no-print { display: none !important; }
}

/* ===== Benachrichtigungen (Glocke im Header) ===== */
.header-notif { position: relative; display: inline-flex; }
#notif-bell-btn { position: relative; }
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger, #e74c3c);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--bg-card, #fff);
}
.notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-width: 90vw;
    max-height: 70vh;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.notif-panel.open { display: flex; }
.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    font-weight: 600;
    font-size: 14px;
}
.notif-markall {
    background: none;
    border: none;
    color: var(--primary, #2980b9);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
}
.notif-markall:hover { text-decoration: underline; }
.notif-list { overflow-y: auto; }
.notif-item {
    display: flex;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-color, #eee);
    cursor: pointer;
    transition: background 0.12s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.04)); }
.notif-item.notif-unread { background: rgba(41, 128, 185, 0.07); }
.notif-item.notif-unread .notif-item-title { font-weight: 700; }
.notif-item-icon {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary, #2980b9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; line-height: 1.35; }
.notif-item-msg {
    font-size: 12px;
    color: var(--text-muted, #777);
    margin-top: 2px;
    line-height: 1.4;
}
.notif-item-time { font-size: 11px; color: var(--text-muted, #999); margin-top: 3px; }
.notif-empty {
    padding: 28px 14px;
    text-align: center;
    color: var(--text-muted, #999);
    font-size: 13px;
}

/* Fehler-/Ablehnungs-Benachrichtigungen: roter Icon-Kreis */
.notif-item.notif-danger .notif-item-icon { background: var(--danger, #e74c3c); }

/* ===== Rabattspalte in Angebots-/Rechnungspositionen ===== */
/* Standard-Grid (ohne Rabatt) bleibt unverändert; mit Rabatt eine Spalte mehr. */
.line-item.line-item-disc {
    grid-template-columns: 46px 1fr 72px 60px 92px 104px 92px 34px;
}
.li-disc-cell {
    display: flex;
    gap: 4px;
    align-items: center;
}
.li-disc-cell .item-disc { flex: 1 1 auto; min-width: 0; }
.li-disc-cell .item-disc-type { flex: 0 0 48px; padding-left: 4px; padding-right: 2px; }

/* ===== Freitext-/Strukturposition (item_type = 'text') ===== */
/* Anfasser (Pos-Zelle) + Beschreibung + Löschen sichtbar; Menge/Einheit/Preis/Rabatt/Gesamt aus. */
.line-item.line-item-row.item-type-text { grid-template-columns: 30px 1fr 34px !important; }
.line-item-row.item-type-text > div:has(input[name*="[quantity]"]),
.line-item-row.item-type-text > div:has(input[name*="[unit]"]),
.line-item-row.item-type-text > div:has(input[name*="[unit_price]"]),
.line-item-row.item-type-text > div:has(.item-disc),
.line-item-row.item-type-text > div:has(.item-total) { display: none !important; }
/* Positions-Nummer ausblenden, aber den Drag-Anfasser (Grip) zum Verschieben sichtbar lassen */
.line-item-row.item-type-text input[name*="[position]"] { display: none !important; }
.line-item-row.item-type-text .item-desc { font-style: italic; }
