/**
 * Law Firm MIS — Modern UI Design System
 * Brand: #6A1F27 · #AA9166 · #121518 · #000 · #fff
 *
 * Typography
 * - Body/UI: Plus Jakarta Sans
 * - Headings: Source Serif 4
 * - Scale: --text-xs through --text-4xl on a 16px root
 */

/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
    --burgundy: #6A1F27;
    --burgundy-dark: #4e161c;
    --burgundy-light: #8a2833;
    --burgundy-muted: rgba(106, 31, 39, 0.08);
    --gold: #AA9166;
    --gold-light: #c9b896;
    --gold-dark: #8a7550;
    --gold-muted: rgba(170, 145, 102, 0.15);
    --charcoal: #121518;
    --charcoal-soft: #1e2329;
    --white: #ffffff;
    --surface: #ffffff;
    --surface-muted: #f4f5f7;
    --surface-elevated: #fafbfc;
    --border: #e8eaed;
    --border-subtle: #f0f1f3;
    --text-primary: #121518;
    --text-secondary: #5c6570;
    --text-tertiary: #8b939e;
    --success: #0d7a4e;
    --success-bg: #e8f5ef;
    --warning: #9a6700;
    --warning-bg: #fef7e6;
    --danger: #b42318;
    --danger-bg: #fdecec;
    --info: #1e5a7a;
    --info-bg: #e8f2f8;
    --sidebar-width: 280px;
    --sidebar-width-mobile: min(88vw, 320px);
    --topbar-height: 72px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-xs: 0 1px 2px rgba(18, 21, 24, 0.04);
    --shadow-sm: 0 2px 8px rgba(18, 21, 24, 0.06);
    --shadow-md: 0 4px 20px rgba(18, 21, 24, 0.08);
    --shadow-lg: 0 12px 40px rgba(18, 21, 24, 0.12);
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-body: var(--font-sans);
    --font-display: var(--font-serif);
    --font-script: 'Dancing Script', 'Segoe Script', 'Brush Script MT', cursive;
    --font-base: var(--font-body);
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --leading-none: 1.1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 1.75;
    --tracking-tighter: -0.03em;
    --tracking-tight: -0.02em;
    --tracking-normal: -0.011em;
    --tracking-wide: 0.025em;
    --tracking-wider: 0.06em;
    --tracking-widest: 0.12em;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 2.5rem;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    letter-spacing: var(--tracking-normal);
    background: var(--surface-muted);
    color: var(--text-primary);
    line-height: var(--leading-relaxed);
    min-height: 100vh;
    font-feature-settings: 'kern' 1, 'liga' 1;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5, h6 { font-size: var(--text-base); }

p {
    line-height: var(--leading-relaxed);
}

small,
.text-small {
    font-size: var(--text-sm);
}

strong, b {
    font-weight: var(--font-semibold);
}

label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    letter-spacing: var(--tracking-wide);
}

a {
    color: var(--burgundy);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--burgundy-light); }

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

.icon-svg { flex-shrink: 0; }

/* ==========================================================================
   Auth / Login
   ========================================================================== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(170, 145, 102, 0.2), transparent),
        linear-gradient(155deg, var(--charcoal) 0%, var(--burgundy-dark) 45%, var(--burgundy) 100%);
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: var(--space-2xl) var(--space-xl);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-brand { text-align: center; margin-bottom: var(--space-xl); }

.auth-brand .logo-mark {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--burgundy) 0%, var(--gold) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-lg);
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--white);
    box-shadow: 0 8px 24px rgba(106, 31, 39, 0.35);
}

.auth-brand h1 {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: var(--font-semibold);
    color: var(--burgundy);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
}

.auth-brand p {
    color: var(--text-secondary);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    margin-top: var(--space-sm);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.app-body { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width-mobile);
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 18%),
        linear-gradient(165deg, var(--burgundy-dark) 0%, var(--burgundy) 52%, #5a1a22 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.35);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(18, 21, 24, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: calc(var(--space-md) + env(safe-area-inset-top, 0px)) var(--space-md) var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    flex: 1;
}

.brand-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    text-align: center;
}

.brand-name {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(1rem, 2.4vw, 1.2rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.25;
    color: var(--white);
}

.brand-sub {
    display: block;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--gold-light);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-top: 3px;
}

.sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
    color: var(--white);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-sm) var(--space-sm) var(--space-lg);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
    -webkit-overflow-scrolling: touch;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
}

.nav-section-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    padding: var(--space-sm) var(--space-md) var(--space-xs);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    color: rgba(255, 255, 255, 0.82);
    border-radius: var(--radius);
    margin-bottom: 2px;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: background var(--transition), color var(--transition), transform var(--transition);
    position: relative;
}

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

.nav-link:active {
    transform: scale(0.98);
}

.nav-link.active {
    color: var(--white);
    background: rgba(255, 255, 255, 0.11);
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 55%;
    width: 3px;
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
    border-radius: 0 3px 3px 0;
}

.nav-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.nav-link.active .nav-icon-wrap,
.nav-link:hover .nav-icon-wrap {
    background: rgba(255, 255, 255, 0.1);
}

.nav-link.active .nav-icon-wrap {
    color: var(--gold-light);
}

.nav-label {
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-icon { color: inherit; }

.sidebar-footer {
    padding: var(--space-lg) var(--space-md) var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.25rem 0.125rem;
}

.sidebar-profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--burgundy-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--white);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sidebar-profile-initials {
    letter-spacing: 0.04em;
}

.sidebar-profile-meta {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-profile-name {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-role {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-signout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    margin-top: 0.125rem;
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.sidebar-signout:hover {
    color: #fecaca;
    background: rgba(248, 113, 113, 0.12);
}

.sidebar-signout .icon-svg {
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-signout:hover .icon-svg {
    opacity: 1;
}

.sidebar-toggle {
    flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-overlay {
        transition: none;
    }

    .nav-link:active {
        transform: none;
    }
}

body.sidebar-open {
    overflow: hidden;
    touch-action: none;
}

/* ==========================================================================
   Main layout & topbar
   ========================================================================== */
.main-wrapper {
    flex: 1;
    margin-left: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.topbar {
    position: sticky;
    top: 0;
    min-height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-lg);
    gap: var(--space-md);
    z-index: 100;
}

.topbar-title-wrap { flex: 1; min-width: 0; }

.page-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    color: var(--burgundy);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.topbar-user-chip {
    display: flex;
    align-items: center;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.topbar-logo {
    height: 52px;
    width: 52px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

.content-area {
    flex: 1;
    padding: var(--space-lg);
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

.app-footer {
    padding: var(--space-lg);
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

/* Allow horizontal scroll for data tables (avoid clipping Actions column) */
.card:has(.table-responsive) {
    overflow: visible;
}

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

.card-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    background: var(--surface-elevated);
}

.card-header h2,
.card-header h3 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--burgundy);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-snug);
}

.card-body {
    padding: var(--space-xl);
}

.card-body + .card-body {
    border-top: 1px solid var(--border-subtle);
}

.card-body.compact {
    padding: var(--space-lg);
}

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--burgundy), var(--gold));
}

.stat-card.gold::before {
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
}

.stat-card.charcoal::before {
    background: var(--charcoal);
}

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

.stat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.stat-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--burgundy-muted);
    color: var(--burgundy);
}

.stat-card.gold .stat-icon-wrap {
    background: var(--gold-muted);
    color: var(--gold-dark);
}

.stat-card.charcoal .stat-icon-wrap {
    background: rgba(18, 21, 24, 0.08);
    color: var(--charcoal);
}

.stat-value {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--burgundy);
    letter-spacing: var(--tracking-tighter);
    line-height: var(--leading-none);
}

.stat-card.gold .stat-value { color: var(--gold-dark); }
.stat-card.charcoal .stat-value { color: var(--charcoal); }

.stat-label {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    letter-spacing: var(--tracking-wide);
    margin-top: var(--space-xs);
}

.stat-card-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.stat-card-link:hover {
    color: inherit;
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(106, 31, 39, 0.15);
}

.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.stat-card-top .stat-label {
    margin-top: 0;
    line-height: 1.4;
}

.stat-card-foot {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: auto;
    padding-top: var(--space-md);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    transition: color var(--transition);
}

.stat-card-link:hover .stat-card-foot {
    color: var(--burgundy);
}

.stat-card.gold .stat-card-link:hover .stat-card-foot,
.stat-card-link.gold:hover .stat-card-foot { color: var(--gold-dark); }

.stat-card.charcoal .stat-card-link:hover .stat-card-foot,
.stat-card-link.charcoal:hover .stat-card-foot { color: var(--charcoal); }

.stat-value-sm {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
}

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.dashboard-hero {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: clamp(1rem, 3vw, 2rem);
    padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 4vw, 2rem);
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.dashboard-hero::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
}

.dashboard-hero-user {
    flex-shrink: 0;
    padding-left: 0.5rem;
}

.dashboard-hero-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.dashboard-hero-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--burgundy);
    color: var(--white);
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.dashboard-hero-main {
    min-width: 0;
}

.dashboard-hero-kicker {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold-dark);
    margin-bottom: 0.35rem;
}

.dashboard-hero-title {
    font-family: var(--font-display);
    font-size: clamp(1.375rem, 3.5vw, 1.875rem);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--burgundy);
    margin-bottom: 0.35rem;
}

.dashboard-hero-desc {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    max-width: 42ch;
    line-height: 1.5;
}

.dashboard-hero-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 5.5rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-lg);
    background: var(--burgundy);
    color: var(--white);
    text-align: center;
    flex-shrink: 0;
}

.dashboard-hero-date-day {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.03em;
}

.dashboard-hero-date-weekday {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold-light);
    margin-top: 0.35rem;
}

.dashboard-hero-date-month {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.82);
    margin-top: 0.15rem;
}

.dashboard-stats {
    margin-bottom: 0;
}

.dashboard-stats .stat-card-link {
    min-height: 10.5rem;
    height: 100%;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
}

.dashboard-panel-header {
    align-items: flex-start;
}

.dashboard-panel-header h3 {
    margin-bottom: 0.15rem;
}

.dashboard-panel-desc {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.dashboard-panel-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.dashboard-panel-body {
    padding: var(--space-lg) var(--space-xl);
}

.dashboard-panel-body .btn-primary,
.dashboard-panel-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-md);
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-tertiary);
    font-size: 0.9375rem;
}

.dashboard-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    color: var(--text-tertiary);
}

/* Schedule list */
.schedule-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.schedule-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--surface-elevated);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.schedule-item:hover {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

.schedule-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--burgundy-muted);
    border: 1px solid rgba(106, 31, 39, 0.1);
    line-height: 1;
}

.schedule-day {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--burgundy);
}

.schedule-month {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold-dark);
    margin-top: 3px;
}

.schedule-body {
    flex: 1;
    min-width: 0;
}

.schedule-title {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-title:hover {
    color: var(--burgundy);
}

.schedule-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.schedule-meta a {
    color: var(--text-secondary);
    font-weight: 500;
}

.schedule-meta a:hover {
    color: var(--burgundy);
}

.schedule-meta-sep {
    color: var(--text-tertiary);
}

.schedule-arrow {
    flex-shrink: 0;
    color: var(--text-tertiary);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity var(--transition), transform var(--transition);
}

.schedule-item:hover .schedule-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Case list */
.case-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.case-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.case-list-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.case-list-item:first-child {
    padding-top: 0;
}

.case-list-main {
    min-width: 0;
    flex: 1;
}

.case-list-number {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--burgundy);
    margin-bottom: 0.15rem;
}

.case-list-title {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.case-list-client {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.15rem;
}

/* Quick action tiles */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: var(--space-md);
}

.action-tile {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-elevated);
    color: var(--text-primary);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.action-tile:hover {
    color: var(--text-primary);
    border-color: rgba(106, 31, 39, 0.2);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.action-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--burgundy-muted);
    color: var(--burgundy);
}

.action-tile-text {
    flex: 1;
    min-width: 0;
}

.action-tile-label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
}

.action-tile-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.1rem;
}

.action-tile-arrow {
    flex-shrink: 0;
    color: var(--text-tertiary);
    transition: color var(--transition), transform var(--transition);
}

.action-tile:hover .action-tile-arrow {
    color: var(--burgundy);
    transform: translate(2px, -2px);
}

.dashboard-actions-panel {
    margin-top: 0;
}

@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        align-items: start;
    }
}

@media (max-width: 767px) {
    .dashboard-hero {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }

    .dashboard-hero-date {
        grid-column: 1 / -1;
        flex-direction: row;
        gap: 0.75rem;
        width: 100%;
        padding: 0.75rem 1rem;
        text-align: left;
    }

    .dashboard-hero-date-day {
        font-size: 1.5rem;
        min-width: 2rem;
    }

    .dashboard-hero-date-weekday,
    .dashboard-hero-date-month {
        margin-top: 0;
    }

    .dashboard-hero-date-weekday {
        flex: 1;
    }
}

@media (max-width: 575px) {
    .dashboard-panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-panel-actions {
        width: 100%;
    }

    .dashboard-panel-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .schedule-arrow {
        display: none;
    }
}

/* ==========================================================================
   Client profile (cp) — spacious modern layout
   ========================================================================== */
.cp {
    --cp-pad: clamp(1.25rem, 3vw, 2rem);
    --cp-gap: clamp(1.25rem, 2.5vw, 2rem);
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-lg) var(--space-2xl);
    display: flex;
    flex-direction: column;
    gap: var(--cp-gap);
    min-width: 0;
    width: 100%;
    container-type: inline-size;
    container-name: cp;
}

