:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #14213d;
    background: #f6f8fb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 22px;
    align-items: center;
    min-height: 72px;
    padding: 0 28px;
    border-bottom: 1px solid #d9e1ec;
    background: rgb(255 255 255 / 92%);
    backdrop-filter: blur(14px);
}

.topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brandmark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #2563eb;
    box-shadow: 0 8px 20px rgb(37 99 235 / 28%);
}

.topbar__brand strong,
.topbar__brand small {
    display: block;
}

.topbar__brand strong {
    font-size: 15px;
}

.topbar__brand small {
    color: #526176;
    font-size: 12px;
    font-weight: 700;
}

.topbar__nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
}

.topbar__nav a {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    color: #526176;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.topbar__nav a:hover,
.topbar__nav a.active {
    background: #eef2ff;
    color: #1d4ed8;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #526176;
    font-size: 13px;
    font-weight: 800;
}

.topbar__user form {
    margin: 0;
}

.topbar__user button {
    min-height: 36px;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    color: #14213d;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
}

.app-shell--with-topbar {
    min-height: calc(100vh - 72px);
}

.start-page,
.dashboard {
    min-height: 100vh;
    padding: 48px;
}

.start-page {
    display: grid;
    align-items: center;
}

.start-page__content,
.dashboard {
    max-width: 1120px;
    margin: 0 auto;
}

.brand {
    margin: 0 0 16px;
    color: #2563eb;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(36px, 7vw, 72px);
    line-height: 0.98;
    letter-spacing: 0;
}

p {
    max-width: 680px;
    color: #526176;
    font-size: 18px;
    line-height: 1.7;
}

.start-page__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 32px;
}

.start-page__actions a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    color: #14213d;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 8px 20px rgb(20 33 61 / 8%);
}

.start-page__actions a:first-child {
    border-color: #2563eb;
    background: #2563eb;
    color: #ffffff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 32px;
}

.stats-grid article,
.stats-grid a {
    display: block;
    min-height: 150px;
    padding: 22px;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgb(20 33 61 / 8%);
    text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.stats-grid a:hover {
    transform: translateY(-2px);
    border-color: #bfdbfe;
}

.stats-grid span {
    display: block;
    color: #526176;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.stats-grid strong {
    display: block;
    margin-top: 18px;
    font-size: 44px;
    line-height: 1;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.quick-actions a {
    display: block;
    min-height: 110px;
    padding: 20px;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    text-decoration: none;
    box-shadow: 0 8px 20px rgb(20 33 61 / 8%);
}

.quick-actions span {
    display: block;
    color: #2563eb;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.quick-actions strong {
    display: block;
    margin-top: 12px;
    font-size: 18px;
    line-height: 1.25;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.button,
button.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border: 1px solid #2563eb;
    border-radius: 8px;
    background: #2563eb;
    color: #ffffff;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.button-secondary {
    border-color: #d9e1ec;
    background: #ffffff;
    color: #14213d;
}

.button-ghost {
    border-color: transparent;
    background: transparent;
    color: #526176;
    box-shadow: none;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.notice {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
}

.notice-strong {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.notice-danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.notice code {
    font-size: 16px;
}

.filterbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) repeat(2, minmax(160px, auto)) auto auto;
    gap: 12px;
    margin-bottom: 16px;
}

.filterbar-wide {
    grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(150px, auto)) auto auto;
}

.filterbar input,
.filterbar select,
.form-grid input,
.form-grid select,
.form-grid textarea {
    min-height: 44px;
    width: 100%;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    padding: 0 12px;
    color: #14213d;
    font: inherit;
}

.form-grid textarea {
    min-height: 120px;
    padding-top: 12px;
    resize: vertical;
}

.filterbar input:focus,
.filterbar select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    border-color: #2563eb;
    outline: 3px solid rgb(37 99 235 / 14%);
}

.panel {
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgb(20 33 61 / 8%);
    overflow: hidden;
}

.panel h2 {
    margin: 0;
    padding: 20px 22px 0;
    font-size: 20px;
}

.bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 18px 0;
}

.list-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 16px 18px 0;
}

.list-meta strong {
    font-size: 22px;
}

.list-meta span {
    color: #526176;
    font-size: 13px;
    font-weight: 800;
}

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

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid #e8edf4;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #526176;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.select-cell {
    width: 44px;
    text-align: center;
}

.select-cell input {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    cursor: pointer;
}

.copy-select-label {
    cursor: pointer;
}

td span {
    display: block;
    color: #526176;
    font-size: 13px;
}

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

.table-actions {
    text-align: right;
}

.table-actions a {
    margin-left: 10px;
    color: #2563eb;
    font-weight: 800;
    text-decoration: none;
}

