* {
    box-sizing: border-box;
}

:root {
    --navy: #102d4b;
    --navy2: #0a2037;
    --gold: #c8a14a;
    --ink: #172637;
    --muted: #667789;
    --bg: #f4f7fa;
    --line: #dce4eb;
    --green: #237a5a;
    --red: #b84444;
    --amber: #a46b08;
}


/* =========================================================
   GLOBAL
   ========================================================= */

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a {
    color: inherit;
}


/* =========================================================
   TOP NAVIGATION
   ========================================================= */

.topnav {
    height: 78px;
    background: var(--navy);
    color: white;

    display: flex;
    align-items: center;

    padding: 0 34px;
    gap: 34px;

    box-shadow: 0 2px 10px #0002;

    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;

    text-decoration: none;
    min-width: 235px;
}

.brand-mark {
    display: grid;
    place-items: center;

    width: 40px;
    height: 40px;

    border: 1px solid #ffffff55;
    border-radius: 12px;

    background: #ffffff10;
    color: #f3cc73;

    font-weight: 800;
}

.brand strong {
    display: block;
    font-family: Georgia, serif;
    font-size: 18px;
}

.brand small {
    display: block;
    color: #afbdca;
    font-size: 11px;
    margin-top: 2px;
}

.navlinks {
    display: flex;
    gap: 24px;
    flex: 1;
}

.navlinks a,
.nav-user a {
    text-decoration: none;
    color: #dce6ef;
    font-weight: 600;
    font-size: 14px;
}

.navlinks a:hover,
.nav-user a:hover {
    color: #fff;
}

.nav-user {
    display: flex;
    gap: 14px;
    align-items: center;

    font-size: 13px;
    color: #bfcbd7;
}


/* =========================================================
   PAGE SHELL / HERO
   ========================================================= */

.shell {
    max-width: 1500px;
    margin: 0 auto;
    padding: 34px;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 28px;
    margin-bottom: 28px;
}

.hero.compact {
    padding: 12px 4px;
}

.hero h1 {
    font-family: Georgia, serif;
    color: var(--navy);

    font-size: 38px;
    margin: 4px 0 8px;
}

.hero p {
    color: var(--muted);
    margin: 0;

    max-width: 820px;
    line-height: 1.55;
}

.eyebrow {
    font-size: 12px !important;
    font-weight: 800 !important;
    letter-spacing: 1.5px;

    color: var(--gold) !important;

    margin: 0 0 5px !important;
}


/* =========================================================
   BUTTONS / ACTIONS
   ========================================================= */

.primary-action,
.secondary-action,
.tiny-button,
.voice-button {
    border: 0;
    border-radius: 9px;

    padding: 12px 17px;

    font-weight: 700;

    cursor: pointer;
    text-decoration: none;

    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.primary-action {
    background: var(--navy);
    color: #fff;
}

.secondary-action {
    background: #fff;
    color: var(--navy);

    border: 1px solid var(--line);
}

.tiny-button {
    background: #eef3f7;
    color: var(--navy);

    padding: 8px 11px;
}

.voice-button {
    background: #f6f1e7;
    color: #6e5318;

    border: 1px solid #e4d39f;

    margin-top: 8px;
    width: max-content;
}

.full {
    width: 100%;
}


/* =========================================================
   KPI CARDS
   ========================================================= */

.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);

    gap: 16px;
    margin-bottom: 20px;
}

.kpis article,
.panel {
    background: #fff;

    border: 1px solid var(--line);
    border-radius: 14px;

    box-shadow: 0 8px 28px #102d4b0d;
}

.kpis article {
    padding: 20px;
    border-left: 4px solid var(--gold);
}

.kpis span {
    color: var(--muted);
    font-size: 13px;
}

.kpis strong {
    display: block;

    font-size: 30px;
    color: var(--navy);

    margin: 7px 0;
}

.kpis small {
    color: #8190a0;
}


/* =========================================================
   DASHBOARD
   ========================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.45fr 1fr;

    gap: 18px;
}

.panel {
    padding: 22px;
}

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

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 14px;
}

.panel-head h2,
.panel h2 {
    font-family: Georgia, serif;
    color: var(--navy);

    margin: 0;
    font-size: 24px;
}

.panel-head a {
    font-size: 13px;
    font-weight: 700;
    color: #42617e;
}


/* =========================================================
   QUEUE / FEED / COMMUNICATION CARDS
   ========================================================= */

