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

:root {
    --primary: #1a1a2e;
    --accent: #0f3460;
    --highlight: #3b82f6;
    --bg: #f5f6fa;
    --text: #2d3436;
    --text-muted: #636e72;
    --text-soft: #8a94a0;
    --surface: #ffffff;
    --surface-alt: #f8f9fb;
    --surface-muted: #eef2f7;
    --border: #e2e6ea;
    --border-soft: #eef0f3;
    --border-strong: #d0d4da;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.25);
    --focus-ring: rgba(59, 130, 246, 0.18);
    --input-bg: #ffffff;
    --header-bg: var(--primary);
    --header-text: #ffffff;
    --accent-hover: var(--primary);
    --white: #ffffff;
    --button-primary-text: var(--white);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --primary: #f3f6fb;
    --accent: #7fb4ff;
    --highlight: #93c5fd;
    --bg: #0f141d;
    --text: #e6eaf0;
    --text-muted: #b5bdc8;
    --text-soft: #8d98a7;
    --surface: #171d27;
    --surface-alt: #202733;
    --surface-muted: #263140;
    --border: #343f4f;
    --border-soft: #293241;
    --border-strong: #465367;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.38);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --focus-ring: rgba(147, 197, 253, 0.25);
    --input-bg: #121821;
    --header-bg: #111827;
    --header-text: #f8fafc;
    --accent-hover: #5f9ff2;
    --button-primary-text: var(--input-bg);
    color-scheme: dark;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

button,
input,
select,
textarea {
    color: inherit;
}

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

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

/* Header */
.header {
    --header-gutter: clamp(1rem, 3vw, 2rem);
    --header-height: 60px;
    --header-panel-gap: 8px;
    background: var(--header-bg);
    color: var(--header-text);
    padding-inline: var(--header-gutter);
    position: relative;
    z-index: 50;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.35;
}

.header-container {
    max-width: 1200px;
    min-height: var(--header-height);
    margin-inline: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header button {
    font: inherit;
    cursor: pointer;
}

.header-logo {
    color: var(--header-text);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.header-logo:hover {
    color: var(--header-text);
}

.header-nav,
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.header-nav {
    margin-inline-start: auto;
}

.header-actions {
    gap: 0.5rem;
}

.nav-link,
.nav-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    min-height: 36px;
    padding: 8px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    text-align: start;
    transition: background 0.15s, color 0.15s;
}

.nav-link {
    color: var(--header-text);
    white-space: nowrap;
}

.nav-link:hover,
.nav-link[aria-expanded="true"],
.nav-link[aria-current],
.nav-menu:has([aria-current]) > .nav-link {
    background: rgba(255, 255, 255, 0.12);
    color: var(--header-text);
}

.nav-chevron {
    flex: none;
    width: 7px;
    height: 7px;
    margin-inline-end: 2px;
    border-right: 1.5px solid;
    border-bottom: 1.5px solid;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.15s;
}

[aria-expanded="true"] > .nav-chevron {
    transform: translateY(2px) rotate(225deg);
}

.nav-menu {
    position: relative;
}

.nav-dropdown {
    position: absolute;
    inset-block-start: calc(50% + var(--header-height) / 2 + var(--header-panel-gap));
    inset-inline-start: 0;
    width: max-content;
    min-width: 12.5rem;
    max-width: min(20rem, calc(100vw - 2 * var(--header-gutter)));
    max-height: calc(100dvh - var(--header-height) - 2 * var(--header-panel-gap));
    overflow-y: auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
}

.nav-dropdown--end {
    inset-inline-start: auto;
    inset-inline-end: 0;
}

.nav-dropdown-item {
    width: 100%;
    color: var(--text);
}

.nav-dropdown-item:hover,
.nav-dropdown-item[aria-expanded="true"],
.nav-dropdown-item[aria-current],
.nav-submenu-group:has([aria-current]) > .nav-dropdown-item {
    background: var(--surface-muted);
    color: var(--text);
}

.nav-dropdown-item[aria-current] {
    color: var(--accent);
    font-weight: 700;
}

.nav-submenu {
    margin: 3px 8px 6px;
    padding-inline-start: 8px;
    border-inline-start: 2px solid var(--border);
}

.nav-dropdown-email {
    padding: 8px 12px;
    margin-block-end: 4px;
    border-block-end: 1px solid var(--border-soft);
    color: var(--text-muted);
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

.nav-dropdown-logout,
.nav-dropdown-logout:hover {
    color: #a1271b;
}

:root[data-theme="dark"] .nav-dropdown-logout {
    color: #fda29b;
}

.header a:focus-visible,
.header button:focus-visible {
    outline: 2px solid var(--highlight);
    outline-offset: -2px;
}

.header .header-logo:focus-visible {
    outline-offset: 4px;
}

.header-icon-button {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--header-text);
    transition: background 0.15s, border-color 0.15s;
}

.header-icon-button:hover,
.header-icon-button[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.38);
}

.header .user-avatar {
    font-weight: 700;
}

.header-menu-toggle {
    display: none;
    margin-inline-start: auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.header-menu-line {
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.theme-toggle-icon {
    grid-area: 1 / 1;
    font-size: 1rem;
    line-height: 1;
}

:root[data-theme="light"] .theme-toggle-icon--dark,
:root[data-theme="dark"] .theme-toggle-icon--light {
    visibility: hidden;
}

@media (max-width: 1100px) {
    .header-logo {
        font-size: 1.25rem;
    }

    .header-menu-toggle {
        display: inline-flex;
    }

    .header-icon-button {
        width: 40px;
        height: 40px;
    }

    .header-nav {
        display: none;
        position: absolute;
        inset-block-start: calc(100% + var(--header-panel-gap));
        inset-inline: var(--header-gutter);
        margin: 0;
        max-height: calc(100dvh - var(--header-height) - 2 * var(--header-panel-gap));
        overflow-y: auto;
        align-items: stretch;
        flex-direction: column;
        gap: 2px;
        padding: 6px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: var(--shadow-md);
    }

    .header-menu-toggle[aria-expanded="true"] + .header-nav {
        display: flex;
    }

    .header-nav > * {
        flex: none;
    }

    .header-nav .nav-link {
        width: 100%;
        color: var(--text);
    }

    .header-nav .nav-link:hover,
    .header-nav .nav-link[aria-expanded="true"],
    .header-nav .nav-link[aria-current],
    .header-nav .nav-menu:has([aria-current]) > .nav-link {
        background: var(--surface-muted);
        color: var(--text);
    }

    .header-nav .nav-dropdown {
        position: static;
        width: auto;
        min-width: 0;
        max-width: none;
        max-height: none;
        overflow: visible;
        margin: 3px 0 4px;
        box-shadow: none;
    }

    .nav-link,
    .nav-dropdown-item {
        min-height: 44px;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
    width: 100%;
}

/* Wide variant for data-dense pages (e.g. the emails table). */
.main-content--wide {
    max-width: min(1600px, 95vw);
}

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Feature Grid */
.features {
    padding: 1rem 0 3rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

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

.feature-card h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.feature-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Footer */
.footer {
    background: var(--header-bg);
    color: rgba(255, 255, 255, 0.6);
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.85rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

.footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

.footer a:hover {
    color: var(--white);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100svh;
    padding: 2rem 1rem;
    background: radial-gradient(ellipse at 50% 0%, var(--surface-muted), transparent 70%), var(--bg);
}

.login-card {
    background: var(--surface);
    padding: clamp(1.5rem, 5vw, 3rem);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(15, 52, 96, 0.08);
    width: 100%;
    max-width: 460px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.login-brand-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.login-intro { margin: 2.75rem 0 1.75rem; }
.login-eyebrow {
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    margin-bottom: 0.75rem;
}
.login-title {
    color: var(--primary);
    font-size: clamp(1.75rem, 6vw, 2rem);
    font-weight: 650;
    letter-spacing: -0.04em;
    margin-bottom: 0.75rem;
}
.login-description {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.65;
}
.login-error {
    background: #ffe0e0;
    color: #9b2920;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    margin-bottom: 1rem;
}

.login-form .form-group {
    margin-bottom: 1rem;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-strong);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 4px;
    font-size: 0.95rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.login-btn {
    width: 100%;
    min-height: 48px;
    padding: 0.7rem;
    margin-top: 0.5rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    cursor: pointer;
}
.login-btn:hover { background: var(--surface-muted); }

.ms-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 56px;
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--accent);
    color: var(--surface);
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.15s ease;
}
.ms-login-btn:hover {
    background: var(--accent-hover);
    color: var(--surface);
}
.ms-login-icon-wrap {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: #fff;
}
.ms-login-icon { width: 20px; height: 20px; }
.ms-login-arrow { margin-left: auto; font-size: 1.25rem; }
.login-hint {
    margin: 0.85rem 0 1.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.5;
}
.login-alternative {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}
.login-alternative summary {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    list-style: none;
}
.login-alternative summary::-webkit-details-marker { display: none; }
.login-alternative summary::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}
.login-alternative[open] summary::after { transform: translateY(2px) rotate(225deg); }
.login-alternative summary:hover { color: var(--text); background: var(--surface-alt); }
.login-alternative .login-form { padding-top: 1rem; }
.login-form-description {
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}
.login-form .form-input { min-height: 46px; font-size: 1rem; border-radius: 8px; }
.ms-login-btn:focus-visible,
.login-btn:focus-visible,
.login-alternative summary:focus-visible {
    outline: 3px solid var(--highlight);
    outline-offset: 4px;
}
@media (max-width: 380px) {
    .login-break { display: none; }
    .ms-login-btn { gap: 0.5rem; padding-inline: 0.75rem; font-size: 0.85rem; }
}

/* Email Page */
.email-page h1 {
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.email-filters {
    background: var(--surface);
    padding: 1.25rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Grouped, grid-aligned email filters. */
.filter-section + .filter-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
}

.filter-section-title {
    display: block;
    margin-bottom: 0.7rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #95a0a8;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.85rem 1.1rem;
    align-items: end;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.filter-field .filter-label {
    white-space: normal;
}

.filter-field .filter-input {
    width: 100%;
}

.filter-field--narrow {
    max-width: 150px;
}

.filter-field--wide {
    grid-column: span 2;
}

/* Checkbox aligned to the height of a sibling input within its grid cell. */
.filter-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 38px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 0.9rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-group-grow {
    flex: 1 1 180px;
}

/* Compact, fixed-width id lookup at the head of the search row. */
.filter-group--id {
    flex: 0 0 auto;
}

.filter-group--id .filter-input {
    width: 84px;
}

.filter-group-grow .filter-input {
    flex: 1;
    min-width: 0;
}

.filter-row-search {
    margin-bottom: 0.75rem;
}

/* Extra breathing room above the date-range row in the email filters. */
.filter-row--dates {
    margin-top: 1rem;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-date {
    width: 160px;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
}

.btn-primary,
.btn-primary:hover {
    color: var(--button-primary-text);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--border-strong);
}

.btn-secondary,
.btn-secondary:hover {
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-muted);
}

.btn-danger {
    background: #b42318;
}

.btn-danger,
.btn-danger:hover {
    color: var(--white);
}

.btn-danger:hover {
    background: #912018;
}

.results-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

#email-results {
    position: relative;
    transition: opacity 0.15s ease;
}

#email-results.is-loading {
    pointer-events: none;
}

#email-results.is-loading > :not(.email-results-loading) {
    opacity: 0.35;
}

.email-results-loading {
    position: absolute;
    z-index: 2;
    top: 18px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateX(-50%);
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--text-soft);
    font-size: 13px;
}

.email-loading-spinner {
    width: 14px;
    height: 14px;
    flex: none;
    border: 2px solid var(--border-strong);
    border-top-color: var(--highlight);
    border-radius: 50%;
    animation: email-results-spin 0.75s linear infinite;
}

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

.search-error {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
}

.table-wrapper {
    overflow-x: auto;
}

.email-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.email-table thead {
    background: var(--header-bg);
    color: var(--white);
}

.email-table th,
.email-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.9rem;
}

.email-table tbody tr {
    border-bottom: 1px solid var(--border-soft);
}

.email-table tbody tr:hover {
    background: var(--surface-alt);
}

.col-subject {
    max-width: 400px;
}

.col-sender {
    white-space: nowrap;
}

.col-client {
    min-width: 140px;
    font-size: 0.82rem;
    line-height: 1.2;
}

.col-client small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.col-date {
    white-space: nowrap;
    color: var(--text-muted);
}

.col-attach {
    color: var(--text-muted);
}

.col-spam {
    white-space: nowrap;
    text-align: center;
}

/* Routing cell: From / To / Fwd stacked in a single column, with tiny aligned
   labels so the addresses line up and a colour-coded forward chip. */
.col-route {
    min-width: 250px;
    max-width: 320px;
}

