@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
    --navy: #1b2e4b;
    --navy-mid: #243b5e;
    --navy-light: #2f4f7f;
    --navy-pale: #3a6298;
    --crimson: #c0272d;
    --crimson-dark: #a01f24;
    --crimson-glow: rgba(192, 39, 45, 0.12);
    --sky: #6aafe6;
    --sky-pale: rgba(106, 175, 230, 0.10);
    --white: #ffffff;
    --off-white: #f8f9fc;
    --grey-bg: #eef1f6;
    --grey-border: #dce1ea;
    --grey-mid: #c4ccd9;
    --grey-text: #6b7a90;
    --grey-dark: #4a5568;
    --text: #1a2332;
    --green: #16a34a;
    --green-bg: #ecfdf5;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --blue-bg: #eff6ff;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(27,46,75,0.06);
    --shadow: 0 2px 8px rgba(27,46,75,0.08), 0 1px 2px rgba(27,46,75,0.04);
    --shadow-md: 0 4px 16px rgba(27,46,75,0.10), 0 2px 4px rgba(27,46,75,0.05);
    --shadow-lg: 0 8px 32px rgba(27,46,75,0.12), 0 2px 8px rgba(27,46,75,0.06);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--grey-bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===================== HEADER ===================== */
.header {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    color: var(--white);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(27,46,75,0.25);
    position: relative;
    z-index: 50;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--crimson), var(--sky), var(--crimson));
    opacity: 0.7;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo {
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-branch {
    font-size: 0.9rem;
    opacity: 0.7;
    font-weight: 400;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(255,255,255,0.2);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-logout {
    background: rgba(255,255,255,0.08);
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.18);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition);
    backdrop-filter: blur(4px);
}

.btn-logout:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.35);
}

/* ===================== APP SHELL & TOPBAR ===================== */
.app-shell {
    min-height: 100vh;
}

.topbar {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    color: var(--white);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(27,46,75,0.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--crimson), var(--sky), var(--crimson));
    opacity: 0.7;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-brand {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.topbar-branch {
    font-size: 0.9rem;
    opacity: 0.7;
    font-weight: 400;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(255,255,255,0.2);
}

.topbar-nav {
    display: flex;
    gap: 0.25rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.topbar-user {
    opacity: 0.85;
}

/* Desktop nav links */
.nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--white);
    background: rgba(255,255,255,0.1);
}

.nav-link.active {
    color: var(--white);
    background: rgba(255,255,255,0.15);
}

/* ===================== BURGER MENU ===================== */
.burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.burger span {
    display: block;
    width: 100%;
    height: 2.5px;
    background: var(--white);
    border-radius: 2px;
    transition: all 0.25s ease;
}

/* ===================== MOBILE DRAWER ===================== */
.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27,46,75,0.5);
    backdrop-filter: blur(2px);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-backdrop.open {
    display: block;
    opacity: 1;
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: var(--white);
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(27,46,75,0.15);
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--grey-border);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--navy);
    background: var(--off-white);
}

.drawer-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--grey-text);
    padding: 0.25rem;
    line-height: 1;
    transition: color var(--transition);
}

.drawer-close:hover {
    color: var(--text);
}

.drawer-link {
    display: block;
    padding: 0.85rem 1.25rem;
    color: var(--grey-dark);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}

.drawer-link:hover {
    background: var(--off-white);
    color: var(--navy);
}

.drawer-link.active {
    color: var(--navy);
    background: var(--sky-pale);
    border-left-color: var(--crimson);
}

.drawer-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--grey-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--grey-text);
    font-weight: 500;
    background: var(--off-white);
}

/* ===================== PAGE SYSTEM ===================== */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeUp 0.3s ease;
}

/* ===================== SEARCH HERO ===================== */
.search-hero {
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-mid) 60%, var(--navy-light) 100%);
    padding: 3rem 1.25rem 2.5rem;
    text-align: center;
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.search-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(106,175,230,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.search-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.search-hero p {
    font-size: 1.05rem;
    opacity: 0.75;
    margin-bottom: 1.5rem;
}

.search-hero-form {
    display: flex;
    gap: 0.5rem;
    max-width: 580px;
    margin: 0 auto;
}

.search-input-wrap {
    flex: 1;
    position: relative;
}

.search-input-wrap input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.75rem;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: rgba(255,255,255,0.1);
    color: var(--white);
    transition: all var(--transition);
    backdrop-filter: blur(4px);
}

