/* ============================================================
   SecureDMS — Main Stylesheet
   Modern dark/light mode, card-based, responsive
   ============================================================ */

/* ── Google Font ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
    /* Dark theme (default) */
    --bg-base: #0d1117;
    --bg-surface: #161b22;
    --bg-elevated: #1e2530;
    --bg-card: #1e2530;
    --bg-hover: #252d3a;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --text-heading: #f0f6fc;

    --accent: #2196f3;
    --accent-hover: #1976d2;
    --accent-dark: #0d47a1;
    --accent-light: rgba(33, 150, 243, 0.15);

    --success: #2da44e;
    --success-bg: rgba(45, 164, 78, 0.15);
    --error: #f85149;
    --error-bg: rgba(248, 81, 73, 0.15);
    --warning: #e3b341;
    --warning-bg: rgba(227, 179, 65, 0.15);
    --info: #58a6ff;
    --info-bg: rgba(88, 166, 255, 0.15);

    --border: rgba(255, 255, 255, 0.08);
    --border-focus: #2196f3;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 18px 60px rgba(0, 0, 0, 0.65);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --topbar-h: 60px;
    --transition: 0.2s ease;
}

[data-theme="light"] {
    --bg-base: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f0f4f8;
    --text-primary: #1a1f2e;
    --text-secondary: #5a6475;
    --text-muted: #8b97a8;
    --text-heading: #111827;

    --border: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 18px 60px rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .nav-item:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-heading);
}

[data-theme="light"] .nav-item.active {
    background: rgba(33, 150, 243, 0.12);
}

[data-theme="light"] .btn-logout {
    background: #f8fafc;
}

/* ── Reset & Base ────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

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

a:hover {
    color: var(--accent-hover);
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

img {
    max-width: 100%;
    height: auto;
}

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

/* ── Layout ──────────────────────────────────────────────── */
.layout {
    display: block;
    min-height: 100vh;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent), #7c4dff);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
    display: block;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all var(--transition);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-item .nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-profile-link {
    color: inherit;
    text-decoration: none;
}

.user-profile-link:hover .user-name {
    color: var(--accent);
}

.user-avatar,
.user-avatar-img {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #7c4dff, var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.user-avatar-img {
    background: none;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
}