.route {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.route-line {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.route-tag {
    flex: none;
    width: 30px;
    text-align: center;
    padding: 1px 0;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.35;
    color: #6b7785;
    background: #eef1f4;
}

.route-tag--fwd {
    color: #51606e;
    background: #e6eaef;
}

.route-addr {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.route-addr--empty {
    color: #b0b6bb;
}

.route-more {
    flex: none;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #51606e;
    background: #e6eaef;
    cursor: default;
}

/* Cc count pill — outlined so it reads as secondary to the +N "to" overflow. */
.route-cc {
    flex: none;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #6b7785;
    background: var(--surface);
    border: 1px solid #d8dee4;
}

/* The whole To line is hoverable when there's more to reveal. */
.route-recipients--more {
    cursor: help;
}

.route-recipients--more:hover .route-more,
.route-recipients--more:hover .route-cc {
    color: var(--text);
    border-color: #b9c1c9;
    background: #eef1f4;
}

/* Floating popover with the full recipient list (anchored via JS to <body>). */
.recipients-pop {
    position: fixed;
    z-index: 1200;
    max-width: 340px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(20, 30, 45, 0.16);
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    pointer-events: none;
}

.recipients-pop.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.recipients-pop__group + .recipients-pop__group {
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid #f0f2f4;
}

.recipients-pop__label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a949e;
}

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

.recipients-pop__list li {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.5;
    word-break: break-all;
    font-variant-numeric: tabular-nums;
}

/* Forward destination chip — colour keyed to where it was routed. */
.route-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.route-chip svg {
    flex: none;
}

.route-chip-addr {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-chip--client {
    color: #157a45;
    background: #e7f6ee;
    border-color: #bce8cf;
}

.route-chip--spam {
    color: #c0392b;
    background: #fdecea;
    border-color: #f5c6c0;
}

.route-chip--unknown {
    color: #b45309;
    background: #fff7ed;
    border-color: #fed7aa;
}

/* Forwarded chip on the email detail page (icon + full address). */
.fwd-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    background: #e7f6ee;
    border: 1px solid #bce8cf;
    color: #157a45;
    font-size: 0.82rem;
    font-weight: 600;
}

.fwd-chip svg {
    flex: none;
}

.muted {
    color: #b0b6bb;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-spam {
    background: #fdecea;
    color: #c0392b;
}

.client-missing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px 2px 7px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: 0.01em;
    color: #b45309;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    white-space: nowrap;
}

.client-missing__icon {
    flex: none;
    color: #ea940c;
}

.check-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #27ae60;
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}

.spam-circle {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #c0392b;
    vertical-align: middle;
}

.spam-check {
    cursor: pointer;
}

.col-id {
    width: 1%;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.id-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Tiny AI-processed status sparkle next to the email id. */
.ai-dot {
    flex: none;
    display: inline-flex;
    line-height: 0;
}

.ai-dot--on {
    color: #7c3aed;
}

.ai-dot--off {
    color: #c4ccd6;
}

.index-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex: none;
    line-height: 1;
    font-size: 11px;
    font-weight: 800;
    opacity: 0.72;
}

.index-dot--indexed {
    color: #15803d;
    background: #dcfce7;
}

.index-dot--pending {
    color: #b45309;
    background: #fef3c7;
}

.index-dot--empty {
    color: #64748b;
    background: var(--surface-muted);
}

.index-dot--failed {
    color: #b91c1c;
    background: #fee2e2;
}

.id-link,
.email-id {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: #eef1f6;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.id-link {
    transition: background 0.15s, color 0.15s;
}

.col-action {
    width: 1%;
    white-space: nowrap;
}

.view-email-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.view-email-link svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
}

.view-email-link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
}

.id-link:hover {
    background: var(--accent);
    color: var(--white);
}

.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.attachment-list a {
    font-size: 0.85rem;
    color: var(--accent);
    word-break: break-all;
}

.attachment-list a:hover {
    color: var(--highlight);
}

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

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
}

.page-link {
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.page-link:hover {
    background: var(--surface-muted);
}

.page-link.current {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.page-link.dots {
    border: none;
}

/* Email Detail */
.email-detail {
    max-width: 900px;
    margin: 0 auto;
}

.back-link {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

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

.email-card {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.email-header {
    padding: 1.75rem 2rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
}

.email-subject {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
    line-height: 1.3;
}

.email-meta {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.9rem;
}

.email-meta dt {
    color: var(--text-soft);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    padding-top: 0.15rem;
}

.email-meta dd {
    color: var(--text);
    word-break: break-word;
}

/* --- Email detail header: grouped, card-based layout --- */
.email-head-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem 1.25rem;
}

.email-head-top .email-subject {
    margin-bottom: 0;
    flex: 1 1 320px;
}

.email-head-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.email-received-line {
    margin-top: 0.45rem;
    color: var(--text-soft);
    font-size: 0.85rem;
}

.badge-clean {
    background: #eef5f0;
    color: #3f7d57;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid #e3e7ec;
    background: #f4f6f8;
    color: #5b6671;
    white-space: nowrap;
}

.meta-chip svg { flex: none; }
.meta-chip--muted { color: #98a1ab; }

/* Labelled, urgency-coloured deadline pill (colour comes from .prio-*). */
.deadline-flag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.deadline-flag svg { flex: none; opacity: 0.85; }

.deadline-flag-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.66rem;
    font-weight: 700;
    opacity: 0.8;
}

.deadline-flag-date { font-weight: 600; }
.deadline-flag-rel { font-weight: 700; }

.email-info-grid {
    margin-top: 1.3rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.info-card {
    background: var(--surface-alt);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 0.9rem 1.1rem 1rem;
}

.info-card-title {
    display: block;
    margin-bottom: 0.7rem;
    color: var(--text-soft);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
}

.kv {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 0.4rem 0.9rem;
    font-size: 0.88rem;
    margin: 0;
}

.kv dt {
    color: var(--text-soft);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    padding-top: 0.12rem;
}

.kv dd {
    margin: 0;
    color: var(--text);
    word-break: break-word;
}

.client-ident {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}

.client-ident-avatar {
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--white);
    font-weight: 700;
    font-size: 1rem;
}

.client-ident-name {
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.client-ident-name:hover { text-decoration: underline; }

.client-ident-sub {
    color: var(--text-soft);
    font-size: 0.8rem;
    margin-top: 1px;
}

.info-empty {
    color: #98a1ab;
    font-size: 0.88rem;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    margin-bottom: 0.75rem;
}

.email-attachments {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-alt);
}

.attachment-list-detail li {
    margin-bottom: 0.4rem;
}

.attachment-list-detail li:last-child {
    margin-bottom: 0;
}

.attachment-detail-card,
.attachment-storage-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
}

.attachment-detail-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.attachment-list-detail > li > a {
    display: inline-flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.attachment-list-detail > li > a:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(15, 52, 96, 0.08);
}

.attachment-name {
    color: var(--primary);
    font-size: 0.92rem;
    font-weight: 500;
}

.attachment-meta {
    color: var(--text-soft);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.attachment-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
    margin-bottom: 0.45rem;
}

.attachment-file-main {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.attachment-file-main a:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-action-row {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
    padding: 0.16rem 0.16rem 0.16rem 0.5rem;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--surface-alt);
}

.email-file-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding: 0.35rem 0.4rem 0.35rem 0.65rem;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--surface);
}

.file-action-label {
    color: var(--text-soft);
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
}

.file-download-link,
.file-download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.download-icon {
    width: 0.95rem;
    height: 0.95rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.file-download-link {
    padding: 0;
}

.file-download-button {
    padding: 0;
}

.file-download-link:hover,
.file-download-button:hover {
    border-color: var(--accent);
    background: var(--surface-alt);
    color: var(--accent);
}

.col-download {
    white-space: nowrap;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.email-body-section {
    padding: 1.25rem 2rem 1.75rem;
}

.email-body-frame {
    width: 100%;
    min-height: 480px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface);
}

/* Small button variant (table row actions) */
.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
}

/* Compact read-only table (clients) */
.compact-table th,
.compact-table td {
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Clickable client name (opens the edit modal) */
.client-name-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    text-align: left;
}

.client-name-link:hover {
    color: var(--highlight);
    text-decoration: underline;
}

/* Scrollable wrapper with a nicer scrollbar. */
.table-wrapper {
    overflow-x: auto;
    scrollbar-width: thin;
}

.table-wrapper::-webkit-scrollbar {
    height: 9px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #cdd2d8;
    border-radius: 999px;
}

/* Modal */
.modal-overlay {
    display: none;  /* shown via .is-open so it never renders inline */
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 1rem;
    background: rgba(20, 24, 33, 0.55);
    backdrop-filter: blur(2px);
    overflow-y: auto;
    animation: modal-fade 0.18s ease;
}

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

@keyframes modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

body.modal-open {
    overflow: hidden;
}

.modal {
    width: 100%;
    max-width: 640px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modal-pop 0.18s ease;
}

@keyframes modal-pop {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.modal-title {
    font-size: 1.15rem;
    color: var(--primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: #b0b6bb;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
}

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

.modal .model-form {
    padding: 1.5rem;
}

/* Two/three fields per row inside the modal. */
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1 1 180px;
}

.modal .form-actions {
    margin: 1.5rem -1.5rem -1.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-alt);
    border-radius: 0 0 12px 12px;
    justify-content: flex-end;
}

.modal .form-input:focus {
    outline: none;
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Attachment content preview modal */
.modal-wide {
    max-width: 820px;
}

.modal-body {
    padding: 1.5rem;
}

.attachment-modal-status {
    margin: 0;
    color: var(--text-muted);
}

.attachment-frame {
    display: block;
    width: 100%;
    height: 70vh;
    margin: 0;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
}

.attachment-image {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    margin: 0 auto;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    object-fit: contain;
}

/* The modal toggles these via the `hidden` attribute; their explicit
   display:block would otherwise override it and leave an empty iframe /
   broken-image icon showing for the inactive views. */
.attachment-frame[hidden],
.attachment-image[hidden],
.attachment-content[hidden] {
    display: none;
}

.attachment-content {
    margin: 0;
    max-height: 60vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    background: var(--surface-alt);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 1rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin: 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-alt);
    border-radius: 0 0 12px 12px;
}

/* Page toolbar (title + primary action) */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-toolbar h1 {
    margin: 0;
}

/* Inline form error summary (notification style, inside the modal) */
.form-alert {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid #e74c3c;
    background: #fdecea;
    color: #b3261e;
    font-size: 0.88rem;
}

.form-alert[hidden] {
    display: none;
}

.form-alert-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e74c3c;
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 700;
}

/* Field-level error state */
.has-error .form-input {
    border-color: #e74c3c;
    background: #fff6f5;
}

.has-error .form-input:focus {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.18);
}

.col-actions {
    white-space: nowrap;
    text-align: right;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: min(380px, calc(100vw - 2rem));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    border-left: 4px solid var(--border-strong);
    font-size: 0.9rem;
    line-height: 1.35;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    animation: toast-in 0.3s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast-hide {
    opacity: 0;
    transform: translateX(20px);
}

.toast-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--white);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
}

.toast-text {
    flex: 1;
    color: var(--text);
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #b0b6bb;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
}

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

.toast-success {
    border-left-color: #27ae60;
}

.toast-success .toast-icon {
    background: #27ae60;
}

.toast-error {
    border-left-color: #e74c3c;
}

.toast-error .toast-icon {
    background: #e74c3c;
}

/* Model form (client edit, etc.) */
.model-form {
    padding: 1.75rem 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.form-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-help {
    font-size: 0.8rem;
    color: #8a8f94;
    margin: 0.3rem 0 0;
}

.form-error {
    font-size: 0.82rem;
    color: #c0392b;
    margin: 0.3rem 0 0;
}

.form-errors {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    background: #fdecea;
    color: #c0392b;
    border-radius: 6px;
    font-size: 0.88rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* ══ Task board ════════════════════════════════════════════════
   Priority tones (shared):
     overdue  #c0392b   today #e67e22   week #d4a017
     upcoming #1e8449   none  #828b94
*/

/* Toolbar */
.task-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.task-page h1 {
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.task-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
}


/* Quick-filter cards */
.task-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.7rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--surface);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-top: 3px solid var(--border-strong);
    color: var(--text);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    color: var(--text);
}

.stat-card.is-active {
    box-shadow: 0 0 0 2px var(--primary), 0 4px 12px rgba(0, 0, 0, 0.12);
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
    color: var(--primary);
}