.search-input-wrap input::placeholder {
    color: rgba(255,255,255,0.5);
}

.search-input-wrap input:focus {
    outline: none;
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.15);
    box-shadow: 0 0 0 3px rgba(106,175,230,0.2);
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.15rem;
    height: 1.15rem;
    color: rgba(255,255,255,0.5);
    pointer-events: none;
}

.search-hero .btn-primary {
    background: var(--crimson);
    box-shadow: 0 2px 8px rgba(192,39,45,0.3);
    white-space: nowrap;
    flex-shrink: 0;
}

.search-hero .btn-primary:hover {
    background: var(--crimson-dark);
    box-shadow: 0 4px 14px rgba(192,39,45,0.4);
}

/* ===================== DOCUMENT CARD GRID ===================== */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.doc-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--grey-border);
    padding: 1.25rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.doc-card:hover {
    border-color: var(--navy-pale);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.doc-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.doc-card-body h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc-card-meta {
    font-size: 0.8rem;
    color: var(--grey-text);
    font-weight: 400;
}

/* ===================== PAGE HEADER ===================== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.02em;
    margin-bottom: 0.15rem;
}

.page-header p {
    color: var(--grey-text);
    font-size: 1rem;
}

/* ===================== SECTION TITLE ===================== */
.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

/* ===================== BADGE ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--sky-pale);
    color: var(--navy);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    min-width: 1.5rem;
}

/* ===================== OUTLINE BUTTON ===================== */
.btn-outline {
    background: var(--white);
    color: var(--navy);
    border: 1.5px solid var(--grey-border);
    box-shadow: none;
}

.btn-outline:hover {
    border-color: var(--navy-pale);
    background: var(--sky-pale);
    color: var(--navy);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* ===================== CONTAINER ===================== */
.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

.container-wide {
    max-width: 980px;
}

/* ===================== CARDS ===================== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--grey-border);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--navy);
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--grey-bg);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.1em;
    background: var(--crimson);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ===================== FORMS ===================== */
.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--grey-dark);
    letter-spacing: 0.01em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--grey-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: var(--off-white);
    color: var(--text);
    transition: all var(--transition);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--grey-mid);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--navy-pale);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(47, 79, 127, 0.10);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    gap: 0.4rem;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--white);
    box-shadow: 0 2px 6px rgba(27,46,75,0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy-pale) 100%);
    box-shadow: 0 4px 12px rgba(27,46,75,0.30);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(27,46,75,0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: var(--white);
    box-shadow: 0 2px 6px rgba(220,38,38,0.25);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 12px rgba(220,38,38,0.30);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.875rem;
    border-radius: 7px;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ===================== TABS ===================== */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 0.3rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--grey-border);
}

.tab {
    flex: 1;
    padding: 0.6rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 1rem;
    color: var(--grey-text);
    background: none;
    border: none;
    border-radius: var(--radius);
    transition: all var(--transition);
    text-align: center;
}

.tab.active {
    color: var(--white);
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    box-shadow: 0 2px 8px rgba(27,46,75,0.25);
}

.tab:not(.active):hover {
    color: var(--navy);
    background: var(--grey-bg);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================== CATEGORY PILLS ===================== */
.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.pill {
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1.5px solid var(--grey-border);
    background: var(--white);
    color: var(--grey-text);
    transition: all var(--transition);
}

.pill:hover {
    border-color: var(--navy-pale);
    color: var(--navy);
    background: var(--sky-pale);
}

.pill.active {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
    box-shadow: 0 2px 6px rgba(27,46,75,0.25);
}

/* ===================== DOCUMENT LIST ===================== */
.doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0.75rem;
    margin: 0 -0.75rem;
    border-radius: var(--radius);
    transition: background var(--transition);
    border-bottom: 1px solid var(--grey-bg);
}

.doc-item:last-child {
    border-bottom: none;
}

.doc-item:hover {
    background: var(--off-white);
}

.doc-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    color: var(--text);
}