/* Hero */
.cp-hero {
    background: var(--white);
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(18, 21, 24, 0.04), 0 12px 40px rgba(18, 21, 24, 0.06);
    overflow: hidden;
}

.cp-hero__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem var(--cp-pad) 0;
}

.cp-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.cp-back:hover { color: var(--burgundy); }

.cp-back-icon { transform: rotate(180deg); }

.cp-hero__code {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold-dark);
    padding: 0.35rem 0.75rem;
    background: var(--gold-muted);
    border-radius: 999px;
}

.cp-hero__main {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    padding: 1.25rem var(--cp-pad) 1.5rem;
}

/* Ensure hero internal content never forces horizontal scroll */
.cp-hero__identity,
.cp-hero__metrics,
.cp-hero__footer,
.cp-quick,
.cp-hero__actions {
    min-width: 0;
}

.cp-hero__identity {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    min-width: 0;
}

.cp-avatar {
    width: 88px;
    height: 88px;
    flex-shrink: 0;
    border-radius: 20px;
    background: linear-gradient(145deg, var(--burgundy) 0%, var(--burgundy-dark) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: var(--font-bold);
    box-shadow: 0 8px 24px rgba(106, 31, 39, 0.25);
}

.cp-avatar--icon .icon-svg {
    color: var(--white);
    opacity: 0.95;
}

.cp-hero__intro { min-width: 0; flex: 1; }

.cp-hero__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.cp-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.65rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: 999px;
    background: var(--burgundy-muted);
    color: var(--burgundy);
}

