:root {
    --bg: #f4efe7;
    --panel: #fffdf9;
    --panel-strong: #fff;
    --sidebar: linear-gradient(180deg, #12343b 0%, #0b1f24 100%);
    --text: #1f2a30;
    --muted: #61727b;
    --accent: #cc7a00;
    --accent-dark: #9c5d00;
    --border: #e2d8ca;
    --success: #1f7a53;
    --error: #a63c3c;
    --shadow: 0 18px 40px rgba(18, 52, 59, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Roboto", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(204, 122, 0, 0.12), transparent 28%),
        linear-gradient(135deg, #f8f4ed 0%, var(--bg) 100%);
    color: var(--text);
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

.shell > * {
    min-width: 0;
}

.sidebar {
    padding: 32px;
    color: #f5efe5;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.1;
}

.content {
    min-width: 0;
    padding: 40px;
}

.page-header,
.hero-card,
.panel,
.stat-card {
    width: 100%;
    min-width: 0;
}

.menu {
    display: grid;
    gap: 12px;
    margin: 32px 0;
}

.sidebar-user-card {
    display: grid;
    gap: 6px;
    margin: 24px 0 0;
    padding: 16px;
    border: 1px solid rgba(245, 239, 229, 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-card strong {
    font-size: 1rem;
}

.sidebar-user-card span {
    font-size: 0.92rem;
    color: rgba(245, 239, 229, 0.76);
    overflow-wrap: anywhere;
}

.sidebar-user-role {
    display: inline-flex;
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(204, 122, 0, 0.22);
    color: #ffe2b3;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.menu a {
    padding: 14px 16px;
    border: 1px solid rgba(245, 239, 229, 0.16);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
}

.menu a:hover,
.menu a:focus {
    background: rgba(255, 255, 255, 0.14);
}

.menu a.is-active {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.28);
}

.page-header h2,
.hero-card h2 {
    margin: 6px 0 8px;
    font-size: 2rem;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--accent);
}

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

.alert {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
}

.alert.success {
    background: rgba(31, 122, 83, 0.12);
    border-color: rgba(31, 122, 83, 0.24);
}

.alert.error {
    background: rgba(166, 60, 60, 0.12);
    border-color: rgba(166, 60, 60, 0.22);
}

.hero-card,
.panel,
.stat-card {
    background: rgba(255, 253, 249, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero-card,
.panel {
    padding: 28px;
}

.hero-card.narrow {
    max-width: 560px;
}

.split,
.panel-header,
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(280px, 420px) 1fr;
    gap: 24px;
    align-items: start;
}

.content-grid > * {
    min-width: 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.stat-card {
    padding: 26px;
}

.stat-card span {
    display: block;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 12px;
    font-size: 2.4rem;
}

.stack-form {
    display: grid;
    gap: 16px;
}

.stack-form > * {
    min-width: 0;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
    min-width: 0;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid #d8ccb9;
    background: var(--panel-strong);
    color: var(--text);
}

input.is-invalid {
    border-color: rgba(166, 60, 60, 0.5);
    box-shadow: 0 0 0 3px rgba(166, 60, 60, 0.12);
}

textarea {
    resize: vertical;
}

.button {
    border: 0;
    border-radius: 14px;
    padding: 14px 18px;
    font-weight: 700;
    cursor: pointer;
    color: #fff7ec;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.button.secondary {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.button.neutral {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: rgba(18, 52, 59, 0.08);
}

.form-actions {
    display: grid;
    gap: 12px;
}

.settings-grid {
    grid-template-columns: minmax(320px, 420px) minmax(320px, 1fr);
}

.settings-grid-single {
    grid-template-columns: minmax(0, 1fr);
}

.settings-hub-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 24px;
}

.settings-nav-card {
    display: grid;
    gap: 14px;
    padding: 28px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: rgba(255, 253, 249, 0.92);
    box-shadow: var(--shadow);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.settings-nav-card:hover,
.settings-nav-card:focus {
    transform: translateY(-3px);
    border-color: rgba(18, 52, 59, 0.2);
    box-shadow: 0 22px 44px rgba(18, 52, 59, 0.16);
}

.settings-nav-card h3,
.settings-nav-card p,
.settings-nav-card strong {
    margin: 0;
}

.settings-nav-card__eyebrow {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
}

.settings-nav-card strong {
    color: #0f5c73;
}

.settings-nav-card--accent {
    background: linear-gradient(180deg, rgba(18, 52, 59, 0.06) 0%, rgba(255, 253, 249, 0.95) 100%);
}

.compact-actions,
.compact-stack {
    gap: 12px;
}

.settings-panel-header {
    align-items: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.status-pill.is-success {
    color: var(--success);
    background: rgba(31, 122, 83, 0.12);
    border-color: rgba(31, 122, 83, 0.24);
}

.status-pill.is-pending {
    color: var(--accent-dark);
    background: rgba(204, 122, 0, 0.12);
    border-color: rgba(204, 122, 0, 0.24);
}

.status-pill.is-error {
    color: var(--error);
    background: rgba(166, 60, 60, 0.12);
    border-color: rgba(166, 60, 60, 0.22);
}

.settings-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 16px;
    margin: 22px 0;
}

.settings-meta div {
    padding: 16px;
    border-radius: 18px;
    background: rgba(18, 52, 59, 0.05);
    border: 1px solid rgba(18, 52, 59, 0.08);
}

.settings-meta-card.is-warning {
    background: rgba(204, 122, 0, 0.12);
    border-color: rgba(204, 122, 0, 0.24);
}

.settings-meta-card.is-success {
    background: rgba(31, 122, 83, 0.12);
    border-color: rgba(31, 122, 83, 0.24);
}

.settings-meta strong,
.settings-meta span {
    display: block;
}

.settings-meta strong {
    margin-bottom: 8px;
}

.settings-meta-note {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    line-height: 1.5;
}

.field-hint,
.field-error {
    margin: -4px 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.field-hint {
    color: var(--muted);
}

.field-error {
    color: var(--error);
    font-weight: 600;
}

.qr-card {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr;
    gap: 24px;
    align-items: center;
}

.qr-card__image {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 20px;
    border-radius: 24px;
    background: linear-gradient(145deg, #fffdf9 0%, #f6efe4 100%);
    border: 1px dashed rgba(18, 52, 59, 0.2);
}

.qr-card__image img {
    width: 100%;
    max-width: 320px;
    border-radius: 18px;
}

.qr-placeholder {
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
}

@media (max-width: 980px) {
    .settings-grid,
    .qr-card,
    .settings-meta {
        grid-template-columns: 1fr;
    }
}

.search-form {
    margin: 12px 0 18px;
}

.searchable-select {
    position: relative;
}

.searchable-select-control {
    position: relative;
}

.searchable-select-control input {
    padding-right: 54px;
}

.searchable-select-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transform: translateY(-50%);
}

.searchable-select-toggle svg {
    width: 20px;
    height: 20px;
}

.searchable-select[data-open="true"] .searchable-select-toggle {
    color: var(--text);
}

.searchable-select[data-open="true"] .searchable-select-toggle svg {
    transform: rotate(180deg);
}

.searchable-select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 60;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 253, 249, 0.99);
    box-shadow: var(--shadow);
    gap: 8px;
}

.searchable-select-option {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.searchable-select-option:hover,
.searchable-select-option:focus {
    border-color: rgba(15, 92, 115, 0.18);
    background: rgba(18, 52, 59, 0.06);
    outline: none;
}

.searchable-select-option.is-active {
    border-color: rgba(15, 92, 115, 0.28);
    background: rgba(18, 52, 59, 0.1);
}

.searchable-select-option strong {
    font-size: 0.95rem;
}

.searchable-select-option small,
.searchable-select-empty {
    color: var(--muted);
}

.searchable-select-empty {
    padding: 12px 14px;
}

.search-form input[aria-busy="true"] {
    border-color: rgba(15, 92, 115, 0.45);
    background: linear-gradient(90deg, rgba(15, 92, 115, 0.05), rgba(15, 92, 115, 0.12), rgba(15, 92, 115, 0.05));
    background-size: 200% 100%;
    animation: search-loading 1s linear infinite;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row-actions form {
    margin: 0;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(11, 31, 36, 0.48);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    width: min(100%, 420px);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: rgba(255, 253, 249, 0.98);
    box-shadow: var(--shadow);
}

.modal-card h3 {
    margin: 0 0 10px;
}

.modal-card p {
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
}

body.modal-open {
    overflow: hidden;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.pagination-summary {
    font-size: 0.92rem;
    color: var(--muted);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination-link {
    min-width: 44px;
    padding: 10px 14px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-strong);
    color: var(--text);
    cursor: pointer;
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

.icon-button.edit {
    color: #0f5c73;
}

.icon-button.delete {
    color: var(--error);
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap.is-loading {
    opacity: 0.72;
    transition: opacity 0.18s ease;
}

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

.clients-table th,
.clients-table td {
    font-size: 13px;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

.documents-table th,
.documents-table td {
    font-size: 13px;
}

th,
td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

th {
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

@keyframes search-loading {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(18, 52, 59, 0.08);
}

.logout-form {
    margin-top: auto;
    width: 100%;
}

small {
    color: var(--muted);
}

@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-hub-grid {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 960px) {
    .shell,
    .stat-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .shell {
        min-height: auto;
    }

    .sidebar,
    .content {
        padding: 24px;
    }

    .sidebar {
        gap: 24px;
    }

    .modal-actions {
        justify-content: stretch;
    }

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

    .searchable-select-menu {
        position: static;
        margin-top: 8px;
    }

    .settings-hub-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .menu {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        margin: 24px 0 0;
    }

    .page-header h2,

    .pagination,
    .pagination-link {
        width: 100%;
    }
    .hero-card h2 {
        font-size: 1.75rem;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    .content,
    .sidebar,
    .hero-card,
    .panel,
    .stat-card {
        padding: 18px;
    }

    .page-header,
    .panel-header,
    .split {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header h2,
    .hero-card h2 {
        font-size: 1.5rem;
    }

    .eyebrow {
        letter-spacing: 0.14em;
    }

    .menu {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .menu a,
    .button,
    .button.secondary,
    .button.neutral {
        width: 100%;
    }

    .stat-grid {
        gap: 16px;
        margin: 20px 0;
    }

    .stat-card strong {
        font-size: 2rem;
    }

    input,
    select,
    textarea,
    button {
        font-size: 16px;
    }

    table {
        min-width: 0;
        table-layout: fixed;
    }

    th,
    td {
        padding: 12px 8px;
        font-size: 0.92rem;
    }
}