.queue-row,
.feed,
.comm-card {
    display: flex;
    align-items: center;

    gap: 13px;

    border-top: 1px solid #edf1f4;

    padding: 14px 0;
}

.queue-row > div:nth-child(2),
.feed > div,
.comm-card > div {
    flex: 1;
}

.queue-row strong,
.feed strong,
.comm-card strong {
    display: block;
}

.queue-row small,
.feed small,
.comm-card small {
    display: block;

    color: var(--muted);

    margin-top: 4px;
}

.queue-due {
    text-align: right;
}


/* =========================================================
   BADGES
   ========================================================= */

.priority,
.status,
.channel {
    display: inline-flex;
    align-items: center;

    border-radius: 999px;

    padding: 6px 9px;

    font-size: 11px;
    font-weight: 800;

    background: #edf3f0;
    color: var(--green);

    white-space: nowrap;
}

.priority.urgent,
.priority.high {
    background: #fff0df;
    color: #a55700;
}

.priority.overdue {
    background: #fdeaea;
    color: var(--red);
}

.priority.normal {
    background: #edf3f0;
    color: var(--green);
}

.channel {
    background: #edf3f8;
    color: #43637e;
}

.datebox {
    font-size: 11px;
    font-weight: 800;

    color: var(--navy);
    background: #f4efe4;

    padding: 9px;
    border-radius: 8px;

    min-width: 82px;

    text-align: center;
}


/* =========================================================
   TABLES
   ========================================================= */

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

    font-size: 14px;
}

th {
    text-align: left;

    color: #647789;

    font-size: 11px;
    letter-spacing: .5px;

    text-transform: uppercase;

    padding: 12px 9px;

    border-bottom: 1px solid var(--line);
}

td {
    padding: 14px 9px;

    border-bottom: 1px solid #edf1f4;

    vertical-align: top;
}


/* =========================================================
   AI DRAFTING
   ========================================================= */

.draft-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;

    gap: 20px;

    align-items: start;
}

.drafting-form {
    padding: 28px;
}

.drafting-guide {
    position: sticky;
    top: 98px;
}

.section-title {
    display: flex;
    gap: 14px;
    align-items: center;

    border-bottom: 1px solid var(--line);

    padding-bottom: 12px;
    margin: 4px 0 17px;
}

.section-title:not(:first-child) {
    margin-top: 30px;
}

.section-title > span {
    width: 34px;
    height: 34px;

    border-radius: 50%;

    display: grid;
    place-items: center;

    background: var(--navy);
    color: white;

    font-weight: 800;
}

.section-title h2 {
    margin: 0;
    font-size: 22px;
}

.section-title p {
    margin: 3px 0 0;

    color: var(--muted);

    font-size: 13px;
}


/* =========================================================
   FORMS
   ========================================================= */

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid.three {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid.two {
    grid-template-columns: repeat(2, 1fr);
}

label {
    display: block;

    color: #42576b;

    font-size: 13px;
    font-weight: 700;

    margin: 13px 0;
}

input,
select,
textarea {
    display: block;

    width: 100%;

    margin-top: 7px;

    border: 1px solid #cfd9e2;
    border-radius: 8px;

    background: #fff;

    padding: 11px 12px;

    font: inherit;
    color: var(--ink);
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

.voice-field {
    position: relative;
}

.draft-actions,
.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;

    margin-top: 24px;
}


/* =========================================================
   DRAFT QUALITY / REVIEW
   ========================================================= */

.checklist {
    list-style: none;

    padding: 0;
    margin: 18px 0;
}

.checklist li {
    padding: 10px 0 10px 28px;

    border-bottom: 1px solid #edf1f4;

    position: relative;

    font-size: 14px;
}

.checklist li::before {
    content: '✓';

    position: absolute;
    left: 2px;

    color: var(--green);

    font-weight: 900;
}

.warning-card,
.integration-note,
.review-banner {
    background: #fff9e9;

    border: 1px solid #ead38c;
    border-radius: 10px;

    padding: 14px;

    color: #6e5518;

    line-height: 1.45;
}

.assurance {
    background: #eaf5f0;
    color: #1d684e;

    border-radius: 12px;

    padding: 14px 18px;

    min-width: 280px;
}

.assurance strong,
.assurance small {
    display: block;
}

.assurance small {
    margin-top: 5px;
    color: #527568;
}


/* =========================================================
   GENERATED DOCUMENT RESULT
   ========================================================= */

.result-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 1.5fr)
        minmax(330px, .7fr);

    gap: 18px;
}