.cp-chip--muted {
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.cp-hero__name {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    overflow-wrap: break-word;
    word-break: normal;
}

.cp-hero__sub {
    margin: 0 0 0.5rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.cp-hero__lawyer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.cp-hero__lawyer .icon-svg { color: var(--gold-dark); flex-shrink: 0; }

.cp-hero__since {
    color: var(--text-tertiary);
    padding-left: 0.5rem;
    border-left: 1px solid var(--border);
}

.cp-hero__metrics {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cp-metric {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-width: 100px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    background: var(--surface-elevated);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color var(--transition), box-shadow var(--transition), transform 0.15s ease;
}

.cp-metric:hover {
    border-color: var(--gold);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.cp-metric__value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--burgundy);
}

.cp-metric__label {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.cp-hero__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem var(--cp-pad);
    background: linear-gradient(180deg, var(--surface-elevated) 0%, #f6f7f9 100%);
    border-top: 1px solid var(--border-subtle);
}

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

.cp-quick__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    transition: all var(--transition);
    min-width: 0;
}

.cp-quick__btn span {
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.cp-quick__btn:hover {
    color: var(--burgundy);
    border-color: var(--gold);
    box-shadow: var(--shadow-xs);
}

.cp-quick__btn--wa:hover {
    color: #128c7e;
    border-color: #128c7e;
}

.cp-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cp-hero__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Body layout */
.cp-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--cp-gap);
    align-items: start;
}

.cp-aside {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cp-card {
    padding: 1.25rem 1.35rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(18, 21, 24, 0.03);
}

.cp-card__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.cp-card__title .icon-svg { color: var(--burgundy); opacity: 0.85; }

.cp-card__text {
    margin: 0;
    font-size: var(--text-sm);
    line-height: 1.65;
    color: var(--text-secondary);
}

.cp-detail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cp-detail-list li {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cp-detail-list__label {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
}

.cp-detail-list__value {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    word-break: break-word;
}

.cp-detail-list__value a {
    font-weight: var(--font-semibold);
    color: var(--burgundy);
}

.cp-na {
    font-style: normal;
    color: var(--text-tertiary);
}

.cp-notes {
    font-size: var(--text-sm);
    line-height: 1.7;
    color: var(--text-secondary);
    padding: 1rem;
    background: var(--surface-muted);
    border-radius: 12px;
}

.cp-card--notes .cp-card__title { margin-bottom: 0.75rem; }

/* Main panel */
.cp-main {
    min-width: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(18, 21, 24, 0.04);
    overflow: hidden;
}

.cp-tabs {
    display: flex;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cp-tab {
    flex-shrink: 0;
    padding: 0.55rem 1.1rem;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.cp-tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.6); }

.cp-tab.is-active {
    color: var(--burgundy);
    background: var(--white);
    box-shadow: 0 1px 4px rgba(18, 21, 24, 0.08);
}

.cp-tab__count {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    font-weight: var(--font-bold);
    border-radius: 999px;
    background: var(--burgundy-muted);
    color: var(--burgundy);
}

.cp-tab.is-active .cp-tab__count {
    background: var(--burgundy);
    color: var(--white);
}

.cp-panel { display: none; }
.cp-panel.is-active { display: block; }

.cp-panel__inner {
    padding: clamp(1.25rem, 3vw, 2rem);
}

/* Overview summary */
.cp-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.cp-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.15rem;
    background: var(--surface-elevated);
    border-radius: 12px;
    border: 1px solid transparent;
}

.cp-summary-item__label {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
}

.cp-summary-item__value {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    word-break: break-word;
}

.cp-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.cp-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.cp-section__head--lg { margin-bottom: 1.75rem; }

.cp-section__head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.cp-section__desc {
    margin: 0.25rem 0 0;
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.cp-link-btn {
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--burgundy);
    cursor: pointer;
    text-decoration: none;
}

.cp-link-btn:hover { text-decoration: underline; }

/* Rows list */
.cp-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cp-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.cp-row:hover {
    border-color: var(--border);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.cp-row__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--burgundy-muted);
    color: var(--burgundy);
}

.cp-row__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.cp-row__meta {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: 0.04em;
    color: var(--burgundy);
}

.cp-row__title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-row__sub {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.cp-row__chev,
.cp-row__arrow {
    flex-shrink: 0;
    color: var(--text-tertiary);
    opacity: 0.5;
    transition: opacity var(--transition), transform var(--transition);
}

.cp-row:hover .cp-row__chev,
.cp-row:hover .cp-row__arrow {
    opacity: 1;
    color: var(--burgundy);
    transform: translateX(2px);
}

.cp-row--static {
    cursor: default;
}

.cp-row--static:hover {
    border-color: var(--border-subtle);
    background: var(--surface-elevated);
    box-shadow: none;
}

.cp-rows--cards .cp-row--card {
    padding: 1.15rem 1.25rem;
}

.cp-compose {
    margin-bottom: 2rem;
    padding: 1.25rem 1.35rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cp-compose__row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.cp-compose .btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Timeline */
.cp-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1.25rem;
    border-left: 2px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cp-timeline__item {
    position: relative;
    padding-left: 0.5rem;
}

.cp-timeline__dot {
    position: absolute;
    left: -1.35rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--white);
    box-shadow: 0 0 0 2px var(--gold-muted);
}

.cp-timeline__content {
    padding: 0.85rem 1rem;
    background: var(--surface-elevated);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.cp-timeline__top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.cp-timeline__top span {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--burgundy);
}

.cp-timeline__top time {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.cp-timeline__content p {
    margin: 0;
    font-size: var(--text-sm);
    line-height: 1.55;
    color: var(--text-primary);
}

.cp-timeline__by {
    display: block;
    margin-top: 0.5rem;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.cp-timeline--full { gap: 1.25rem; }

/* Empty states */
.cp-zero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

.cp-zero--lg {
    padding: 3.5rem 2rem;
    border: 1px dashed var(--border);
    border-radius: 16px;
    background: var(--surface-elevated);
}

.cp-zero--lg .icon-svg { opacity: 0.45; color: var(--text-tertiary); }

.cp-print-sheet.only-print { display: none; }

/* Touch-friendly targets (profile actions) */
.cp-metric,
.cp-tab,
.cp-quick__btn,
.cp-link-btn,
.cp-hero__actions .btn,
.cp-section__head .btn,
.cp-zero .btn {
    min-height: 44px;
}

.cp-link-btn {
    min-height: auto;
    padding: 0.35rem 0;
}

/* Client profile — responsive (container-based; accounts for sidebar width) */
.cp-hero__footer {
    flex-direction: column;
    align-items: stretch;
}

.cp-hero__metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
}

.cp-metric {
    width: 100%;
    min-width: 0;
}

.cp-quick {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
}

.cp-hero__actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
}

.cp-hero__actions .btn {
    width: 100%;
    justify-content: center;
}

.cp-body {
    grid-template-columns: 1fr;
}

.cp-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.cp-tab {
    scroll-snap-align: start;
}

@container cp (min-width: 30rem) {
    .cp-quick {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

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

@container cp (min-width: 40rem) {
    .cp-hero__footer {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    .cp-quick {
        flex: 1 1 16rem;
        min-width: 0;
    }

    .cp-hero__actions {
        display: flex;
        flex-wrap: wrap;
        width: auto;
        flex: 0 1 auto;
        justify-content: flex-end;
    }

    .cp-hero__actions .btn {
        width: auto;
    }
}

@container cp (min-width: 52rem) {
    .cp-hero__main {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
        gap: 1.25rem;
    }

    .cp-hero__identity {
        flex: 1;
        min-width: 0;
    }

    .cp-hero__metrics {
        display: flex;
        flex-shrink: 0;
        width: auto;
    }

    .cp-metric {
        min-width: 6.5rem;
    }

    .cp-body {
        grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
        gap: 1.5rem;
    }

    .cp-aside {
        position: sticky;
        top: calc(var(--topbar-height) + 1rem);
    }
}

@container cp (min-width: 62rem) {
    .cp-body {
        grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    }

    .cp-split {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

/* Tablet viewport: page padding only (layout follows container width) */
@media (min-width: 641px) and (max-width: 1100px) {
    .content-area:has(.cp) {
        padding: var(--space-md) var(--space-lg);
        overflow-x: hidden;
    }

    .cp {
        padding-left: 0;
        padding-right: 0;
    }

    .cp-quick__btn {
        padding: 0.45rem 0.45rem;
        font-size: 0.75rem;
        gap: 0.25rem;
    }

    .cp-quick__btn .icon-svg {
        width: 15px;
        height: 15px;
    }
}

/* Mobile: 640px and below */
@media (max-width: 640px) {
    .content-area:has(.cp) {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
        padding-top: var(--space-md);
    }

    .cp {
        --cp-pad: 1rem;
        --cp-gap: 1rem;
        padding-left: 0;
        padding-right: 0;
        padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px));
        gap: var(--cp-gap);
    }

    .cp-hero,
    .cp-main,
    .cp-card {
        border-radius: 14px;
    }

    .cp-hero__top {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding-top: 0.75rem;
    }

    .cp-hero__code {
        font-size: 0.65rem;
        padding: 0.3rem 0.6rem;
    }

    .cp-hero__main {
        padding: 1rem var(--cp-pad) 1.15rem;
        gap: 1.25rem;
    }

    .cp-hero__identity {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1rem;
    }

    .cp-avatar {
        width: 76px;
        height: 76px;
        font-size: 1.5rem;
        border-radius: 16px;
    }

    .cp-hero__chips,
    .cp-hero__lawyer {
        justify-content: center;
    }

    .cp-hero__lawyer {
        flex-direction: column;
        gap: 0.35rem;
    }

    .cp-hero__since {
        border-left: none;
        padding-left: 0;
        width: 100%;
        text-align: center;
    }

    .cp-hero__metrics {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 0.5rem;
    }

    .cp-metric {
        width: 100%;
        min-width: 0;
        padding: 0.85rem 1rem;
        align-items: center;
        text-align: center;
    }

    .cp-metric__value {
        font-size: 1.5rem;
    }

    .cp-hero__footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        padding: 1rem var(--cp-pad);
    }

    .cp-quick {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
        gap: 0.5rem;
    }

    .cp-quick__btn {
        justify-content: center;
        padding: 0.65rem 0.5rem;
        font-size: var(--text-xs);
        min-height: 48px;
    }

    .cp-hero__actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        gap: 0.5rem;
    }

    .cp-hero__actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .cp-aside {
        gap: 0.75rem;
    }

    .cp-card {
        padding: 1rem 1.1rem;
    }

    .cp-tabs {
        padding: 0.5rem;
        gap: 0.25rem;
        scroll-snap-type: x mandatory;
    }

    .cp-tab {
        scroll-snap-align: start;
        padding: 0.6rem 0.85rem;
        font-size: var(--text-xs);
        min-height: 44px;
    }

    .cp-panel__inner {
        padding: 1rem;
    }

    .cp-summary-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .cp-summary-item {
        padding: 0.85rem 1rem;
    }

    .cp-split {
        gap: 1.5rem;
    }

    .cp-section__head,
    .cp-section__head--lg {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .cp-section__head--lg {
        margin-bottom: 1.25rem;
    }

    .cp-section__head .btn,
    .cp-section__head--lg .btn {
        width: 100%;
        justify-content: center;
    }

    .cp-link-btn {
        align-self: flex-start;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .cp-row {
        flex-wrap: wrap;
        gap: 0.65rem 0.75rem;
        padding: 0.85rem 1rem;
    }

    .cp-row__body {
        flex: 1 1 calc(100% - 56px);
        min-width: 0;
    }

    .cp-row__title {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.35;
    }

    .cp-row .badge {
        flex-shrink: 0;
        margin-left: auto;
    }

    .cp-row__chev,
    .cp-row__arrow {
        display: none;
    }

    .cp-rows--cards .cp-row--card {
        padding: 1rem;
    }

    .cp-timeline {
        padding-left: 1rem;
        gap: 1rem;
    }

    .cp-timeline__dot {
        left: -1.1rem;
        width: 8px;
        height: 8px;
    }

    .cp-timeline__content {
        padding: 0.75rem 0.85rem;
    }

    .cp-zero {
        padding: 1.75rem 1rem;
    }

    .cp-zero .btn {
        width: 100%;
        justify-content: center;
    }

    .cp-zero--lg {
        padding: 2rem 1.25rem;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .cp-quick {
        grid-template-columns: 1fr;
    }

    .cp-hero__metrics {
        grid-template-columns: 1fr;
    }

    .cp-hero__name {
        font-size: 1.5rem;
    }
}

@media print {
    .sidebar,
    .sidebar-overlay,
    .topbar,
    .alert,
    .no-print,
    .cp-tabs,
    .cp-quick,
    .cp-hero__actions,
    .cp-link-btn,
    .footer {
        display: none !important;
    }

    .main-wrapper,
    .content-area,
    .cp {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
    }

    .only-print,
    .cp-print-sheet.only-print {
        display: block !important;
        text-align: center;
        padding-bottom: 1.5rem;
        margin-bottom: 1rem;
        border-bottom: 2px solid #AA9166;
    }

    .cp-print-logo {
        max-width: 140px;
        height: auto;
        margin: 0 auto 0.75rem;
    }

    .cp-print-sheet h1 {
        font-family: Georgia, serif;
        font-size: 1.5rem;
        margin: 0 0 0.35rem;
        color: #6A1F27;
    }

    .cp-print-meta {
        font-size: 0.85rem;
        color: #5c6570;
        margin: 0;
    }

    .cp-hero,
    .cp-card,
    .cp-main {
        break-inside: avoid;
        box-shadow: none !important;
    }

    .cp-body { display: block !important; }

    .cp-aside { margin-bottom: 1rem; }

    .cp-panel[hidden] { display: none !important; }

    .cp-panel.is-active { display: block !important; }

    body { background: #fff !important; }
}

/* Detail fields (profile cards) */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

.detail-item {
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    transition: border-color var(--transition), background var(--transition);
}

.detail-item:hover {
    border-color: var(--border);
    background: var(--surface);
}

.detail-item label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
}

.detail-item span,
.detail-item p {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
}

.detail-item a {
    font-weight: 600;
}

/* ==========================================================================
   Modern data tables
   ========================================================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: calc(var(--space-xl) * -1);
    margin-top: 0;
    padding: 0;
}

.card .table-responsive {
    margin: 0;
}

.card-body.table-responsive,
.card .card-body:has(.table-responsive) {
    padding: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    border-radius: inherit;
}

.card .card-body:has(.table-responsive) .table {
    margin: 0;
}

.table-clients {
    min-width: 36rem;
    table-layout: auto;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
}

.table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.table th {
    padding: 0.875rem 1.25rem;
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table th:first-child { padding-left: var(--space-xl); }
.table th:last-child { padding-right: var(--space-xl); }

.table td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-weight: var(--font-medium);
    line-height: var(--leading-snug);
}

.table td:first-child { padding-left: var(--space-xl); }
.table td:last-child { padding-right: var(--space-xl); }

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: var(--burgundy-muted);
}

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

.table tbody tr:last-child td:first-child {
    border-bottom-left-radius: var(--radius-lg);
}

.table tbody tr:last-child td:last-child {
    border-bottom-right-radius: var(--radius-lg);
}

.table a {
    font-weight: 600;
    color: var(--burgundy);
}

.table a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.table .empty-state,
.table td.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Clients listing — readable cells */
.table-clients th {
    color: var(--charcoal);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.table-clients td {
    color: var(--charcoal);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.45;
}

.table-clients .cell-name {
    font-weight: 600;
    color: var(--text-primary);
}

.table-clients .cell-muted {
    color: var(--text-secondary);
    font-weight: 500;
}

.table-staff .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.staff-avatar-img,
.staff-avatar-fallback {
    width: 5rem;
    height: 5rem;
    border-radius: 999px;
}

.staff-avatar-img {
    object-fit: cover;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.staff-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border: 1px solid rgba(106, 31, 39, 0.16);
}

.staff-onboarding {
    display: grid;
    gap: var(--space-lg);
}

.staff-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-md);
}

.staff-onboarding-head {
    padding: var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--surface) 0%, #fff 100%);
}

.staff-onboarding-eyebrow {
    margin: 0 0 0.3rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--burgundy);
}

.staff-onboarding-title {
    margin: 0;
    font-size: 1.35rem;
}

.staff-onboarding-subtitle {
    margin: 0.4rem 0 0;
    color: var(--text-secondary);
}

.staff-onboarding-card {
    border-radius: var(--radius-lg);
}

.staff-onboarding-grid {
    display: grid;
    gap: var(--space-xl);
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
}

.staff-onboarding-fields {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    min-width: 0;
}

.staff-avatar-pane {
    padding: var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    align-self: start;
}

.staff-avatar-preview-wrap {
    margin-bottom: var(--space-md);
}

.staff-avatar-preview {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1/1;
    border-radius: var(--radius-lg);
    object-fit: cover;
    border: 1px solid var(--border);
}

.staff-avatar-empty {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1/1;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border);
    background: var(--surface-muted);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.staff-avatar-preview.is-hidden,
.staff-avatar-empty.is-hidden {
    display: none;
}

.staff-onboarding-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-top: var(--space-lg);
    padding-top: var(--space-sm);
}

.staff-view-name-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 767px) {
    .staff-view-name-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .staff-onboarding-grid {
        grid-template-columns: 1fr;
    }

    .staff-avatar-preview,
    .staff-avatar-empty {
        max-width: 180px;
    }
}

.table-clients .col-actions,
.table-cases .col-actions,
.table-appointments .col-actions,
.table-invoices .col-actions {
    width: 1%;
    min-width: 7.5rem;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

.table-clients .col-actions .action-dropdown,
.table-cases .col-actions .action-dropdown,
.table-appointments .col-actions .action-dropdown,
.table-invoices .col-actions .action-dropdown {
    display: inline-flex;
    justify-content: center;
}

.table-clients .action-dropdown-btn,
.table-cases .action-dropdown-btn,
.table-appointments .action-dropdown-btn,
.table-invoices .action-dropdown-btn {
    max-width: 100%;
}

.table-appointments {
    min-width: 44rem;
}

.table-invoices {
    min-width: 44rem;
}

.table-invoices .invoice-status-text {
    font-weight: 600;
}

.table-invoices .invoice-status--paid {
    color: var(--success);
}

.table-invoices .invoice-status--partially_paid {
    color: var(--warning);
}

.table-invoices .invoice-status--not_paid {
    color: var(--danger);
}

/* Clients table — tablet / narrow content */
@media (max-width: 1100px) {
    .content-area:has(.list-toolbar) {
        overflow-x: hidden;
        max-width: 100%;
    }

    .list-toolbar {
        padding-right: 0;
    }

    .table-clients,
    .table-cases,
    .table-appointments,
    .table-invoices {
        min-width: 34rem;
    }

    .table-clients th,
    .table-clients td,
    .table-cases th,
    .table-cases td {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .table-clients th:first-child,
    .table-clients td:first-child,
    .table-cases th:first-child,
    .table-cases td:first-child {
        padding-left: 1rem;
    }

    .table-clients th.col-actions,
    .table-clients td.col-actions,
    .table-cases th.col-actions,
    .table-cases td.col-actions,
    .table-appointments th.col-actions,
    .table-appointments td.col-actions,
    .table-invoices th.col-actions,
    .table-invoices td.col-actions {
        padding-right: 1rem;
        min-width: 8rem;
    }

    .table th {
        white-space: nowrap;
    }

    .table-clients .cell-name,
    .table-cases .cell-name {
        max-width: 10rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-clients .cell-muted,
    .table-cases .cell-muted {
        max-width: 8rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 767px) {
    /* Scrollable table: let columns grow — no ellipsis */
    .table-clients {
        width: max-content;
        min-width: 100%;
    }

    .table-clients th,
    .table-clients td {
        padding-left: 1rem;
        padding-right: 1rem;
        white-space: nowrap;
    }

    .table-clients .cell-name,
    .table-clients .cell-muted {
        max-width: none;
        overflow: visible;
        text-overflow: unset;
        white-space: nowrap;
    }

    .table-clients th:nth-child(1),
    .table-clients td:nth-child(1) {
        min-width: 6.25rem;
    }

    .table-clients th:nth-child(2),
    .table-clients td:nth-child(2) {
        min-width: 7rem;
    }

    .table-clients th:nth-child(3),
    .table-clients td:nth-child(3) {
        min-width: 8.5rem;
    }

    .table-clients th:nth-child(4),
    .table-clients td:nth-child(4) {
        min-width: 7.5rem;
    }

    .table-clients th:nth-child(5),
    .table-clients td:nth-child(5) {
        min-width: 6.5rem;
    }

    .table.table-clients th.col-actions {
        min-width: 6.25rem;
        padding-left: 1rem;
        padding-right: 1rem;
        text-align: center;
        vertical-align: middle;
    }

    .table.table-clients td.col-actions {
        min-width: 6.25rem;
        padding-left: 1rem;
        padding-right: 1rem;
        text-align: center;
        vertical-align: middle;
    }

    .table-clients .col-actions .action-dropdown {
        display: flex;
        width: 100%;
        justify-content: center;
    }

    .table-clients .col-actions .action-dropdown-btn {
        width: 100%;
        justify-content: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
        box-sizing: border-box;
    }
}

/* Row action dropdown */
.action-dropdown {
    position: relative;
    display: inline-block;
}

.action-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.875rem;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--burgundy);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.action-dropdown-btn:hover,
.action-dropdown-btn[aria-expanded="true"] {
    background: var(--burgundy-muted);
    border-color: rgba(106, 31, 39, 0.25);
    box-shadow: var(--shadow-sm);
}

.action-dropdown-btn .icon-svg {
    opacity: 0.7;
    transition: transform var(--transition);
}

.action-dropdown-btn[aria-expanded="true"] .icon-chevron {
    transform: rotate(180deg);
}

.action-dropdown-menu {
    display: none;
    position: fixed;
    z-index: 2500;
    min-width: 268px;
    max-width: min(320px, calc(100vw - 1.5rem));
    max-height: min(70vh, 420px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.4rem 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(18, 21, 24, 0.14);
    -webkit-overflow-scrolling: touch;
}

.action-dropdown-menu.show {
    display: block;
}

.action-dropdown-menu[data-placement="below"] {
    transform-origin: top right;
}

.action-dropdown-menu[data-placement="above"] {
    transform-origin: bottom right;
}

.action-dropdown-group {
    padding: 0.2rem 0;
}

.action-dropdown-group + .action-dropdown-group {
    margin-top: 0.35rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border-subtle);
}

.action-dropdown-group-status {
    display: flex;
    flex-direction: column;
    margin: 0.35rem 0.5rem 0.45rem;
    padding: 0.35rem 0 0.25rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface-elevated) 0%, var(--white) 100%);
}

.action-dropdown-group-status .action-dropdown-form {
    order: 10;
}

.action-dropdown-group-status .action-dropdown-form[data-status-order="ongoing"] { order: 1; }
.action-dropdown-group-status .action-dropdown-form[data-status-order="cancelled"] { order: 2; }
.action-dropdown-group-status .action-dropdown-form[data-status-order="completed"] { order: 3; }

.action-dropdown-status-item.is-current {
    order: 1;
    cursor: default;
    background: var(--burgundy-muted);
    color: var(--burgundy);
    font-weight: 600;
}

.action-dropdown-status-item.is-current.is-status-cancelled { order: 2; }
.action-dropdown-status-item.is-current.is-status-completed { order: 3; }

.action-dropdown-status-hint {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
}

.action-dropdown-group-status .action-dropdown-label {
    padding-left: 0.875rem;
    padding-right: 0.875rem;
}

.action-dropdown-divider {
    height: 1px;
    margin: 0.35rem 0;
    background: var(--border-subtle);
}

.action-dropdown-label {
    display: block;
    padding: 0.35rem 1rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    text-align: left;
}

.action-dropdown-current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem 0.55rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

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

.action-dropdown-form {
    margin: 0;
    display: block;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot-ongoing { background: #3b82f6; }
.status-dot-completed { background: var(--success); }
.status-dot-cancelled { background: var(--danger); }

.status-dot-open { background: #3b82f6; }
.status-dot-active { background: var(--success); }
.status-dot-pending { background: var(--warning); }
.status-dot-on_hold { background: #94a3b8; }
.status-dot-closed { background: #64748b; }
.status-dot-won { background: var(--success); }
.status-dot-lost { background: var(--danger); }
.status-dot-settled { background: #0d9488; }

.status-dot-scheduled { background: #3b82f6; }
.status-dot-confirmed { background: var(--success); }

.action-dropdown-status-item .status-dot {
    margin-right: -0.15rem;
}

.action-dropdown-status-item.is-status-ongoing:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.08);
    color: #1d4ed8;
}

.action-dropdown-status-item.is-status-completed:hover:not(:disabled) {
    background: var(--success-bg);
    color: var(--success);
}

.action-dropdown-status-item.is-status-cancelled:hover:not(:disabled) {
    background: var(--danger-bg);
    color: var(--danger);
}

.action-dropdown-group-status--case .action-dropdown-form[data-status-order="open"] { order: 1; }
.action-dropdown-group-status--case .action-dropdown-form[data-status-order="active"] { order: 2; }
.action-dropdown-group-status--case .action-dropdown-form[data-status-order="pending"] { order: 3; }
.action-dropdown-group-status--case .action-dropdown-form[data-status-order="on_hold"] { order: 4; }
.action-dropdown-group-status--case .action-dropdown-form[data-status-order="closed"] { order: 5; }
.action-dropdown-group-status--case .action-dropdown-form[data-status-order="won"] { order: 6; }
.action-dropdown-group-status--case .action-dropdown-form[data-status-order="lost"] { order: 7; }
.action-dropdown-group-status--case .action-dropdown-form[data-status-order="settled"] { order: 8; }

.action-dropdown-status-item.is-status-open:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.08);
    color: #1d4ed8;
}

.action-dropdown-status-item.is-status-active:hover:not(:disabled),
.action-dropdown-status-item.is-status-won:hover:not(:disabled),
.action-dropdown-status-item.is-status-settled:hover:not(:disabled) {
    background: var(--success-bg);
    color: var(--success);
}

.action-dropdown-status-item.is-status-pending:hover:not(:disabled),
.action-dropdown-status-item.is-status-on_hold:hover:not(:disabled) {
    background: var(--warning-bg, rgba(245, 158, 11, 0.1));
    color: var(--warning);
}

.action-dropdown-status-item.is-status-closed:hover:not(:disabled) {
    background: var(--gray-50, #f8fafc);
    color: var(--text-secondary);
}

.action-dropdown-status-item.is-status-lost:hover:not(:disabled) {
    background: var(--danger-bg);
    color: var(--danger);
}

.returning-client-card {
    margin-bottom: var(--space-lg);
}

.card-header-desc {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.returning-client-results {
    margin-top: var(--space-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.returning-client-hit {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    color: inherit;
    transition: background var(--transition);
}

.returning-client-hit:last-child {
    border-bottom: 0;
}

.returning-client-hit:hover {
    background: var(--burgundy-muted);
    color: inherit;
}

.returning-client-hit-main {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.returning-client-hit-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--burgundy);
}

.returning-client-hit-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.returning-client-empty {
    margin: 0;
    padding: 0.75rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.opposing-party-field {
    position: relative;
}

.opposing-party-results {
    margin-top: var(--space-sm);
}

.opposing-party-hit {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.action-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-primary);
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition), color var(--transition);
    box-sizing: border-box;
}

a.action-dropdown-item,
a.action-dropdown-item:hover {
    text-decoration: none;
}

.action-dropdown-item .icon-svg {
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.action-dropdown-item:hover:not(.is-disabled) {
    background: var(--surface-muted);
    color: var(--text-primary);
}

.action-dropdown-item:hover:not(.is-disabled) .icon-svg {
    color: var(--text-secondary);
}

.action-dropdown-item.is-danger {
    color: var(--danger);
}

.action-dropdown-item.is-danger .icon-svg {
    color: var(--danger);
}

.action-dropdown-item.is-danger:hover:not(.is-disabled) {
    background: var(--danger-bg);
    color: var(--danger);
}

.action-dropdown-item.is-disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.55;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-normal);
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
    line-height: var(--leading-tight);
}

.btn-primary {
    background: var(--burgundy);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(106, 31, 39, 0.25);
}
.btn-primary:hover {
    background: var(--burgundy-light);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(106, 31, 39, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gold);
    color: var(--charcoal);
}
.btn-secondary:hover {
    background: var(--gold-light);
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--burgundy);
}
.btn-outline:hover {
    border-color: var(--burgundy);
    background: var(--burgundy-muted);
}

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.btn-danger { background: var(--danger); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }

.btn-icon {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: var(--radius);
    transition: all var(--transition);
}
.btn-icon:hover {
    background: var(--surface-muted);
    border-color: var(--gold);
    color: var(--burgundy);
}

/* Contact chips */
.contact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.btn-contact {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn-contact:hover {
    transform: translateY(-1px);
    color: var(--white);
}

.btn-email { background: var(--charcoal); color: var(--white); }
.btn-call { background: var(--burgundy); color: var(--white); }
.btn-sms { background: var(--gold-dark); color: var(--white); }
.btn-whatsapp { background: #128c7e; color: var(--white); }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-group { margin-bottom: var(--space-lg); }
.form-group-full { grid-column: 1 / -1; }

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
    letter-spacing: var(--tracking-wide);
}

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-base);
    font-family: inherit;
    line-height: var(--leading-normal);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--surface);
    color: var(--text-primary);
}

.form-control:hover {
    border-color: #d0d4d9;
}

.form-control:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 4px var(--gold-muted);
}

select.form-control { cursor: pointer; }

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    line-height: 1.55;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

.form-label-optional {
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
}

/* ==========================================================================
   Settings — practice areas
   ========================================================================== */
.settings-page {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    width: 100%;
    max-width: 72rem;
}

.settings-card + .settings-card,
.settings-page .settings-card + .settings-card {
    margin-top: 0;
}

.settings-form-page__form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding-bottom: 5rem;
}

.settings-form-divider {
    height: 1px;
    margin: var(--space-lg) 0 var(--space-md);
    background: var(--border-subtle);
}

.settings-form-subsection {
    margin-bottom: 0.25rem;
}

.settings-form-subsection__title {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-form-subsection__hint {
    margin: 0 0 var(--space-sm);
}

.settings-form-page__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    position: sticky;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
    z-index: 5;
}

.settings-form-page__btn-save {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.75rem;
    padding-left: 1.25rem;
    padding-right: 1.35rem;
}

.settings-form-page__btn-save .icon-svg {
    flex-shrink: 0;
}

@media (max-width: 639px) {
    .settings-form-page__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .settings-form-page__btn-save {
        width: 100%;
        justify-content: center;
    }
}

.card-header--stacked {
    align-items: flex-start;
}

.card-header__text {
    flex: 1;
    min-width: 0;
}

.card-header--stacked .card-header-desc {
    margin-top: 0.35rem;
}

.practice-areas-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.practice-areas-card:has(.table-responsive) {
    overflow: hidden;
}

.practice-areas-card .card-header {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.practice-areas-card .card-body,
.practice-areas-card .card-body:has(.table-responsive) {
    padding: clamp(1.25rem, 3vw, 1.75rem);
}

.practice-areas-toolbar.list-toolbar {
    width: 100%;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

.practice-areas-toolbar .list-toolbar-search-wrap {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.75rem 1rem;
    flex: 1 1 auto;
    min-width: 0;
}

.practice-areas-toolbar .table-live-search {
    margin-bottom: 0;
    flex: 0 0 auto;
    width: min(100%, 300px);
    max-width: 300px;
}

.practice-areas-toolbar .table-live-search .form-control {
    min-height: 2.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.9375rem;
    border-radius: var(--radius);
    box-sizing: border-box;
}

.practice-areas-toolbar .list-toolbar-count {
    flex-shrink: 0;
    margin: 0;
    font-size: 0.8125rem;
}

.practice-areas-toolbar .list-toolbar-count-num {
    font-size: 0.9375rem;
}

.practice-areas-toolbar .list-toolbar-action {
    align-self: center;
    margin-left: auto;
    min-height: 2.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: var(--font-semibold);
    border-radius: var(--radius);
    box-sizing: border-box;
}

.practice-areas-add-panel {
    margin-bottom: var(--space-lg);
    padding: clamp(1.15rem, 2.5vw, 1.5rem);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
}

.practice-areas-add-panel[hidden] {
    display: none;
}

.practice-areas-add-panel__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.practice-areas-add-panel .form-group {
    margin-bottom: 0;
    min-width: 0;
}

.practice-areas-add-panel .form-label {
    margin-bottom: 0.5rem;
}

.practice-areas-add-panel .form-control {
    width: 100%;
    box-sizing: border-box;
}

.practice-areas-add-panel__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.practice-areas-list {
    margin-top: 0.5rem;
}

.practice-areas-list__title {
    margin: 0 0 0.75rem;
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: var(--font-semibold);
    line-height: 1.3;
    color: var(--text-primary);
}

.practice-areas-table-wrap {
    border: 1px solid var(--border);
    border-radius: 0;
    overflow: hidden;
    background: var(--white);
}

.table-practice-areas {
    margin: 0;
    border-collapse: collapse;
}

.table-practice-areas thead th {
    padding: 0.85rem 1.15rem;
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.table-practice-areas thead th:first-child,
.table-practice-areas thead th:last-child {
    border-radius: 0;
}

.table-practice-areas tbody tr:last-child td:first-child,
.table-practice-areas tbody tr:last-child td:last-child {
    border-radius: 0;
}

.table-practice-areas tbody td {
    padding: 0.9rem 1.15rem;
    vertical-align: middle;
}

.table-practice-areas tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--border-subtle);
}

.table-practice-areas .cell-name {
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.table-practice-areas .cell-muted {
    color: var(--text-secondary);
    line-height: 1.45;
}

.table-practice-areas .col-cases {
    width: 5.5rem;
    text-align: center;
}

.practice-areas-case-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    padding: 0.2rem 0.55rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    font-variant-numeric: tabular-nums;
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border-radius: 999px;
}

.table-practice-areas .col-actions {
    width: 8.5rem;
    text-align: center;
}

.practice-areas-delete-form {
    margin: 0;
    display: flex;
    justify-content: center;
}

.btn-delete {
    min-height: 2.35rem;
    padding: 0.5rem 1.1rem;
    font-size: 0.875rem;
    font-weight: var(--font-semibold);
    color: var(--danger);
    border-color: rgba(180, 35, 24, 0.35);
    background: var(--white);
}

.btn-delete:hover {
    color: var(--white);
    background: var(--danger);
    border-color: var(--danger);
}

@media (max-width: 720px) {
    .practice-areas-toolbar.list-toolbar {
        flex-wrap: wrap;
    }

    .practice-areas-toolbar .list-toolbar-search-wrap {
        flex-wrap: wrap;
    }

    .practice-areas-toolbar .table-live-search {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }

    .practice-areas-toolbar .list-toolbar-count {
        width: 100%;
    }

    .practice-areas-toolbar .list-toolbar-action {
        width: 100%;
        margin-left: 0;
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .practice-areas-add-panel__grid {
        grid-template-columns: 1fr;
    }

    .practice-areas-add-panel__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .practice-areas-add-panel__actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   Badges & alerts
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    line-height: var(--leading-snug);
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-secondary { background: var(--surface-muted); color: var(--text-secondary); }

.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(13, 122, 78, 0.2);
}
.alert-error, .alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(180, 35, 24, 0.2);
}
.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
}
.alert-info {
    background: var(--info-bg);
    color: var(--info);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
    padding: 0.25rem;
}
.alert-close:hover { opacity: 1; }

/* Custom confirm modal */
.confirm-modal-root {
    position: fixed;
    inset: 0;
    z-index: 1600;
    display: none;
}

.confirm-modal-root.is-open {
    display: grid;
    place-items: center;
}

.confirm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(2px);
}

