:root {
    --bg: #f7f2e5;
    --panel: #fffdf8;
    --panel-alt: #f5ecd5;
    --ink: #2d2513;
    --muted: #6f6446;
    --line: #d8c78a;
    --brand: #5a8f18;
    --brand-strong: #3f6c0d;
    --accent: #d89a00;
    --accent-strong: #b87e00;
    --danger: #a73f3f;
    --shadow: 0 18px 40px rgba(88, 67, 14, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ink);
    overflow-x: hidden;
    background:
        radial-gradient(circle at top left, rgba(216, 154, 0, 0.22), transparent 30%),
        radial-gradient(circle at bottom right, rgba(90, 143, 24, 0.16), transparent 28%),
        linear-gradient(180deg, #fbf6e8 0%, #efe3bf 100%);
}

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

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

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card,
.panel,
.stat-card,
.badge-panel {
    background: rgba(255, 253, 248, 0.92);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(216, 199, 138, 0.9);
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(100%, 560px);
    border-radius: 30px;
    padding: 34px;
}

.auth-brand {
    display: grid;
    gap: 10px;
}

.auth-logo,
.brand-logo {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    background: #fff;
    border-radius: 18px;
}

.auth-logo {
    max-width: 360px;
    padding: 10px 14px;
    border: 1px solid rgba(216, 199, 138, 0.75);
}

.eyebrow {
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    color: var(--accent-strong);
    font-weight: 700;
}

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

.stack-lg {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

.field {
    display: grid;
    gap: 8px;
    font-size: 0.95rem;
}

.field .btn {
    justify-self: start;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

.field textarea {
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #fffdf4;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #e0a813 0%, #9b6c00 100%);
}

.btn-secondary {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 241, 223, 0.95) 100%);
    color: var(--ink);
    border: 1px solid rgba(216, 199, 138, 0.42);
}

.btn-block {
    width: 100%;
}

.alert {
    border-radius: 16px;
    padding: 12px 14px;
    margin: 16px 0;
}

.alert-error {
    background: rgba(167, 63, 63, 0.1);
    border: 1px solid rgba(167, 63, 63, 0.2);
    color: var(--danger);
}

.alert-success {
    background: rgba(90, 143, 24, 0.1);
    border: 1px solid rgba(90, 143, 24, 0.22);
    color: var(--brand-strong);
}

.login-note {
    margin-top: 20px;
    color: var(--muted);
    font-size: 0.95rem;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar-backdrop {
    display: none;
}

.sidebar {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 28px;
    padding: 34px 24px 28px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(251, 246, 232, 0.98) 100%);
    color: var(--ink);
    border-right: 1px solid rgba(184, 126, 0, 0.12);
    box-shadow: inset -1px 0 0 rgba(90, 143, 24, 0.04);
}

.sidebar .muted,
.sidebar a {
    color: rgba(45, 37, 19, 0.78);
}

.brand-block {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 251, 242, 0.98) 0%, rgba(247, 239, 214, 0.92) 100%);
    border: 1px solid rgba(216, 199, 138, 0.52);
    box-shadow: 0 12px 30px rgba(88, 67, 14, 0.08);
}

.brand-block h1 {
    margin-bottom: 2px;
    font-size: 1.85rem;
}

.brand-logo {
    padding: 10px 12px;
    border: 1px solid rgba(216, 199, 138, 0.52);
    box-shadow: 0 10px 22px rgba(88, 67, 14, 0.08);
}

.sidebar-section {
    margin: 0 0 12px;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(184, 126, 0, 0.78);
    font-weight: 700;
}

.nav-panel,
.profile-card {
    padding: 14px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 244, 228, 0.94) 100%);
    border: 1px solid rgba(216, 199, 138, 0.42);
    box-shadow: 0 10px 22px rgba(88, 67, 14, 0.05);
}

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

.nav-list a,
.doc-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid transparent;
    transition: 0.18s ease;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: rgba(45, 37, 19, 0.82);
}

.nav-marker {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 999px;
    background: rgba(90, 143, 24, 0.22);
    box-shadow: 0 0 0 4px rgba(90, 143, 24, 0.05);
}

.doc-list {
    display: grid;
    gap: 8px;
}

