:root {
    --blue: #0866e8;
    --blue-dark: #0754c4;
    --blue-deep: #064aad;
    --navy: #10213f;
    --muted: #7c8da3;
    --line: #e1eaf4;
    --bg: #e7f0f8;
    --green: #07965a;
    --red: #e9363e;
    --shadow: 0 10px 30px rgba(16, 40, 80, 0.06);
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    color: var(--navy);
    background: var(--bg);
}

button, input { font-family: inherit; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

body.app-body { overflow-x: clip; min-height: 100vh; }

.app-frame {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    min-height: 100vh;
    padding: 16px;
}

.app-shell {
    flex: 1;
    min-width: 0;
    display: flex;
    min-height: calc(100vh - 32px);
    background: #fff;
    border: 1px solid #e5eef6;
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.sidebar,
.drawer {
    position: relative;
    width: 200px;
    flex: none;
    display: flex;
    flex-direction: column;
    color: #fff;
    background: linear-gradient(180deg, #0b63dc 0%, #0754c4 48%, #064aad 100%);
}

.sidebar::before,
.drawer::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(120% 70% at 0% 0%, rgba(255, 255, 255, 0.16), transparent 48%),
        repeating-linear-gradient(-28deg, rgba(255, 255, 255, 0.045) 0 2px, transparent 2px 16px);
}

.sidebar > *,
.drawer > * { position: relative; z-index: 1; }

.brand,
.drawer-head .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 14px 16px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 18px;
}

.brand-name,
.mobile-brand span:last-child {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.15;
}

.side-nav { padding: 4px 12px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.nav-link.active {
    background: #1e74ee;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.logout-form { margin-top: auto; padding: 8px 12px 16px; }

.logout-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
}

.logout-button:hover,
.nav-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.workspace { flex: 1; min-width: 0; background: #fff; }

.workspace-body { padding: 16px 18px 14px; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.page-head h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-head p { margin: 3px 0 0; color: #8b9bb0; font-size: 12.5px; }

.admin-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-top: 2px;
    color: #31445f;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.admin-avatar {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e7f0ff;
    color: var(--blue);
    font-size: 16px;
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
}

.flash-success { background: #e8f8f0; color: #067348; }
.flash-error { background: #fdecee; color: #c4232c; }

.flash-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.search-field { position: relative; flex: 1; min-width: 0; }

.search-field > i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #93a3b8;
    font-size: 14px;
}

.search-field input {
    width: 100%;
    height: 36px;
    padding: 0 28px 0 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--navy);
    font-size: 13px;
    outline: none;
}

.search-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8, 102, 232, 0.12); }

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #8b9bb0;
    text-decoration: none;
    font-size: 16px;
    line-height: 1;
}

.btn-main,
.btn-reset,
.btn-outline,
.btn-cancel,
.btn-bulk {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.btn-main {
    border: 0;
    background: var(--blue);
    color: #fff;
}

.btn-main:hover { background: #0759cc; color: #fff; }

.btn-reset,
.btn-outline,
.btn-cancel {
    border: 1px solid var(--line);
    background: #f4f7fb;
    color: #52647a;
}

.btn-outline { background: #fff; }

.btn-reset:hover,
.btn-outline:hover,
.btn-cancel:hover { background: #eaf0f7; color: #31445f; }

.search-submit .icon { display: none; }

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 7px 8px;
    border: 1px solid #e6eef6;
    border-radius: 10px;
    background: #f8fbfe;
}

.bulk-main,
.bulk-actions,
.select-all { display: flex; align-items: center; gap: 8px; }

.select-all label { margin: 0; color: #3e5168; font-size: 12.5px; font-weight: 600; }

.caret-btn {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #607089;
}

.selected-count { min-width: 72px; color: var(--blue); font-size: 12.5px; font-weight: 700; }

.btn-bulk {
    height: 30px;
    border: 0;
    color: #fff;
    font-size: 12.5px;
    border-radius: 7px;
}

.btn-csv { background: var(--green); }
.btn-csv:hover { background: #067d4b; color: #fff; }
.btn-zip { background: var(--blue); }
.btn-zip:hover { background: #0759cc; }
.btn-del { background: var(--red); }
.btn-del:hover { background: #d1262e; color: #fff; }
.btn-bulk:disabled,
button:disabled { opacity: 0.45; cursor: not-allowed; }

.label-short { display: none; }

.bulk-meta { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.range-pill {
    padding: 4px 10px;
    border-radius: 999px;
    background: #e8f2fc;
    color: #3e5874;
    font-size: 11.5px;
    white-space: nowrap;
}

.page-size {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 52px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: #41556e;
    font-size: 12px;
}

input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--blue); }

.desktop-table { margin-top: 8px; overflow: hidden; }

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

.data-table th {
    padding: 8px 10px;
    background: #f5f8fc;
    color: #667890;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    border-bottom: 1px solid #e6eef6;
    white-space: nowrap;
}

.data-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f4f8;
    color: #3c4e66;
    font-size: 13px;
    vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fbfe; }

.check-col { width: 36px; }
.num-col { width: 42px; color: #8a9bb0; }
.actions-col { width: 116px; text-align: right; }
.name-cell, .file-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-cell { color: #17304f; font-weight: 700; }
.date-col { width: 168px; }
.date-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }

.actions { display: flex; justify-content: flex-end; gap: 6px; }

.icon-btn {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    text-decoration: none;
}

.icon-btn.view { background: var(--blue); }
.icon-btn.down { background: var(--green); }
.icon-btn.del { background: var(--red); }
.icon-btn:hover { filter: brightness(0.95); color: #fff; }

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.range-text { margin: 0; color: #8090a6; font-size: 12px; }
.range-text.lone { margin-top: 10px; }

.pages { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.pages a,
.pages span {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #3e5168;
    font-size: 13px;
    text-decoration: none;
}

.pages .active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }
.pages .disabled { opacity: 0.4; }
.pages .ellipsis { border: 0; background: transparent; min-width: 16px; }

.empty { padding: 36px 16px; text-align: center; color: #6d7f95; }
.empty i { color: var(--blue); font-size: 32px; }
.empty h2 { margin: 8px 0 4px; color: var(--navy); font-size: 16px; }
.empty p { margin: 0; font-size: 13px; }

.preview-dock {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    width: 340px;
    height: calc(100vh - 32px);
    flex: none;
    padding: 14px;
    background: #fff;
    border: 1px solid #e5eef6;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(16, 40, 80, 0.08);
}

.preview-dock[hidden],
.preview-screen[hidden],
.mobile-bar,
.mobile-list,
.drawer,
.drawer-backdrop { display: none !important; }

.preview-head,
.preview-actions { display: flex; align-items: center; justify-content: space-between; }

.preview-head h2,
.pm-modal .modal-title { margin: 0; color: var(--navy); font-size: 16px; font-weight: 800; }

.icon-x {
    border: 0;
    background: transparent;
    color: #607089;
    font-size: 16px;
}

.preview-name { margin: 10px 0 0; color: var(--navy); font-size: 14px; font-weight: 800; }
.preview-file { margin: 0; color: #8090a6; font-size: 12px; }
.preview-fallback { margin: 8px 0 0; color: #8b9bb0; font-size: 11.5px; }

.pdf-stage {
    flex: 1;
    min-height: 280px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 8px;
    background: #525659;
}

.pdf-stage iframe,
.pdf-modal-stage iframe { width: 100%; height: 100%; border: 0; background: #525659; }

.preview-actions { justify-content: flex-end; gap: 8px; margin-top: 12px; }

.preview-screen {
    position: fixed;
    inset: 0;
    z-index: 1030;
    background: rgba(10, 22, 44, 0.35);
}

.mobile-bar,
.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-btn {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 22px;
}

.proposal-card {
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e4edf6;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(16, 40, 80, 0.04);
}

.proposal-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pick { display: flex; align-items: flex-start; gap: 8px; min-width: 0; margin: 0; }
.proposal-card .name { color: #17304f; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.proposal-card .file,
.proposal-card .date { margin: 2px 0 0 23px; color: #6d7f95; font-size: 12px; overflow-wrap: anywhere; }

.pm-modal .modal-content { border: 0; border-radius: 16px; box-shadow: 0 20px 50px rgba(16, 33, 63, 0.18); }
.pm-modal .modal-header { padding: 14px 16px; border-bottom: 1px solid #eef2f7; }
.pm-modal .modal-body { padding: 14px 16px 6px; }
.pm-modal .modal-footer { gap: 8px; padding: 8px 16px 16px; border: 0; }
.pm-modal .form-label { margin-bottom: 6px; color: #1c314e; font-size: 13px; font-weight: 700; }
.req { color: var(--red); }
.pm-modal .form-control { height: 40px; border-color: var(--line); border-radius: 8px; font-size: 13px; }
.pm-modal .form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8, 102, 232, 0.12); }
.add-dialog, .preview-dialog, .confirm-dialog { max-width: 420px; }

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 148px;
    padding: 16px;
    border: 1.5px dashed #c9d8ea;
    border-radius: 12px;
    background: #fbfcfe;
    text-align: center;
    cursor: pointer;
}

.dropzone i { color: var(--blue); font-size: 28px; }
.dropzone strong { color: #1c314e; font-size: 13.5px; }
.dropzone small,
.file-name { color: #8b9bb0; font-size: 12px; }
.file-name { min-height: 16px; color: var(--blue); font-weight: 700; }
.file-name.is-error { color: var(--red); }
.dropzone.is-over { border-color: var(--blue); background: #f3f8ff; }

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.pdf-modal-stage { height: 46vh; min-height: 220px; margin-top: 10px; overflow: hidden; border-radius: 8px; background: #525659; }
.confirm-copy { margin: 0; color: #3c4e66; font-size: 14px; }
.field-error { margin: 4px 0 0; color: var(--red); font-size: 12px; }

body.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px 16px;
    background:
        radial-gradient(900px 420px at 8% -10%, rgba(8, 102, 232, 0.08), transparent 50%),
        radial-gradient(700px 320px at 110% 110%, rgba(8, 102, 232, 0.07), transparent 42%),
        #f3f7fb;
}

.login-card {
    width: min(400px, 100%);
    padding: 32px 26px 22px;
    border: 1px solid #e7eef6;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(16, 40, 80, 0.08);
    text-align: center;
}

.login-logo { color: var(--blue); font-size: 42px; line-height: 1; }
.login-card h1 { margin: 10px 0 0; font-size: 22px; font-weight: 800; }
.login-card .subtitle { margin: 4px 0 18px; color: #8b9bb0; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.field-block { display: flex; flex-direction: column; }
.input-shell { position: relative; }

.input-shell .lead {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #93a3b8;
    font-size: 16px;
}

.input-shell input {
    width: 100%;
    height: 46px;
    padding: 0 42px;
    border: 1px solid #e1e8f0;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
}

.input-shell input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8, 102, 232, 0.12); }
.input-shell input.is-invalid { border-color: var(--red); }

.eye-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    width: 32px;
    height: 32px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #8b9bb0;
}

.login-submit {
    width: 100%;
    height: 46px;
    margin-top: 4px;
    border: 0;
    border-radius: 10px;
    background: var(--blue);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.login-submit:hover { background: #0759cc; }
.secure-note { margin: 14px 0 0; color: #a0aec0; font-size: 12px; text-align: center; }

@media (max-width: 1279.98px) {
    .preview-dock:not([hidden]) {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 1040;
        width: min(400px, calc(100vw - 24px));
        height: calc(100vh - 24px);
    }
}

@media (max-width: 1199.98px) {
    .name-cell, .file-cell { max-width: 140px; }
}

@media (max-width: 991.98px) {
    .app-frame { display: block; min-height: 100vh; padding: 0; }
    .app-shell {
        display: block;
        min-height: 100vh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: #f4f8fc;
    }
    .sidebar { display: none; }
    .page-head,
    .desktop-table,
    .bulk-meta,
    .btn-reset,
    .search-submit .label,
    .label-long { display: none !important; }
    .mobile-bar {
        display: flex !important;
        position: sticky;
        top: 0;
        z-index: 20;
        height: 56px;
        padding: 0 12px;
        background: linear-gradient(180deg, #0b63dc 0%, #0757c8 100%);
        color: #fff;
    }
    .mobile-bar .brand-mark { width: 30px; height: 30px; font-size: 16px; }
    .mobile-bar .mobile-brand { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
    .workspace-body { padding: 12px 0 20px; }
    .flash, .toolbar, .bulk-bar, .pager, .range-text.lone { margin-left: 12px; margin-right: 12px; }
    .toolbar { flex-wrap: wrap; }
    .btn-add, .search-form { width: 100%; }
    .search-submit { width: 38px; padding: 0; }
    .search-submit .icon { display: inline; }
    .bulk-main, .bulk-actions { width: 100%; }
    .bulk-actions .btn-bulk { flex: 1; padding: 0 8px; }
    .label-short { display: inline; }
    .mobile-list { display: flex !important; flex-direction: column; gap: 8px; padding: 8px 12px 0; }
    .pager { align-items: flex-start; flex-direction: column; }
    .pages { justify-content: flex-start; }
    .preview-dock, .preview-screen { display: none !important; }
    .drawer {
        display: flex !important;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1050;
        width: min(280px, 86vw);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
    }
    .drawer.show { transform: translateX(0); }
    .drawer-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(10, 22, 44, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    .drawer-backdrop.show { opacity: 1; pointer-events: auto; }
    .drawer-head { padding: 8px 8px 8px 0; }
    .drawer .logout-form { margin-top: auto; }
}

@media (max-width: 359.98px) {
    .login-card { padding: 24px 16px 18px; }
    .pages a, .pages span { min-width: 28px; height: 28px; }
}

@media (min-width: 1500px) {
    .preview-dock { width: 380px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