.confirm-modal {
    position: relative;
    width: min(92vw, 460px);
    background: #1d1810;
    color: #f8f2e0;
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 14px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
    padding: 1.15rem 1.15rem 1rem;
}

.confirm-modal-title {
    margin: 0 0 0.45rem;
    font-size: 1.03rem;
    font-weight: 700;
    color: #fff4cf;
}

.confirm-modal-message {
    margin: 0;
    font-size: 0.94rem;
    line-height: 1.5;
    color: #f5ebd3;
}

.confirm-modal-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.confirm-modal-actions .btn {
    min-width: 88px;
}

/* Live table search */
.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.list-toolbar-search-wrap {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.75rem 1rem;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

.list-toolbar-count {
    display: inline-flex;
    align-items: baseline;
    flex-shrink: 0;
    gap: 0.35rem;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    white-space: nowrap;
    line-height: 1.3;
}

.list-toolbar-count-num {
    font-size: 1.0625rem;
    font-weight: var(--font-bold);
    font-variant-numeric: tabular-nums;
    color: var(--burgundy);
    letter-spacing: -0.02em;
}

.list-toolbar .table-live-search {
    flex: 0 0 auto;
    width: 300px;
    max-width: min(300px, 100%);
    min-width: 10rem;
    margin-bottom: 0;
}

.list-toolbar-search-wrap .table-live-search {
    flex: 0 0 auto;
    width: 300px;
    max-width: min(300px, 100%);
    min-width: 10rem;
    margin-bottom: 0;
}

.list-toolbar .table-live-search .form-control {
    max-width: none;
    width: 100%;
}

.table-live-search-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.table-live-search-control .table-live-search-input {
    flex: 1;
    min-width: 0;
}

.table-live-search-clear {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.table-live-search-clear:hover {
    background: var(--surface-muted);
    color: var(--burgundy);
    border-color: var(--burgundy);
}

.table-live-search-clear[hidden] {
    display: none;
}

.list-toolbar-action {
    flex-shrink: 0;
    margin-left: auto;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    border-radius: var(--radius);
}

@media (max-width: 768px) {
    .list-toolbar {
        gap: 0.75rem;
    }

    .list-toolbar-search-wrap {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        flex-wrap: wrap;
        box-sizing: border-box;
    }

    .list-toolbar .table-live-search,
    .list-toolbar-search-wrap .table-live-search {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .list-toolbar-count {
        flex: 0 0 auto;
        width: 100%;
        padding-top: 0.15rem;
    }

    .list-toolbar-action {
        flex: 1 1 auto;
        width: 100%;
        margin-left: 0;
        justify-content: center;
    }
}

.table-live-search {
    margin-bottom: var(--space-md);
}

.table-live-search .form-control {
    max-width: 460px;
}

.table-live-empty td {
    text-align: center;
    color: var(--text-tertiary);
    padding: 1rem !important;
}

/* Search & filters */
.search-bar {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-lg);
    padding: 0.9rem 1rem;
    background: linear-gradient(180deg, #ffffff, #fbfcfe);
    border: 1px solid #e5e9f0;
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.search-bar .form-control {
    max-width: 420px;
    flex: 1;
    min-width: 220px;
}

.modern-search .search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: min(100%, 460px);
}

.search-input-icon {
    position: absolute;
    left: 0.9rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

.modern-search .table-live-search-input,
.modern-search input[type="search"].form-control {
    padding-left: 2.45rem;
    border-radius: 999px;
    border-color: #d9e0ea;
    background: #fff;
}

.modern-search .table-live-search-input:focus,
.modern-search input[type="search"].form-control:focus {
    border-color: #b8c8dd;
    box-shadow: 0 0 0 4px rgba(168, 191, 221, 0.24);
}

.modern-search {
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem;
    background: #e5e5e2;
    border: 1px solid #d5d7d2;
    border-radius: 18px;
    box-shadow: none;
}

.modern-search .search-filters-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    flex-wrap: wrap;
}

.modern-search .search-input-wrap {
    width: min(100%, 360px);
}

.modern-search input[type="search"].form-control,
.modern-search .search-filter-select {
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid #afc4bb;
    background: #f4f5f2;
    color: #2f3a35;
    box-shadow: none;
}

.modern-search .search-filter-select {
    width: 200px;
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 2.1rem;
}

.modern-search input[type="search"].form-control:hover,
.modern-search .search-filter-select:hover {
    border-color: #9fb8ae;
}

.modern-search input[type="search"].form-control:focus,
.modern-search .search-filter-select:focus {
    border-color: #8ead9f;
    box-shadow: 0 0 0 3px rgba(142, 173, 159, 0.22);
    background: #f8f9f6;
}

.modern-search .search-filter-apply,
.modern-search .search-filter-clear {
    min-height: 44px;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    border-color: #afc4bb;
    color: #2f3a35;
    background: #f4f5f2;
}

.modern-search .search-filter-apply:hover,
.modern-search .search-filter-clear:hover {
    border-color: #8ead9f;
    background: #ecefea;
    color: #1f2b26;
}

.modern-search .search-filter-clear {
    margin-left: auto;
}

@media (max-width: 700px) {
    .modern-search .search-filter-clear {
        margin-left: 0;
    }
}

/* Layout grids */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
}

/* Calendar list */
.calendar-list { list-style: none; }

.calendar-list li {
    padding: var(--space-md) var(--space-lg);
    border-left: 3px solid var(--gold);
    margin-bottom: var(--space-sm);
    background: var(--surface-elevated);
    border-radius: 0 var(--radius) var(--radius) 0;
    border: 1px solid var(--border-subtle);
    border-left-width: 3px;
    border-left-color: var(--gold);
    transition: background var(--transition);
}

.calendar-list li:hover {
    background: var(--surface);
}

.calendar-list strong {
    font-weight: 600;
    color: var(--text-primary);
}

/* Tabs (legacy) */
.tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    padding: var(--space-xs);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

.tab-link {
    padding: 0.6rem 1.125rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-radius: var(--radius);
    white-space: nowrap;
    transition: all var(--transition);
}

.tab-link:hover {
    color: var(--burgundy);
    background: var(--burgundy-muted);
}

.tab-link.active {
    color: var(--white);
    background: var(--burgundy);
    box-shadow: var(--shadow-xs);
}

/* Schedule — Upcoming / Past segmented control */
.schedule-view-bar-wrap {
    margin-bottom: var(--space-md);
}

.schedule-view-bar {
    display: inline-flex;
    align-items: stretch;
    gap: 0.2rem;
    width: fit-content;
    max-width: 100%;
    padding: 0.3rem;
    background: linear-gradient(180deg, #eceae6 0%, #e3e0da 100%);
    border: 1px solid rgba(106, 31, 39, 0.1);
    border-radius: 999px;
    box-shadow:
        inset 0 1px 2px rgba(15, 23, 42, 0.06),
        0 1px 2px rgba(255, 255, 255, 0.65) inset,
        0 2px 8px rgba(15, 23, 42, 0.04);
    box-sizing: border-box;
}

.schedule-view-bar__tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 7.25rem;
    padding: 0.65rem 1.65rem;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    color: #6b6560;
    text-decoration: none;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid transparent;
    transition:
        color 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease;
}

.schedule-view-bar__tab:hover:not(.is-active) {
    color: var(--burgundy);
    background: rgba(255, 255, 255, 0.45);
}

.schedule-view-bar__tab.is-active {
    color: var(--burgundy-dark);
    background: linear-gradient(180deg, #ffffff 0%, #f8f6f3 100%);
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 4px 14px rgba(106, 31, 39, 0.14),
        0 0 0 1px rgba(170, 145, 102, 0.22);
    transform: translateY(-0.5px);
}

.schedule-view-bar__tab.is-active::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0.42rem;
    width: 1.35rem;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
    transform: translateX(-50%);
    opacity: 0.9;
}

@media (max-width: 768px) {
    .schedule-view-bar {
        display: flex;
        width: 100%;
        padding: 0.28rem;
    }

    .schedule-view-bar__tab {
        flex: 1 1 0;
        min-width: 0;
        padding: 0.6rem 0.85rem;
        font-size: 0.75rem;
        letter-spacing: 0.035em;
    }
}

/* Pagination (legacy + modern table pagination) */
.pagination {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    margin-top: var(--space-xl);
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.pagination a:hover,
.pagination .active {
    background: var(--burgundy);
    color: var(--white);
    border-color: var(--burgundy);
}

.table-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    margin-top: var(--space-lg);
    padding: 1rem 1.25rem;
    background: linear-gradient(180deg, var(--surface-elevated) 0%, var(--white) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.table-pagination__summary {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.45;
}

.table-pagination__summary strong {
    color: var(--text-primary);
    font-weight: var(--font-bold);
    font-variant-numeric: tabular-nums;
}

.table-pagination__sep {
    margin: 0 0.35rem;
    color: var(--text-tertiary);
}

.table-pagination__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    max-width: 100%;
}

.table-pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.8125rem;
    font-weight: var(--font-semibold);
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}

a.table-pagination__btn:hover {
    color: var(--burgundy);
    border-color: rgba(106, 31, 39, 0.35);
    background: var(--burgundy-muted);
}

.table-pagination__btn.is-active {
    background: var(--burgundy);
    color: var(--white);
    border-color: var(--burgundy);
    box-shadow: 0 2px 8px rgba(106, 31, 39, 0.22);
    cursor: default;
}

.table-pagination__btn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.table-pagination__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 2.25rem;
    font-size: 0.875rem;
    color: var(--text-tertiary);
    user-select: none;
}

@media (max-width: 640px) {
    .table-pagination {
        padding: 0.85rem 0.75rem;
    }

    .table-pagination__controls {
        gap: 0.25rem;
    }

    .table-pagination__btn {
        min-width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-tertiary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.table-empty-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-top: var(--space-lg);
    padding: clamp(2rem, 5vw, 2.75rem) 1.5rem;
    background: linear-gradient(180deg, var(--surface-elevated) 0%, var(--white) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.table-empty-placeholder__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 5.25rem;
    height: 5.25rem;
    margin-bottom: 1.15rem;
    border-radius: 50%;
    background: var(--burgundy);
    box-shadow: 0 8px 24px rgba(106, 31, 39, 0.28);
}

.table-empty-placeholder__scale {
    color: #f5ebd3;
    stroke: #f5ebd3;
}

.table-empty-placeholder__title {
    margin: 0 0 0.4rem;
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.table-empty-placeholder__message {
    margin: 0;
    max-width: 26rem;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Invoice print */
.print-only { display: none; }

@media print {
    .sidebar, .topbar, .app-footer, .no-print, .sidebar-toggle { display: none !important; }
    .main-wrapper { margin: 0 !important; }
    .content-area { padding: 0; max-width: 100%; }
    body { background: white; }

    .staff-print-profile { display: none !important; }
    .print-only { display: block !important; }

    .staff-print-profile {
        max-width: 900px;
        margin: 0 auto;
        padding: 1.2rem;
        display: block;
    }

    .staff-print-profile .staff-onboarding-head {
        border: none;
        padding: 0 0 0.75rem;
        margin-bottom: 0.75rem;
        background: transparent;
        border-bottom: 2px solid #ddd;
        border-radius: 0;
    }

    .staff-print-profile .staff-onboarding-card {
        border: none;
        box-shadow: none;
    }

    .staff-print-profile .card-body {
        padding: 0;
    }

    .staff-print-profile .staff-avatar-preview-wrap {
        border-color: #ddd;
    }

    .staff-print-profile .form-control {
        border-color: #ddd;
        background: #fff;
    }

    .staff-print-profile .print-hide {
        display: none !important;
    }

    .staff-business-print-sheet {
        max-width: 900px;
        margin: 0 auto;
        padding: 0.8rem;
        font-family: "Inter", Arial, sans-serif;
        color: #1f2937;
    }

    .staff-print-header {
        background: #1d4f8f;
        color: #fff;
        padding: 0.9rem 1rem;
        border-radius: 0;
        margin-bottom: 0.85rem;
        display: flex;
        justify-content: space-between;
        gap: 1rem;
    }

    .staff-print-header h1 {
        margin: 0;
        font-size: 1.05rem;
    }

    .staff-print-header p {
        margin: 0.15rem 0 0;
        font-size: 0.82rem;
        opacity: 0.95;
    }

    .staff-print-kicker {
        margin: 0;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-size: 0.72rem;
        font-weight: 700;
    }

    .staff-print-meta {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        text-align: right;
        font-size: 0.74rem;
        gap: 0.2rem;
    }

    .staff-print-section h2 {
        margin: 0 0 0.45rem;
        background: #2f75b5;
        color: #fff;
        padding: 0.32rem 0.5rem;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .staff-print-grid {
        display: grid;
        grid-template-columns: 180px 1fr;
        gap: 0.8rem;
        margin-bottom: 0.8rem;
    }

    .staff-print-photo-cell .label {
        display: block;
        font-size: 0.72rem;
        font-weight: 600;
        margin-bottom: 0.35rem;
        color: #475569;
    }

    .staff-print-photo {
        width: 100%;
        aspect-ratio: 3 / 4;
        object-fit: cover;
        border: 1px solid #d1d5db;
    }

    .staff-print-photo-fallback {
        width: 100%;
        aspect-ratio: 3 / 4;
        border: 1px solid #d1d5db;
        display: grid;
        place-items: center;
        font-size: 1.3rem;
        font-weight: 700;
        color: #334155;
        background: #f8fafc;
    }

    .staff-print-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 0.78rem;
    }

    .staff-print-table th,
    .staff-print-table td {
        border: 1px solid #d1d5db;
        padding: 0.38rem 0.5rem;
        text-align: left;
        vertical-align: top;
    }

    .staff-print-table th {
        width: 34%;
        background: #f8fafc;
        color: #334155;
        font-weight: 700;
    }

    .staff-print-bio {
        margin: 0;
        border: 1px solid #d1d5db;
        padding: 0.55rem 0.6rem;
        min-height: 80px;
        font-size: 0.78rem;
        line-height: 1.45;
        white-space: pre-wrap;
        background: #fff;
    }
}

/* ==========================================================================
   Invoice document (view + print)
   ========================================================================== */
.invoice-print,
.invoice-doc {
    position: relative;
    max-width: 52rem;
    margin: 0 auto;
    padding: 0;
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.55;
    overflow: hidden;
}

.invoice-doc__ribbon {
    position: absolute;
    top: 0.55rem;
    right: -5.15rem;
    z-index: 5;
    width: 17rem;
    padding: 0.48rem 0;
    background: #fff;
    color: var(--burgundy-dark);
    font-size: 0.81rem;
    font-weight: 950;
    letter-spacing: 0.04em;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
    text-transform: uppercase;
    transform: rotate(39deg);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
    border: 1px solid rgba(255, 255, 255, 0.95);
    pointer-events: none;
}

.invoice-doc__ribbon br {
    content: '';
}

.invoice-doc--paid .invoice-doc__ribbon {
    background: #e8f5e9;
    color: #1b5e20;
    border-color: #c8e6c9;
}

.invoice-doc--partial .invoice-doc__ribbon {
    background: #fff8e1;
    color: #b45309;
    border-color: #fde68a;
}

.invoice-doc--unpaid .invoice-doc__hero,
.invoice-doc--paid .invoice-doc__hero,
.invoice-doc--partial .invoice-doc__hero {
    padding-right: 6.1rem;
}

.invoice-doc--unpaid .invoice-doc__hero-doc,
.invoice-doc--paid .invoice-doc__hero-doc,
.invoice-doc--partial .invoice-doc__hero-doc {
    padding-top: 1.7rem;
    padding-right: 1rem;
}

.content-area > .invoice-print {
    margin-top: var(--space-md);
}

.invoice-view-page {
    max-width: 52rem;
    margin: 0 auto;
}

.invoice-view__toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin: 0 0 var(--space-md);
    padding: 0;
}

.invoice-view__print-btn,
.invoice-view__edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.invoice-tax-rate-field[readonly] {
    background: var(--surface-muted);
    cursor: default;
}

.invoice-totals-panel {
    max-width: 28rem;
    margin: var(--space-lg) 0 0 auto;
    padding: var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-elevated);
}

.invoice-totals-panel__fields {
    margin-bottom: var(--space-md);
}

.invoice-totals-panel__summary {
    margin: 0;
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
    text-align: right;
    font-size: var(--text-sm);
}

.invoice-totals-panel__summary p {
    margin: 0.35rem 0;
}

.invoice-totals-panel__grand {
    margin-top: 0.5rem !important;
    font-size: var(--text-base);
    color: var(--burgundy);
}

/* Hero band — firm left, invoice title right */
.invoice-doc__hero {
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--burgundy-dark) 0%, var(--burgundy) 55%, var(--burgundy-light) 100%);
    color: #fff;
    padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 4vw, 2rem) 0.4rem;
    padding-right: 3rem;
}