.document-preview pre,
.research-note pre {
    white-space: pre-wrap;

    font-family: Georgia, "Times New Roman", serif;

    line-height: 1.65;
    font-size: 15px;

    margin: 0;
}

.research-note pre {
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 13px;
}

.review-banner {
    margin-bottom: 18px;
}


/* =========================================================
   COMMUNICATIONS
   ========================================================= */

.communications-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;

    gap: 18px;
}

.comm-card .tiny-button {
    margin-left: auto;
}

.chat-thread {
    background: #f7f9fb;

    border-radius: 12px;

    padding: 16px;

    min-height: 300px;
}

.bubble {
    max-width: 78%;

    padding: 12px 14px;

    border-radius: 12px;

    margin: 10px 0;

    line-height: 1.45;
}

.bubble.client {
    background: #fff;
    border: 1px solid var(--line);
}

.bubble.attorney {
    background: #dfece8;
    margin-left: auto;
}

.chat-compose textarea {
    min-height: 90px;
}

.chat-compose {
    margin-top: 12px;
}

.integration-note {
    margin-top: 16px;
    font-size: 12px;
}


/* =========================================================
   LOGIN
   ========================================================= */

.login-body {
    background:
        linear-gradient(
            120deg,
            var(--navy2) 0 50%,
            #eef3f7 50%
        );
}

.login-layout {
    min-height: 100vh;

    display: grid;
    grid-template-columns: 1fr 520px;

    align-items: center;

    gap: 80px;

    max-width: 1280px;

    margin: auto;

    padding: 50px;
}

.login-brand {
    color: white;
}

.login-brand h1 {
    font-family: Georgia, serif;

    font-size: 48px;
    line-height: 1.05;
}

.login-brand > p:not(.eyebrow) {
    color: #c4d1dc;

    max-width: 650px;

    line-height: 1.7;
}

.brand-mark.large {
    width: 62px;
    height: 62px;

    font-size: 20px;
}

.login-points {
    display: flex;
    flex-direction: column;

    gap: 10px;

    color: #d9e5ed;
}

.login-card {
    background: white;

    border-radius: 18px;

    padding: 38px;

    box-shadow: 0 20px 60px #0003;
}

.login-card h2 {
    font-family: Georgia, serif;

    color: var(--navy);

    font-size: 30px;

    margin: 0;
}

.login-card > p {
    color: var(--muted);
}

.login-card small {
    display: block;

    margin-top: 18px;

    color: #8b98a5;
}

.error {
    margin-top: 12px;
    color: var(--red);
}


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

@media (max-width: 1050px) {

    .navlinks {
        display: none;
    }

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

    .dashboard-grid,
    .draft-grid,
    .result-grid,
    .communications-grid {
        grid-template-columns: 1fr;
    }

    .drafting-guide {
        position: static;
    }

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

    .login-layout {
        grid-template-columns: 1fr;
        background: var(--navy2);
    }

    .login-brand {
        display: none;
    }
}


@media (max-width: 700px) {

    .shell {
        padding: 20px 14px;
    }

    .topnav {
        padding: 0 16px;
    }

    .kpis,
    .form-grid.three,
    .form-grid.two {
        grid-template-columns: 1fr;
    }

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

    .hero h1 {
        font-size: 31px;
    }

    .panel {
        overflow-x: auto;
    }
}

/* =========================================================
   SECURE MATTER MESSAGE ATTACHMENTS
   ========================================================= */

.message-attachments {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 9px;
    border: 1px solid #d9e2e9;
    background: #f5f8fa;
    min-width: 0;
}

.message-row.client .message-attachment {
    background: #f5f8fa;
    border-color: #d9e2e9;
    color: #243f57;
}

.message-row.attorney .message-attachment {
    background: rgba(255, 255, 255, .72);
    border-color: rgba(16, 52, 84, .12);
}

