@import url("https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Open+Sans:wght@400;500;600;700&display=swap");

:root {
    --navy: #1a2332;
    --navy-deep: #101820;
    --navy-soft: #243247;
    --ink: #2b3038;
    --muted: #6b7280;
    --line: #e4e7ec;
    --panel: #ffffff;
    --canvas: #f0f1f3;
    --gold: #c9a227;
    --gold-deep: #a8861a;
    --accent: #ff9800;
    --accent-deep: #e68900;
    --success: #2f6b4f;
    --warning: #9a6b16;
    --danger: #9b3b3b;
    --info: #2f5f8a;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Open Sans", "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
    min-height: 100vh;
}

h1, h2, .brand-name, .auth-firm-name {
    font-family: "Libre Baskerville", Georgia, serif;
}

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

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

#wrapper {
    min-height: 100vh;
}

.sidebar {
    width: 268px;
    background: linear-gradient(180deg, var(--navy-deep) 0%, var(--navy) 55%, #1e2a3d 100%);
    color: #d7dee8;
    padding: 1rem 0.85rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    transition: margin-left 0.2s ease;
    border-right: 1px solid rgba(201, 162, 39, 0.18);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 0.6rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.85rem;
    text-align: center;
}

.sidebar-logo {
    width: 100%;
    max-width: 210px;
    height: auto;
    background: #fff;
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.sidebar-brand .brand-sub {
    font-size: 0.72rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    margin-top: 0.35rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar .nav-link {
    color: #c9d2de;
    border-radius: 6px;
    padding: 0.65rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.92rem;
    font-weight: 500;
}

.sidebar .nav-link i {
    width: 1.1rem;
    text-align: center;
    color: #9aa8ba;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 152, 0, 0.14);
    color: #fff;
}

.sidebar .nav-link.active i,
.sidebar .nav-link:hover i {
    color: var(--gold);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.75rem 0.4rem;
}

.sidebar-firm-note {
    margin-top: auto;
    padding: 0.85rem 0.7rem 0.2rem;
    font-size: 0.72rem;
    color: #8b97a8;
    line-height: 1.45;
}

.sidebar-firm-note strong {
    display: block;
    color: #c5ced9;
    margin-bottom: 0.2rem;
    font-weight: 600;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.sidebar-toggle {
    color: var(--navy);
    font-size: 1.35rem;
    padding: 0;
    display: none;
}

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

.user-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--navy);
}

.user-role {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.content-area {
    padding: 1.35rem 1.5rem 2rem;
}

.page-header {
    margin-bottom: 1.15rem;
}

.page-header h1 {
    margin: 0.15rem 0;
    font-size: 1.65rem;
    color: var(--navy);
}

.page-header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.15rem 1.2rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--navy);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.15rem;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--gold);
}

.stat-label {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--navy);
    font-family: "Libre Baskerville", Georgia, serif;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-form .form-control,
.search-form .form-select {
    min-width: 180px;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    color: var(--muted);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom-width: 1px;
    background: #f8f9fb;
}

.list-plain {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-plain li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--line);
}

.list-plain li:last-child {
    border-bottom: 0;
}

.status-badge {
    font-weight: 600;
    border-radius: 4px;
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
}