.badge {
    display: inline-flex;
    width: auto;
    padding: 4px 8px;
    border-radius: 6px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.badge-active,
.badge-trial {
    background: #dcfce7;
    color: #166534;
}

.badge-paused,
.badge-inactive,
.badge-muted {
    background: #f1f5f9;
    color: #475569;
}

.badge-cancelled,
.badge-left,
.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-loaned,
.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-returned {
    background: #e0f2fe;
    color: #075985;
}

.empty {
    padding: 32px 16px;
    color: #526176;
    text-align: center;
}

.pagination-wrap {
    margin-top: 18px;
}

.form-panel {
    padding: 22px;
}

.settings-form {
    display: grid;
    gap: 24px;
}

.settings-section {
    display: grid;
    gap: 14px;
}

.settings-section h2 {
    margin: 0;
    font-size: 18px;
}

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

.form-grid.one-column {
    grid-template-columns: 1fr;
}

.form-grid label {
    display: grid;
    gap: 8px;
    color: #526176;
    font-size: 13px;
    font-weight: 800;
}

.form-grid .checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.form-grid small {
    color: #b91c1c;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 18px;
    margin-top: 18px;
}

.scan-panel {
    display: grid;
    gap: 18px;
    max-width: 760px;
    padding: 28px;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgb(20 33 61 / 8%);
}

.scan-panel label {
    display: grid;
    gap: 8px;
    color: #526176;
    font-size: 13px;
    font-weight: 900;
}

.scan-panel input {
    min-height: 58px;
    width: 100%;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    padding: 0 14px;
    color: #14213d;
    font: inherit;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.scan-panel input:focus {
    border-color: #2563eb;
    outline: 3px solid rgb(37 99 235 / 14%);
}

.scan-panel small {
    color: #b91c1c;
}

.label-print-page {
    max-width: none;
}

.print-controls {
    margin-bottom: 18px;
}

.sheet-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: baseline;
    margin-bottom: 18px;
    color: #526176;
    font-size: 13px;
    font-weight: 800;
}

.sheet-preview strong {
    color: #14213d;
    font-size: 20px;
}

.label-pages {
    display: grid;
    gap: 24px;
    justify-content: center;
}

.label-sheet {
    display: grid;
    grid-template-columns: repeat(var(--sheet-columns), var(--label-width));
    grid-auto-rows: var(--label-height);
    gap: var(--row-gap) var(--column-gap);
    width: 210mm;
    min-height: 297mm;
    padding: var(--page-margin-top) var(--page-margin-right) var(--page-margin-bottom) var(--page-margin-left);
    background: #ffffff;
    box-shadow: 0 8px 20px rgb(20 33 61 / 12%);
    overflow: hidden;
    transform: translate(var(--print-offset-x), var(--print-offset-y));
}

.print-label {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 5px;
    width: var(--label-width);
    height: var(--label-height);
    padding: var(--label-padding);
    border: 1px dashed #94a3b8;
    border-radius: 4px;
    background: #ffffff;
    break-inside: avoid;
    overflow: hidden;
}

.print-label-empty {
    opacity: 0.35;
}

.print-label strong,
.print-label span,
.label-code code {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.print-label strong {
    color: #14213d;
    font-size: 11px;
    line-height: 1.2;
}

.print-label span {
    color: #526176;
    font-size: 9px;
    font-weight: 700;
}

.barcode {
    display: block;
    width: 100%;
    height: 14mm;
    fill: #000000;
}

.label-code {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.label-code code {
    color: #111827;
    font-size: 10px;
    font-weight: 900;
}

.print-hidden {
    display: flex;
}

.login-card {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 48px;
    width: min(1060px, 100%);
    margin: 0 auto;
    align-items: start;
}

.login-card form {
    display: grid;
    gap: 16px;
    padding: 24px;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgb(20 33 61 / 8%);
}

.login-card label {
    display: grid;
    gap: 8px;
    color: #526176;
    font-size: 13px;
    font-weight: 800;
}

.login-card input {
    min-height: 44px;
    width: 100%;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
    padding: 0 12px;
    color: #14213d;
    font: inherit;
}

.login-card input:focus {
    border-color: #2563eb;
    outline: 3px solid rgb(37 99 235 / 14%);
}

.login-card .checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-card .checkbox input {
    min-height: auto;
    width: auto;
}

.login-card button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: #2563eb;
    color: #ffffff;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
}

.form-error {
    margin: 0;
    color: #b91c1c;
    font-size: 14px;
}

@media (max-width: 720px) {
    .topbar {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px;
    }

    .topbar__user {
        justify-content: space-between;
    }

    .start-page,
    .dashboard {
        padding: 28px;
    }

    p {
        font-size: 16px;
    }

    .login-card {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .page-head,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .filterbar,
    .form-grid,
    .split-grid,
    .quick-actions {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .panel {
        overflow-x: auto;
    }
}

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

    .topbar,
    .print-hidden {
        display: none;
    }

    .app-shell,
    .app-shell--with-topbar,
    .dashboard {
        min-height: 0;
        padding: 0;
    }

    .label-sheet {
        display: grid;
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        box-shadow: none;
        transform: translate(var(--print-offset-x), var(--print-offset-y));
        page-break-after: always;
    }

    .label-sheet:last-child {
        page-break-after: auto;
    }

    .print-label {
        border: 0;
        border-radius: 0;
        box-shadow: none;
        page-break-inside: avoid;
    }

    .print-label-empty {
        visibility: hidden;
    }

    @page {
        size: A4;
        margin: 0;
    }
}