.attachment-icon {
    flex: 0 0 auto;
    font-size: 1.2rem;
    line-height: 1;
}

.attachment-details {
    min-width: 0;
    flex: 1;
}

.attachment-details strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: .86rem;
}

.attachment-details small {
    display: block;
    margin-top: 3px;
    font-size: .72rem;
    opacity: .72;
    overflow-wrap: anywhere;
}

.attachment-actions {
    display: flex;
    gap: 12px;
    margin-top: 7px;
    flex-wrap: wrap;
}

.attachment-actions a {
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    color: var(--navy);
}

.message-row.client .attachment-actions a,
.message-row.attorney .attachment-actions a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.attachment-field {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px dashed #cbd7e1;
    border-radius: 10px;
    background: #f8fafc;
}

.attachment-field label {
    display: block;
    margin: 0 0 8px;
    color: #103454;
    font-weight: 800;
}

.attachment-field input[type="file"] {
    width: 100%;
    margin: 0;
}

.attachment-field small {
    display: block;
    margin-top: 7px;
    color: #758596;
}
.dashboard-message {
    text-decoration: none;
    color: inherit;
}

.dashboard-message:hover {
    background: #f8fafc;
}

.dashboard-message-preview {
    display: block;
    margin-top: 4px;
    color: #3f566b;
    font-size: 13px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 430px;
}

.dashboard-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 24px;
    height: 24px;
    padding: 0 7px;

    border-radius: 999px;

    background: #b84444;
    color: white;

    font-size: 11px;
    font-weight: 800;

    margin-left: auto;
}

.diary-date-overdue {
    background: #fff0ee;
    color: #b42318;
    border-color: #efc4bf;
}

.diary-overdue-label {
    color: #b42318;
    font-weight: 800;
}

/* =========================================================
   MATTER ACTIVITY TIMELINE
   ========================================================= */

.matter-timeline-panel {
    margin-bottom: 22px;
}

.timeline-intro {
    margin: 6px 0 0;
    color: #66788d;
    font-size: .92rem;
}

.matter-timeline {
    position: relative;
    margin-top: 8px;
}

.timeline-entry {
    display: grid;
    grid-template-columns: 28px 125px minmax(0, 1fr);
    gap: 16px;
    position: relative;
    padding: 0 0 28px;
}

.timeline-entry:last-child {
    padding-bottom: 4px;
}

.timeline-marker {
    position: relative;
    display: flex;
    justify-content: center;
}

.timeline-marker::after {
    content: "";
    position: absolute;
    top: 18px;
    bottom: -10px;
    width: 2px;
    background: #e1e7ed;
}

.timeline-entry:last-child .timeline-marker::after {
    display: none;
}

.timeline-marker span {
    position: relative;
    z-index: 2;
    width: 13px;
    height: 13px;
    margin-top: 4px;
    border-radius: 50%;
    background: #71869a;
    border: 3px solid white;
    box-shadow: 0 0 0 2px #d7e0e8;
}

.timeline-marker.message span {
    background: #2768a2;
}

.timeline-marker.document span {
    background: #b78727;
}

.timeline-marker.task span {
    background: #6d5b9b;
}

.timeline-marker.task_completed span {
    background: #2d7a50;
}

.timeline-marker.matter span {
    background: #103454;
}

.timeline-time {
    padding-top: 1px;
}

.timeline-time strong {
    display: block;
    color: #344e64;
    font-size: .82rem;
}

.timeline-time small {
    display: block;
    margin-top: 3px;
    color: #8796a5;
    font-size: .75rem;
}

.timeline-content {
    min-width: 0;
    padding: 0 0 2px;
}

.timeline-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.timeline-heading h3 {
    margin: 5px 0 0;
    color: #173b59;
    font-size: 1rem;
}

.timeline-type {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f5;
    color: #62788c;
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .06em;
}

.timeline-type.message {
    background: #edf5fb;
    color: #2768a2;
}

.timeline-type.document {
    background: #fbf5e8;
    color: #956d20;
}

.timeline-type.task {
    background: #f2eff8;
    color: #65548d;
}

.timeline-type.task_completed {
    background: #eaf6ee;
    color: #2d7a50;
}

.timeline-type.matter {
    background: #e9eff4;
    color: #103454;
}

