:root {
    color-scheme: light;
    --bg: #eef1f4;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #17202a;
    --muted: #64748b;
    --border: #d9e0e8;
    --primary: #17202a;
    --primary-hover: #263241;
    --accent: #0f766e;
    --accent-soft: #d9f3ef;
    --danger: #b42318;
    --danger-soft: #fde7e4;
    --warning: #b7791f;
    --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

body.app-loading .site-header,
body.app-loading .container {
    visibility: hidden;
}

body.app-loading::before {
    content: "Reglementlager wird geladen...";
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 16px;
}

button,
input,
select {
    font: inherit;
}

button {
    min-height: 40px;
    border: 0;
    border-radius: var(--radius);
    padding: 10px 14px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

button:hover {
    background: var(--primary-hover);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.28);
    outline-offset: 2px;
}

button.secondary {
    background: #475569;
}

button.secondary:hover {
    background: #334155;
}

button.ghost {
    background: #e2e8f0;
    color: var(--text);
}

button.ghost:hover {
    background: #cbd5e1;
}

button.danger {
    background: var(--danger);
}

button.danger:hover {
    background: #8f1c13;
}

button.ok {
    background: var(--accent);
}

button.ok:hover {
    background: #0d665f;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 9px 10px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--text);
    font-weight: 700;
}

label span {
    font-size: 14px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 2px;
    font-size: 26px;
    line-height: 1.1;
}

h2 {
    margin-bottom: 0;
    font-size: 20px;
}

h3 {
    margin-bottom: 8px;
    font-size: 17px;
}

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

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 12px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #475569;
    font-size: 13px;
    text-transform: uppercase;
}

td strong {
    font-size: 15px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 20px 12px;
}

.brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.brand img {
    flex: 0 0 auto;
    border-radius: var(--radius);
}

.brand p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.header-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.tab-nav {
    display: flex;
    gap: 8px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px 14px;
    overflow-x: auto;
}

.tab-nav button {
    background: #e2e8f0;
    color: var(--text);
}

.tab-nav button.active {
    background: var(--primary);
    color: #ffffff;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stats article,
.panel,
.order-item,
.history-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stats article {
    padding: 14px;
}

.stats span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stats strong {
    font-size: 26px;
}

.panel {
    margin-bottom: 20px;
    padding: 18px;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.inventory-heading {
    align-items: center;
}

.toolbar,
.panel-actions,
.row-actions,
.item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}

.wide-field {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    align-items: end;
}

.form-actions button {
    width: 100%;
}

.search-box {
    margin-bottom: 14px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.table-wrap table {
    min-width: 760px;
}

.edit-row td {
    background: var(--surface-soft);
}

.edit-box {
    padding: 12px;
}

.badge,
.status-dot,
.stock-pill {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge {
    background: #e2e8f0;
    color: #334155;
}

.status-dot {
    background: var(--accent-soft);
    color: #0f5f58;
}

.stock-pill {
    background: var(--accent-soft);
    color: #0f5f58;
}

.stock-pill.low {
    background: #fff4d6;
    color: var(--warning);
}

.stock-pill.empty {
    background: var(--danger-soft);
    color: var(--danger);
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.warning {
    color: var(--danger);
    font-weight: 700;
}

.success {
    color: var(--accent);
    font-weight: 700;
}

.stack {
    display: grid;
    gap: 10px;
}

.order-item,
.history-item {
    padding: 14px;
    box-shadow: none;
}

.order-item header,
.history-item header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.order-item p,
.history-item p {
    margin-bottom: 8px;
}

.order-controls {
    display: grid;
    grid-template-columns: minmax(100px, 180px) auto;
    gap: 10px;
    align-items: end;
}

.empty-state {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 18px;
    background: var(--surface-soft);
    color: var(--muted);
}

.print-area {
    display: none;
}

.signature-table {
    margin-top: 36px;
}

.signature-table td {
    height: 76px;
}

@media (max-width: 900px) {
    .header-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-meta {
        justify-content: flex-start;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wide-field {
        grid-column: span 2;
    }
}

@media (max-width: 620px) {
    h1 {
        font-size: 22px;
    }

    .container {
        padding: 14px;
    }

    .panel {
        padding: 14px;
    }

    .stats,
    .form-grid,
    .order-controls {
        grid-template-columns: 1fr;
    }

    .wide-field {
        grid-column: span 1;
    }

    .panel-heading,
    .inventory-heading,
    .order-item header,
    .history-item header {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar button,
    .panel-actions button {
        flex: 1 1 140px;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    body * {
        visibility: hidden;
    }

    #druckbereich,
    #druckbereich * {
        visibility: visible;
    }

    #druckbereich {
        position: absolute;
        inset: 0 auto auto 0;
        display: block;
        width: 100%;
        padding: 24px;
        background: #ffffff;
    }

    .nicht-drucken {
        display: none !important;
    }
}