.status-secondary { background: #eef0f3; color: #4b5563; }
.status-info { background: #e7f0f8; color: var(--info); }
.status-warning { background: #f7ecd2; color: var(--warning); }
.status-success { background: #d9efe3; color: var(--success); }
.status-danger { background: #f5dede; color: var(--danger); }
.status-orange { background: #fff1df; color: #9a5524; }
.status-primary { background: #eef2f7; color: var(--navy); }

.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-deep);
    --bs-btn-hover-border-color: var(--accent-deep);
    --bs-btn-active-bg: var(--accent-deep);
    --bs-btn-active-border-color: var(--accent-deep);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    font-weight: 600;
}

.btn-outline-primary {
    --bs-btn-color: var(--navy);
    --bs-btn-border-color: var(--navy);
    --bs-btn-hover-bg: var(--navy);
    --bs-btn-hover-border-color: var(--navy);
    --bs-btn-hover-color: #fff;
    font-weight: 600;
}

.btn-outline-secondary {
    font-weight: 600;
}

.thread-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.thread-item,
.thread-reply {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    background: #fbfcfe;
}

.thread-reply {
    margin-top: 0.7rem;
    margin-left: 0.85rem;
    background: #f5f7fa;
    border-left: 3px solid var(--gold);
}

.thread-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    color: var(--muted);
}

.thread-item p,
.thread-reply p {
    margin: 0;
}

.detail-list {
    margin: 0;
}

.detail-list > div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
}

.detail-list dt {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.detail-list dd {
    margin: 0;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline li {
    padding: 0.65rem 0 0.65rem 0.95rem;
    border-left: 2px solid var(--gold);
    margin-left: 0.25rem;
}

.flash-stack {
    margin-bottom: 1rem;
}

.app-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    justify-content: space-between;
}

.app-footer a {
    color: var(--navy);
    font-weight: 600;
}

.firm-card .firm-line {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}

.firm-card .firm-line:last-child {
    border-bottom: 0;
}

.firm-card .firm-line i {
    color: var(--accent);
    margin-top: 0.15rem;
    width: 1rem;
}

.firm-card .firm-line span {
    color: var(--ink);
}

.auth-body {
    min-height: 100vh;
    background:
        linear-gradient(120deg, rgba(16, 24, 32, 0.92), rgba(26, 35, 50, 0.88)),
        radial-gradient(circle at 15% 20%, rgba(201, 162, 39, 0.22), transparent 35%),
        linear-gradient(160deg, #101820 0%, #1a2332 50%, #243247 100%);
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}

.auth-panel {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 1.5rem;
    align-items: stretch;
}

.auth-panel.narrow {
    grid-template-columns: 1fr;
    width: min(460px, 100%);
}

.auth-brand {
    color: #edf2f7;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-logo {
    width: min(320px, 100%);
    background: #fff;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.auth-firm-name {
    margin: 0 0 0.4rem;
    font-size: 1.85rem;
    color: #fff;
}

.auth-brand .gold-rule {
    width: 72px;
    height: 2px;
    background: var(--gold);
    margin: 0.75rem 0 1rem;
}

.auth-brand p {
    max-width: 28rem;
    color: #c5d0dc;
    margin-bottom: 1.25rem;
}

.auth-contact {
    font-size: 0.85rem;
    color: #aeb9c7;
    line-height: 1.7;
}

.auth-contact a {
    color: #fff;
    font-weight: 600;
}

.auth-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.75rem;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
    border-top: 3px solid var(--gold);
}

.auth-card h2 {
    margin-bottom: 0.35rem;
    color: var(--navy);
    font-size: 1.45rem;
}

.auth-card .lead-muted {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.15rem;
}

.auth-hint {
    font-size: 0.8rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding-top: 0.95rem;
}

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.error-card {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    width: min(420px, 100%);
    box-shadow: var(--shadow);
    border-top: 3px solid var(--gold);
}

.error-code {
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--navy);
    font-family: "Libre Baskerville", Georgia, serif;
}

.sidebar.collapsed {
    margin-left: -268px;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 32, 0.45);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

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

.sidebar-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.1rem;
}

.sidebar-brand {
    position: relative;
}

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

.global-search {
    position: relative;
    flex: 1;
    max-width: 420px;
}

.global-search i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.global-search input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.5rem 0.75rem 0.5rem 2.1rem;
    background: #f8f9fb;
}

.btn-notify {
    position: relative;
    border: 1px solid var(--line);
}

.notify-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.notify-menu {
    width: min(340px, 90vw);
    padding: 0;
}

.notify-head {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
}

.notify-item {
    display: flex;
    flex-direction: column;
    white-space: normal;
    gap: 0.15rem;
    border-bottom: 1px solid #f0f2f5;
}

.notify-item.unread,
.notify-row.unread {
    background: #fff8ef;
}

.notify-row {
    border-bottom: 1px solid var(--line);
}

.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    color: #fff;
    font-weight: 700;
}

.profile-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold);
}

.stat-card {
    display: flex;
    gap: 0.85rem;
    align-items: center;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f3f5f8;
    color: var(--navy);
    font-size: 1.2rem;
}

.stat-card.tone-gold { border-top-color: var(--gold); }
.stat-card.tone-success { border-top-color: var(--success); }
.stat-card.tone-warning { border-top-color: var(--warning); }
.stat-card.tone-danger { border-top-color: var(--danger); }
.stat-card.tone-info { border-top-color: var(--info); }

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.activity-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-feed li {
    display: flex;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
}

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    margin-top: 0.4rem;
    flex-shrink: 0;
}

.portal-tabs {
    border-bottom: 0;
}

.portal-tabs .nav-link {
    color: var(--muted);
    font-weight: 600;
    border: 1px solid transparent;
    border-bottom: 0;
}

.portal-tabs .nav-link.active {
    color: var(--navy);
    background: #fff;
    border-color: var(--line) var(--line) #fff;
}

.tab-panel {
    border-top-left-radius: 0;
}

.matter-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.5rem;
}

.matter-timeline li {
    position: relative;
    padding: 0 0 1.25rem 1.4rem;
    border-left: 2px solid #e5e7eb;
}

.matter-timeline .timeline-marker {
    position: absolute;
    left: -7px;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--gold);
}

.timeline-card {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.8rem 1rem;
}

.empty-state {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--muted);
}

.empty-state i {
    font-size: 1.8rem;
    color: var(--gold);
    display: block;
    margin-bottom: 0.5rem;
}

.empty-state h3 {
    font-size: 1rem;
    color: var(--navy);
    margin: 0 0 0.25rem;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.per-page-form {
    display: flex;
    align-items: center;
}

.per-page-form .form-select {
    width: auto;
}

.filter-bar .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.doc-table td {
    vertical-align: middle;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.55);
    z-index: 2000;
    display: grid;
    place-items: center;
}

.breadcrumb {
    margin-bottom: 0.5rem;
}

.export-actions {
    display: flex;
    gap: 0.35rem;
}

.chart-row {
    overflow: hidden;
}

.chart-box {
    position: relative;
    width: 100%;
    height: 240px;
    max-height: 240px;
    overflow: hidden;
}

.chart-box canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 240px;
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        z-index: 40;
        margin-left: -268px;
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.2);
    }

    .sidebar.show {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    body.sidebar-open {
        overflow: hidden;
    }

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

    .content-area {
        padding: 1rem;
    }

    .detail-list > div {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .global-search {
        display: none;
    }

    .user-chip .user-name,
    .user-chip .user-role {
        display: none;
    }

    .doc-table {
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    .stat-value {
        font-size: 1.35rem;
    }

    .quick-actions .btn {
        width: 100%;
    }

    .portal-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
}