.doc-meta {
    font-size: 0.875rem;
    color: var(--grey-text);
    font-weight: 400;
}

.doc-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ===================== MEMBER LIST ===================== */
.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0.75rem;
    margin: 0 -0.75rem;
    border-radius: var(--radius);
    transition: background var(--transition);
    border-bottom: 1px solid var(--grey-bg);
}

.member-item:last-child {
    border-bottom: none;
}

.member-item:hover {
    background: var(--off-white);
}

/* ===================== BRANCH LIST ===================== */
.branch-item {
    padding: 1rem 1.15rem;
    border: 1.5px solid var(--grey-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    transition: all var(--transition);
    background: var(--white);
}

.branch-item:hover {
    border-color: var(--navy-pale);
    box-shadow: var(--shadow);
    background: var(--off-white);
}

.branch-item h4 {
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: var(--navy);
}

.branch-stats {
    font-size: 0.875rem;
    color: var(--grey-text);
    margin-bottom: 0.6rem;
}

/* ===================== SEARCH ===================== */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-bar input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--grey-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: var(--off-white);
    transition: all var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--navy-pale);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(47, 79, 127, 0.10);
}

/* ===================== SEARCH RESULTS ===================== */
.search-result {
    padding: 1rem 1rem 1rem 1.15rem;
    border-left: 4px solid var(--crimson);
    background: var(--off-white);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 0.75rem;
    transition: all var(--transition);
}

.search-result:hover {
    background: var(--white);
    box-shadow: var(--shadow);
}

.search-result h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--navy);
}

.search-result .excerpt {
    font-size: 0.9375rem;
    color: var(--grey-dark);
    margin-bottom: 0.4rem;
    line-height: 1.5;
}

.search-result .result-meta {
    font-size: 0.8125rem;
    color: var(--grey-text);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ===================== ALERTS ===================== */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-left: 4px solid;
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border-left-color: var(--red);
}

.alert-success {
    background: var(--green-bg);
    color: var(--green);
    border-left-color: var(--green);
}

.alert-info {
    background: var(--blue-bg);
    color: #1e40af;
    border-left-color: var(--sky);
}

.hidden {
    display: none;
}

/* ===================== LOGIN PAGE ===================== */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-mid) 40%, var(--navy-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 70%;
    height: 160%;
    background: radial-gradient(ellipse, rgba(106,175,230,0.12) 0%, transparent 60%);
    pointer-events: none;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -15%;
    width: 50%;
    height: 80%;
    background: radial-gradient(ellipse, rgba(192,39,45,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.login-card {
    background: var(--white);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.1);
    padding: 3rem 2.5rem 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.login-card::before {
    display: none;
}

.login-logo {
    width: 280px;
    height: auto;
    margin-bottom: 1.25rem;
    filter: drop-shadow(0 4px 12px rgba(27,46,75,0.15));
}

.login-card h1 {
    font-family: inherit;
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.2rem;
    letter-spacing: -0.02em;
}

.login-card p {
    color: var(--grey-text);
    font-size: 1.05rem;
    margin-bottom: 2rem;
}

.login-card .form-group {
    text-align: left;
}

.login-card .btn {
    width: 100%;
    padding: 0.8rem;
    margin-top: 0.75rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    box-shadow: 0 4px 14px rgba(27,46,75,0.3);
}

.login-card .btn:hover {
    box-shadow: 0 6px 20px rgba(27,46,75,0.4);
}

/* ===================== FILE UPLOAD ===================== */
.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 2px dashed var(--grey-border);
    border-radius: var(--radius);
    background: var(--off-white);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--grey-dark);
    transition: all var(--transition);
}

.file-input-wrapper input[type="file"]:hover {
    border-color: var(--navy-pale);
    background: var(--sky-pale);
}

/* ===================== SPINNER ===================== */
.spinner {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border: 2.5px solid var(--grey-border);
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-btn {
    width: 1rem;
    height: 1rem;
    border-color: rgba(255,255,255,0.3);
    border-top-color: var(--white);
    vertical-align: middle;
}

.spinner-lg {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
    border-color: rgba(255,255,255,0.2);
    border-top-color: var(--white);
}

/* ===================== LOGIN OVERLAY ===================== */
.login-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27,46,75,0.85);
    backdrop-filter: blur(6px);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.login-overlay.active {
    display: flex;
}

.login-overlay-content {
    text-align: center;
    color: var(--white);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.login-overlay-content p {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    opacity: 0.9;
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--grey-text);
    font-size: 1rem;
}

/* ===================== DOCUMENT VIEWER PANEL ===================== */
.viewer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27,46,75,0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.viewer-backdrop.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.viewer-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--white);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(27,46,75,0.2);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.viewer-panel.active {
    transform: translateX(0);
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--grey-border);
    flex-shrink: 0;
    background: var(--off-white);
}