.invoice-doc__hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(10rem, auto);
    gap: clamp(1.25rem, 4vw, 2.5rem);
    align-items: start;
}

.invoice-doc__hero-firm {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.invoice-doc__brand-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.invoice-doc__logo {
    display: block;
    width: auto;
    max-width: 4.75rem;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.invoice-doc__brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    padding-top: 0.125rem;
}

.invoice-doc__firm-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1rem, 2.2vw, 1.25rem);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: var(--tracking-tight);
    color: #fff;
}

.invoice-doc__tagline {
    margin: 0;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--gold-light);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1.4;
}

.invoice-doc__firm-contact {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 20rem;
    padding-left: 0.125rem;
}

.invoice-doc__contact-line {
    margin: 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.6;
}

.invoice-doc__contact-line .icon-svg {
    vertical-align: -0.12em;
    margin-right: 0.35rem;
    opacity: 0.85;
}

.invoice-doc__hero-contact {
    margin: 0.75rem 0 0;
    padding: 0.5rem 0 0.35rem;
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.92);
}

.invoice-doc__hero-contact-item {
    display: inline;
    white-space: nowrap;
}

.invoice-doc__hero-contact-item .icon-svg {
    vertical-align: -0.12em;
    margin-right: 0.3rem;
    opacity: 0.9;
}

