:root {
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #657181;
    --line: #d9e0e7;
    --primary: #256f8f;
    --primary-dark: #1d5872;
    --danger: #b42318;
    --ok: #1f7a4d;
    --warn: #9a6200;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

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

a:hover {
    text-decoration: underline;
}

.topbar {
    align-items: center;
    background: #173242;
    color: #fff;
    display: flex;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
}

.topbar nav {
    align-items: center;
    display: flex;
    gap: 18px;
}

.topbar a {
    color: #fff;
}

.topbar span {
    color: #c7d3dc;
}

.page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px;
}

.page-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 22px;
}

h1 {
    font-size: 28px;
    line-height: 1.2;
    margin: 0 0 6px;
}

h2 {
    font-size: 18px;
    margin: 0 0 12px;
}

p {
    color: var(--muted);
    margin: 0;
}

button,
.button {
    background: var(--primary);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    justify-content: center;
    min-height: 40px;
    padding: 10px 16px;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.button.secondary {
    background: #e8eef2;
    color: var(--text);
}

.filters,
.form,
.notice,
.auth-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.filters {
    background: #f3faf8;
    border-color: #bedfd6;
    box-shadow: 0 10px 24px rgba(31, 122, 77, 0.10);
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(6, minmax(120px, 1fr)) auto auto;
    margin-bottom: 18px;
    padding: 16px;
    position: sticky;
    top: 12px;
    z-index: 10;
}

.filters a {
    align-self: center;
    white-space: nowrap;
}

.toggle-filter {
    align-items: center;
    color: #41505f;
    display: flex;
    font-weight: 700;
    gap: 8px;
    min-height: 40px;
    white-space: nowrap;
}

.toggle-filter input {
    min-height: auto;
    width: auto;
}

input,
select {
    background: #fff;
    border: 1px solid #c7d0d9;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    padding: 9px 10px;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: 2px solid rgba(37, 111, 143, 0.18);
}

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

table {
    border-collapse: collapse;
    min-width: 980px;
    width: 100%;
}

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

th {
    background: #edf2f5;
    color: #44515f;
    font-size: 13px;
    font-weight: 700;
}

.sort-link {
    color: inherit;
    display: inline-block;
    min-height: 18px;
}

.sort-link:hover {
    color: var(--primary);
}

.statistics-table th:not(:first-child),
.statistics-table td:not(:first-child) {
    text-align: right;
}

.statistics-chart-panel {
    align-items: center;
    background: #fff8ef;
    border: 1px solid #f1d9b8;
    border-radius: 8px;
    display: flex;
    gap: 24px;
    margin-bottom: 18px;
    padding: 20px 22px;
}

.brand-ratio-panel {
    background: #f7f4ff;
    border: 1px solid #d9d1f0;
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 20px 22px;
}

.brand-ratio-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.brand-ratio-item {
    align-items: center;
    background: #ffffff;
    border: 1px solid #e4ddf4;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    padding: 12px;
}

.brand-ratio-item strong,
.brand-ratio-item span,
.brand-ratio-item small {
    display: block;
}

.brand-ratio-item span,
.brand-ratio-item small {
    color: var(--muted);
    line-height: 1.35;
}

.ratio-chart {
    background: conic-gradient(#c8ead7 0 var(--free), #f6c9c4 var(--free) 100%);
    border: 8px solid #fff;
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(23, 50, 66, 0.12);
    flex: 0 0 auto;
    height: 150px;
    width: 150px;
}

.ratio-chart.small {
    border-width: 5px;
    height: 70px;
    width: 70px;
}

.ratio-summary {
    display: grid;
    gap: 12px;
}

.ratio-legend {
    display: grid;
    gap: 8px;
}

.ratio-legend span {
    align-items: center;
    color: #41505f;
    display: flex;
    gap: 8px;
}

.ratio-legend i {
    border-radius: 999px;
    display: inline-block;
    height: 12px;
    width: 12px;
}

.legend-free {
    background: #c8ead7;
}

.legend-assigned {
    background: #f6c9c4;
}

tr:last-child td {
    border-bottom: 0;
}

.status {
    border-radius: 999px;
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    padding: 5px 10px;
}

.status.frei {
    background: #e1f4ea;
    color: var(--ok);
}

.status.reserviert {
    background: #fff2cc;
    color: var(--warn);
}

.status.vergeben {
    background: #fde8e5;
    color: var(--danger);
}

.status.gesperrt {
    background: #e5e7eb;
    color: #4b5563;
}

.locked-row {
    background: #f3f4f6;
}

.inline-status {
    margin: 0;
}

.inline-form {
    margin: 0;
}

.inline-supplier {
    margin: 0;
}

.inline-supplier select {
    min-width: 160px;
}

.status-select {
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    min-height: 34px;
    padding: 5px 28px 5px 10px;
}

.status-select.frei {
    background: #e1f4ea;
    color: var(--ok);
}

.status-select.reserviert {
    background: #fff2cc;
    color: var(--warn);
}

.status-select.vergeben {
    background: #fde8e5;
    color: var(--danger);
}

.status-select.gesperrt {
    background: #e5e7eb;
    color: #4b5563;
}

.status-picker.frei,
.status-option.frei {
    background: #e1f4ea;
    color: var(--ok);
}

.status-picker.reserviert,
.status-option.reserviert {
    background: #fff2cc;
    color: var(--warn);
}

.status-picker.vergeben,
.status-option.vergeben {
    background: #fde8e5;
    color: var(--danger);
}

.status-picker.gesperrt,
.status-option.gesperrt {
    background: #e5e7eb;
    color: #4b5563;
}

.status-select:disabled {
    cursor: not-allowed;
    opacity: 0.82;
}

.actions {
    text-align: right;
}

.row-actions {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.row-actions form {
    margin: 0;
}

.small-secondary {
    align-items: center;
    background: #e8eef2;
    border-radius: 6px;
    color: var(--text);
    display: inline-flex;
    font-weight: 700;
    min-height: 34px;
    padding: 7px 12px;
}

.small-secondary:hover {
    background: #dce5eb;
    text-decoration: none;
}

.icon-button {
    align-items: center;
    border: 0;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    height: 34px;
    justify-content: center;
    min-height: 34px;
    padding: 0;
    width: 38px;
}

.icon-button:hover {
    text-decoration: none;
}

.icon-button svg {
    fill: none;
    height: 17px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    width: 17px;
}

.icon-secondary {
    background: #e8eef2;
}

.icon-secondary:hover {
    background: #dce5eb;
}

.icon-success {
    background: #d8efe3;
    color: var(--ok);
}

.icon-success:hover {
    background: #c5e5d4;
}

.icon-danger {
    background: #f3d2ce;
    color: var(--danger);
}

.icon-danger:hover {
    background: #edc0ba;
}

.release-date {
    color: var(--muted);
    display: grid;
    gap: 2px;
    line-height: 1.25;
}

.release-date span {
    font-size: 12px;
}

.release-date strong {
    color: #374151;
}

.empty {
    color: var(--muted);
    padding: 26px;
    text-align: center;
}

.form {
    display: grid;
    gap: 16px;
    max-width: 680px;
    padding: 22px;
}

.form label {
    color: #41505f;
    display: grid;
    font-weight: 700;
    gap: 7px;
}

.form .checkbox-label {
    align-items: center;
    display: flex;
    gap: 8px;
}

.form .checkbox-label input {
    min-height: auto;
    width: auto;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

.form-help {
    color: var(--muted);
    line-height: 1.45;
}

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

.generator-results {
    max-width: 820px;
}

.generator-results table {
    min-width: 760px;
}

.generator-results .actions {
    white-space: nowrap;
}

.similar-list {
    display: grid;
    gap: 4px;
}

.similar-list span {
    color: #374151;
    display: grid;
    gap: 2px;
}

.similar-list small,
.muted {
    color: var(--muted);
}

.auth-panel {
    margin: 80px auto 0;
    max-width: 420px;
    padding: 28px;
}

.auth-panel h1 {
    margin-bottom: 18px;
}

.auth-extra {
    margin-top: 16px;
    text-align: center;
}

.flash {
    border-radius: 6px;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.flash.success {
    background: #e1f4ea;
    color: var(--ok);
}

.flash.error {
    background: #fde8e5;
    color: var(--danger);
}

.notice {
    margin-bottom: 16px;
    max-width: 680px;
    padding: 18px 22px;
}

.notice ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.notice li {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
}

.notice li:first-child {
    border-top: 0;
}

.notice span {
    color: var(--muted);
}

.approval-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 18px 22px;
}

.approval-list {
    display: grid;
    gap: 10px;
}

.approval-item {
    align-items: center;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(180px, 1fr) auto auto;
    margin: 0;
    padding-top: 10px;
}

.approval-item:first-child {
    border-top: 0;
    padding-top: 0;
}

.approval-item small {
    color: var(--muted);
}

.profile-approval {
    margin-top: 24px;
}

.approval-item-expanded {
    grid-template-columns: minmax(180px, 1fr) minmax(280px, 1.2fr) auto;
}

.approval-item-expanded strong,
.approval-item-expanded small {
    display: block;
}

.user-state {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    margin-top: 6px;
    padding: 4px 8px;
}

.user-state.approved {
    background: #e1f4ea;
    color: var(--ok);
}

.user-state.pending {
    background: #fff2cc;
    color: var(--warn);
}

.approval-password {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(160px, 1fr) auto;
    margin: 0;
}

.delete-form {
    margin-top: 18px;
}

.delete-form button {
    background: #f3d2ce;
    color: var(--danger);
}

.delete-form button:hover {
    background: #edc0ba;
}

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

.lookup-table {
    max-width: 820px;
}

.inline-edit {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(180px, 1fr) auto;
    margin: 0;
}

.small-danger {
    background: #f3d2ce;
    color: var(--danger);
    min-height: 34px;
    padding: 7px 12px;
}

.small-danger:hover {
    background: #edc0ba;
}

.small-success {
    background: #d8efe3;
    color: var(--ok);
    min-height: 34px;
    padding: 7px 12px;
}

.small-success:hover {
    background: #c5e5d4;
}

.scroll-top-button {
    align-items: center;
    background: var(--primary);
    border: 0;
    border-radius: 999px;
    bottom: 24px;
    box-shadow: 0 10px 24px rgba(23, 50, 66, 0.22);
    color: #fff;
    cursor: pointer;
    display: flex;
    font-size: 24px;
    font-weight: 700;
    height: 46px;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    right: 24px;
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform: translateY(8px);
    width: 46px;
    z-index: 20;
}

.scroll-top-button.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-top-button:hover {
    background: var(--primary-dark);
}

@media (max-width: 860px) {
    .topbar,
    .page-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .topbar nav {
        flex-wrap: wrap;
    }

    .filters {
        grid-template-columns: 1fr;
        top: 8px;
    }

    .statistics-chart-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .page {
        padding: 18px;
    }
}