.viewer-header h3 {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 0.75rem;
    min-width: 0;
    color: var(--navy);
}

.viewer-header-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-close-viewer {
    background: none;
    border: 1.5px solid var(--grey-border);
    border-radius: var(--radius);
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 600;
    color: var(--grey-text);
    transition: all var(--transition);
}

.btn-close-viewer:hover {
    background: var(--white);
    border-color: var(--grey-mid);
    color: var(--text);
}

.viewer-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.viewer-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.viewer-body .text-content {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 1.5rem;
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text);
    margin: 0;
}

.viewer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--grey-text);
    gap: 0.5rem;
    font-size: 1rem;
}

.pdf-pages {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: #3d4148;
}

.pdf-pages canvas {
    margin: 0 auto;
    display: block;
    border-bottom: 3px solid #3d4148;
}

/* Desktop: full-page viewer */
@media (min-width: 641px) {
    .viewer-backdrop {
        display: none !important;
    }

    .viewer-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        transform: none;
        box-shadow: none;
        display: none;
    }

    .viewer-panel.active {
        display: flex;
        transform: none;
    }

    .viewer-header {
        padding: 0.75rem 2rem;
        background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
        color: var(--white);
        border-bottom: none;
    }

    .viewer-header::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, var(--crimson), var(--sky));
        opacity: 0.5;
    }

    .viewer-header h3 {
        color: var(--white);
    }

    .btn-close-viewer {
        color: rgba(255,255,255,0.9);
        border-color: rgba(255,255,255,0.2);
        background: rgba(255,255,255,0.08);
    }

    .btn-close-viewer:hover {
        background: rgba(255,255,255,0.18);
        border-color: rgba(255,255,255,0.35);
        color: var(--white);
    }

    .viewer-header-actions .btn-primary {
        background: rgba(255,255,255,0.1);
        border: 1px solid rgba(255,255,255,0.2);
        box-shadow: none;
    }

    .viewer-header-actions .btn-primary:hover {
        background: rgba(255,255,255,0.2);
        transform: none;
    }

    .viewer-body {
        max-width: 900px;
        margin: 0 auto;
        width: 100%;
    }

    .viewer-body .text-content {
        padding: 2.5rem;
    }
}

/* ===================== RESPONSIVE ===================== */

/* Mobile: show burger, hide desktop nav */
@media (max-width: 768px) {
    .burger {
        display: flex;
    }

    .topbar-nav {
        display: none;
    }

    .topbar-user {
        display: none;
    }

    .topbar-branch {
        font-size: 0.8rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .search-hero {
        padding: 2rem 1rem 1.75rem;
    }

    .search-hero h1 {
        font-size: 1.5rem;
    }

    .search-hero-form {
        flex-direction: column;
    }

    .search-hero .btn-primary {
        width: 100%;
    }

    .doc-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem;
    }

    .doc-card {
        padding: 1rem;
    }

    .doc-card-icon {
        width: 40px;
        height: 40px;
        font-size: 0.7rem;
    }
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.4rem;
        text-align: center;
    }

    .header-branch {
        border-left: none;
        padding-left: 0;
    }

    .doc-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
        padding: 0.85rem 0.5rem;
    }

    .doc-actions {
        width: 100%;
    }

    .doc-actions .btn {
        flex: 1;
    }

    .member-item {
        padding: 0.85rem 0.5rem;
    }

    .container {
        padding: 1.25rem 0.85rem;
    }

    .card {
        padding: 1.25rem;
    }

    .login-card {
        padding: 2rem 1.5rem 1.5rem;
    }

    .tabs {
        gap: 0.15rem;
    }

}