.invoice-doc__hero-contact-sep {
    margin: 0 0.65rem;
    opacity: 0.55;
}

.invoice-doc__hero-doc {
    text-align: right;
    padding-top: 0.125rem;
}

.invoice-doc__doc-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 2.75rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gold);
}

.invoice-doc__hero-meta {
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-end;
}

.invoice-doc__hero-meta-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.invoice-doc__hero-meta-row dt {
    margin: 0;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
}

.invoice-doc__hero-meta-row dd {
    margin: 0;
    font-weight: 600;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.invoice-doc__accent-bar {
    height: 0.5rem;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 70%, var(--burgundy) 100%);
}

.invoice-doc__body {
    padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 4vw, 2rem);
}

/* Info row — bill to left, ways to pay right */
.invoice-doc__info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(1.5rem, 4vw, 2.5rem);
    align-items: start;
    margin-bottom: var(--space-xl);
}

.invoice-doc__info-row--bill-only {
    grid-template-columns: 1fr;
}

.invoice-doc__bill-to {
    margin: 0;
    max-width: 20rem;
    text-align: left;
}

.invoice-doc__pay--info {
    margin: 0 0 0 auto;
    justify-self: end;
    width: min(100%, 17.5rem);
    text-align: right;
}

.invoice-doc__info-heading {
    margin: 0 0 0.625rem;
    padding: 0;
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.3;
}

.invoice-doc__info-row .invoice-doc__info-heading,
.invoice-doc__pay--info > .invoice-doc__info-heading {
    font-size: 1.1875rem;
    letter-spacing: 0.06em;
    line-height: 1.2;
}

.invoice-doc__client-name {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.45;
}

.invoice-doc__client-code {
    margin: 0.25rem 0 0.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--burgundy);
    line-height: 1.4;
}

.invoice-doc__client-detail {
    margin: 0.25rem 0 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.invoice-doc__table-wrap {
    margin-bottom: var(--space-lg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 1px 0 var(--border);
}

.invoice-doc__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.invoice-doc__table thead {
    background: var(--burgundy);
}

.invoice-doc__table th {
    padding: 0.75rem 1rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: left;
    color: #fff;
    border: none;
    vertical-align: bottom;
}

.invoice-doc__table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light, #eee);
    color: var(--text-primary);
    vertical-align: top;
}

.invoice-doc__table tbody tr:last-child td {
    border-bottom: none;
}

.invoice-doc__table tbody tr:nth-child(even) {
    background: rgba(106, 31, 39, 0.03);
}

.invoice-doc__table th.invoice-doc__col-num,
.invoice-doc__table td.invoice-doc__col-num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.invoice-doc__table th.invoice-doc__col-num:nth-child(2),
.invoice-doc__table td.invoice-doc__col-num:nth-child(2) {
    width: 4.25rem;
}

.invoice-doc__table th.invoice-doc__col-num:nth-child(3),
.invoice-doc__table td.invoice-doc__col-num:nth-child(3),
.invoice-doc__table th.invoice-doc__col-num:nth-child(4),
.invoice-doc__table td.invoice-doc__col-num:nth-child(4) {
    width: 7.5rem;
}

.invoice-doc__empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.invoice-doc__pay--info .invoice-doc__info-heading {
    text-align: right;
}

.invoice-doc__pay--info .invoice-doc__pay-list {
    gap: 1rem;
}

.invoice-doc__pay--info .invoice-doc__pay-item {
    display: block;
    padding: 0;
    border: none;
}

.invoice-doc__pay--info .invoice-doc__pay-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text-primary);
}

.invoice-doc__pay--info .invoice-doc__pay-lines {
    margin-top: 0.4rem;
    padding: 0;
}

.invoice-doc__pay--info .invoice-doc__pay-line {
    margin: 0.25rem 0 0;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.invoice-doc__pay--info .invoice-doc__pay-line:first-child {
    margin-top: 0;
}

.invoice-doc__pay-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 1rem;
}

.invoice-doc__pay-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.625rem 0.875rem;
    align-items: start;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.invoice-doc__pay-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.invoice-doc__pay-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    padding-top: 0.15rem;
    color: var(--burgundy);
}

.invoice-doc__pay-icon .icon-svg {
    display: block;
    width: 22px;
    height: 22px;
    opacity: 0.9;
}

.invoice-doc__pay-body {
    min-width: 0;
}

.invoice-doc__pay-title {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text-primary);
}

.invoice-doc__pay-line {
    margin: 0.15rem 0 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.invoice-doc__payment-ref {
    margin: var(--space-xl) 0 var(--space-lg);
    max-width: 36rem;
}

.invoice-doc__note-ref {
    margin-top: 0.75rem;
}

.invoice-doc__notes-text + .invoice-doc__note-ref {
    margin-top: 0.75rem;
}

.invoice-doc__pay-ref {
    margin: 0;
    padding: 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.invoice-doc__pay-ref strong {
    color: var(--burgundy);
    font-weight: 700;
}

.invoice-doc__totals {
    margin: 0;
    width: 100%;
    display: grid;
    gap: 0.5rem;
}

.invoice-doc__footer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 22rem);
    gap: clamp(1.5rem, 4vw, 2.5rem);
    align-items: start;
    margin-top: var(--space-lg);
}

.invoice-doc__footer-row:not(:has(.invoice-doc__footer-notes)) {
    grid-template-columns: 1fr;
    justify-items: end;
}

.invoice-doc__summary {
    width: 100%;
    max-width: 22rem;
    justify-self: end;
}

.invoice-doc__total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1.5rem;
    padding: 0.2rem 0;
}

.invoice-doc__total-row dt {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.invoice-doc__total-row dd {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.invoice-doc__total-row--grand {
    margin-top: 0.625rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    background: var(--burgundy);
}

.invoice-doc__total-row--grand dt,
.invoice-doc__total-row--grand dd {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.invoice-doc__total-row--balance dd {
    color: var(--burgundy);
}

.invoice-doc__footer-notes {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.invoice-doc__notes,
.invoice-doc__terms {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.invoice-doc__notes-text {
    margin: 0;
}

.invoice-doc__notes .invoice-doc__pay-ref {
    font-size: 0.8125rem;
}

.invoice-doc__notes p:last-child,
.invoice-doc__terms p:last-child {
    margin: 0;
}

.invoice-doc__thank-you {
    margin: 1.25rem 0 0;
    padding: 0;
    font-family: var(--font-script);
    font-size: 1.375rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--burgundy);
}

@media (max-width: 640px) {
    .invoice-doc__hero {
        padding-right: 1.25rem;
    }

    .invoice-doc__hero-grid {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    .invoice-doc__hero-doc {
        text-align: left;
        padding-top: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        padding-top: var(--space-md);
    }

    .invoice-doc--unpaid .invoice-doc__hero,
    .invoice-doc--paid .invoice-doc__hero,
    .invoice-doc--partial .invoice-doc__hero {
        padding-right: 1.5rem;
    }

    .invoice-doc--unpaid .invoice-doc__hero-doc,
    .invoice-doc--paid .invoice-doc__hero-doc,
    .invoice-doc--partial .invoice-doc__hero-doc {
        padding-top: 2.25rem;
    }

    .invoice-doc__hero-meta {
        align-items: flex-start;
    }

    .invoice-doc__hero-meta-row {
        justify-content: flex-start;
    }

    .invoice-doc__info-row {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    .invoice-doc__bill-to {
        max-width: none;
    }

    .invoice-doc__pay--info {
        justify-self: start;
        margin-left: 0;
        width: 100%;
        max-width: none;
        text-align: left;
    }

    .invoice-doc__pay--info .invoice-doc__info-heading {
        text-align: left;
    }


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

    .invoice-doc__summary {
        justify-self: stretch;
        max-width: none;
    }

    .invoice-doc__table-wrap {
        overflow-x: auto;
    }

    .invoice-doc__table {
        min-width: 28rem;
    }
}

@media print {
    .invoice-print,
    .invoice-doc {
        max-width: none;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .invoice-doc__table tbody tr:nth-child(even) {
        background: #fafafa;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .invoice-doc__accent-bar,
    .invoice-doc__hero,
    .invoice-doc__table thead,
    .invoice-doc__total-row--grand,
    .invoice-doc__ribbon {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Legacy alias */
.invoice-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 3px solid var(--burgundy);
    padding-bottom: var(--space-lg);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-lg);
}

/* Utilities */
.d-none { display: none !important; }
.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-lg); }
.mb-2 { margin-bottom: var(--space-lg); }
.gap-1 { gap: var(--space-sm); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (min-width: 576px) {
    .form-row { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    }

    .sidebar.open { box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12); }

    .sidebar-overlay { display: none !important; }

    .sidebar-close { display: none; }

    .sidebar-header {
        padding: var(--space-lg) var(--space-lg) var(--space-md);
    }

    .sidebar-nav {
        padding: var(--space-xs) var(--space-md) var(--space-lg);
    }

    .nav-link {
        padding: 0.7rem 0.85rem;
        font-size: 0.9375rem;
    }

    .main-wrapper { margin-left: var(--sidebar-width); }
    .sidebar-toggle { display: none; }
    .d-md-inline { display: inline !important; }
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .content-area { padding: var(--space-xl) var(--space-2xl); }
}

@media (min-width: 992px) {
    :root { --sidebar-width: 288px; }

    .main-wrapper { margin-left: var(--sidebar-width); }

    .nav-link {
        padding: 0.72rem 0.9rem;
    }

    .form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
    .detail-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1200px) {
    .page-title { font-size: var(--text-3xl); }
}

/* Split login — form embedded in page (no floating card) */
.auth-split-body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-base);
    background: var(--surface);
    color: var(--text-primary);
}

.auth-split-container {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
}

.auth-split-left {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 5vw, 4rem);
    background:
        radial-gradient(ellipse 90% 70% at 15% 20%, rgba(170, 145, 102, 0.22), transparent 55%),
        radial-gradient(ellipse 60% 50% at 85% 90%, rgba(106, 31, 39, 0.35), transparent 50%),
        linear-gradient(155deg, var(--charcoal) 0%, var(--burgundy-dark) 42%, var(--burgundy) 100%);
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.auth-split-left::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.12) 100%);
    pointer-events: none;
}

.auth-brand {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 22rem;
}

.auth-brand__logo {
    max-width: min(280px, 72vw);
    height: auto;
    margin: 0 auto var(--space-lg);
    display: block;
    border-radius: var(--radius);
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.25));
}

.auth-split-left .auth-brand__title,
.auth-split-left .auth-brand h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    color: #fff;
}

.auth-split-left .auth-brand__tagline,
.auth-split-left .auth-brand p {
    margin: 0.65rem 0 0;
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: #fff;
}

.auth-split-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 5vw, 4rem);
    background:
        linear-gradient(180deg, #faf9f7 0%, var(--surface) 28%),
        var(--surface);
    border-left: 1px solid var(--border-subtle);
}

.auth-login {
    width: 100%;
    max-width: 26rem;
}

.auth-login__header {
    margin-bottom: clamp(1.5rem, 4vw, 2rem);
}

.auth-login__eyebrow {
    margin: 0 0 0.35rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--gold-dark);
}

.auth-login__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, 2.125rem);
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--burgundy);
}

.auth-login__lead {
    margin: 0.5rem 0 0;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
    max-width: 22rem;
}

.auth-login__alert {
    margin-bottom: 1.25rem;
}