.stat-label {
    font-size: 0.76rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.stat-total { border-top-color: var(--accent); }
.stat-overdue { border-top-color: #c0392b; }
.stat-overdue .stat-value { color: #c0392b; }
.stat-today { border-top-color: #e67e22; }
.stat-today .stat-value { color: #e67e22; }
.stat-soon { border-top-color: #d4a017; }
.stat-soon .stat-value { color: #b7860b; }
.stat-upcoming { border-top-color: #1e8449; }
.stat-none { border-top-color: #b0b6bb; }

/* Advanced filter bar */
.task-filters {
    background: var(--surface);
    padding: 1rem 1.25rem 1.1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.filters-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-soft);
}

.filters-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
}

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

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.85rem 0.9rem;
}

.task-filters .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
}

.task-filters .filter-label { color: var(--text-soft); }

.task-filters .filter-input {
    width: 100%;
    height: 38px;
}

/* Deadline range — keep the two dates together in one cell */
.filter-group--dates { grid-column: span 2; }

.docketing-list-page { max-width: 1500px; margin-inline: auto; }
.docketing-page-heading { align-items: center; }
.docketing-page-heading h1 { font-size: clamp(1.65rem, 2vw, 2.15rem); letter-spacing: -0.025em; }
.docketing-record-count {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.65rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}
.docketing-heading-actions { display: flex; align-items: center; gap: 0.65rem; }
.docketing-create-page { max-width: 1180px; }
.create-progress { position: sticky; top: 0; z-index: 5; display: flex; gap: 0.25rem; overflow-x: auto; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); }
.create-progress a { flex: 0 0 auto; padding: 0.4rem 0.65rem; border-radius: 6px; color: var(--text-muted); font-size: 0.72rem; font-weight: 650; }
.create-progress a:hover { background: var(--surface-muted); color: var(--accent); }
.create-section { scroll-margin-top: 70px; border-bottom: 1px solid var(--border); }
.create-section-heading { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1.15rem 1.35rem 0; }
.create-section-heading > span { display: grid; place-items: center; flex: 0 0 27px; height: 27px; border-radius: 50%; background: var(--accent); color: var(--surface); font-size: 0.75rem; font-weight: 750; }
:root[data-theme="dark"] .create-section-heading > span { color: #0f141d; }
.create-section-heading h2 { margin: 0; color: var(--text); font-size: 1rem; }
.create-section-heading p { margin-top: 0.2rem; color: var(--text-muted); font-size: 0.78rem; }
.create-section > .docketing-form-grid { padding-top: 1rem; }
.required-mark { margin-left: 0.2rem; color: #c0392b; }
.create-related { margin: 1rem 1.35rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-alt); overflow: hidden; }
.create-related.needs-review { border-color: #d4a017; box-shadow: 0 0 0 3px color-mix(in srgb, #d4a017 13%, transparent); }
.create-related-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border); }
.create-related-heading h3 { margin: 0; color: var(--text); font-size: 0.86rem; }
.create-related-heading p { margin-top: 0.15rem; color: var(--text-muted); font-size: 0.72rem; }
.create-related-row { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; padding: 0.85rem 2.7rem 0.85rem 0.9rem; border-bottom: 1px solid var(--border-soft); background: var(--surface); }
.create-related-row:last-child { border-bottom: 0; }
.create-row-remove { position: absolute; top: 0.75rem; right: 0.7rem; display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--surface-muted); color: var(--text-muted); cursor: pointer; font-size: 1.05rem; }
.create-row-remove:hover { background: #c0392b; color: #fff; }
.create-schema-loading, .create-empty-note { grid-column: 1 / -1; padding: 1rem; border: 1px dashed var(--border); border-radius: 8px; color: var(--text-muted); text-align: center; font-size: 0.8rem; }
.create-subfield-group { padding: 0.85rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-alt); }
.create-subfield-rows { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.4rem; }
.create-subfield-rows .create-related-row { border: 1px solid var(--border-soft); border-radius: 7px; }
.create-subfield-add { align-self: flex-start; margin-top: 0.55rem; }
.docketing-form-field.is-conditionally-required > .form-label::after { content: " *"; color: #c0392b; }
.docketing-form-field.dependency-error { padding: 0.55rem; border: 1px solid #c0392b; border-radius: 7px; background: color-mix(in srgb, #c0392b 6%, var(--surface)); }
.create-dependency-errors { margin: 0.9rem 1.35rem 0; padding: 0.75rem 0.9rem; border: 1px solid #c0392b; border-radius: 7px; background: color-mix(in srgb, #c0392b 7%, var(--surface)); color: var(--text); font-size: 0.78rem; }
.create-dependency-errors p + p { margin-top: 0.25rem; }
.create-related select { min-width: 0; max-width: 100%; }

@media (max-width: 620px) {
    .create-related-heading { align-items: flex-start; flex-direction: column; }
    .create-related-row { grid-template-columns: 1fr; }
    .create-progress { margin-inline: -1px; }
}
.docketing-record-count strong { color: var(--primary); font-size: 1.15rem; }
.docketing-record-count span { color: var(--text-muted); font-size: 0.8rem; }
.docketing-search-card { padding: 0; gap: 0; overflow: hidden; border: 1px solid var(--border); }
.docketing-search-card .filters-bar { padding: 0.9rem 1rem; background: var(--surface-alt); }
.docketing-search-card .docketing-filters-grid { padding: 1rem; }
.filters-description { margin-top: 0.2rem; color: var(--text-muted); font-size: 0.78rem; }
.docketing-filters-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.docketing-filters-grid .filter-group--wide { grid-column: span 2; }
.docketing-filters-grid .filter-input:focus,
.docketing-form-field .filter-input:focus {
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}
.docketing-table td:nth-child(1) { width: 13%; white-space: nowrap; }
.docketing-table td:nth-child(2) { min-width: 260px; }
.docketing-table td:nth-child(3),
.docketing-table td:nth-child(4),
.docketing-table td:nth-child(5) { width: 16%; }
.docketing-row--deleted { opacity: 0.62; }
.docketing-table tbody tr { transition: background 0.12s ease, box-shadow 0.12s ease; }
.docketing-table tbody tr:hover { background: color-mix(in srgb, var(--highlight) 5%, var(--surface)); }
.docketing-table td { padding-top: 0.85rem; padding-bottom: 0.85rem; vertical-align: middle; }
.docketing-matter-title { display: inline-block; color: var(--text); font-weight: 650; line-height: 1.35; }
.docketing-matter-title:hover { color: var(--accent); }
.docketing-status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 0.18rem 0.55rem;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 7%, var(--surface));
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 650;
    line-height: 1.2;
}
.docketing-sync-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-soft);
    font-size: 0.72rem;
    font-weight: 600;
}

.docketing-detail-page { max-width: 1500px; margin-inline: auto; }
.docketing-detail-hero {
    position: relative;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1rem;
    padding: 1.3rem 1.4rem 1.35rem 1.55rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--surface) 60%, color-mix(in srgb, var(--highlight) 7%, var(--surface)));
    box-shadow: var(--shadow-sm);
}
.docketing-detail-hero::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    border-radius: 12px 0 0 12px;
    background: linear-gradient(180deg, var(--highlight), var(--accent));
}
.docketing-detail-hero h1 { max-width: 900px; margin: 0.35rem 0 0.7rem; font-size: clamp(1.2rem, 1.55vw, 1.55rem); line-height: 1.25; letter-spacing: -0.015em; }
.docketing-breadcrumb { display: flex; align-items: center; gap: 0.65rem; color: var(--text-soft); font-size: 0.75rem; }
.docketing-breadcrumb a { font-weight: 650; }
.docketing-breadcrumb span { padding-left: 0.65rem; border-left: 1px solid var(--border); }
.docketing-hero-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.8rem; color: var(--text-muted); font-size: 0.8rem; }
.docketing-hero-actions { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 0.65rem; }
.docketing-hero-actions .btn { min-width: 118px; justify-content: center; }
.docketing-id-chip { font-weight: 700; color: var(--text); }
.matter-home-card {
    margin-bottom: 1rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.matter-home-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 8%, var(--surface)), var(--surface-alt));
}
.matter-home-heading h2 { margin: 0.08rem 0 0; color: var(--text); font-size: 0.96rem; }
.matter-home-health { display: flex; align-items: center; gap: 0.4rem; }
.matter-home-health span { padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); font-size: 0.68rem; white-space: nowrap; }
.matter-home-health strong { color: var(--text); }
.matter-home-health .has-alert { border-color: color-mix(in srgb, #c0392b 35%, var(--border)); background: color-mix(in srgb, #c0392b 7%, var(--surface)); color: #a43227; }
.matter-home-health .has-alert strong { color: #a43227; }
.matter-record-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.matter-record-item {
    display: grid;
    grid-template-columns: minmax(130px, 31%) minmax(0, 1fr);
    min-height: 43px;
    border-bottom: 1px solid var(--border-soft);
}
.matter-record-item:nth-child(odd):not(.matter-record-item--wide) { border-right: 1px solid var(--border-soft); }
.matter-record-item--wide { grid-column: 1 / -1; grid-template-columns: minmax(130px, 15.5%) minmax(0, 1fr); }
.matter-record-item dt { display: flex; align-items: center; padding: 0.55rem 0.7rem; background: color-mix(in srgb, var(--surface-alt) 78%, var(--surface)); color: var(--text-muted); font-size: 0.72rem; font-weight: 700; }
.matter-record-item dd { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 0.32rem; margin: 0; padding: 0.5rem 0.7rem; color: var(--text); font-size: 0.82rem; font-weight: 560; line-height: 1.4; }
.matter-record-item dd small { display: block; flex-basis: 100%; color: var(--text-muted); font-size: 0.67rem; font-weight: 450; }
.matter-record-title { font-size: 0.9rem !important; font-weight: 720 !important; }
.matter-record-id { color: var(--accent); font-weight: 750; font-variant-numeric: tabular-nums; }
.matter-record-long { display: block !important; max-height: 70px; overflow: auto; }
.matter-class-chip { display: inline-flex; min-width: 25px; justify-content: center; padding: 0.13rem 0.38rem; border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); border-radius: 5px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); color: var(--accent); font-size: 0.7rem; font-weight: 750; }
.docketing-panel {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.docketing-eyebrow { display: block; color: var(--text-soft); font-size: 0.66rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; }
.docketing-sync-state { display: inline-flex; align-items: center; gap: 0.38rem; padding: 0.3rem 0.6rem; border-radius: 999px; background: var(--surface-muted); color: var(--text-muted); font-size: 0.72rem; font-weight: 650; white-space: nowrap; }
.docketing-sync-state i { width: 7px; height: 7px; border-radius: 50%; background: #b27621; box-shadow: 0 0 0 3px color-mix(in srgb, #b27621 13%, transparent); }
.docketing-sync-state.is-synced { background: color-mix(in srgb, #1e8449 12%, var(--surface)); color: #1e8449; }
.docketing-sync-state.is-synced i { background: #1e8449; box-shadow: 0 0 0 3px color-mix(in srgb, #1e8449 13%, transparent); }
.docketing-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
}
.docketing-detail-grid > div {
    display: grid;
    grid-template-columns: minmax(130px, 34%) 1fr;
    border-bottom: 1px solid var(--border-soft);
}
.docketing-detail-grid dt {
    padding: 0.65rem 0.75rem;
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 650;
}
.docketing-detail-grid dd {
    margin: 0;
    padding: 0.65rem 0.75rem;
    min-width: 0;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.45;
}
.docketing-tabs {
    display: flex;
    overflow-x: auto;
    margin-bottom: 1rem;
    gap: 0.15rem;
    padding: 0.3rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}
.docketing-tab {
    flex: 0 0 auto;
    padding: 0.65rem 0.8rem;
    border-radius: 7px;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
}
.docketing-tab:hover,
.docketing-tab.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.docketing-tab.active { box-shadow: inset 0 -2px 0 var(--highlight), var(--shadow-sm); }
.docketing-tab:hover { color: var(--accent); }
.docketing-tab span { opacity: 0.72; font-size: 0.78rem; }
.docketing-tab:first-child { padding-inline: 1rem; }
.docketing-tab-panel { position: relative; min-height: 100px; }
.docketing-tab-panel::after {
    content: "Loading section…";
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 650;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
}
.docketing-tab-panel.is-loading { min-height: 180px; }
.docketing-tab-panel.is-loading::after { opacity: 1; visibility: visible; }
.docketing-tab-error { display: flex; flex-direction: column; align-items: center; gap: 0.45rem; padding: 2.5rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-muted); text-align: center; }
.docketing-tab-error strong { color: var(--text); }
.docketing-tab-error .btn { margin-top: 0.35rem; }
.docketing-task-panel { overflow: hidden; }
.docketing-workflow-header { align-items: flex-end; }
.docketing-workflow-header p { margin: 0.2rem 0 0; color: var(--text-muted); font-size: 0.74rem; }
.docketing-workflow-tools { display: flex; gap: 0.55rem; align-items: flex-end; }
.docketing-workflow-tools label { display: flex; flex-direction: column; gap: 0.25rem; color: var(--text-muted); font-size: 0.66rem; font-weight: 650; }
.docketing-workflow-tools .filter-input { min-height: 34px; padding: 0.35rem 0.5rem; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--input-bg); font-size: 0.76rem; }
.docketing-workflow-tools input { width: min(220px, 24vw); }
.docketing-task-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; border-bottom: 1px solid var(--border); background: var(--border); }
.docketing-task-summary > div { display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 1.2rem; background: var(--surface); }
.docketing-task-summary strong { color: var(--text); font-size: 1.35rem; line-height: 1; }
.docketing-task-summary span { color: var(--text-muted); font-size: 0.72rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.docketing-task-summary .is-open strong { color: #b66a00; }
.docketing-task-summary .is-complete strong { color: #218653; }
.docketing-activity-list { display: grid; gap: 0; padding: 0; background: var(--surface); }
.docketing-activity-columns { display: grid; grid-template-columns: 42px minmax(210px, 1.35fr) minmax(220px, 1.5fr) minmax(135px, 0.7fr) minmax(105px, 0.55fr); border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.docketing-activity-columns span { padding: 0.55rem 0.7rem; color: var(--text-muted); font-size: 0.65rem; font-weight: 750; letter-spacing: 0.045em; text-transform: uppercase; }
.docketing-activity-group { overflow: hidden; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: var(--surface); box-shadow: none; }
.docketing-activity-group:last-child { border-bottom: 0; }
.docketing-activity-header { display: grid; grid-template-columns: 42px minmax(210px, 1.35fr) minmax(220px, 1.5fr) minmax(135px, 0.7fr) minmax(105px, 0.55fr); gap: 0; align-items: stretch; padding: 0; transition: background 0.12s ease; }
.docketing-activity-header:hover { background: color-mix(in srgb, var(--highlight) 4%, var(--surface)); }
.docketing-activity-header > * { display: flex; min-width: 0; justify-content: center; flex-direction: column; padding: 0.7rem; border-right: 1px solid var(--border-soft); }
.docketing-activity-header > *:last-child { border-right: 0; }
.docketing-activity-number { align-items: center; color: var(--text-soft); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.docketing-activity-name h3 { margin: 0 0 0.12rem; color: var(--accent); font-size: 0.8rem; font-weight: 700; }
.docketing-activity-name small, .docketing-activity-date small { color: var(--text-soft); font-size: 0.63rem; }
.docketing-activity-comment { margin: 0; color: var(--text-muted); font-size: 0.72rem; line-height: 1.4; }
.docketing-activity-date strong { color: var(--text); font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.docketing-activity-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
.docketing-activity-meta > span { padding: 0.2rem 0.45rem; border-radius: 999px; background: var(--surface-muted); color: var(--text); font-size: 0.69rem; font-weight: 700; }
.docketing-activity-meta > a { color: var(--accent); font-size: 0.66rem; font-weight: 650; }
.docketing-activity-tasks { display: grid; gap: 0.4rem; padding: 0.6rem 0.7rem 0.7rem 3.1rem; border-top: 1px solid var(--border-soft); background: color-mix(in srgb, var(--highlight) 2%, var(--surface-alt)); }
.docketing-activity-task-label { display: flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.docketing-activity-task-label span { display: inline-grid; place-items: center; min-width: 19px; height: 19px; border-radius: 50%; background: var(--surface-muted); font-size: 0.63rem; }
.docketing-no-linked-tasks { margin: 0; padding: 0.65rem; border: 1px dashed var(--border-strong); border-radius: 7px; color: var(--text-muted); font-size: 0.74rem; text-align: center; }
.docketing-unlinked-tasks { display: grid; gap: 0.65rem; padding: 1rem; border: 1px dashed #d4a017; border-radius: 10px; background: color-mix(in srgb, #d4a017 5%, var(--surface)); }
.docketing-unlinked-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.docketing-unlinked-heading h3 { margin: 0.1rem 0; color: var(--text); font-size: 0.9rem; }
.docketing-unlinked-heading p { margin: 0; color: var(--text-muted); font-size: 0.72rem; }
.docketing-unlinked-heading > span { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 50%; background: #d4a017; color: #fff; font-size: 0.75rem; font-weight: 800; }
.docketing-task-card { overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); box-shadow: none; }
.docketing-task-card > summary { display: grid; grid-template-columns: 80px minmax(0, 1fr) 145px 18px; align-items: center; gap: 0.65rem; padding: 0.55rem 0.7rem; cursor: pointer; list-style: none; }
.docketing-task-card > summary::-webkit-details-marker { display: none; }
.docketing-task-card > summary::after { content: "⌄"; color: var(--text-muted); font-size: 1rem; transition: transform 0.15s ease; }
.docketing-task-card[open] > summary::after { transform: rotate(180deg); }
.docketing-task-state { padding: 0.22rem 0.48rem; border-radius: 999px; font-size: 0.67rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.035em; }
.docketing-task-state.is-open { background: #fff4dd; color: #8b5700; }
.docketing-task-state.is-complete { background: #e8f7ef; color: #187047; }
.docketing-task-state.is-inactive { background: var(--surface-muted); color: var(--text-muted); }
.docketing-task-title { display: flex; flex-direction: column; min-width: 0; }
.docketing-task-title strong { overflow: hidden; color: var(--text); font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.docketing-task-title small, .docketing-docket-row small { color: var(--text-muted); font-size: 0.69rem; }
.docketing-task-next { display: flex; flex-direction: column; align-items: flex-end; min-width: 105px; }
.docketing-task-next small { color: var(--text-muted); font-size: 0.65rem; text-transform: uppercase; }
.docketing-task-next strong { color: var(--accent); font-size: 0.8rem; }
.docketing-task-body { padding: 0 1rem 1rem; border-top: 1px solid var(--border); }
.docketing-task-dates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0 -1rem 1rem; background: var(--border); }
.docketing-task-dates > div { padding: 0.75rem 1rem; background: var(--surface); }
.docketing-task-dates dt { margin-bottom: 0.2rem; color: var(--text-muted); font-size: 0.68rem; }
.docketing-task-dates dd { margin: 0; color: var(--text); font-size: 0.82rem; font-weight: 650; }
.docketing-task-notes { margin-bottom: 0.85rem; padding: 0.7rem 0.8rem; border-left: 3px solid var(--border-strong); background: var(--surface-alt); color: var(--text-muted); font-size: 0.76rem; }
.docketing-docket-list h3 { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.55rem; font-size: 0.8rem; }
.docketing-docket-list h3 span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 50%; background: var(--surface-muted); color: var(--text-muted); font-size: 0.65rem; }
.docketing-docket-row { display: grid; grid-template-columns: minmax(180px, 1fr) 150px 150px; gap: 1rem; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: 7px; }
.docketing-docket-row + .docketing-docket-row { margin-top: 0.45rem; }
.docketing-docket-row > div { display: flex; flex-direction: column; }
.docketing-docket-row strong { color: var(--text); font-size: 0.76rem; }
.docketing-docket-row p { grid-column: 1 / -1; margin: 0; color: var(--text-muted); font-size: 0.74rem; }
.docketing-task-empty { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; padding: 2.5rem 1rem; color: var(--text-muted); text-align: center; }
.docketing-task-empty strong { color: var(--text); }

@media (max-width: 800px) {
    .matter-record-grid { grid-template-columns: 1fr; }
    .matter-record-item,
    .matter-record-item--wide { grid-column: auto; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); border-right: 0 !important; }
    .docketing-activity-columns { display: none; }
    .docketing-activity-header { grid-template-columns: 36px minmax(0, 1fr) minmax(125px, 0.45fr); }
    .docketing-activity-comment { grid-column: 2; border-top: 1px solid var(--border-soft); }
    .docketing-activity-date { grid-column: 3; grid-row: 1; }
    .docketing-activity-meta { grid-column: 3; grid-row: 2; border-top: 1px solid var(--border-soft); }
    .docketing-activity-number { grid-row: 1 / span 2; }
    .docketing-workflow-header { align-items: stretch; flex-direction: column; }
    .docketing-workflow-tools { width: 100%; }
    .docketing-workflow-tools label { flex: 1; }
    .docketing-workflow-tools input, .docketing-workflow-tools select { width: 100%; }
    .docketing-task-summary { grid-template-columns: repeat(2, 1fr); }
    .docketing-task-dates { grid-template-columns: repeat(2, 1fr); }
    .docketing-docket-row { grid-template-columns: 1fr 1fr; }
    .docketing-docket-row > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
    .docketing-detail-hero { gap: 1rem; padding-inline: 1.2rem 1rem; }
    .docketing-hero-actions { width: 100%; align-items: stretch; }
    .docketing-hero-actions .docketing-sync-state { align-self: flex-start; }
    .docketing-workflow-tools { flex-direction: column; align-items: stretch; }
    .matter-home-heading { align-items: flex-start; flex-direction: column; }
    .matter-home-health { width: 100%; flex-wrap: wrap; }
    .matter-record-item,
    .matter-record-item--wide { grid-template-columns: 40% 60%; }
    .docketing-activity-header { grid-template-columns: 32px minmax(0, 1fr); }
    .docketing-activity-number { grid-row: 1 / span 3; }
    .docketing-activity-comment,
    .docketing-activity-date,
    .docketing-activity-meta { grid-column: 2; grid-row: auto; align-items: flex-start; border-top: 1px solid var(--border-soft); }
    .docketing-activity-tasks { padding-left: 1rem; }
    .docketing-task-card > summary { grid-template-columns: 72px minmax(0, 1fr); }
    .docketing-task-next { grid-column: 2; align-items: flex-start; }
    .docketing-task-card > summary::after { grid-column: 1; grid-row: 2; }
    .docketing-task-dates, .docketing-docket-row { grid-template-columns: 1fr; }
    .docketing-docket-row > div:first-child { grid-column: auto; }
}
.docketing-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: var(--surface-alt);
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.docketing-panel-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 700;
}
.docketing-panel-header .docketing-eyebrow { margin-bottom: 0.12rem; }
.docketing-panel .email-table th { background: var(--surface-alt); color: var(--text-muted); font-size: 0.72rem; letter-spacing: 0.035em; text-transform: uppercase; }
.docketing-panel .email-table td { font-size: 0.82rem; line-height: 1.45; }
.docketing-panel .table-wrapper { margin: 0; border: 0; border-radius: 0; }
.docketing-data-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1rem; }
.docketing-data-columns h3 { font-size: 0.9rem; color: var(--text); margin-bottom: 0.5rem; }
.docketing-data-row { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr auto; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border-soft); font-size: 0.84rem; }
.docketing-image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; padding: 1rem; }
.docketing-image-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); font-size: 0.84rem; }
.docketing-image-card img,
.docketing-image-placeholder { width: 100%; height: 180px; object-fit: contain; background: var(--surface-alt); }
.docketing-image-placeholder { display: grid; place-items: center; color: var(--text-soft); }
.docketing-image-card > div:last-child { padding: 0.75rem; }
.docketing-edit-page { max-width: 1080px; margin-inline: auto; }
.docketing-form-back { display: inline-block; margin-bottom: 0.65rem; font-size: 0.8rem; font-weight: 650; }
.docketing-edit-form { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); }
.docketing-form-notice { display: flex; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid color-mix(in srgb, #d4a017 35%, var(--border)); background: color-mix(in srgb, #d4a017 9%, var(--surface)); color: var(--text-muted); font-size: 0.78rem; }
.docketing-form-notice strong { flex: none; color: var(--text); }
.docketing-form-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.25rem 1.35rem; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.docketing-form-header h2 { margin: 0.15rem 0 0.25rem; color: var(--text); font-size: 1.1rem; }
.docketing-form-header p { color: var(--text-muted); font-size: 0.8rem; }
.docketing-form-header > span { padding: 0.25rem 0.5rem; border-radius: 999px; background: var(--surface-muted); color: var(--text-muted); font-size: 0.7rem; white-space: nowrap; }
.docketing-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.15rem; padding: 1.35rem; }
.docketing-form-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.docketing-form-field--wide { grid-column: 1 / -1; }
.docketing-form-field .form-label { color: var(--text); font-size: 0.78rem; font-weight: 650; }
.docketing-form-field .filter-input { width: 100%; min-height: 42px; padding: 0.55rem 0.65rem; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--input-bg); transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.docketing-form-field textarea.filter-input { min-height: 125px; resize: vertical; line-height: 1.5; }
.docketing-form-field input[type="checkbox"] { align-self: flex-start; width: 18px; min-height: 18px; margin-top: 0.35rem; accent-color: var(--highlight); }
.docketing-form-field.has-error .filter-input { border-color: #c0392b; }
.docketing-form-field.needs-review { padding: 0.55rem; border: 1px solid #d4a017; border-radius: 7px; background: color-mix(in srgb, #d4a017 7%, var(--surface)); }
.foundationip-error-report { display: grid; grid-template-columns: auto 1fr; gap: 0.85rem; margin: 1rem 1.35rem 0; padding: 0.9rem 1rem; border: 1px solid color-mix(in srgb, #c0392b 45%, var(--border)); border-radius: 9px; background: color-mix(in srgb, #c0392b 7%, var(--surface)); }
.foundationip-error-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #c0392b; color: #fff; font-weight: 800; }
.foundationip-error-report h2 { margin: 0; color: var(--text); font-size: 0.9rem; }
.foundationip-error-report p { margin: 0.3rem 0; color: var(--text); font-size: 0.8rem; overflow-wrap: anywhere; }
.foundationip-error-report small { color: var(--text-muted); font-size: 0.72rem; }
.docketing-form-actions { display: flex; justify-content: flex-end; gap: 0.65rem; padding: 0.9rem 1.35rem; border-top: 1px solid var(--border); background: var(--surface-alt); }
.docketing-form-actions .docketing-delete-button { margin-right: auto; }

@media (max-width: 800px) {
    .docketing-detail-grid,
    .docketing-data-columns,
    .docketing-form-grid { grid-template-columns: 1fr; }
    .docketing-form-field--wide { grid-column: auto; }
    .docketing-filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .docketing-detail-hero { align-items: flex-start; }
}

@media (max-width: 520px) {
    .docketing-filters-grid { grid-template-columns: 1fr; }
    .docketing-filters-grid .filter-group--wide,
    .docketing-filters-grid .filter-group--dates { grid-column: auto; }
    .docketing-form-header { align-items: flex-start; flex-direction: column; }
    .docketing-detail-grid > div { grid-template-columns: 42% 58%; }
    .docketing-form-actions { position: sticky; bottom: 0; }
}

.date-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-range .filter-input { flex: 1; min-width: 0; }

.date-range-sep {
    font-size: 0.85rem;
    color: var(--text-soft);
}

/* Client autocomplete combobox */
.combobox { position: relative; }

.combobox-input { padding-right: 1.9rem; }

.combobox-clear {
    position: absolute;
    top: 0;
    right: 0;
    height: 38px;
    width: 1.9rem;
    border: none;
    background: transparent;
    color: #9aa0a6;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.combobox-clear:hover { color: #c0392b; }

.combobox-list {
    position: absolute;
    z-index: 40;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

.combobox-option {
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

.combobox-option:hover,
.combobox-option.is-active {
    background: var(--surface-muted);
    color: var(--accent);
}

.combobox-empty {
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    color: #9aa0a6;
}

.results-info strong { color: var(--primary); }

/* Urgency sections */
.task-section { margin-bottom: 1.75rem; }

.section-head {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    padding: 0 0.2rem 0.6rem;
    border-bottom: 1px solid #e6e9ec;
    margin-bottom: 0.85rem;
}

.section-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #b0b6bb;
    align-self: center;
}

.section-title {
    font-size: 1.05rem;
    color: var(--primary);
    margin: 0;
}

.section-count {
    background: var(--surface-muted);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 9px;
}

.section-hint {
    font-size: 0.82rem;
    color: #9aa0a6;
    margin-left: auto;
}

.section-head--overdue .section-dot { background: #c0392b; }
.section-head--today .section-dot { background: #e67e22; }
.section-head--soon .section-dot { background: #d4a017; }
.section-head--upcoming .section-dot { background: #1e8449; }
.section-head--none .section-dot { background: #b0b6bb; }

/* Task cards */
.task-cards { display: flex; flex-direction: column; gap: 0.6rem; }

.task-card {
    display: block;
    background: var(--surface);
    border-radius: 10px;
    border-left: 4px solid var(--border-strong);
    padding: 0.8rem 1.1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    color: var(--text);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.task-card:hover {
    transform: translateX(2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    color: var(--text);
}

.task-card--overdue { border-left-color: #c0392b; }
.task-card--today { border-left-color: #e67e22; }
.task-card--soon { border-left-color: #d4a017; }
.task-card--upcoming { border-left-color: #1e8449; }
.task-card--none { border-left-color: var(--border-strong); }

.task-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.task-card-subject {
    font-weight: 600;
    font-size: 0.98rem;
    color: var(--primary);
    line-height: 1.3;
}

.task-card-meta {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-top: 0.2rem;
}

.task-card-meta .meta-client { font-weight: 600; color: var(--text-muted); }
.task-card-meta .meta-sep { margin: 0 0.4rem; color: #c5cbd1; }

.task-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
}

/* Deadline tag (relative + date) */
.deadline-tag {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.prio-overdue { background: #fdecea; color: #c0392b; }
.prio-today { background: #fdf0e6; color: #d35400; }
.prio-soon { background: #fdf6e3; color: #b7860b; }
.prio-upcoming { background: #eafaf1; color: #1e8449; }
.prio-none { background: #f0f1f3; color: #828b94; }

.col-deadline { min-width: 150px; }

.email-deadline-pill {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    align-items: flex-start;
    min-width: 118px;
    border-radius: 7px;
    padding: 5px 9px;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
}

.email-deadline-label { font-size: 0.75rem; }

.email-deadline-date {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.78;
}

.email-deadline-empty {
    color: #a1a8af;
    font-size: 0.85rem;
}

.task-list-table td { vertical-align: top; }

.row-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}


.muted-cell { color: #a1a8af; }

/* Role chips — who owns this task */
.task-roles { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.76rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.role-chip .role-key {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #9aa0a6;
}

.role-chip--you {
    background: #e8f0fe;
    border-color: #b9d2fb;
    color: #1a3e72;
    font-weight: 600;
}

.role-chip--you .role-key { color: var(--highlight); }

/* Empty state */
.task-empty {
    background: var(--surface);
    border-radius: 10px;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

.task-empty-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.4rem;
}

.task-empty-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    max-width: 460px;
    margin: 0 auto;
    line-height: 1.5;
}

@media (max-width: 1024px) {
    .task-stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
    .task-stats { grid-template-columns: repeat(2, 1fr); }
    .task-card-head { flex-direction: column; gap: 0.3rem; }
}

/* ══ Client list: name + inline edit ═══════════════════════════ */
.client-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.row-edit-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #9aa0a6;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease, color 0.12s ease;
}

.compact-table tr:hover .row-edit-link { opacity: 1; }
.row-edit-link:hover { color: var(--highlight); }

/* ══ Client detail ═════════════════════════════════════════════ */
.client-detail { max-width: 1000px; margin: 0 auto; }

.client-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin: 0.75rem 0 1.5rem;
}

.client-hero-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.client-avatar {
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--highlight));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    font-weight: 700;
}

.client-hero-name {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.client-hero-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.hero-chip {
    background: #f0f3f7;
    color: var(--text-muted);
    border-radius: 6px;
    padding: 2px 9px;
    font-size: 0.8rem;
    font-weight: 500;
}

.hero-chip--muted { background: #fdecea; color: #c0392b; }

.client-hero-side {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.client-counts { display: flex; gap: 0.75rem; }

.count-box {
    background: var(--surface-alt);
    border-radius: 10px;
    padding: 0.6rem 1.1rem;
    text-align: center;
    min-width: 78px;
}

.count-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}

.count-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
}

.count-box--link {
    display: block;
    text-decoration: none;
    transition: background 0.12s ease, transform 0.12s ease;
}

.count-box--link:hover {
    background: #eaf1fb;
    transform: translateY(-2px);
}

/* Client/entity scope banner (e.g. attachments filtered to one client) */
.scope-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: #eaf1fb;
    border: 1px solid #c7dbfb;
    border-radius: 8px;
    padding: 0.7rem 1.1rem;
    margin-bottom: 1rem;
}

.scope-banner-text { font-size: 0.9rem; color: #1a3e72; }
.scope-banner-actions { display: flex; gap: 0.75rem; }
.scope-banner-link { font-size: 0.85rem; font-weight: 600; }
.scope-banner-clear { color: #c0392b; }

.client-team {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    justify-content: center;
}

.team-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.team-role {
    width: 92px;
    color: var(--text-soft);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

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

.client-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.9rem;
    flex-wrap: wrap;
}

.client-section-head h2 { color: var(--primary); font-size: 1.15rem; }

/* Email timeline */
.email-timeline { display: flex; flex-direction: column; gap: 0.7rem; }

.email-item {
    background: var(--surface);
    border-radius: 10px;
    border-left: 3px solid var(--border);
    padding: 0.9rem 1.2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.email-item:hover {
    border-left-color: var(--highlight);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.email-item-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.email-item-subject {
    font-weight: 600;
    font-size: 0.98rem;
    color: var(--primary);
    line-height: 1.3;
}

.email-item-subject:hover { color: var(--highlight); }

.email-item-date {
    flex: none;
    font-size: 0.8rem;
    color: var(--text-soft);
    white-space: nowrap;
}

.email-item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.email-item-meta .meta-from { font-weight: 500; }
.email-item-meta .meta-sep { color: #c5cbd1; }
.email-item-meta .meta-deadline { color: #c0392b; font-weight: 600; }

.email-item-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.65rem;
}

.attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 280px;
    background: #f4f6f9;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 3px 9px 3px 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.attachment-pill:hover {
    background: #eaf1fb;
    border-color: #b9d2fb;
    color: var(--accent);
}

.attachment-pill-ext {
    flex: none;
    background: var(--accent);
    color: var(--white);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.attachment-pill-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state--card {
    background: var(--surface);
    border-radius: 10px;
    padding: 2.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

@media (max-width: 640px) {
    .client-hero { flex-direction: column; }
    .email-item-head { flex-direction: column; gap: 0.2rem; }
}

/* ══ Task detail ═══════════════════════════════════════════════ */
.task-detail { max-width: 1100px; margin: 0 auto; }

.task-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--surface);
    border-radius: 12px;
    border-left: 5px solid var(--border-strong);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin: 0.75rem 0 1.25rem;
}

.task-detail-header--overdue { border-left-color: #c0392b; }
.task-detail-header--today { border-left-color: #e67e22; }
.task-detail-header--soon { border-left-color: #d4a017; }
.task-detail-header--upcoming { border-left-color: #1e8449; }
.task-detail-header--none { border-left-color: var(--border-strong); }

.task-detail-subject {
    color: var(--primary);
    font-size: 1.4rem;
    line-height: 1.3;
    margin-bottom: 0.6rem;
}

.task-detail-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.task-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.25rem;
    align-items: start;
}

.task-detail-main,
.task-detail-side {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.panel {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
    margin-bottom: 0.9rem;
}

.panel-empty { color: #9aa0a6; font-size: 0.9rem; }

.client-line { font-weight: 600; font-size: 1.05rem; }
.client-sub { font-size: 0.82rem; color: var(--text-soft); margin-top: 0.15rem; }

.deadline-line { font-weight: 600; color: var(--primary); margin-bottom: 0.5rem; }

@media (max-width: 860px) {
    .task-detail-grid { grid-template-columns: 1fr; }
}

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

/* ══ Client report drafting ════════════════════════════════════ */
.report-page { max-width: 900px; margin: 0 auto; }

.report-head { margin: 0.75rem 0 0.75rem; }
.report-head h1 { color: var(--primary); margin-bottom: 0.2rem; }
.report-sub { font-size: 0.92rem; color: var(--text-muted); }

.ai-badge {
    display: inline-block;
    margin-left: 0.4rem;
    background: #e8f0fe;
    color: #1a3e72;
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.report-notice {
    background: #fef9e7;
    border: 1px solid #f4e2a6;
    color: #8a6d1b;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-size: 0.86rem;
    margin-bottom: 1rem;
}

.report-editor { display: flex; flex-direction: column; gap: 0.85rem; }

.report-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-soft);
}

.copy-status { font-size: 0.85rem; color: #1e8449; font-weight: 600; }
.copy-status--error { color: #c0392b; }

.report-field--inline { max-width: 360px; }

.report-field { display: flex; flex-direction: column; gap: 0.3rem; }

.report-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
}

.report-hint { text-transform: none; font-weight: 400; color: #b0b6bb; letter-spacing: 0; }

.report-field .filter-input { width: 100%; height: 40px; }

.report-body {
    border: 1px solid #d7dbe0;
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    background: var(--surface);
    font-family: Calibri, Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    min-height: 300px;
}

.report-body:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(15, 52, 96, 0.1);
}

.report-body table { width: 100%; }
.report-body p { margin: 0 0 0.75rem; }

.report-source {
    margin-top: 1.25rem;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    padding: 0.5rem 1.25rem;
}

.report-source summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
    padding: 0.6rem 0;
}

.report-source-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0.5rem 0 0.85rem;
}

.report-source-meta .src-key {
    display: inline-block;
    width: 70px;
    color: var(--text-soft);
    font-weight: 600;
}

/* ══ AIMatter (matter id tags, status badges, matter panel) ════ */

/* Open/closed status pill, shared by matters and their deadlines. */
.status-badge {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-open { background: #eafaf1; color: #1e8449; }
.status-closed { background: #f0f1f3; color: #828b94; }

/* Monospace matter id, used as a tag/link across pages. */
.matter-tag {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--surface-muted);
    border-radius: 5px;
    padding: 1px 7px;
    white-space: nowrap;
}
a.matter-tag:hover { background: #e1e9f5; color: var(--highlight); }

.matter-tag-type { font-size: 0.78rem; color: var(--text-muted); }

/* Email list matter column */
.col-matter { font-size: 0.82rem; line-height: 1.2; white-space: nowrap; }
.col-matter small { display: block; color: var(--text-muted); font-size: 0.72rem; }

/* Task board card matter row */
.task-card-matter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.task-card-matter .matter-tag-type { flex: 1; min-width: 0; }

/* Task detail matter panel */
.matter-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}
.matter-type { font-size: 0.9rem; color: var(--text-muted); margin: 0.15rem 0 0.5rem; }
.matter-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.6rem; line-height: 1.4; }

.matter-deadlines { margin-top: 0.9rem; }
.matter-deadlines-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
    margin-bottom: 0.4rem;
}
.matter-deadline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-top: 1px solid var(--border-soft);
    font-size: 0.85rem;
}
.matter-deadline-date { color: var(--text); }

/* ══ Matters board / detail / forms ════════════════════════════ */

/* Page-level flash messages (matter pages) */
.page-flash {
    border-radius: 8px;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash-success { background: #eafaf1; color: #1e8449; border: 1px solid #b8e6cb; }
.flash-error { background: #fdecea; color: #c0392b; border: 1px solid #f5c6c0; }

/* Matter cards grid */
.matter-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.85rem;
}

.matter-card {
    display: block;
    background: var(--surface);
    border-radius: 10px;
    border-left: 4px solid var(--border-strong);
    padding: 1rem 1.2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    color: var(--text);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.matter-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); color: var(--text); }
.matter-card--open { border-left-color: #1e8449; }
.matter-card--closed { border-left-color: #b0b6bb; }

.matter-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.matter-card-type { font-weight: 600; color: var(--primary); }
.matter-card-client { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem; }
.matter-card-team { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.3rem; }
.matter-card-team .meta-sep { margin: 0 0.3rem; color: #c5cbd1; }
.panel-subnote { font-size: 0.8rem; color: var(--text-soft); margin: -0.4rem 0 0.6rem; }
.matter-card-desc { font-size: 0.84rem; color: var(--text-muted); margin-top: 0.5rem; line-height: 1.4; }
.matter-card-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.matter-card-emails { margin-left: auto; font-size: 0.78rem; color: var(--text-soft); }

.deadline-pill {
    display: inline-block;
    border-radius: 5px;
    padding: 1px 8px;
    font-size: 0.74rem;
    font-weight: 600;
}
.deadline-pill--open { background: #eafaf1; color: #1e8449; }
.deadline-pill--closed { background: #f0f1f3; color: #828b94; text-decoration: line-through; }

.matter-id--lg { font-size: 1.4rem; }

/* Assign-matter form (task detail) */
.assign-matter-form { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border-soft); }
.assign-label {
    display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-soft); margin-bottom: 0.4rem;
}
.assign-row { display: flex; gap: 0.4rem; }
.assign-row .filter-input { flex: 1; min-width: 0; }
.assign-new-link { display: inline-block; margin-top: 0.5rem; font-size: 0.82rem; }

/* Matter detail: deadline toggle + linked emails */
.deadline-toggle { margin: 0; }
.status-toggle { border: none; cursor: pointer; font-family: inherit; }
.add-deadline-form { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border-soft); }
.add-deadline-form .form-group { margin-bottom: 0.5rem; }

.matter-email-list { display: flex; flex-direction: column; gap: 0.5rem; }
.matter-email-row {
    display: flex; flex-direction: column; gap: 0.15rem;
    padding: 0.6rem 0.8rem; border-radius: 8px; background: var(--surface-alt);
}
.matter-email-row:hover { background: #eaf1fb; }
.matter-email-subject { font-weight: 600; color: var(--primary); font-size: 0.92rem; }
.matter-email-meta { font-size: 0.78rem; color: var(--text-soft); }

.matter-form-page { max-width: 640px; margin: 0 auto; }
.matter-form-page h1 { color: var(--primary); margin: 0.5rem 0 1.25rem; }
.matter-form .form-hint { margin-top: 0.75rem; font-size: 0.82rem; color: var(--text-soft); }

/* ══ Email ↔ matter association (task detail) ══════════════════ */
.assoc-matter {
    border-left: 3px solid var(--border);
    padding: 0.5rem 0 0.5rem 0.7rem;
    margin-bottom: 0.6rem;
}
.assoc-matter-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.assoc-remove { margin: 0; }
.assoc-remove-btn {
    border: none; background: transparent; cursor: pointer;
    font-size: 1.1rem; line-height: 1; color: #b0b6bb; padding: 0 0.2rem;
}
.assoc-remove-btn:hover { color: #c0392b; }

.matter-name { font-size: 0.95rem; color: var(--text-muted); margin: 0.1rem 0 0.5rem; }

.assign-matter-form .combobox { margin-bottom: 0.5rem; }
.assign-matter-form .btn-sm { width: auto; }

/* ===== Cost Estimator ===== */

/* ===== WIPO Fee Calculator ===== */
.wfc-page { max-width: 1180px; margin: 0 auto; }
.wfc-head { margin-bottom: 24px; }
.wfc-head h1 { margin: 2px 0 8px; }
.wfc-head > p:last-child, .wfc-source { color: var(--text-muted); }
.wfc-kicker { margin: 0; color: var(--accent); font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.wfc-card, .wfc-result { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 24px; }
.wfc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.wfc-grid label { display: grid; gap: 7px; font-size: .86rem; font-weight: 650; }
.wfc-grid select, .wfc-grid input, #wfc-search { min-height: 42px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--input-bg); padding: 8px 11px; color: var(--text); }
.wfc-grid select:focus, .wfc-grid input:focus, #wfc-search:focus { border-color: var(--highlight); box-shadow: 0 0 0 3px var(--focus-ring); outline: 0; }
.wfc-grid select:disabled { background: var(--surface-alt); color: var(--text-muted); opacity: 1; }
.wfc-checks { display: flex; flex-wrap: wrap; gap: 22px; margin: 22px 0 8px; }
.wfc-checks label { display: flex; align-items: center; gap: 8px; }
.wfc-party-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-top: 26px; border-top: 1px solid var(--border-soft); padding-top: 22px; }
.wfc-party-head h2 { margin: 0 0 3px; font-size: 1.08rem; }
.wfc-party-head p { margin: 0; color: var(--text-muted); font-size: .85rem; }
#wfc-search { width: min(330px, 100%); }
.wfc-parties { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px 14px; margin-top: 15px; max-height: 420px; overflow: auto; padding: 4px; }
.wfc-party { display: flex; align-items: flex-start; gap: 8px; border-radius: 6px; padding: 8px; font-size: .86rem; }
.wfc-party { color: var(--text); }
.wfc-party:hover { background: var(--surface-alt); }
.wfc-party:has(input:checked) { background: color-mix(in srgb, var(--highlight) 11%, var(--surface)); }
.wfc-party strong { display: inline-block; min-width: 28px; color: var(--accent); }
.wfc-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; border-top: 1px solid var(--border-soft); padding-top: 18px; }
.wfc-result { margin-top: 20px; overflow: hidden; padding: 0; }
.wfc-result-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 26px; border-bottom: 1px solid var(--border-soft); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, var(--surface)), var(--surface)); }
.wfc-result-head h2 { margin: 3px 0 0; color: var(--text); font-size: 1.35rem; }
.wfc-result-eyebrow { margin: 0; color: var(--accent); font-size: .7rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.wfc-result-currency { padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); font-size: .72rem; font-weight: 750; letter-spacing: .08em; }
.wfc-result-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr); gap: 24px; padding: 24px 26px; }
.wfc-breakdown { align-self: center; }
.wfc-fee-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 52px; border-bottom: 1px solid var(--border-soft); }
.wfc-fee-row:last-child { border-bottom: 0; }
.wfc-fee-row span { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: .88rem; }
.wfc-fee-row strong { color: var(--text); font-size: 1rem; font-variant-numeric: tabular-nums; }
.wfc-fee-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-soft); }
.wfc-fee-dot--basic { background: #3b82f6; }
.wfc-fee-dot--party { background: #8b5cf6; }
.wfc-fee-dot--extra { background: #d4a017; }
.wfc-grand { display: flex; min-height: 178px; justify-content: center; flex-direction: column; padding: 24px; border: 1px solid #a84a64; border-radius: 12px; background: linear-gradient(145deg, #8b1d35, #651526); color: #fff; box-shadow: 0 10px 24px rgba(101, 21, 38, .2); }
.wfc-grand > span { color: rgba(255,255,255,.75); font-size: .76rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.wfc-grand > strong { margin: 7px 0 6px; font-size: clamp(1.75rem, 3vw, 2.35rem); font-variant-numeric: tabular-nums; line-height: 1; }
.wfc-grand > strong small { font-size: .42em; letter-spacing: .06em; opacity: .78; }
.wfc-grand > em { color: rgba(255,255,255,.68); font-size: .72rem; font-style: normal; }
.wfc-result-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 26px 22px; }
.wfc-result-meta span { padding: 5px 9px; border-radius: 999px; background: var(--surface-alt); color: var(--text-muted); font-size: .72rem; }
.wfc-equation { margin-top: 14px; padding: 13px 15px; border-radius: 8px; background: var(--surface-alt); }
.wfc-equation span { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.wfc-equation strong { color: var(--text); font-size: .86rem; font-variant-numeric: tabular-nums; }
.wfc-result-details { display: grid; grid-template-columns: minmax(260px, .7fr) minmax(0, 1.3fr); gap: 28px; margin: 0 26px 22px; padding: 22px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface-alt); }
.wfc-result-details h3 { margin: 0 0 13px; color: var(--text); font-size: .9rem; }
.wfc-result-details h3 span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 5px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); font-size: .7rem; }
.wfc-result-details dl { display: grid; gap: 8px; margin: 0; }
.wfc-result-details dl div { display: flex; justify-content: space-between; gap: 16px; }
.wfc-result-details dt { color: var(--text-muted); font-size: .78rem; }
.wfc-result-details dd { margin: 0; color: var(--text); font-size: .78rem; font-weight: 650; text-align: right; }
.wfc-party-details { margin: 0 26px 22px; padding: 22px; border: 1px solid var(--border-soft); border-radius: 10px; }
.wfc-party-details h3 { margin: 0 0 13px; color: var(--text); font-size: .9rem; }
.wfc-party-details h3 span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 5px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); font-size: .7rem; }
.wfc-detail-scroll { overflow-x: auto; }
.wfc-detail-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.wfc-detail-table th { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 700; text-align: left; }
.wfc-detail-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); color: var(--text); vertical-align: top; }
.wfc-detail-table tr:last-child td { border-bottom: 0; }
.wfc-detail-table th:last-child, .wfc-detail-table td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wfc-detail-table--parties th:nth-child(3), .wfc-detail-table--parties td:nth-child(3) { text-align: center; white-space: nowrap; }
.wfc-detail-table--parties td:nth-child(2) { min-width: 300px; color: var(--text-muted); line-height: 1.45; }
.wfc-selected-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 0; padding: 0; list-style: none; }
.wfc-selected-parties li { display: flex; align-items: baseline; gap: 7px; padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: 7px; background: var(--surface); color: var(--text); font-size: .76rem; }
.wfc-selected-parties li strong { color: var(--accent); }
.wfc-result-note { padding: 0 26px 22px; color: var(--text-muted); font-size: .75rem; }
.wfc-source { margin: 16px 2px; font-size: .8rem; }
:root[data-theme="dark"] .wfc-card,
:root[data-theme="dark"] .wfc-result { box-shadow: var(--shadow-md); }
:root[data-theme="dark"] .wfc-grand { background: linear-gradient(145deg, #7f2941, #571525); border-color: #a84a64; box-shadow: 0 12px 28px rgba(0,0,0,.28); }
@media (max-width: 800px) {
    .wfc-grid, .wfc-parties { grid-template-columns: 1fr 1fr; }
    .wfc-result-body { grid-template-columns: 1fr; }
    .wfc-result-details { grid-template-columns: 1fr; }
    .wfc-party-head { align-items: stretch; flex-direction: column; }
    #wfc-search { width: 100%; }
}
@media (max-width: 520px) {
    .wfc-grid, .wfc-parties { grid-template-columns: 1fr; }
    .wfc-card { padding: 17px; }
    .wfc-result-head, .wfc-result-body { padding: 18px; }
    .wfc-result-meta { padding: 0 18px 18px; }
    .wfc-result-details { margin: 0 18px 18px; padding: 17px; }
    .wfc-party-details { margin: 0 18px 18px; padding: 17px; }
    .wfc-selected-parties { grid-template-columns: 1fr; }
    .wfc-result-note { padding: 0 18px 18px; }
}
.ce-page { max-width: 980px; margin: 0 auto; }
.ce-head h1 { color: var(--primary); margin-bottom: 0.35rem; }
.ce-sub { color: #6b7682; margin-bottom: 1.25rem; }

.ce-chat {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 1rem 1.1rem 1.25rem;
}

.ce-messages {
    height: 56vh;
    min-height: 340px;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.ce-msg { display: flex; }
.ce-msg--user { justify-content: flex-end; }
.ce-msg--assistant { justify-content: flex-start; }

.ce-bubble {
    max-width: 88%;
    padding: 0.7rem 0.95rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.5;
}
.ce-msg--user .ce-bubble {
    background: var(--accent);
    color: var(--white);
    border-bottom-right-radius: 4px;
}
.ce-msg--assistant .ce-bubble {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border-soft);
    border-bottom-left-radius: 4px;
}
.ce-msg--assistant .ce-bubble:has(.ce-table--wide) {
    width: 100%;
    max-width: 100%;
}
.ce-bubble p { margin: 0 0 0.5rem; }
.ce-bubble p:last-child { margin-bottom: 0; }
.ce-bubble ul { margin: 0.25rem 0 0.5rem 1.1rem; }
.ce-bubble h2, .ce-bubble h3, .ce-bubble h4 { margin: 0.6rem 0 0.35rem; color: var(--primary); }
.ce-bubble code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
.ce-bubble pre { background: #1f2430; color: #e6e9ef; padding: 0.7rem 0.85rem; border-radius: 8px; overflow-x: auto; }
.ce-bubble pre code { background: none; padding: 0; color: inherit; }
.ce-hint { color: var(--text-soft); font-size: 0.82rem; }

.ce-table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
    font-size: 0.85rem;
    background: var(--surface);
}
.ce-table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}
.ce-table--wide { min-width: 940px; }
.ce-table th, .ce-table td {
    border: 1px solid #dfe3e8;
    padding: 6px 9px;
    text-align: left;
    vertical-align: top;
}
.ce-table th { background: var(--surface-muted); font-weight: 600; }
.ce-table th:nth-child(n+3),
.ce-table td:nth-child(n+3) { text-align: right; white-space: nowrap; }

.ce-input {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    margin-top: 0.85rem;
}
.ce-textarea {
    flex: 1;
    resize: vertical;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d8dde3;
    border-radius: 8px;
    font: inherit;
    font-size: 0.92rem;
}
.ce-input .btn { white-space: nowrap; }
.ce-input .btn:disabled,
.ce-input .btn:disabled:hover,
.ce-input .btn:disabled:active {
    background: var(--border-strong);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
    filter: none;
    box-shadow: none;
    transform: none;
}
.ce-copy-link { margin-left: 0.65rem; padding: 0.25rem 0.55rem; font-size: 0.78rem; }
.ce-disclaimer { color: var(--text-soft); font-size: 0.78rem; margin-top: 0.6rem; }

.ce-estimating-bubble {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 310px;
    background: linear-gradient(
        110deg,
        var(--surface-alt) 18%,
        color-mix(in srgb, var(--accent) 8%, var(--surface)) 48%,
        var(--surface-alt) 78%
    ) !important;
    background-size: 220% 100% !important;
    animation: ce-estimating-shimmer 3s ease-in-out infinite;
}

.ce-estimating-mark {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
}

.ce-estimating-orbit {
    position: absolute;
    inset: 0;
    border: 2px solid color-mix(in srgb, var(--accent) 18%, transparent);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ce-estimating-orbit 1.25s linear infinite;
}

.ce-estimating-orbit::after {
    content: "";
    position: absolute;
    top: 1px;
    right: 1px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.ce-estimating-coin {
    display: grid;
    place-items: center;
    width: 23px;
    height: 23px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 13%, var(--surface));
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 750;
    animation: ce-estimating-coin 1.8s ease-in-out infinite;
}

.ce-estimating-copy {
    display: grid;
    min-width: 0;
    line-height: 1.35;
}

.ce-estimating-copy strong {
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 650;
}

.ce-estimating-step {
    color: var(--text-muted);
    font-size: 0.76rem;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.ce-estimating-step.is-changing {
    opacity: 0;
    transform: translateY(2px);
}

.ce-estimating-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
}

.ce-estimating-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    animation: ce-estimating-dot 1.2s ease-in-out infinite;
}

.ce-estimating-dots i:nth-child(2) { animation-delay: 0.15s; }
.ce-estimating-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes ce-estimating-shimmer {
    0%, 100% { background-position: 100% 0; }
    50% { background-position: 0 0; }
}

@keyframes ce-estimating-orbit {
    to { transform: rotate(360deg); }
}

@keyframes ce-estimating-coin {
    0%, 100% { transform: scale(0.94); }
    50% { transform: scale(1.06); }
}

@keyframes ce-estimating-dot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .ce-estimating-bubble,
    .ce-estimating-orbit,
    .ce-estimating-coin,
    .ce-estimating-dots i {
        animation: none;
    }

    .ce-estimating-step { transition: none; }
}

@media (max-width: 520px) {
    .ce-estimating-bubble {
        width: 100%;
        min-width: 0;
    }
}

/* ===== Ask IPLA ===== */
.qa-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.qa-session {
    flex: none;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    line-height: 1;
    font: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.qa-session:hover,
.qa-session:focus-visible {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent);
}

.qa-session:active {
    transform: translateY(1px);
}

.qa-session:disabled {
    cursor: wait;
    opacity: 0.6;
}

.qa-messages {
    min-height: 420px;
}

.qa-thinking-bubble {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 210px;
    color: var(--text-muted);
    background: linear-gradient(
        110deg,
        var(--surface-alt) 20%,
        color-mix(in srgb, var(--accent) 7%, var(--surface)) 48%,
        var(--surface-alt) 76%
    );
    background-size: 220% 100%;
    animation: qa-thinking-shimmer 2.8s ease-in-out infinite;
}

.qa-thinking-spark {
    color: var(--accent);
    font-size: 1rem;
    animation: qa-thinking-pulse 1.5s ease-in-out infinite;
}

.qa-thinking-text {
    font-size: 0.86rem;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.qa-thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
}

.qa-thinking-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    animation: qa-thinking-dot 1.2s ease-in-out infinite;
}

.qa-thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.qa-thinking-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes qa-thinking-shimmer {
    0%, 100% { background-position: 100% 0; }
    50% { background-position: 0 0; }
}

@keyframes qa-thinking-pulse {
    0%, 100% { opacity: 0.55; transform: scale(0.9) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.08) rotate(12deg); }
}

@keyframes qa-thinking-dot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .qa-thinking-bubble,
    .qa-thinking-spark,
    .qa-thinking-dots i {
        animation: none;
    }
}

.qa-sources {
    margin-top: 0.75rem;
    border-top: 1px solid var(--border-soft);
    padding-top: 0.7rem;
    display: grid;
    gap: 0.55rem;
}

.qa-sources-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.qa-source {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.6rem 0.7rem;
}

.qa-source-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.25rem;
}

.qa-source-ref {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
}

.qa-source-kind {
    font-size: 0.7rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.qa-source-title {
    display: block;
    font-size: 0.86rem;
    font-weight: 650;
    color: var(--text);
    overflow-wrap: anywhere;
}

.qa-source-excerpt {
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.qa-source-timestamp {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Theme compatibility for older page-local styles and legacy hard-coded tones. */
.filter-input,
.ce-textarea,
.combobox-input,
.report-field .filter-input,
.fld-input,
.search-input,
select,
textarea {
    background: var(--input-bg);
    color: var(--text);
    border-color: var(--border);
}

.filter-input:focus,
.ce-textarea:focus,
.fld-input:focus,
.search-input:focus {
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}

.email-filters,
.task-filters,
.stat-card,
.task-card,
.task-empty,
.client-hero,
.email-item,
.empty-state--card,
.task-detail-header,
.panel,
.report-body,
.report-source,
.matter-card,
.ce-chat,
.doc-filters,
.doc-card,
.stat-chip,
.crumbs {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.info-card,
.email-attachments,
.modal .form-actions,
.modal-footer,
.attachment-content,
.role-chip,
.hero-chip,
.count-box,
.matter-email-row,
.ce-msg--assistant .ce-bubble,
.ce-table th,
.pill,
.ico-file {
    background: var(--surface-alt);
    border-color: var(--border-soft);
}

.combobox-option:hover,
.combobox-option.is-active,
.page-link:hover,
.count-box--link:hover,
.matter-email-row:hover,
.attachment-pill:hover,
.node-row:hover {
    background: var(--surface-muted);
}

.page-link,
.recipients-pop,
.modal,
.attachment-frame,
.attachment-image,
.email-body-frame,
.ce-table th,
.ce-table td {
    background: var(--surface);
    border-color: var(--border);
}

.email-header,
.filter-section + .filter-section,
.filter-actions,
.modal-header,
.report-toolbar,
.matter-deadline-row,
.assign-matter-form,
.add-deadline-form,
.children,
.node:not(:last-child) .node-row {
    border-color: var(--border-soft);
}

.col-date,
.col-attach,
.filter-label,
.results-info,
.back-link,
.email-meta dt,
.email-received-line,
.info-card-title,
.kv dt,
.client-ident-sub,
.section-title,
.attachment-meta,
.form-label,
.form-help,
.task-subtitle,
.filters-title,
.date-range-sep,
.combobox-empty,
.section-hint,
.task-card-meta,
.email-deadline-empty,
.muted-cell,
.role-chip,
.task-empty-text,
.email-item-date,
.email-item-meta,
.panel-title,
.report-sub,
.report-source-meta,
.matter-tag-type,
.matter-type,
.matter-desc,
.matter-deadlines-title,
.matter-card-client,
.matter-card-team,
.panel-subnote,
.matter-card-desc,
.matter-card-emails,
.matter-email-meta,
.matter-name,
.ce-sub,
.ce-hint,
.ce-disclaimer,
.doc-sub,
.fld-label,
.date-sep,
.node-meta,
.file-size,
.empty,
.loading {
    color: var(--text-muted);
}

.route-addr,
.recipients-pop__list li,
.team-name,
.node-name,
.matter-deadline-date {
    color: var(--text);
}

.route-tag,
.route-more,
.route-cc,
.meta-chip,
.matter-tag,
.section-count {
    background: var(--surface-muted);
    border-color: var(--border);
}

:root[data-theme="dark"] .email-table thead,
:root[data-theme="dark"] .footer {
    color: var(--header-text);
}

:root[data-theme="dark"] .badge-spam,
:root[data-theme="dark"] .prio-overdue,
:root[data-theme="dark"] .flash-error,
:root[data-theme="dark"] .route-chip--spam,
:root[data-theme="dark"] .hero-chip--muted {
    background: rgba(231, 76, 60, 0.18);
}

:root[data-theme="dark"] .prio-today {
    background: rgba(230, 126, 34, 0.18);
}

:root[data-theme="dark"] .prio-soon,
:root[data-theme="dark"] .report-notice {
    background: rgba(212, 160, 23, 0.18);
}

:root[data-theme="dark"] .badge-clean,
:root[data-theme="dark"] .prio-upcoming,
:root[data-theme="dark"] .status-open,
:root[data-theme="dark"] .flash-success,
:root[data-theme="dark"] .route-chip--client,
:root[data-theme="dark"] .fwd-chip,
:root[data-theme="dark"] .deadline-pill--open {
    background: rgba(39, 174, 96, 0.18);
}

:root[data-theme="dark"] .ai-badge,
:root[data-theme="dark"] .scope-banner,
:root[data-theme="dark"] .role-chip--you {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(147, 197, 253, 0.28);
}

/* ===== Responsive layout ===== */
@media (max-width: 1100px) {
    .main-content--wide {
        max-width: 100%;
    }

    .email-table {
        min-width: 980px;
    }
}

@media (max-width: 760px) {
    .footer {
        padding: 0.9rem 1rem;
    }

    .hero {
        padding: 2.5rem 0;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .feature-grid,
    .matter-cards {
        grid-template-columns: 1fr;
    }

    .email-filters,
    .task-filters,
    .ce-chat,
    .panel,
    .task-detail-header,
    .client-hero,
    .modal .model-form,
    .model-form {
        padding: 1rem;
    }

    .filter-grid,
    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filter-field--narrow {
        max-width: none;
    }

    .filter-field--wide,
    .filter-group--dates {
        grid-column: auto;
    }

    .date-range {
        align-items: stretch;
        flex-direction: column;
        gap: 0.35rem;
    }

    .date-range-sep {
        line-height: 1;
    }

    .filter-actions,
    .filters-bar,
    .page-toolbar,
    .section-title-row,
    .modal-footer,
    .form-actions,
    .ce-input,
    .assign-row {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-actions .btn,
    .filters-actions,
    .filters-actions .btn,
    .page-toolbar .btn,
    .form-actions .btn,
    .modal-footer .btn,
    .ce-input .btn,
    .assign-row .btn {
        width: 100%;
    }

    .filters-actions,
    .scope-banner-actions {
        display: flex;
        flex-direction: column;
    }

    .table-wrapper {
        margin-inline: -1rem;
        padding-inline: 1rem;
    }

    .email-table th,
    .email-table td {
        padding: 0.6rem 0.75rem;
        font-size: 0.84rem;
    }

    .compact-table th,
    .compact-table td {
        font-size: 0.78rem;
    }

    .modal-overlay {
        padding: 1rem;
    }

    .modal {
        border-radius: 10px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .modal .form-actions {
        margin: 1rem -1rem -1rem;
        padding: 1rem;
    }

    .attachment-frame {
        height: 65vh;
    }

    .toast-container {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }

    .client-hero-main,
    .client-hero-side,
    .client-counts,
    .team-row {
        width: 100%;
    }

    .client-hero-main {
        align-items: flex-start;
    }

    .client-hero-side,
    .client-counts {
        flex-direction: column;
        align-items: stretch;
    }

    .count-box {
        width: 100%;
    }

    .team-role {
        width: auto;
        min-width: 92px;
    }

    .email-item-meta,
    .matter-card-head,
    .matter-deadline-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }

    .matter-card-emails {
        margin-left: 0;
    }

    .ce-messages {
        height: 52vh;
        min-height: 280px;
    }

    .ce-bubble {
        max-width: 100%;
    }

    .qa-head {
        flex-direction: column;
        gap: 0.35rem;
    }

    .qa-session {
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding-inline: 0.85rem;
    }

    .email-filters,
    .task-filters,
    .ce-chat,
    .qa-source,
    .panel,
    .task-detail-header,
    .client-hero,
    .feature-card,
    .email-item,
    .matter-card,
    .empty-state--card {
        border-radius: 8px;
        padding: 0.85rem;
    }

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

    .stat-card {
        padding: 0.75rem 0.85rem;
    }

    .stat-value {
        font-size: 1.45rem;
    }

    .client-avatar {
        width: 46px;
        height: 46px;
        border-radius: 10px;
        font-size: 1.35rem;
    }

    .client-hero-name,
    .task-detail-subject,
    .matter-id--lg {
        font-size: 1.2rem;
    }

    .attachment-pill,
    .route-chip {
        max-width: 100%;
    }
}

/* Reports */
.reports-page { max-width: 1180px; margin-inline: auto; }
.report-titlebar h1 { margin: 0.2rem 0 0.45rem; color: var(--text); letter-spacing: -0.025em; }
.report-titlebar p { margin: 0; color: var(--text-muted); }
.reports-eyebrow { color: var(--accent); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.feature-card-link { color: inherit; text-decoration: none; }
.feature-card-link:hover { border-color: var(--accent); }

.deadline-report-page { max-width: 1720px; }
.report-breadcrumb { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; color: var(--text-soft); font-size: 0.75rem; }
.report-breadcrumb a { font-weight: 700; }
.report-titlebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1rem; }
.report-summary { display: grid; grid-template-columns: auto auto; align-items: center; gap: 0.35rem 0.7rem; flex: none; padding: 0.7rem 0.85rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); }
.report-summary > time { color: var(--text-soft); font-size: 0.68rem; white-space: nowrap; }
.report-count { display: flex; grid-row: 1 / span 2; align-items: baseline; gap: 0.35rem; padding-right: 0.7rem; border-right: 1px solid var(--border); }
.report-count strong { color: var(--text); font-size: 1.45rem; line-height: 1; }
.report-count span { color: var(--text-muted); font-size: 0.66rem; font-weight: 750; letter-spacing: 0.055em; text-transform: uppercase; }
.report-live-state { display: flex; align-items: center; gap: 0.35rem; color: #187047; font-size: 0.69rem; font-weight: 750; }
.report-live-state i { width: 7px; height: 7px; border-radius: 50%; background: #27ae60; box-shadow: 0 0 0 3px color-mix(in srgb, #27ae60 14%, transparent); }
.report-rules { margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.report-rules summary { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 0.9rem; color: var(--text); cursor: pointer; font-size: 0.78rem; font-weight: 750; list-style: none; }
.report-rules summary::-webkit-details-marker { display: none; }
.report-rules summary::before { content: "+"; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; background: var(--surface-muted); color: var(--accent); font-size: 0.85rem; line-height: 1; }
.report-rules[open] summary::before { content: "−"; }
.report-rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border-top: 1px solid var(--border); background: var(--border); }
.report-rule-grid > div { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem 0.9rem; background: var(--surface-alt); }
.report-rule-grid span { color: var(--text-muted); font-size: 0.68rem; font-weight: 650; }
.report-rule-grid strong { color: var(--text); font-size: 0.78rem; }
.report-rule-wide { grid-column: 1 / -1; }
.report-code-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.report-code-list code { padding: 0.15rem 0.35rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); font-size: 0.68rem; }
.report-filters { border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.report-filter-grid { grid-template-columns: minmax(260px, 2fr) repeat(2, minmax(150px, 0.7fr)); }
.report-search-control { position: relative; }
.report-search-control svg { position: absolute; top: 50%; left: 0.7rem; z-index: 1; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--text-soft); stroke-linecap: round; stroke-width: 1.6; pointer-events: none; }
.report-search-control .filter-input { padding-left: 2.15rem; }
.report-apply-button { min-width: 102px; font-weight: 700; }
.report-active-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; padding-top: 0.7rem; border-top: 1px solid var(--border-soft); }
.report-active-label { color: var(--text-soft); font-size: 0.67rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.report-filter-chip { padding: 0.22rem 0.5rem; border: 1px solid color-mix(in srgb, var(--highlight) 25%, var(--border)); border-radius: 999px; background: color-mix(in srgb, var(--highlight) 8%, var(--surface)); color: var(--text); font-size: 0.7rem; }
.report-clear-filters { margin-left: auto; font-size: 0.7rem; font-weight: 700; }
.report-results-panel { overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow-sm); }
.report-results-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.report-results-heading { display: flex; align-items: center; gap: 0.65rem; }
.report-results-heading h2 { margin: 0; color: var(--text); font-size: 0.82rem; }
.report-results-heading p { margin: 0.12rem 0 0; color: var(--text-soft); font-size: 0.68rem; }
.report-results-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; background: color-mix(in srgb, var(--highlight) 11%, var(--surface)); color: var(--accent); }
.report-results-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.report-scroll-hint { display: flex; align-items: center; gap: 0.35rem; color: var(--text-soft); font-size: 0.68rem; white-space: nowrap; }
.report-scroll-hint svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.5; }
.deadline-report-table-wrapper { max-height: calc(100vh - 210px); margin: 0; overflow: auto; border: 0; border-radius: 0; outline: none; }
.deadline-report-table-wrapper:focus-visible { box-shadow: inset 0 0 0 3px var(--focus-ring); }
.deadline-report-table { min-width: 2085px; table-layout: fixed; overflow: visible; }
.deadline-report-table col.report-col-title { width: 220px; }
.deadline-report-table col.report-col-class { width: 90px; }
.deadline-report-table col.report-col-country { width: 85px; }
.deadline-report-table col.report-col-application { width: 160px; }
.deadline-report-table col.report-col-status { width: 110px; }
.deadline-report-table col.report-col-activity { width: 210px; }
.deadline-report-table col.report-col-detail { width: 190px; }
.deadline-report-table col.report-col-date { width: 125px; }
.deadline-report-table col.report-col-comments { width: 250px; }
.deadline-report-table col.report-col-name { width: 210px; }
.deadline-report-table col.report-col-assigned { width: 160px; }
.deadline-report-table col.report-col-role { width: 145px; }
.deadline-report-table col.report-col-team { width: 130px; }
.deadline-report-table th { position: sticky; z-index: 3; border-right: 1px solid var(--border); white-space: nowrap; }
.deadline-report-table .report-heading-primary th { top: 0; }
.deadline-report-table .report-heading-secondary th { top: 33px; background: var(--surface-muted); color: var(--text-muted); font-size: 0.65rem; }
.deadline-report-table th[rowspan="2"] { vertical-align: middle; }
.deadline-report-table td { min-width: 0; max-width: none; border-right: 1px solid var(--border-soft); vertical-align: top; white-space: normal; }
.deadline-report-table th:first-child,
.deadline-report-table td:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: 1px 0 0 var(--border), 8px 0 16px -14px rgba(0, 0, 0, 0.65); }
.deadline-report-table th:first-child { z-index: 5; background: var(--header-bg); }
.deadline-report-table tbody > tr:nth-child(even) > td { background: var(--surface-alt); }
.deadline-report-table tbody > tr:nth-child(even) > td:first-child { background: var(--surface-alt); }
.deadline-report-table tbody > tr:hover > td { background: color-mix(in srgb, var(--highlight) 5%, var(--surface)); }
.deadline-report-table tbody > tr:hover > td:first-child { background: color-mix(in srgb, var(--highlight) 5%, var(--surface)); }
.deadline-report-table .report-team-heading { border-bottom: 1px solid var(--border); text-align: center; }
.report-primary-cell span { display: block; color: var(--text); font-weight: 750; line-height: 1.35; }
.report-date-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-date-cell time { display: block; color: var(--accent); font-weight: 800; }
.report-deadline-state { display: inline-flex; margin-top: 0.35rem; padding: 0.15rem 0.38rem; border-radius: 999px; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.02em; }
.report-deadline-state.is-overdue { background: #fdecea; color: #b42318; }
.report-deadline-state.is-today { background: #fff4dd; color: #8b5700; }
.report-deadline-state.is-soon { background: #fff9db; color: #7a6300; }
.report-deadline-state.is-upcoming { background: #e8f7ef; color: #187047; }
.report-long-cell { white-space: normal; }
.report-status { display: inline-flex; padding: 0.2rem 0.45rem; border-radius: 999px; background: var(--surface-muted); color: var(--text); font-size: 0.7rem; font-weight: 700; white-space: nowrap; }
.report-stack-item { display: block; }
.report-stack-item + .report-stack-item { margin-top: 0.25rem; }
.report-class-code { display: inline-flex; margin: 0 0.2rem 0.2rem 0; padding: 0.16rem 0.38rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-alt); font-size: 0.7rem; font-weight: 700; }
.deadline-report-table td.report-assignment-cell { padding: 0; }
.report-assignment-row { display: grid; grid-template-columns: 160px 145px 130px; min-height: 34px; }
.report-assignment-row + .report-assignment-row { border-top: 1px solid var(--border-soft); }
.report-assignment-row > span { display: flex; align-items: flex-start; padding: 0.55rem 0.6rem; border-right: 1px solid var(--border-soft); overflow-wrap: anywhere; }
.report-assignment-row > span:last-child { border-right: 0; }
.report-assignment-row .report-assignee { align-items: center; gap: 0.45rem; }
.report-assignee i { display: grid; place-items: center; flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; background: color-mix(in srgb, var(--highlight) 13%, var(--surface)); color: var(--accent); font-size: 0.62rem; font-style: normal; font-weight: 850; }
.report-assignee b { font-weight: 650; }
.report-assignment-empty { padding: 0.55rem 0.6rem; color: var(--text-soft); text-align: center; }
.report-empty-state { padding: 2rem !important; text-align: center !important; }
.report-empty-state strong,
.report-empty-state span { display: block; }
.report-empty-state strong { color: var(--text); }
.report-empty-state span { margin-top: 0.25rem; color: var(--text-muted); font-size: 0.78rem; font-weight: 400; }
.report-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:root[data-theme="dark"] .report-live-state { color: #8ce3b7; }
:root[data-theme="dark"] .report-deadline-state.is-overdue { background: rgba(231, 76, 60, 0.18); color: #fda29b; }
:root[data-theme="dark"] .report-deadline-state.is-today,
:root[data-theme="dark"] .report-deadline-state.is-soon { background: rgba(212, 160, 23, 0.18); color: #ffd18a; }
:root[data-theme="dark"] .report-deadline-state.is-upcoming { background: rgba(39, 174, 96, 0.18); color: #8ce3b7; }

@media (max-width: 760px) {
    .report-titlebar { align-items: flex-start; flex-direction: column; }
    .report-summary,
    .report-count { align-items: flex-start; }
    .report-rule-grid,
    .report-filter-grid { grid-template-columns: 1fr; }
    .report-rule-wide { grid-column: auto; }
    .report-results-toolbar { align-items: flex-start; flex-direction: column; }
    .report-scroll-hint { white-space: normal; }
    .report-clear-filters { margin-left: 0; }
}