.doc-marker {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 2px;
    background: rgba(216, 154, 0, 0.24);
    box-shadow: 0 0 0 4px rgba(216, 154, 0, 0.06);
}

.nav-list a:hover,
.nav-list a.is-active,
.doc-list a:hover {
    color: var(--ink);
    background: linear-gradient(135deg, rgba(245, 236, 207, 0.9) 0%, rgba(255, 251, 241, 0.98) 100%);
    border-color: rgba(216, 199, 138, 0.42);
    transform: translateX(2px);
    box-shadow: 0 8px 18px rgba(88, 67, 14, 0.06);
}

.nav-list a.is-active .nav-marker {
    background: linear-gradient(135deg, #f4c33c 0%, #7fb52a 100%);
    box-shadow: 0 0 0 4px rgba(244, 195, 60, 0.12);
}

.doc-list a:hover .doc-marker {
    background: linear-gradient(135deg, #f4c33c 0%, #7fb52a 100%);
    box-shadow: 0 0 0 4px rgba(244, 195, 60, 0.08);
}

.sidebar-footer {
    display: grid;
    gap: 14px;
    margin-top: auto;
}

.profile-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 1rem;
    color: var(--brand-strong);
}


.content {
    padding: 28px;
}

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding: 10px 12px;
    border: 1px solid rgba(216, 199, 138, 0.5);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.96) 0%, rgba(248, 241, 221, 0.96) 100%);
    box-shadow: 0 10px 24px rgba(88, 67, 14, 0.08);
}

.mobile-topbar-logo {
    display: block;
    width: 136px;
    max-width: 100%;
    height: auto;
}

.mobile-menu-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(216, 199, 138, 0.52);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 18px rgba(88, 67, 14, 0.06);
    cursor: pointer;
    flex: 0 0 auto;
}

.mobile-menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--ink);
}

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

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.badge-panel {
    max-width: 340px;
    padding: 16px 18px;
    border-radius: 20px;
    color: var(--muted);
    background: linear-gradient(135deg, rgba(255, 248, 225, 0.95) 0%, rgba(243, 236, 205, 0.95) 100%);
}

.stats-grid,
.content-grid {
    display: grid;
    gap: 18px;
}

.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 22px;
}

.stat-card {
    padding: 22px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 252, 243, 0.96) 0%, rgba(247, 240, 219, 0.96) 100%);
}

.stat-card span {
    display: block;
    color: var(--brand-strong);
    margin-bottom: 12px;
}

.stat-card strong {
    font-size: 2rem;
    line-height: 1;
    color: var(--accent-strong);
}

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

.master-grid {
    align-items: start;
}

.panel {
    border-radius: 24px;
    padding: 22px;
    background:
        linear-gradient(180deg, rgba(255, 253, 248, 0.96) 0%, rgba(250, 245, 230, 0.96) 100%);
}

.table-panel {
    overflow: hidden;
}