.user-role {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-admin {
    color: #f5a623;
}

.badge-user,
.badge-representative,
.badge-director {
    color: var(--info);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-logout:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

/* ── Main Content Area ───────────────────────────────────── */
.main-content {
    margin-left: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

.topbar {
    min-height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 10px 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    color: var(--text-heading);
    flex-shrink: 0;
}

.topbar-brand:hover {
    color: var(--text-heading);
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.topbar-nav::-webkit-scrollbar {
    display: none;
}

.topbar-nav .nav-item {
    margin-bottom: 0;
    padding: 8px 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

.page-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-heading);
    flex: 0 1 auto;
    margin: 0;
    min-width: 80px;
    text-align: right;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.theme-toggle {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.notification-link {
    position: relative;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.notification-link:hover,
.notification-link.has-unread {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
}

.notification-count {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--error);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
}

.content-area {
    width: 100%;
    max-width: 1320px;
    padding: 28px 32px 40px;
    margin: 0 auto;
    flex: 1;
}

/* ── Auth Pages ──────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    min-height: 100vh;
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    font-size: 2.5rem;
    text-align: center;
    background: linear-gradient(135deg, var(--accent), #7c4dff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.auth-title {
    font-size: 1.6rem;
    font-weight: 800;
    text-align: center;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.auth-sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 28px;
}

.auth-footer-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.form-input-sm {
    padding: 7px 10px;
    font-size: 0.85rem;
}

.form-input::placeholder {
    color: var(--text-muted);
}

select.form-input {
    cursor: pointer;
}

.input-group {
    display: flex;
}

.input-group .form-input {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    border-right: none;
}

.input-btn {
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.input-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

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

.form-check {
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Password strength bar */
.password-strength-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

#strengthFill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border-color: transparent;
}

.btn-danger:hover {
    background: var(--error);
    color: #fff;
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: transparent;
}

.btn-success:hover {
    background: var(--success);
    color: #fff;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    opacity: 0.7;
    transition: opacity var(--transition);
    color: var(--text-primary);
}

.btn-icon:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.btn-icon.btn-danger:hover {
    background: var(--error-bg);
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid transparent;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(45, 164, 78, 0.3);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border-color: rgba(248, 81, 73, 0.3);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border-color: rgba(88, 166, 255, 0.3);
}

/* ── Dashboard ───────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    gap: 28px;
    max-width: 100%;
    margin: 0 auto;
}

.hero-card {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    border-radius: var(--radius-xl);
    padding: 64px 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
    border: none;
    box-shadow: 0 20px 50px -15px rgba(59, 130, 246, 0.5);
    min-height: 320px;
    margin-bottom: 8px;
}

.hero-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 70% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    pointer-events: none;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 12px;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.hero-sub {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.15rem;
    margin-bottom: 40px;
    max-width: 600px;
    line-height: 1.5;
}

.hero-actions {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.hero-art {
    font-size: 8rem;
    opacity: 0.85;
    flex-shrink: 0;
    margin-left: 20px;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.3));
}

.directorate-board {
    position: relative;
    overflow: hidden;
    min-height: auto;
    padding: 18px 32px 42px;
    background:
        linear-gradient(rgba(0, 0, 0, 0.52), rgba(0, 0, 0, 0.64)),
        url('../img/saaf-hero.jpeg') center 56% / cover no-repeat;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.command-hero {
    position: relative;
    min-height: clamp(290px, 31vh, 380px);
    margin-bottom: 34px;
    padding: 28px 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
}

.command-hero-content {
    position: relative;
    z-index: 1;
    width: min(960px, calc(100% - 48px));
    text-align: center;
    color: #fff;
}

.command-hero-logo {
    display: block;
    width: clamp(58px, 6.4vw, 86px);
    height: auto;
    margin: 0 auto 18px;
    filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.48));
}

.command-hero-kicker {
    margin: 0 0 10px;
    font-size: 0.84rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.86);
}

.command-hero-title {
    margin: 0;
    font-size: 2.45rem;
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: 0;
    color: #fff;
    text-transform: uppercase;
    text-shadow: 0 12px 28px rgba(0, 0, 0, 0.58);
}

.command-hero-subtitle {
    margin: 12px 0 0;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.86);
}

.command-hero-meta {
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.command-meta-item,
.command-search {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(4, 12, 24, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 6px;
    color: #fff;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.command-meta-item {
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 700;
}

.command-meta-label {
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.command-search {
    min-width: min(280px, 100%);
    padding: 0 12px;
}

.command-search-icon {
    color: rgba(255, 255, 255, 0.74);
    font-size: 1.15rem;
    line-height: 1;
}

.command-search input {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 0;
    color: #fff;
    font: inherit;
    font-size: 0.9rem;
    outline: 0;
}

.command-search input::placeholder {
    color: rgba(255, 255, 255, 0.62);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.directorate-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(10, 78px);
    gap: 44px 0;
    justify-content: center;
    align-items: center;
}

.directorate-link {
    grid-column: span 2;
    justify-self: center;
}

.directorate-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    color: #061a40;
}

.directorate-link:hover {
    color: #061a40;
}

.directorate-link.is-filtered {
    display: none;
}

.directorate-link.directorate-locked {
    cursor: not-allowed;
    opacity: 0.34;
    filter: grayscale(1);
    pointer-events: none;
}

.directorate-link.directorate-locked .directorate-tile {
    box-shadow: none;
}

.directorate-tile {
    width: 104px;
    height: 104px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 50%;
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.26);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.directorate-link:hover .directorate-tile {
    border-color: rgba(125, 211, 252, 0.85);
    transform: translateY(-6px);
    box-shadow: 0 26px 42px rgba(0, 0, 0, 0.34);
}

.directorate-name {
    color: #ffffff;
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.15;
    text-shadow: 0 8px 18px rgba(0, 0, 0, 0.42);
}

.directorate-board .directorate-name,
[data-theme="dark"] .directorate-name {
    color: #ffffff;
}

.directorate-empty {
    margin: 0;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 700;
}

.directorate-lock-label {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dashboard-main-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 24px;
    align-items: start;
}

.dashboard-left-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    min-width: 0;
}

.dashboard-right-col {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.directorate-emblem-wrap {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
}

.directorate-emblem-combo {
    gap: 2px;
    padding: 5px;
}

.directorate-emblem {
    max-width: 84%;
    max-height: 84%;
    object-fit: contain;
}

.directorate-emblem-combo .directorate-emblem {
    width: 50%;
    max-width: 50%;
    max-height: 78%;
}

.directorate-initials {
    color: #061a40;
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.04em;
}

.stats-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
}

.document-search-card {
    padding: 18px;
}

.document-search-card .section-header {
    margin-bottom: 12px;
}

.document-search-form {
    display: grid;
    gap: 10px;
}

.document-search-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.document-filter-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr)) auto;
    gap: 8px;
    align-items: end;
}

.document-filter-grid label {
    min-width: 0;
}

.document-filter-grid label span {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.document-search-results {
    margin-top: 12px;
    display: grid;
    gap: 8px;
    max-height: 248px;
    overflow-y: auto;
    padding-right: 4px;
}

.document-result-item {
    min-height: 54px;
    padding: 9px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.document-result-item:hover {
    color: var(--text-heading);
    border-color: rgba(33, 150, 243, 0.42);
    background: var(--accent-light);
}

.document-result-size {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 800;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 92px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

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

.stat-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: 1.45rem;
}

.stat-val {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1;
    margin-bottom: 3px;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.storage-stat .stat-info {
    width: 100%;
    min-width: 0;
}

.storage-panel {
    padding: 20px;
}

.storage-panel .section-header {
    margin-bottom: 12px;
}

.storage-panel-value {
    margin-bottom: 8px;
    color: var(--text-heading);
    font-size: 1.75rem;
    font-weight: 850;
    line-height: 1;
}

.storage-meter {
    position: relative;
    width: 100%;
    height: 7px;
    margin-top: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.storage-meter-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--success);
    box-shadow: 0 0 14px rgba(45, 164, 78, 0.36);
}

.storage-warning .storage-meter-fill {
    background: var(--warning);
    box-shadow: 0 0 14px rgba(227, 179, 65, 0.34);
}

.storage-danger .storage-meter-fill {
    background: var(--error);
    box-shadow: 0 0 14px rgba(248, 81, 73, 0.34);
}

.storage-meter-scale {
    display: grid;
    grid-template-columns: repeat(4, max-content);
    justify-content: space-between;
    gap: 8px;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.2;
}

.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.section-subtitle {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-panel {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.profile-photo-preview {
    display: flex;
    justify-content: center;
}

.profile-photo-lg,
.profile-photo-fallback {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.profile-photo-lg {
    object-fit: cover;
}

.profile-photo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7c4dff, var(--accent));
    color: #fff;
    font-size: 3rem;
    font-weight: 800;
}

.profile-details-card {
    min-width: 0;
}

.profile-details-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin: 0 0 18px;
}

.profile-details-list div {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
}

.profile-details-list dt {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.profile-details-list dd {
    margin: 0;
    color: var(--text-primary);
    font-weight: 700;
}

.profile-photo-form {
    max-width: 520px;
}

.notifications-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.notification-card.unread {
    border-color: rgba(33, 150, 243, 0.45);
    box-shadow: 0 0 0 1px rgba(33, 150, 243, 0.08), var(--shadow-sm);
}

.notification-main {
    min-width: 0;
}

.notification-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.notification-title-row h3 {
    margin: 0;
    color: var(--text-heading);
    font-size: 1rem;
    line-height: 1.3;
}

.notification-meta {
    margin-top: 7px;
    display: flex;
    gap: 8px 14px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.notification-note {
    margin: 12px 0 0;
    padding: 12px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
}

.notification-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.badge-unread {
    background: var(--accent-light);
    color: var(--accent);
}

.pending-files-card .section-header {
    margin-bottom: 14px;
}

.pending-file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.pending-file-item {
    min-height: 58px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.pending-file-item:hover,
.pending-file-item.unread {
    color: var(--text-heading);
    border-color: rgba(33, 150, 243, 0.42);
    background: var(--accent-light);
}

.pending-file-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.pending-file-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pending-file-body strong {
    color: inherit;
    font-size: 0.86rem;
    line-height: 1.2;
}

.pending-file-body small {
    color: var(--text-secondary);
    font-size: 0.72rem;
}

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

.document-summary-card {
    padding: 18px;
}

.document-summary-card .section-header {
    margin-bottom: 12px;
}

.document-summary-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.document-summary-item {
    min-height: 58px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.document-summary-item:hover {
    color: var(--text-heading);
    border-color: rgba(33, 150, 243, 0.42);
    background: var(--accent-light);
}

.document-summary-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.document-summary-body {
    min-width: 0;
}

.document-summary-body strong,
.document-summary-body small,
.document-summary-body em {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-summary-body strong {
    color: var(--text-heading);
    font-size: 0.88rem;
    line-height: 1.25;
}

.document-summary-body small,
.document-summary-body em {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-style: normal;
    line-height: 1.25;
}

.compact-empty {
    min-height: 58px;
    padding: 14px;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    font-weight: 600;
}

.pending-dot {
    width: 8px;
    height: 8px;
    margin-left: auto;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.14);
}

.pending-empty {
    min-height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: var(--text-secondary);
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
}

.pending-empty-icon {
    font-size: 1.8rem;
}

/* ── Chat Drawer ─────────────────────────────────────────── */
.chat-widget {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 180;
}

.chat-toggle {
    position: relative;
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 1.35rem;
    box-shadow: var(--shadow-lg);
}

.chat-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--error);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
}

.chat-panel {
    position: absolute;
    right: 0;
    bottom: 66px;
    width: min(380px, calc(100vw - 32px));
    height: min(620px, calc(100vh - 120px));
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.chat-widget.open .chat-panel {
    display: flex;
}

.chat-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.chat-header h2,
.chat-header p {
    margin: 0;
}

.chat-header h2 {
    color: var(--text-heading);
    font-size: 1rem;
}

.chat-header p {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.chat-close,
.chat-record,
.chat-send {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    cursor: pointer;
}

.chat-close {
    width: 32px;
    height: 32px;
}

.chat-messages {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.chat-empty {
    margin: auto;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.chat-message {
    max-width: 86%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.chat-message.mine {
    align-self: flex-end;
    background: var(--accent-light);
    border-color: rgba(33, 150, 243, 0.35);
}

.chat-message-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.chat-message-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.86rem;
}

.chat-message audio {
    width: 100%;
    max-width: 260px;
    display: block;
}

.chat-message-status {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
}

.chat-message-status.seen {
    color: var(--text-secondary);
}

.chat-delivery-tick,
.chat-seen-logo,
.chat-seen-initials {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.chat-delivery-tick {
    color: var(--accent);
    font-size: 0.82rem;
    line-height: 1;
}

.chat-seen-logo {
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(6, 26, 64, 0.12);
}

.chat-seen-logo.is-combo {
    gap: 1px;
    padding: 1px;
}

.chat-seen-logo img {
    max-width: 82%;
    max-height: 82%;
    object-fit: contain;
}

.chat-seen-logo.is-combo img {
    width: 50%;
    max-width: 50%;
    max-height: 74%;
}

.chat-seen-initials {
    background: #fff;
    border: 1px solid rgba(6, 26, 64, 0.12);
    color: #061a40;
    font-size: 0.45rem;
    font-weight: 900;
    overflow: hidden;
}

.chat-compose {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

.chat-recipient {
    height: 38px;
}

.chat-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px 38px;
    gap: 8px;
    align-items: end;
}

.chat-text {
    min-height: 42px;
    resize: none;
}

.chat-record,
.chat-send {
    width: 38px;
    height: 38px;
    font-weight: 800;
}

.chat-record.recording {
    color: #fff;
    background: var(--error);
    border-color: var(--error);
}

.chat-status {
    min-height: 16px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.system-status {
    margin-top: 16px;
}

.system-status-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px 0;
}

.section-heading {
    font-size: 1.05rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 20px;
    margin-top: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-heading:first-child {
    margin-top: 0;
}

.count-badge {
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.action-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.action-btn:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 1.35rem;
    flex-shrink: 0;
}

/* Activity Feed */
.activity-card {
    max-height: 460px;
    overflow: hidden;
}

.activity-list {
    max-height: 350px;
    overflow-y: auto;
    padding-right: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.activity-item:hover {
    background: var(--bg-hover);
}

.activity-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.activity-info {
    flex: 1;
    font-size: 0.85rem;
    min-width: 0;
}

.activity-action {
    font-weight: 600;
    color: var(--text-primary);
}

.activity-target {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.activity-user {
    color: var(--text-muted);
    font-size: 0.78rem;
    display: block;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 18px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    gap: 18px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.toolbar-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 260px;
    flex: 1;
}

.toolbar-context {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    flex-wrap: wrap;
    font-weight: 500;
}

.crumb {
    color: var(--text-secondary);
    transition: color var(--transition);
}

.crumb:hover {
    color: var(--accent);
}

.crumb-sep {
    color: var(--text-muted);
}

.dc-tabs-card {
    margin: -4px 0 24px;
    padding: 22px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.dc-tabs-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.dc-tabs-header h2 {
    color: var(--text-heading);
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
    text-transform: uppercase;
}

.dc-tabs-header p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin: 0;
    text-align: right;
}

.dc-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dc-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 700;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.dc-tab:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.dc-tab.active {
    color: var(--accent);
    background: var(--accent-light);
    border-color: rgba(33, 150, 243, 0.42);
}

/* ── File Grid ───────────────────────────────────────────── */
.file-section {
    margin-bottom: 24px;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

.file-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: var(--shadow-sm);
    min-height: 160px;
}

.file-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    background: var(--bg-hover);
}

.file-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 4px;
}

.file-icon {
    font-size: 2rem;
}

.file-type-badge {
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.file-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.3;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-actions {
    display: flex;
    gap: 4px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.folder-card .file-card-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: inherit;
    text-decoration: none;
    flex: 1;
}

.folder-card {
    flex-direction: column;
}

/* ── Explorer Layout (Folders & Files) ───────────────────── */
.explorer-grid {
    display: flex;
    flex-direction: column;
    gap: 36px;
    max-width: 100%;
    margin: 0 auto;
}

.explorer-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Folder Horizontal Grid */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.folder-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.folder-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.folder-link {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-primary);
    font-weight: 600;
    flex: 1;
    min-width: 0;
}

.folder-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    line-height: 1;
}

.folder-name {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-file-count {
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--accent-light);
    border: 1px solid rgba(33, 150, 243, 0.28);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
}

.folder-owner {
    min-width: 0;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.folder-item:hover .folder-actions {
    opacity: 1;
}

/* Explorer Table */
.explorer-table {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.file-name-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon-sm {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.file-name-text {
    font-weight: 500;
    color: var(--text-heading);
}

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

.btn-xs {
    padding: 2px 6px;
    font-size: 0.75rem;
}

.empty-state-card {
    background: var(--bg-surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 16px;
    text-align: center;
}

/* ── File Upload in Modal ────────────────────────────────── */
.file-drop-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 48px 32px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.file-drop-area:hover,
.file-drop-area.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-drop-label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}

.drop-icon-sm {
    font-size: 3rem;
    margin-bottom: 8px;
}

.progress-wrap {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.3s;
    border-radius: 3px;
}

.hidden {
    display: none !important;
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
    from {
        transform: translateY(-20px) scale(0.97);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.routing-panel {
    margin-top: 22px;
    padding: 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.routing-panel .form-group:last-child {
    margin-bottom: 0;
}

.modal-close:hover {
    background: var(--error-bg);
    color: var(--error);
}

.modal-body {
    padding: 32px;
}

.modal-footer {
    padding: 24px 32px;
    background: var(--bg-elevated-light);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ── Preview ─────────────────────────────────────────────── */
.preview-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preview-toolbar {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 30px 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.preview-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    min-width: 0;
    flex-wrap: wrap;
}

.preview-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.preview-body {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-height: 400px;
    overflow: hidden;
}

.preview-image-wrap {
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.preview-image {
    max-height: 70vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.preview-pdf {
    width: 100%;
    height: 75vh;
    border: none;
    display: block;
}

.preview-text-wrap {
    padding: 20px;
    overflow: auto;
    max-height: 70vh;
}

.preview-text {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

.preview-unsupported {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 16px;
    text-align: center;
}

.preview-icon-lg {
    font-size: 4rem;
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.data-table {
    font-size: 0.875rem;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 16px 20px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.row-inactive td {
    opacity: 0.5;
}

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 32px !important;
}

.actions-cell {
    white-space: nowrap;
}

.truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-admin {
    background: rgba(245, 166, 35, 0.15);
    color: #f5a623;
}

.badge-user,
.badge-representative,
.badge-director {
    background: var(--info-bg);
    color: var(--info);
}

.badge-cdfp {
    background: rgba(33, 150, 243, 0.15);
    color: var(--accent);
}

.badge-pending {
    background: rgba(245, 166, 35, 0.15);
    color: #f5a623;
}

.badge-approved {
    background: rgba(67, 160, 71, 0.15);
    color: var(--success);
}

.badge-rejected,
.badge-revoked {
    background: rgba(229, 57, 53, 0.15);
    color: var(--danger);
}

.status-dot.active {
    color: var(--success);
    font-size: 0.8rem;
}

.status-dot.inactive {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Action chips */
.action-chip {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.action-upload {
    background: rgba(45, 164, 78, 0.15);
    color: var(--success);
}

.action-download {
    background: rgba(33, 150, 243, 0.15);
    color: var(--accent);
}

.action-file_deleted,
.action-folder_deleted {
    background: var(--error-bg);
    color: var(--error);
}

.action-login_success {
    background: var(--success-bg);
    color: var(--success);
}

.action-login_failed {
    background: var(--error-bg);
    color: var(--error);
}

/* ── Filters ─────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.page-btn {
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition);
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-info {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Settings ────────────────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.info-table {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    gap: 16px;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-secondary);
}

.info-val {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

/* ── Error Card ──────────────────────────────────────────── */
.error-card {
    text-align: center;
}

.error-code {
    font-size: 5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--error), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

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

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .layout {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .topbar {
        padding: 10px 16px;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    .topbar-brand {
        min-width: 0;
    }

    .topbar-nav {
        order: 3;
        flex-basis: 100%;
        padding-bottom: 2px;
    }

    .page-title {
        display: none;
    }

    .hero-art {
        display: none;
    }

    .hero-card {
        padding: 40px 24px;
        min-height: auto;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .hero-sub {
        font-size: 1rem;
        margin-bottom: 24px;
    }

    .directorate-board {
        padding: 16px 20px 34px;
        min-height: auto;
    }

    .command-hero {
        min-height: 280px;
        margin-bottom: 30px;
        padding: 24px 0 18px;
    }

    .command-hero-content {
        width: min(100% - 32px, 760px);
    }

    .command-hero-logo {
        width: 62px;
        margin-bottom: 16px;
    }

    .command-hero-title {
        font-size: 1.8rem;
    }

    .command-hero-subtitle {
        font-size: 0.95rem;
    }

    .command-hero-meta {
        margin-top: 22px;
        align-items: stretch;
    }

    .command-meta-item,
    .command-search {
        min-height: 40px;
    }

    .directorate-grid {
        grid-template-columns: repeat(3, 100px);
        gap: 28px 30px;
    }

    .directorate-tile {
        width: 96px;
        height: 96px;
        padding: 11px;
    }

    .content-area {
        padding: 20px 16px 32px;
    }

    .dashboard-main-columns {
        grid-template-columns: 1fr;
    }

    .dashboard-documents-grid {
        grid-template-columns: 1fr;
    }

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

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

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

    .document-filter-grid .btn {
        min-height: 40px;
    }

    .toolbar {
        padding: 18px;
        gap: 16px;
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        justify-content: flex-start;
    }

    .dc-tabs-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .dc-tabs-header p {
        text-align: left;
    }

    .explorer-grid {
        gap: 32px;
    }

    .folder-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    }
}

@media (max-width: 600px) {
    .auth-card {
        padding: 28px 20px;
        box-shadow: var(--shadow-md);
    }

    .auth-title {
        font-size: 1.4rem;
    }

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

    .document-search-main,
    .document-filter-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 14px;
        gap: 12px;
        align-items: center;
        flex-direction: row;
    }

    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 1.25rem;
    }

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

    .stat-val {
        font-size: 1.35rem;
    }

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

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .activity-card {
        max-height: 420px;
    }

    .activity-list {
        max-height: 310px;
    }

    .topbar-actions .user-details {
        display: none;
    }

    .notification-card,
    .notification-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .command-hero {
        min-height: 300px;
        margin-bottom: 26px;
        align-items: flex-end;
        padding: 34px 0 22px;
    }

    .command-hero-content {
        width: calc(100% - 28px);
    }

    .command-hero-logo {
        width: 54px;
        margin-bottom: 14px;
    }

    .command-hero-kicker {
        font-size: 0.72rem;
    }

    .command-hero-title {
        font-size: 1.42rem;
    }

    .command-hero-subtitle {
        font-size: 0.88rem;
    }

    .command-hero-meta {
        flex-direction: column;
        gap: 8px;
    }

    .command-meta-item,
    .command-search {
        width: 100%;
        justify-content: center;
    }

    .directorate-grid {
        grid-template-columns: repeat(2, 96px);
        gap: 26px 22px;
    }

    .directorate-tile {
        width: 92px;
        height: 92px;
    }

    .action-btn {
        padding: 16px;
        flex-direction: row;
        text-align: left;
    }

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

    .profile-panel {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        min-width: 100%;
    }

    .filter-actions {
        margin-top: 8px;
    }

    .modal {
        max-width: 100%;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        margin-top: auto;
        /* Bottom-sheet feel on mobile */
        max-height: 85vh;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 20px;
    }

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

    .preview-toolbar {
        padding: 20px;
    }

}

/* Text helpers */
.text-muted {
    color: var(--text-muted);
}


/* Custom Logo Image Styles */
.auth-logo-img {
    border-radius: 50%;
    clip-path: circle(50%);
    width: 80px;
    height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto 12px auto;
}

.brand-logo-img {
    border-radius: 50%;
    clip-path: circle(50%);
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: block;
}