.auth-login__form {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

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

.auth-field {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-field__icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: var(--text-muted);
    pointer-events: none;
}

.auth-field .auth-input {
    width: 100%;
    padding: 0.8rem 2.75rem 0.8rem 2.65rem;
    font-size: var(--text-base);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.auth-field .auth-input:focus {
    border-color: rgba(106, 31, 39, 0.45);
    box-shadow: 0 0 0 3px var(--burgundy-muted);
    background: var(--white);
    outline: none;
}

.auth-field__toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.auth-field__toggle:hover {
    color: var(--burgundy);
    background: var(--burgundy-muted);
}

.auth-login__submit {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.85rem 1.25rem;
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    border-radius: var(--radius);
    box-shadow: 0 4px 14px rgba(106, 31, 39, 0.22);
}

.auth-login__footer {
    margin-top: clamp(1.5rem, 4vw, 2rem);
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.auth-login__hint {
    margin: 0 0 0.85rem;
}

.auth-login__back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.auth-login__back:hover {
    color: var(--burgundy);
}

.auth-login__back .icon-svg {
    opacity: 0.7;
}

@media (max-width: 900px) {
    .auth-split-container {
        grid-template-columns: 1fr;
    }

    .auth-split-left {
        min-height: min(42vh, 22rem);
        padding: 2rem 1.5rem;
    }

    .auth-split-right {
        border-left: none;
        border-top: 1px solid var(--border-subtle);
        align-items: flex-start;
        padding-top: 2rem;
        padding-bottom: 2.5rem;
    }

    .auth-brand__logo {
        max-width: 200px;
        margin-bottom: var(--space-md);
    }
}

.btn-lg {
    padding: 0.85rem 1.5rem;
    font-size: 1.05rem;
    border-radius: var(--radius);
}

.settings-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: clamp(1rem, 2.5vw, 1.5rem);
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.settings-subnav__link {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-full, 999px);
    border: 1px solid transparent;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.settings-subnav__link:hover {
    color: var(--burgundy);
    background: var(--burgundy-muted);
}

.settings-subnav__link.is-active {
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border-color: rgba(106, 31, 39, 0.15);
}

.settings-profile-page {
    max-width: 44rem;
}

.settings-profile-photo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
}

.settings-profile-photo__preview {
    flex-shrink: 0;
    width: 5.5rem;
    height: 5.5rem;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(145deg, var(--burgundy-muted), var(--gold-muted));
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-profile-photo__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.settings-profile-photo__img.is-hidden {
    display: none;
}

.settings-profile-photo__initials {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--burgundy);
}

.settings-profile-photo__initials.is-hidden {
    display: none;
}

.settings-profile-photo__upload {
    flex: 1;
    min-width: 12rem;
}

.settings-firm-logo__preview {
    width: 8.5rem;
    height: 5.5rem;
    border-radius: var(--radius-md, 8px);
}

.settings-firm-logo__img {
    object-fit: contain;
    padding: 0.35rem;
    background: #fff;
}

/* ==========================================================================
   Compose mail — responsive email UI
   ========================================================================== */
.compose-mail {
    --compose-pad: clamp(1rem, 2.5vw, 1.5rem);
    --compose-gap: clamp(1rem, 2vw, 1.5rem);
    max-width: 42rem;
    margin: 0 auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem);
    font-family: var(--font-body);
}

.compose-mail__header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: var(--compose-gap);
}

.compose-mail__back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.compose-mail__back:hover {
    color: var(--burgundy);
}

.compose-mail__back-icon {
    display: flex;
    transform: rotate(180deg);
    color: var(--burgundy);
}

.compose-mail__eyebrow {
    margin: 0 0 0.25rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--gold-dark);
}

.compose-mail__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.625rem, 4vw, 2rem);
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
}

.compose-mail__subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-muted);
}

.compose-mail__recipient {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.875rem 1rem;
    padding: var(--compose-pad);
    margin-bottom: var(--compose-gap);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.compose-mail__recipient::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
}

.compose-mail__avatar {
    width: clamp(2.75rem, 8vw, 3.25rem);
    height: clamp(2.75rem, 8vw, 3.25rem);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    letter-spacing: 0.02em;
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border: 1px solid rgba(106, 31, 39, 0.12);
}

.compose-mail__recipient-label {
    margin: 0 0 0.15rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.compose-mail__recipient-name {
    margin: 0;
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    font-weight: var(--font-semibold);
    line-height: var(--leading-snug);
    color: var(--text-primary);
}

.compose-mail__recipient-email {
    margin: 0.2rem 0 0;
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--text-secondary);
    word-break: break-all;
}

.compose-mail__code {
    align-self: start;
    padding: 0.3rem 0.65rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border-radius: 999px;
    white-space: nowrap;
}

.compose-mail__form {
    display: flex;
    flex-direction: column;
    gap: var(--compose-gap);
}

.compose-mail__section {
    padding: var(--compose-pad);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
}

.compose-mail__section-head {
    margin-bottom: clamp(1rem, 2.5vw, 1.25rem);
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.compose-mail__section-title {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-size: clamp(1.0625rem, 2.5vw, 1.1875rem);
    font-weight: 600;
    line-height: var(--leading-snug);
    color: var(--text-primary);
}

.compose-mail__section-desc {
    margin: 0;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
}

.compose-mail__fields {
    display: flex;
    flex-direction: column;
    gap: clamp(0.875rem, 2vw, 1.125rem);
}

.compose-mail__field label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
}

.compose-mail__input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-family: inherit;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.compose-mail__input:focus {
    outline: none;
    border-color: var(--gold);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--gold-muted);
}

.compose-mail__input--readonly {
    color: var(--text-secondary);
    background: var(--surface-muted);
    cursor: default;
}

.compose-mail__input--readonly:focus {
    border-color: var(--border);
    box-shadow: none;
}

.compose-mail__extras {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: -0.25rem 0 0;
}

.compose-mail__extra-btn {
    padding: 0.4rem 0.85rem;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--burgundy);
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.compose-mail__extra-btn:hover,
.compose-mail__extra-btn.is-active {
    background: var(--burgundy-muted);
    border-color: rgba(106, 31, 39, 0.28);
    border-style: solid;
}

.compose-mail__editor {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--white);
}

/* Rich-text editor toolbar */
.rte-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    background: linear-gradient(180deg, #f8f9fb 0%, #f1f3f6 100%);
    border-bottom: 1px solid var(--border);
}

.rte-toolbar__group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--white);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    flex-shrink: 0;
}

.rte-toolbar__group--end {
    margin-left: auto;
}

.rte-toolbar__divider {
    width: 1px;
    height: 1.75rem;
    margin: 0 0.15rem;
    background: var(--border);
    flex-shrink: 0;
}

.rte-toolbar__spacer {
    flex: 1;
    min-width: 0.5rem;
}

.rte-toolbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 2.375rem;
    height: 2.375rem;
    padding: 0 0.45rem;
    border: none;
    border-radius: calc(var(--radius-sm) + 1px);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform 0.1s ease;
}

.rte-toolbar__btn .icon-svg {
    flex-shrink: 0;
}

.rte-toolbar__btn:hover {
    background: var(--surface-muted);
    color: var(--burgundy);
}

.rte-toolbar__btn:active {
    transform: scale(0.96);
}

.rte-toolbar__btn.is-active {
    background: var(--burgundy-muted);
    color: var(--burgundy);
    box-shadow: inset 0 0 0 1px rgba(106, 31, 39, 0.18);
}

.rte-toolbar__btn--label {
    min-width: auto;
    padding: 0 0.65rem 0 0.5rem;
}

.rte-toolbar__btn--label span {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: 0.02em;
}

@media (max-width: 480px) {
    .rte-toolbar__btn--label span {
        display: none;
    }

    .rte-toolbar__btn--label {
        min-width: 2.375rem;
        padding: 0 0.45rem;
    }
}

.rte-link-bar {
    padding: 0.65rem 0.75rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    animation: rteLinkBarIn 0.18s ease-out;
}

@keyframes rteLinkBarIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rte-link-bar__inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.rte-link-bar__inner > .icon-svg {
    flex-shrink: 0;
    color: var(--burgundy);
}

.rte-link-bar__input {
    flex: 1;
    min-width: min(100%, 12rem);
    padding: 0.55rem 0.75rem;
    font-family: inherit;
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.rte-link-bar__input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-muted);
}

.rte-link-bar__apply,
.rte-link-bar__cancel {
    padding: 0.45rem 0.85rem;
    font-family: inherit;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.rte-link-bar__apply {
    color: var(--white);
    background: var(--burgundy);
    border: 1px solid var(--burgundy);
}

.rte-link-bar__apply:hover {
    background: var(--burgundy-dark);
}

.rte-link-bar__cancel {
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
}

.rte-link-bar__cancel:hover {
    background: var(--surface-muted);
    color: var(--text-primary);
}

.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;
}

.compose-mail__body {
    min-height: clamp(12rem, 35vh, 18rem);
    padding: clamp(0.875rem, 2.5vw, 1.25rem);
    font-size: var(--text-base);
    line-height: var(--leading-loose);
    color: var(--text-primary);
    outline: none;
}

.compose-mail__body:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    pointer-events: none;
    white-space: pre-wrap;
}

.compose-mail__body ul,
.compose-mail__body ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.compose-mail__drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: clamp(1.25rem, 4vw, 2rem) clamp(1rem, 3vw, 1.5rem);
    text-align: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-elevated);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.compose-mail__drop:hover,
.compose-mail__drop.is-dragover {
    border-color: var(--gold);
    background: var(--gold-muted);
}

.compose-mail__drop-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.25rem;
    border-radius: 50%;
    color: var(--burgundy);
    background: var(--white);
    border: 1px solid var(--border);
}

.compose-mail__drop-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.compose-mail__drop-hint {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    line-height: var(--leading-relaxed);
}

.compose-mail__files {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.compose-mail__file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

.compose-mail__file-icon {
    display: flex;
    flex-shrink: 0;
    color: var(--burgundy);
}

.compose-mail__file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.compose-mail__file-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compose-mail__file-size {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.compose-mail__file-remove {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.compose-mail__file-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.compose-mail__attach-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.compose-mail__attach-count {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--burgundy);
}

.compose-mail__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.25rem;
}

.compose-mail__actions-secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.compose-mail__btn-send {
    min-width: min(100%, 10rem);
    padding: 0.75rem 1.5rem;
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
}

.compose-mail__btn-cancel {
    min-width: min(100%, 7rem);
}

/* Tablet: slightly wider column */
@media (min-width: 640px) {
    .compose-mail {
        max-width: 44rem;
    }

    .compose-mail__actions {
        gap: 1rem;
    }

    .compose-mail__btn-send,
    .compose-mail__btn-cancel {
        min-width: auto;
    }
}

/* Desktop: wider compose column */
@media (min-width: 900px) {
    .compose-mail {
        max-width: 52rem;
        padding-bottom: var(--space-xl);
    }

    .compose-mail__header {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
}

/* Mobile: sticky action bar */
@media (max-width: 639px) {
    .compose-mail__actions {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        flex-direction: column;
        gap: 0.5rem;
        margin: 0;
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 24px rgba(18, 21, 24, 0.08);
    }

    .compose-mail__actions-secondary {
        width: 100%;
        flex-direction: column;
    }

    .compose-mail__btn-send,
    .compose-mail__btn-cancel,
    .compose-mail__actions-secondary .btn {
        width: 100%;
        min-width: 0;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .compose-mail__recipient {
        grid-template-columns: auto 1fr;
    }

    .compose-mail__code {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

/* ==========================================================================
   Client form — add / edit client
   ========================================================================== */
.client-form-page {
    --cf-pad: clamp(1rem, 2.5vw, 1.5rem);
    --cf-gap: clamp(1rem, 2vw, 1.35rem);
    max-width: 52rem;
    margin: 0 auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
}

.client-form-page__header {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: var(--cf-gap);
}

.client-form-page__back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.client-form-page__back:hover {
    color: var(--burgundy);
}

.client-form-page__back-icon {
    display: flex;
    transform: rotate(180deg);
    color: var(--burgundy);
}

.client-form-page__eyebrow {
    margin: 0 0 0.25rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--gold-dark);
}

.client-form-page__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.625rem, 4vw, 2rem);
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
}

.client-form-page__lead {
    margin: 0.5rem 0 0;
    max-width: 38rem;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
}

.client-form-page__lookup {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem 1.25rem;
    align-items: start;
    padding: var(--cf-pad);
    margin-bottom: var(--cf-gap);
    background: linear-gradient(135deg, var(--burgundy-muted) 0%, var(--white) 55%);
    border: 1px solid rgba(106, 31, 39, 0.12);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.client-form-page__lookup::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--burgundy) 0%, var(--gold) 100%);
}

.client-form-page__lookup-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    color: var(--burgundy);
    background: var(--white);
    border: 1px solid rgba(106, 31, 39, 0.1);
    box-shadow: var(--shadow-xs);
}

.client-form-page__lookup-title {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
}

.client-form-page__lookup-desc {
    margin: 0 0 0.85rem;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
}

.client-form-page__search {
    position: relative;
}

.client-form-page__search-icon {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: var(--text-tertiary);
    pointer-events: none;
}

.client-form-page__search-input {
    padding-left: 2.65rem;
    min-height: 2.75rem;
    border-radius: 999px;
    background: var(--white);
}

.client-form-page__results {
    margin-top: 0.65rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.client-form-page__form {
    display: flex;
    flex-direction: column;
    gap: var(--cf-gap);
}

.client-form-page__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: var(--cf-pad);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    position: sticky;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
    z-index: 5;
}

.client-form-page__btn-save {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.75rem;
    padding-left: 1.25rem;
    padding-right: 1.35rem;
}

.client-form-page__btn-save .icon-svg {
    flex-shrink: 0;
}

.client-form__sections {
    display: flex;
    flex-direction: column;
    gap: var(--cf-gap, 1.25rem);
}

.client-form__section {
    padding: var(--cf-pad, clamp(1rem, 2.5vw, 1.5rem));
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
}

.client-form__section-head {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    margin-bottom: clamp(1rem, 2.5vw, 1.25rem);
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.client-form__section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border: 1px solid rgba(106, 31, 39, 0.08);
}

.client-form__section-title {
    margin: 0 0 0.3rem;
    font-family: var(--font-display);
    font-size: clamp(1.0625rem, 2.5vw, 1.1875rem);
    font-weight: 600;
    line-height: var(--leading-snug);
    color: var(--text-primary);
}

.client-form__section-desc {
    margin: 0;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
}