.timeline-status {
    flex-shrink: 0;
    padding: 5px 8px;
    border-radius: 999px;
    background: #f1f4f6;
    color: #607486;
    font-size: .67rem;
    font-weight: 800;
}

.timeline-description {
    margin: 10px 0 0;
    color: #4e6376;
    line-height: 1.55;
    white-space: pre-line;
}

.timeline-meta {
    margin-top: 8px;
    color: #82909e;
    font-size: .78rem;
}

.timeline-meta strong {
    margin-left: 4px;
    color: #536a7d;
}

.timeline-document {
    margin-top: 13px;
    padding: 11px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    border: 1px solid #dce4eb;
    border-radius: 10px;
    background: #f8fafc;
}

.timeline-document > div {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.timeline-document-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 8px;
    background: #103454;
    color: white;

    font-size: .62rem;
    font-weight: 900;
}

.timeline-document small {
    display: block;
    color: #8997a4;
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .06em;
}

.timeline-document strong {
    display: block;
    margin-top: 2px;
    color: #314b61;
    font-size: .84rem;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 760px) {

    .timeline-entry {
        grid-template-columns: 24px minmax(0, 1fr);
    }

    .timeline-time {
        grid-column: 2;
        margin-bottom: -8px;
    }

    .timeline-content {
        grid-column: 2;
    }

    .timeline-marker {
        grid-row: 1 / span 2;
    }

    .timeline-document {
        align-items: flex-start;
        flex-direction: column;
    }
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.task-actions form {
    margin: 0;
}

.queue-button.complete {
    background: #eaf6ee;
    color: #17663c;
    border: 1px solid #c9e6d3;
}

.queue-button.complete:hover {
    background: #dff1e5;
}

.task-completed {
    display: inline-flex;
    padding: 6px 9px;
    border-radius: 999px;
    background: #eaf6ee;
    color: #17663c;
    font-size: .75rem;
    font-weight: 800;
}

.task-cancelled {
    color: #7c8791;
    font-size: .78rem;
    font-weight: 700;
}

/* =========================================================
   SHARED RECORD / QUEUE UTILITIES
   ========================================================= */

.record-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #edf2f6;
    color: #526b80;
    font-size: .78rem;
    font-weight: 800;
    white-space: nowrap;
}

.queue-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid #cfd9e2;
    border-radius: 8px;
    background: #fff;
    color: var(--navy);
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.queue-button:hover {
    background: #f4f8fb;
    border-color: #aebfcd;
}

.empty-state {
    padding: 24px;
    text-align: center;
    color: #718296;
    background: #f8fafc;
    border: 1px dashed #ccd7e0;
    border-radius: 10px;
}


/* =========================================================
   ATTORNEY VOICE DICTATION
   ========================================================= */

.voice-dictation-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid #b8c8d6;
    border-radius: 8px;
    background: #ffffff;
    color: #103454;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition:
        background .15s ease,
        border-color .15s ease,
        box-shadow .15s ease;
}

.voice-dictation-button:hover {
    background: #f4f8fb;
    border-color: #8fa8bc;
}

.voice-dictation-button.listening {
    background: #fff3f2;
    border-color: #c94b43;
    color: #a72d27;
    box-shadow: 0 0 0 3px rgba(201, 75, 67, .10);
}

.voice-dictation-status {
    min-height: 20px;
    margin-top: 7px;
    text-align: right;
    font-size: .78rem;
    color: #66788d;
}

.voice-dictation-status.listening {
    color: #a72d27;
    font-weight: 700;
}


/* =========================================================
   EXTRA RESPONSIVE POLISH
   ========================================================= */

@media (max-width: 700px) {
    .compose-actions {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .voice-dictation-button,
    .compose-actions .primary-action {
        flex: 1 1 160px;
    }

    .record-count {
        white-space: normal;
        text-align: center;
    }
}
/* =========================================================
   MATTER NOTES
   ========================================================= */

.matter-notes-panel form {
    margin-top: 20px;
}

.matter-note-entry {
    padding: 18px 0;
    border-top: 1px solid #e1e7ed;
}

.matter-note-entry:first-child {
    margin-top: 8px;
}

.matter-note-entry h3 {
    margin: 7px 0 0;
}

.matter-note-entry p {
    margin: 14px 0;
    line-height: 1.65;
}

.timeline-type.note {
    display: inline-block;
}