.content-grid > .table-panel:only-child {
    grid-column: 1 / -1;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

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

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.data-table th {
    color: var(--brand-strong);
    font-weight: 700;
}

.data-table tbody tr {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.data-table tbody tr:hover td {
    background: rgba(245, 236, 207, 0.62);
}

.empty-state {
    color: var(--muted);
    margin-bottom: 0;
}

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

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

.form-section-title {
    grid-column: 1 / -1;
    margin: 8px 0 -2px;
    padding-top: 8px;
    border-top: 1px solid rgba(216, 199, 138, 0.42);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.field-note {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.table-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-link,
.action-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(216, 199, 138, 0.48);
    background: rgba(255, 255, 255, 0.85);
    color: var(--ink);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.action-link:hover,
.action-form button:hover {
    background: rgba(245, 236, 207, 0.9);
}

.action-form {
    margin: 0;
}

.action-form button {
    box-shadow: none;
}

.btn-danger {
    background: rgba(167, 63, 63, 0.08);
    border-color: rgba(167, 63, 63, 0.24);
    color: var(--danger);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(45, 37, 19, 0.38);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.modal-card {
    width: min(100%, 960px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    border-radius: 28px;
    padding: 24px;
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.98) 0%, rgba(250, 245, 230, 0.98) 100%);
    border: 1px solid rgba(216, 199, 138, 0.6);
    box-shadow: 0 28px 60px rgba(45, 37, 19, 0.18);
}

.modal-card-compact {
    width: min(100%, 860px);
}

.modal-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.modal-close {
    flex: 0 0 auto;
}

.detail-section + .detail-section {
    margin-top: 18px;
}

.detail-section h4 {
    margin: 0 0 12px;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

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

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid rgba(216, 199, 138, 0.42);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
}

.detail-item span {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.detail-item strong {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--ink);
    white-space: pre-wrap;
}

.detail-item-wide {
    grid-column: 1 / -1;
}

@media (max-width: 980px) {
    .app-shell,
    .stats-grid,
    .content-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        border: 0;
        padding: 0;
        background: rgba(45, 37, 19, 0.4);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 998;
    }

    .mobile-topbar {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(320px, calc(100vw - 48px));
        height: 100vh;
        gap: 18px;
        padding: 18px 16px;
        border-right: 1px solid rgba(184, 126, 0, 0.12);
        border-bottom: none;
        box-shadow: inset -1px 0 0 rgba(90, 143, 24, 0.04), 20px 0 40px rgba(45, 37, 19, 0.14);
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        z-index: 999;
    }

    .brand-block,
    .nav-panel,
    .profile-card {
        border-radius: 20px;
    }

    .nav-list,
    .doc-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .nav-list a,
    .doc-list a {
        min-height: 48px;
    }

    .sidebar-footer {
        margin-top: 0;
    }

    .content {
        min-width: 0;
        padding: 18px 16px 26px;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 18px;
    }

    .page-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .page-actions .btn,
    .page-actions .action-link {
        width: auto;
        min-height: 38px;
        padding: 9px 14px;
        font-size: 0.88rem;
    }

    .stats-grid {
        margin-bottom: 18px;
    }

    .stat-card {
        padding: 18px;
    }

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

    .panel {
        padding: 18px;
        border-radius: 20px;
    }

    .panel-head {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 14px;
    }

    .data-table th,
    .data-table td {
        padding: 11px 8px;
        font-size: 0.92rem;
    }

    .table-actions {
        gap: 8px;
    }

    .action-link,
    .action-form button {
        min-height: 34px;
    }

    .modal-card {
        width: 100%;
        max-height: none;
        padding: 18px;
        border-radius: 22px;
    }

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

    body.sidebar-open {
        overflow: hidden;
    }

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

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 640px) {
    .auth-shell {
        padding: 16px;
    }

    .auth-card {
        padding: 22px 18px;
        border-radius: 24px;
    }

    .auth-logo {
        max-width: 100%;
    }

    .nav-list,
    .doc-list {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 12px 10px 20px;
    }

    .mobile-topbar {
        gap: 10px;
        margin-bottom: 12px;
        padding: 8px 10px;
        border-radius: 16px;
    }

    .mobile-topbar-logo {
        width: 112px;
    }

    .mobile-menu-toggle {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .page-head {
        gap: 14px;
        margin-bottom: 14px;
    }

    .page-actions {
        gap: 8px;
    }

    .page-head h2 {
        margin-bottom: 0;
        font-size: 1.15rem;
    }

    .sidebar {
        padding: 14px 12px;
    }

    .brand-block {
        padding: 12px;
    }

    .brand-logo {
        padding: 8px 10px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 14px;
    }

    .stat-card {
        padding: 14px 12px;
        border-radius: 18px;
    }

    .stat-card span {
        margin-bottom: 8px;
        font-size: 0.92rem;
    }

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

    .panel {
        padding: 16px 14px;
    }

    .data-table th,
    .data-table td {
        font-size: 0.88rem;
    }

    .modal-backdrop {
        align-items: flex-start;
        padding: 12px;
        overflow-y: auto;
    }

    .modal-card,
    .modal-card-compact {
        width: 100%;
        padding: 16px 14px;
        border-radius: 18px;
    }

    .modal-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-close {
        width: 100%;
    }

    .field input,
    .field select,
    .field textarea {
        padding: 11px 12px;
    }

    .btn {
        width: 100%;
    }

    .field .btn {
        justify-self: stretch;
    }
}