.client-form__fields {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.client-form__fields .form-group {
    margin-bottom: 0;
}

.client-form__fields .form-row {
    margin-top: 0;
}

.client-form__required {
    color: var(--burgundy);
    font-weight: var(--font-bold);
}

.client-form__type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

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

.client-form__type-option {
    position: relative;
    cursor: pointer;
}

.client-form__type-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.75rem;
    padding: 0.65rem 1rem;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    background: var(--surface-elevated);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
}

.client-form__type-pill .icon-svg {
    color: var(--text-tertiary);
    transition: color var(--transition);
}

.client-form__type-input:focus-visible + .client-form__type-pill {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.client-form__type-input:checked + .client-form__type-pill {
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border-color: rgba(106, 31, 39, 0.35);
    box-shadow: 0 0 0 3px rgba(106, 31, 39, 0.08);
}

.client-form__type-input:checked + .client-form__type-pill .icon-svg {
    color: var(--burgundy);
}

.client-form__company-field.is-hidden {
    display: none;
}

@media (min-width: 640px) {
    .client-form__fields .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 639px) {
    .client-form-page__lookup {
        grid-template-columns: 1fr;
    }

    .client-form-page__lookup-badge {
        width: 2.25rem;
        height: 2.25rem;
    }

    .client-form-page__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .client-form-page__btn-save,
    .client-form-page__btn-cancel {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   Appointment form — schedule
   ========================================================================== */
.appointment-form-page {
    --cf-pad: clamp(1rem, 2.5vw, 1.5rem);
    --cf-gap: clamp(1rem, 2vw, 1.35rem);
    max-width: 52rem;
    margin: 0 auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
}

.appointment-form-page__header {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: var(--cf-gap);
}

.appointment-form-page__back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.appointment-form-page__back:hover {
    color: var(--burgundy);
}

.appointment-form-page__back-icon {
    display: flex;
    transform: rotate(180deg);
    color: var(--burgundy);
}

.appointment-form-page__eyebrow {
    margin: 0 0 0.25rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--gold-dark);
}

.appointment-form-page__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.625rem, 4vw, 2rem);
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

.appointment-form-page__lead {
    margin: 0.5rem 0 0;
    max-width: 38rem;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
}

.appointment-form-page__form .client-form__sections {
    display: flex;
    flex-direction: column;
    gap: var(--cf-gap);
}

.appointment-form__datetime-row .form-control {
    min-height: 2.75rem;
}

.appointment-form__calendar-section .client-form__section-head {
    margin-bottom: 0.75rem;
}

.appointment-form__calendar-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.appointment-form__calendar-option {
    display: block;
    cursor: pointer;
}

.appointment-form__calendar-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.appointment-form__calendar-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.appointment-form__calendar-input:focus-visible + .appointment-form__calendar-card {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.appointment-form__calendar-input:checked + .appointment-form__calendar-card {
    border-color: rgba(106, 31, 39, 0.35);
    background: linear-gradient(135deg, var(--burgundy-muted) 0%, var(--white) 70%);
    box-shadow: 0 4px 16px rgba(106, 31, 39, 0.1);
}

.appointment-form__calendar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius);
    color: var(--burgundy);
    background: var(--white);
    border: 1px solid rgba(106, 31, 39, 0.12);
}

.appointment-form__calendar-icon--google {
    color: #1a73e8;
    border-color: rgba(66, 133, 244, 0.25);
    background: rgba(66, 133, 244, 0.06);
}

.appointment-form__calendar-icon--ical {
    color: #c9342a;
    border-color: rgba(201, 52, 42, 0.2);
    background: rgba(201, 52, 42, 0.06);
}

.appointment-form__calendar-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.appointment-form__calendar-text strong {
    font-size: 0.9375rem;
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.appointment-form__calendar-text span:last-child {
    font-size: var(--text-sm);
    line-height: 1.45;
    color: var(--text-secondary);
}

.appointment-form-page__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: var(--cf-gap);
    padding: 1rem 0;
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: linear-gradient(180deg, rgba(245, 246, 248, 0) 0%, var(--surface) 28%);
}

.appointment-form-page__btn-save {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 11rem;
    padding: 0.75rem 1.35rem;
}

.appointment-form-page__btn-save .icon-svg {
    flex-shrink: 0;
}

.appointment-calendar-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.25rem;
    margin-bottom: var(--space-md);
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--burgundy-muted) 0%, var(--white) 60%);
    border: 1px solid rgba(106, 31, 39, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.appointment-calendar-banner__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    color: var(--burgundy);
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid rgba(106, 31, 39, 0.12);
}

.appointment-calendar-banner__body {
    flex: 1 1 12rem;
    min-width: 0;
}

.appointment-calendar-banner__title {
    margin: 0 0 0.2rem;
    font-size: 0.9375rem;
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.appointment-calendar-banner__text {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

.appointment-calendar-banner__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.appointment-calendar-banner__ics {
    white-space: nowrap;
}

@media (max-width: 639px) {
    .appointment-form-page__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .appointment-form-page__btn-save,
    .appointment-form-page__btn-cancel {
        width: 100%;
        justify-content: center;
    }

    .appointment-calendar-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .appointment-calendar-banner__actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .appointment-calendar-banner__actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   Invoice form — create / edit
   ========================================================================== */
.invoice-form-page {
    --cf-pad: clamp(1rem, 2.5vw, 1.5rem);
    --cf-gap: clamp(1rem, 2vw, 1.35rem);
    max-width: 52rem;
    margin: 0 auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
}

.invoice-form-page__header {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: var(--cf-gap);
}

.invoice-form-page__back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.invoice-form-page__back:hover {
    color: var(--burgundy);
}

.invoice-form-page__back-icon {
    display: flex;
    transform: rotate(180deg);
    color: var(--burgundy);
}

.invoice-form-page__eyebrow {
    margin: 0 0 0.25rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--gold-dark);
}

.invoice-form-page__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.625rem, 4vw, 2rem);
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

.invoice-form-page__lead {
    margin: 0.5rem 0 0;
    max-width: 40rem;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
}

.invoice-form-page__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.invoice-form-page__chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-full, 999px);
}

.invoice-form-page__chip--due {
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border-color: rgba(106, 31, 39, 0.2);
}

.invoice-form-page__form .client-form__sections {
    display: flex;
    flex-direction: column;
    gap: var(--cf-gap);
}

.invoice-form__line-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.invoice-form__line-items-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--white);
    box-shadow: var(--shadow-xs);
}

.invoice-form__line-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.invoice-form__line-table thead {
    background: linear-gradient(180deg, #f8f6f4 0%, #f3f0ec 100%);
}

.invoice-form__line-table th {
    padding: 0.65rem 0.85rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.invoice-form__line-table td {
    padding: 0.5rem 0.65rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
}

.invoice-form__line-table tbody tr:last-child td {
    border-bottom: none;
}

.invoice-form__line-table .form-control {
    min-height: 2.5rem;
    font-size: var(--text-sm);
}

.invoice-form__col-qty {
    width: 5.5rem;
}

.invoice-form__col-price {
    width: 7.5rem;
}

.invoice-form__col-amount {
    width: 6.5rem;
    text-align: right;
}

.invoice-form__col-action {
    width: 3rem;
    text-align: center;
}

.invoice-form__line-amount {
    display: block;
    padding: 0.5rem 0.25rem;
    font-weight: var(--font-semibold);
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.invoice-form__add-line {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: fit-content;
}

.invoice-form__totals-layout {
    display: grid;
    grid-template-columns: 1fr minmax(14rem, 20rem);
    gap: clamp(1.25rem, 4vw, 2rem);
    align-items: start;
}

.invoice-form__tax-readonly {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.invoice-form__tax-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--burgundy);
}

.invoice-form__totals-summary {
    padding: 1.15rem 1.25rem;
    background: linear-gradient(135deg, var(--burgundy-muted) 0%, var(--white) 55%);
    border: 1px solid rgba(106, 31, 39, 0.12);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.invoice-form__totals-dl {
    margin: 0;
}

.invoice-form__totals-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.35rem 0;
    font-size: var(--text-sm);
}

.invoice-form__totals-row dt {
    margin: 0;
    font-weight: 500;
    color: var(--text-secondary);
}

.invoice-form__totals-row dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.invoice-form__totals-row--grand {
    margin-top: 0.5rem;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(106, 31, 39, 0.15);
}

.invoice-form__totals-row--grand dt,
.invoice-form__totals-row--grand dd {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--burgundy);
}

.invoice-form-page__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: var(--cf-gap);
    padding: 1rem 0;
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: linear-gradient(180deg, rgba(245, 246, 248, 0) 0%, var(--surface) 28%);
}

.invoice-form-page__btn-save {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 11rem;
    padding: 0.75rem 1.35rem;
}

.invoice-form-page__btn-save .icon-svg {
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .invoice-form__totals-layout {
        grid-template-columns: 1fr;
    }

    .invoice-form__line-items-wrap {
        overflow-x: auto;
    }

    .invoice-form__line-table {
        min-width: 32rem;
    }
}

/* ==========================================================================
   Communication detail view
   ========================================================================== */
.comm-view-page {
    max-width: 44rem;
}

.comm-view-page__header {
    margin-bottom: 1.5rem;
}

.comm-view-hero {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.comm-view-hero__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: var(--radius-lg);
    color: var(--burgundy);
    background: linear-gradient(145deg, var(--burgundy-muted) 0%, var(--gold-muted) 100%);
    border: 1px solid rgba(106, 31, 39, 0.12);
    box-shadow: var(--shadow-xs);
}

.comm-view-hero__main {
    flex: 1;
    min-width: 0;
}

.comm-view-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.comm-view-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.7rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: 0.02em;
    border-radius: var(--radius-full, 999px);
    border: 1px solid transparent;
}

.comm-view-chip--sm {
    padding: 0.2rem 0.55rem;
    font-size: 0.6875rem;
}

.comm-view-chip--outbound {
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border-color: rgba(106, 31, 39, 0.18);
}

.comm-view-chip--inbound {
    color: #1e5a8a;
    background: var(--info-bg);
    border-color: rgba(30, 90, 138, 0.15);
}

.comm-view-chip--channel-email {
    color: #5c4a1a;
    background: var(--gold-muted);
    border-color: rgba(170, 145, 102, 0.35);
}

.comm-view-chip--channel-phone {
    color: var(--burgundy);
    background: var(--burgundy-muted);
    border-color: rgba(106, 31, 39, 0.15);
}

.comm-view-chip--channel-sms,
.comm-view-chip--channel-whatsapp {
    color: #1a6b4a;
    background: rgba(26, 107, 74, 0.1);
    border-color: rgba(26, 107, 74, 0.2);
}

.comm-view-chip--channel-in_person {
    color: var(--text-secondary);
    background: var(--surface-muted);
    border-color: var(--border);
}

.comm-view-chip--channel-letter {
    color: var(--gold-dark);
    background: var(--gold-muted);
    border-color: rgba(138, 117, 80, 0.25);
}

.comm-view-section .client-form__fields {
    gap: 0;
}

.comm-view-party-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.comm-view-party-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem 1.1rem;
    text-decoration: none;
    color: inherit;
    background: linear-gradient(180deg, #faf9f7 0%, var(--white) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

a.comm-view-party-card:hover {
    border-color: rgba(106, 31, 39, 0.35);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.comm-view-party-card--empty {
    background: var(--surface-muted);
    cursor: default;
}

.comm-view-party-card__label {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--text-muted);
}

.comm-view-party-card__value {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    line-height: var(--leading-snug);
}

a.comm-view-party-card .comm-view-party-card__value {
    color: var(--burgundy);
}

.comm-view-party-card__meta {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

.comm-view-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem 1rem;
    margin: 0;
}

.comm-view-meta__item {
    margin: 0;
    padding: 0.85rem 1rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

.comm-view-meta__item--wide {
    grid-column: span 2;
}

.comm-view-meta__item--full {
    grid-column: 1 / -1;
}

.comm-view-meta dt {
    margin: 0 0 0.35rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.comm-view-meta dd {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    line-height: var(--leading-snug);
}

.comm-view-meta__mono {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.comm-view-meta__unit {
    font-weight: var(--font-normal);
    color: var(--text-secondary);
}

.comm-view-meta__emphasis {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
}

.comm-view-notes {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.comm-view-notes__title {
    margin: 0 0 0.65rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--text-muted);
}

.comm-view-notes__body {
    padding: 1.1rem 1.25rem;
    font-size: var(--text-sm);
    line-height: 1.65;
    color: var(--text-primary);
    background: linear-gradient(180deg, #fff 0%, #faf8f5 100%);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.comm-view-notes__body ol,
.comm-view-notes__body ul {
    margin: 0.35rem 0 0;
    padding-left: 1.35rem;
}

.comm-view-notes__body li + li {
    margin-top: 0.35rem;
}

.comm-view-notes__empty {
    color: var(--text-muted);
    font-style: italic;
}

.doc-upload-file-list {
    margin: 0.65rem 0 0;
    padding: 0.65rem 0.85rem;
    list-style: none;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

.doc-upload-file-list li + li {
    margin-top: 0.35rem;
}

@media (max-width: 640px) {
    .comm-view-party-grid {
        grid-template-columns: 1fr;
    }

    .comm-view-meta {
        grid-template-columns: 1fr 1fr;
    }

    .comm-view-meta__item--wide,
    .comm-view-meta__item--full {
        grid-column: 1 / -1;
    }
}

@media (max-width: 639px) {
    .invoice-form-page__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .invoice-form-page__btn-save,
    .invoice-form-page__btn-cancel {
        width: 100%;
        justify-content: center;
    }
}
