/* =====================================================
   BatiCalc SaaS - Design System
   Couleur principale: Violet #7c3aed
   ===================================================== */

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

:root {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --primary-light: #a78bfa;
    --primary-50: #f5f3ff;
    --primary-100: #ede9fe;
    --primary-200: #ddd6fe;
    --secondary: #64748b;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #2563eb;
    --info-light: #dbeafe;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-lg: 1rem;
    --transition: 0.2s ease;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =====================================================
   Auth Layout
   ===================================================== */
.auth-layout {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-50) 0%, #ffffff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    animation: fadeInUp 0.5s ease;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.auth-logo h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.auth-logo p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

.auth-form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.auth-form input,
.auth-form select,
.auth-form textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: var(--font);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.auth-form input:focus,
.auth-form select:focus,
.auth-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}

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

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    text-decoration: none;
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}

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

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

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* =====================================================
   Alerts
   ===================================================== */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border-color: #fecaca;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border-color: #bbf7d0;
}

.alert-info {
    background: var(--info-light);
    color: var(--info);
    border-color: #bfdbfe;
}

/* =====================================================
   App Layout
   ===================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-dark {
    background: #1e293b;
    border-right: none;
}

.sidebar-dark .logo span,
.sidebar-dark .nav-item,
.sidebar-dark .user-name {
    color: #f1f5f9;
}

.sidebar-dark .nav-item:hover,
.sidebar-dark .nav-item.active {
    background: rgba(255,255,255,0.08);
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text);
}

.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.sidebar-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: 0.2s;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
    background: var(--primary-50);
    color: var(--primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary-100);
    color: var(--primary);
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-group {
    margin-bottom: 0.5rem;
}

.nav-group-title {
    padding: 0.5rem 0.875rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    opacity: 0.7;
}

.nav-group .nav-item {
    padding-left: 1.25rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-dark .sidebar-footer {
    border-color: rgba(255,255,255,0.08);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

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

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-form .btn {
    width: 100%;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 1.5rem 2rem;
    max-width: 1200px;
}

.has-workspace-aside .main-content {
    margin-right: 320px;
    max-width: none;
}

.main-content-wide {
    max-width: none;
    width: auto;
}

.workspace-aside {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    padding: 1rem;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: #f8fafc;
    z-index: 90;
}

.workspace-panel {
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1rem;
    padding: 0.95rem;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.workspace-panel-primary {
    border-color: rgba(37, 99, 235, 0.22);
    background: linear-gradient(180deg, #eff6ff 0%, #ffffff 72%);
}

.workspace-panel-heading,
.workspace-notification-summary,
.workspace-usage div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.workspace-panel-heading span {
    color: #2563eb;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.workspace-panel-heading a,
.workspace-action-list a {
    color: #2563eb;
    font-size: 0.78rem;
    font-weight: 800;
    text-decoration: none;
}

.workspace-panel-heading a:hover,
.workspace-action-list a:hover {
    text-decoration: underline;
}

.workspace-notification-summary {
    align-items: flex-end;
    padding-bottom: 0.2rem;
}

.workspace-notification-summary strong {
    color: #1d4ed8;
    font-size: 2rem;
    line-height: 1;
}

.workspace-notification-summary span,
.workspace-muted,
.workspace-company-card span,
.workspace-project-item span,
.workspace-project-item small,
.workspace-mini-item span,
.workspace-usage span {
    color: #64748b;
    font-size: 0.8rem;
}

.workspace-muted {
    margin: 0;
    line-height: 1.4;
}

.workspace-mini-list,
.workspace-project-list,
.workspace-action-list {
    display: grid;
    gap: 0.55rem;
}

.workspace-mini-item,
.workspace-project-item {
    display: grid;
    gap: 0.15rem;
    padding: 0.65rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    text-decoration: none;
}

.workspace-mini-item:hover,
.workspace-project-item:hover {
    border-color: rgba(37, 99, 235, 0.32);
    background: #f0f7ff;
    text-decoration: none;
}

.workspace-mini-item.is-unread {
    border-color: rgba(37, 99, 235, 0.36);
    background: #eff6ff;
}

.workspace-mini-item strong,
.workspace-project-item strong,
.workspace-company-card strong {
    color: #0f172a;
    font-size: 0.86rem;
    line-height: 1.25;
}

.workspace-company-card {
    display: grid;
    gap: 0.2rem;
}

.workspace-usage {
    display: grid;
    gap: 0.45rem;
}

.workspace-usage div strong {
    color: #0f172a;
    font-size: 0.85rem;
}

.workspace-usage-track {
    display: block;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.workspace-usage-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #2563eb;
}

.workspace-action-list {
    padding-top: 0.7rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

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

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

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

.card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
    gap: 1.25rem;
    align-items: start;
}

.dashboard-main {
    display: grid;
    gap: 1rem;
}

.dashboard-aside {
    position: sticky;
    top: 1rem;
}

.dashboard-aside-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

.dashboard-aside-item {
    min-width: 0;
}

.dashboard-aside-item-command {
    grid-column: 1 / -1;
}

.dashboard-stats-card .card-body,
.dashboard-plan-card .card-body {
    padding: 0.9rem;
}

.dashboard-stat-list {
    display: grid;
    gap: 0.55rem;
}

.dashboard-stat-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.dashboard-stat-list span,
.dashboard-plan-card span {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.dashboard-stat-list strong {
    color: var(--text);
    font-size: 1.05rem;
}

.dashboard-plan-card .card-body {
    display: grid;
    gap: 0.25rem;
}

.dashboard-plan-card strong {
    color: var(--text);
}

.dashboard-command-card .card-body,
.dashboard-priority-card .card-body,
.dashboard-actions-card .card-body {
    padding: 0.9rem;
}

.dashboard-command-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
}

.dashboard-command-metrics div,
.dashboard-plan-limits div {
    display: grid;
    gap: 0.2rem;
    padding: 0.65rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #f8fafc;
}

.dashboard-command-metrics span,
.dashboard-priority-item small,
.dashboard-muted,
.dashboard-plan-summary span,
.dashboard-plan-limits span {
    color: #64748b;
    font-size: 0.78rem;
}

.dashboard-command-metrics strong {
    color: #0f172a;
    font-size: 1.15rem;
}

.dashboard-priority-list,
.dashboard-action-list,
.dashboard-plan-card .card-body {
    display: grid;
    gap: 0.65rem;
}

.dashboard-priority-item {
    display: grid;
    gap: 0.28rem;
    padding: 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    text-decoration: none;
}

.dashboard-priority-item:hover {
    border-color: rgba(37, 99, 235, 0.35);
    background: #eff6ff;
    text-decoration: none;
}

.dashboard-priority-item.is-unread {
    border-color: rgba(217, 119, 6, 0.35);
    background: #fffbeb;
}

.dashboard-priority-item .badge {
    width: fit-content;
}

.dashboard-priority-item strong,
.dashboard-action-list a,
.dashboard-plan-summary strong,
.dashboard-plan-limits strong {
    color: #0f172a;
    font-size: 0.86rem;
}

.dashboard-muted {
    margin: 0;
    line-height: 1.4;
}

.dashboard-action-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 800;
    text-decoration: none;
}

.dashboard-action-list a:hover {
    border-color: rgba(37, 99, 235, 0.36);
    background: #dbeafe;
    text-decoration: none;
}

.dashboard-plan-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.dashboard-plan-track {
    display: block;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.dashboard-plan-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #2563eb;
}

.dashboard-plan-limits {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.dashboard-estimate-list {
    display: grid;
    gap: 0.55rem;
}

.dashboard-estimate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.dashboard-estimate-item:hover {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: var(--shadow-sm);
}

.dashboard-estimate-main,
.dashboard-estimate-side {
    display: grid;
    gap: 0.25rem;
}

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

.dashboard-estimate-title,
.dashboard-estimate-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-estimate-title {
    color: var(--text);
    font-weight: 700;
}

.dashboard-estimate-meta {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.dashboard-estimate-side {
    justify-items: end;
    flex: 0 0 auto;
    text-align: right;
}

.dashboard-estimate-side strong {
    color: var(--text);
    font-size: 0.94rem;
}

.estimate-progress {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

.estimate-progress.is-compact {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.estimate-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    min-width: 0;
}

.estimate-progress-head strong,
.estimate-progress-value {
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.estimate-progress-head span,
.estimate-progress-note {
    color: var(--text-muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.estimate-progress-track {
    display: block;
    width: 100%;
    min-width: 86px;
    height: 7px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.estimate-progress.is-compact .estimate-progress-track {
    flex: 1 1 120px;
    max-width: 180px;
}

.estimate-progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--success));
}

@media (max-width: 900px) {
    .dashboard-grid,
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .dashboard-aside {
        position: static;
        order: -1;
    }
    .dashboard-aside-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dashboard-stat-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .dashboard-command-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .project-estimate-progress-list {
        grid-template-columns: 1fr;
    }
    .project-work-assignment-grid,
    .project-work-assignment-item {
        grid-template-columns: 1fr;
    }
    .project-work-assignment-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .dashboard-stat-list {
        grid-template-columns: 1fr;
    }
    .dashboard-aside-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-command-metrics,
    .dashboard-plan-limits {
        grid-template-columns: 1fr;
    }
    .dashboard-estimate-item {
        align-items: flex-start;
        flex-direction: column;
    }
    .dashboard-estimate-side {
        justify-items: start;
        text-align: left;
    }
}

/* =====================================================
   Projects / Lists
   ===================================================== */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background var(--transition), box-shadow var(--transition);
}

.project-item:hover {
    background: var(--primary-50);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.project-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.project-name {
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
    flex-shrink: 0;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-secondary { background: var(--primary-50); color: var(--text-muted); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }

.project-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.project-detail-grid div,
.project-finance-grid div {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-detail-grid span,
.project-finance-grid span,
.project-finance-header span {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-detail-grid strong,
.project-finance-grid strong {
    color: var(--text);
    overflow-wrap: anywhere;
}

.project-description {
    margin-bottom: 1.25rem;
}

.project-description p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.project-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.project-tab-button {
    min-height: 36px;
    padding: 0.45rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #ffffff;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.project-tab-button:hover,
.project-tab-button.active {
    border-color: rgba(37, 99, 235, 0.22);
    background: var(--primary-50);
    color: var(--primary);
}

.project-tab-button.active {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.10);
}

.project-tab-panel {
    scroll-margin-top: 1rem;
}

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

.project-tab-panel:not(.project-overview-panel) {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: 0 !important;
}

.project-estimate-progress-block {
    margin: 1rem 0 1.25rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.project-estimate-progress-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-estimate-progress-item {
    display: grid;
    gap: 0.65rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: inherit;
    text-decoration: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.project-estimate-progress-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.project-estimate-progress-item > div:first-child {
    display: grid;
    gap: 0.15rem;
}

.project-estimate-progress-item > div:first-child span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.project-finance-block,
.project-budget-block,
.project-schedule-block,
.project-site-log-block,
.project-alert-block,
.project-quality-block,
.project-stakeholder-block,
.project-document-register-block,
.project-risk-block,
.project-procurement-block,
.project-stock-block,
.project-work-assignments-block,
.project-reminder-block,
.project-expense-block,
.project-documents-block {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.project-finance-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.project-finance-header h3 {
    margin: 0;
    font-size: 1rem;
}

.project-finance-header > strong {
    white-space: nowrap;
    color: var(--success);
}

.project-finance-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-finance-progress {
    height: 8px;
    margin-top: 0.85rem;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.project-finance-progress span {
    display: block;
    height: 100%;
    background: var(--success);
}

.project-detail-grid + .project-finance-block,
.project-description + .project-finance-block {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.project-documents-table td small {
    display: block;
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-reminder-list {
    display: grid;
    gap: 0.65rem;
}

.project-reminder-item {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius);
    background: #fffaf0;
}

.project-reminder-item strong,
.project-reminder-item small,
.project-reminder-item span:not(.badge) {
    display: block;
}

.project-reminder-item small,
.project-reminder-item span:not(.badge) {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.project-reminder-panel {
    margin: 1rem 0 1.25rem;
    padding: 1rem;
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    background: #fffaf0;
}

.project-reminder-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.9rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.project-reminder-message input,
.project-reminder-message textarea {
    background: #fff;
}

.project-budget-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.project-budget-summary div {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-budget-summary span,
.project-budget-table td small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-budget-summary span {
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-budget-table td small {
    margin-top: 0.2rem;
}

.project-budget-table tr.is-over-budget td {
    background: #fff1f2;
}

.project-budget-progress {
    display: block;
    height: 6px;
    margin-top: 0.35rem;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.project-budget-progress span {
    display: block;
    height: 100%;
    background: var(--success);
}

.project-budget-table tr.is-over-budget .project-budget-progress span {
    background: var(--danger);
}

.project-alert-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.project-alert-item {
    display: grid;
    gap: 0.25rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius);
    background: #fffbeb;
    color: var(--text);
    text-decoration: none;
}

.project-alert-item.is-danger {
    border-left-color: var(--danger);
    background: #fff1f2;
}

.project-alert-item small {
    color: var(--text-muted);
}

.project-alert-empty {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
    color: var(--text-muted);
}

.project-schedule-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.project-schedule-summary div {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-schedule-summary span,
.project-schedule-table td small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-schedule-summary span {
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-schedule-form {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-schedule-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-schedule-table th,
.project-schedule-table td {
    vertical-align: top;
}

.project-schedule-table td {
    min-width: 120px;
}

.project-schedule-table td:first-child {
    min-width: 220px;
}

.project-schedule-input,
.project-schedule-table textarea {
    width: 100%;
    min-width: 100px;
    padding: 0.42rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 0.82rem;
}

.project-schedule-table textarea {
    min-height: 54px;
    margin-top: 0.35rem;
    resize: vertical;
}

.project-schedule-table input + input,
.project-schedule-table select + .badge,
.project-schedule-table textarea + .badge {
    margin-top: 0.35rem;
}

.project-schedule-progress {
    display: block;
    height: 6px;
    margin-top: 0.4rem;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.project-schedule-progress span {
    display: block;
    height: 100%;
    background: var(--success);
}

.project-schedule-table tr.is-late td {
    background: #fff1f2;
}

.project-schedule-table tr.is-cancelled {
    opacity: 0.62;
}

.project-schedule-cancel {
    margin-top: 0.35rem;
}

.project-site-log-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.project-site-log-summary div {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-site-log-summary span,
.project-site-log-meta span,
.project-site-log-item small,
.project-site-log-notes-grid span {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-site-log-summary span {
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-site-log-form {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-site-log-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-site-log-notes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-site-log-list {
    display: grid;
    gap: 0.75rem;
}

.project-site-log-item {
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.project-site-log-item.is-cancelled {
    opacity: 0.62;
}

.project-site-log-meta {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(110px, 0.7fr) minmax(90px, 0.5fr) auto;
    align-items: start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.project-site-log-notes-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-site-log-notes-grid div {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f8fafc;
}

.project-site-log-notes-grid div.has-issue {
    border-color: #f59e0b;
    background: #fffbeb;
}

.project-site-log-notes-grid p {
    margin: 0.25rem 0 0;
    color: var(--text);
    font-size: 0.88rem;
}

.project-quality-summary,
.project-stakeholder-summary,
.project-document-register-summary,
.project-risk-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.project-quality-summary div,
.project-stakeholder-summary div,
.project-document-register-summary div,
.project-risk-summary div {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-quality-summary span,
.project-stakeholder-summary span,
.project-document-register-summary span,
.project-risk-summary span,
.project-quality-table td small,
.project-document-register-table td small,
.project-risk-table td small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-quality-summary span,
.project-stakeholder-summary span,
.project-document-register-summary span,
.project-risk-summary span {
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-quality-form,
.project-stakeholder-form,
.project-document-register-form,
.project-risk-form {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-quality-form-grid,
.project-stakeholder-form-grid,
.project-document-register-form-grid,
.project-risk-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-document-attachment-grid {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
    gap: 0.75rem;
}

.project-document-attachment-grid small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.project-quality-notes,
.project-risk-notes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-quality-table th,
.project-quality-table td,
.project-stakeholder-table th,
.project-stakeholder-table td,
.project-document-register-table th,
.project-document-register-table td,
.project-risk-table th,
.project-risk-table td {
    vertical-align: top;
}

.project-quality-table td:first-child,
.project-stakeholder-table td:first-child,
.project-document-register-table td:first-child,
.project-risk-table td:first-child {
    min-width: 220px;
}

.project-quality-input,
.project-stakeholder-input,
.project-document-register-input,
.project-risk-input,
.project-quality-table textarea,
.project-stakeholder-table textarea,
.project-document-register-table textarea,
.project-risk-table textarea {
    width: 100%;
    min-width: 100px;
    padding: 0.42rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 0.82rem;
}

.project-quality-table textarea,
.project-stakeholder-table textarea,
.project-document-register-table textarea,
.project-risk-table textarea {
    min-height: 54px;
    margin-top: 0.35rem;
    resize: vertical;
}

.project-quality-table input + input,
.project-quality-table select + .badge,
.project-stakeholder-table input + input,
.project-stakeholder-table select + .badge,
.project-document-register-table input + input,
.project-document-register-table select + .badge,
.project-risk-table input + input,
.project-risk-table select + .badge {
    margin-top: 0.35rem;
}

.project-quality-table tr.is-late td,
.project-document-register-table tr.is-late td,
.project-risk-table tr.is-late td {
    background: #fff1f2;
}

.project-quality-table tr.is-cancelled,
.project-stakeholder-table tr.is-cancelled,
.project-document-register-table tr.is-cancelled,
.project-risk-table tr.is-cancelled {
    opacity: 0.62;
}

.project-row-action {
    margin-top: 0.35rem;
}

.project-inline-link {
    display: inline-block;
    margin-top: 0.35rem;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
}

.project-risk-score {
    display: grid;
    grid-template-columns: 54px auto 54px;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.35rem;
}

.project-risk-score input {
    width: 100%;
    padding: 0.42rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 0.82rem;
}

.project-risk-score span {
    color: var(--text-muted);
    text-align: center;
}

.project-procurement-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.project-procurement-summary div {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-procurement-summary span,
.project-procurement-table td small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-procurement-summary span {
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-procurement-table th,
.project-procurement-table td {
    vertical-align: top;
}

.project-procurement-table td {
    min-width: 110px;
}

.project-procurement-table td:first-child,
.project-procurement-table td:nth-child(2) {
    min-width: 160px;
}

.project-procurement-table td:nth-child(8) {
    min-width: 180px;
}

.project-procurement-table td small {
    margin-top: 0.2rem;
}

.project-procurement-table label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-procurement-table tr.is-stale {
    opacity: 0.68;
}

.project-procurement-input,
.project-procurement-table textarea {
    width: 100%;
    min-width: 86px;
    padding: 0.42rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 0.82rem;
}

.project-procurement-input.is-price {
    min-width: 92px;
}

.project-procurement-table textarea {
    min-height: 54px;
    margin-top: 0.35rem;
    resize: vertical;
}

.project-procurement-table input + input {
    margin-top: 0.35rem;
}

.project-procurement-progress {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 0.4rem;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.project-procurement-progress span {
    display: block;
    height: 100%;
    background: var(--success);
}

.text-danger {
    color: var(--danger) !important;
}

.project-stock-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.project-stock-summary div {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-stock-summary span,
.project-stock-table td small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-stock-summary span {
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-stock-table td small {
    margin-top: 0.2rem;
}

.project-stock-table tr.is-negative td {
    background: #fff1f2;
}

.project-stock-table tr.is-shortage td {
    background: #fffbeb;
}

.project-expense-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.project-expense-categories span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.project-expense-categories strong {
    color: var(--text);
}

.project-expense-form {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.project-expense-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-expense-table td small {
    display: block;
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.project-expense-table tr.is-cancelled {
    opacity: 0.62;
}

.project-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

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

.empty-state p { margin-bottom: 1rem; }

/* =====================================================
   Company preview
   ===================================================== */
.company-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.company-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
}

.company-logo-thumb {
    width: 64px;
    height: 64px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    object-fit: contain;
    padding: 6px;
    flex: 0 0 auto;
}

.company-logo-thumb-sm {
    width: 48px;
    height: 48px;
}

.company-logo-settings {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.company-logo-preview {
    width: 96px;
    height: 72px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    flex: 0 0 auto;
}

.company-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.company-logo-preview span {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 800;
}

.company-logo-controls {
    flex: 1;
    min-width: 0;
}

.company-details {
    display: flex;
    flex-direction: column;
}

.company-details strong {
    font-weight: 600;
    color: var(--text);
}

.company-details span {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

/* =====================================================
   Forms (general)
   ===================================================== */
.form-section {
    margin-bottom: 1.5rem;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: var(--font);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

/* =====================================================
   Accounting
   ===================================================== */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

.accounting-page {
    display: grid;
    gap: 1.25rem;
}

.accounting-command-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.accounting-command-title {
    min-width: 0;
}

.accounting-command-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.accounting-eyebrow {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.accounting-command-title h3,
.accounting-command-title p {
    margin: 0;
}

.accounting-command-title h3 {
    font-size: 1.15rem;
}

.accounting-command-title p {
    margin-top: 0.3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.accounting-command-actions .btn.is-active {
    border-color: var(--primary);
    background: var(--primary-50);
    color: var(--primary-dark);
}

.accounting-action-panels {
    display: block;
}

.accounting-action-panel {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2rem);
    background: rgba(15, 23, 42, 0.58);
    overflow-y: auto;
}

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

.accounting-modal-card {
    width: min(980px, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid rgba(124, 58, 237, 0.18);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

body.is-accounting-modal-open {
    overflow: hidden;
}

.accounting-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.accounting-panel-heading h3,
.accounting-aside-panel h3 {
    margin: 0;
    font-size: 0.95rem;
}

.accounting-form-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 0.8rem;
}

.accounting-form-grid-wide {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.accounting-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
    gap: 1.25rem;
    align-items: start;
}

.accounting-main,
.accounting-side {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.accounting-side {
    position: sticky;
    top: 1rem;
}

.accounting-amount-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 0.85rem;
}

.accounting-amount-card,
.accounting-aside-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.accounting-amount-card {
    display: grid;
    gap: 0.35rem;
    min-height: 96px;
    padding: 1rem;
}

.accounting-amount-card span,
.accounting-aside-balance span {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.accounting-amount-card strong {
    font-size: 1.2rem;
    line-height: 1.2;
}

.accounting-amount-card.is-inflow {
    border-color: rgba(22, 163, 74, 0.24);
}

.accounting-amount-card.is-outflow {
    border-color: rgba(220, 38, 38, 0.22);
}

.accounting-aside-panel {
    padding: 1rem;
}

.accounting-aside-balance {
    display: grid;
    gap: 0.4rem;
    border-color: rgba(37, 99, 235, 0.22);
}

.accounting-aside-balance strong {
    font-size: 1.35rem;
    line-height: 1.2;
}

.accounting-filter-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.accounting-search {
    grid-column: span 2;
}

.accounting-filter-actions {
    display: flex;
    align-items: end;
}

.accounting-table td {
    vertical-align: top;
}

.accounting-table td small,
.accounting-operation small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.accounting-operation {
    display: grid;
    gap: 0.3rem;
}

.accounting-operation .badge {
    width: fit-content;
}

.accounting-amount {
    white-space: nowrap;
    font-weight: 700;
}

.accounting-table tr.is-cancelled td {
    color: var(--text-muted);
    background: #f8fafc;
}

.accounting-cancel-form {
    display: grid;
    gap: 0.35rem;
    min-width: 150px;
}

.accounting-cancel-form input {
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
}

.accounting-entry-form {
    display: grid;
    gap: 0.85rem;
}

.accounting-mini-list,
.accounting-category-list,
.accounting-trend-list {
    display: grid;
    gap: 0.65rem;
}

.accounting-mini-list div,
.accounting-category-list div,
.accounting-trend-list div {
    display: grid;
    gap: 0.25rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.accounting-mini-list span,
.accounting-trend-list span {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.accounting-category-list .badge {
    width: fit-content;
}

.accounting-category-list em {
    color: var(--text-muted);
    font-style: normal;
    font-weight: 700;
}

.accounting-side-title {
    margin: 1rem 0 0.6rem;
    font-size: 0.9rem;
}

@media (max-width: 1200px) {
    .accounting-amount-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .accounting-layout {
        grid-template-columns: 1fr;
    }

    .accounting-side {
        position: static;
    }
}

@media (max-width: 760px) {
    .accounting-action-panel {
        padding: 0.75rem;
    }

    .accounting-modal-card {
        max-height: calc(100vh - 1.5rem);
        padding: 0.85rem;
    }

    .accounting-command-bar {
        display: grid;
    }

    .accounting-command-actions {
        justify-content: flex-start;
    }

    .accounting-amount-grid,
    .accounting-form-grid,
    .accounting-form-grid-wide,
    .accounting-filter-form {
        grid-template-columns: 1fr;
    }

    .accounting-search {
        grid-column: auto;
    }
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}

textarea { min-height: 100px; resize: vertical; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* =====================================================
   Project Editor
   ===================================================== */
.editor-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.editor-sidebar {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    position: sticky;
    top: 1.5rem;
}

.editor-nav {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
}

.editor-nav li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.editor-nav li a:hover,
.editor-nav li a.active {
    background: var(--primary-50);
    color: var(--primary);
}

.editor-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 1.5rem;
    min-height: 500px;
}

.editor-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.work-item-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg);
}

.work-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.work-item-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

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

.work-item-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.work-item-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.editor-summary {
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1rem;
}

.devis-workbench {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    align-items: start;
}

.editor-estimate-manager {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.editor-estimate-manager:empty {
    display: none;
}

.editor-estimate-manager .estimate-manager {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
    align-items: start;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.editor-estimate-manager .estimate-manager-actions {
    align-content: flex-start;
}

.devis-tree-panel,
.devis-config-panel,
.devis-calc-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.devis-tree-panel {
    padding: 1rem;
}

.devis-config-panel,
.devis-calc-panel {
    position: sticky;
    top: 1rem;
    padding: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.devis-calc-panel {
    background: #fbfdff;
}

.devis-config-panel,
.devis-calc-panel {
    animation: editorPanelIn 0.22s ease-out;
}

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

.devis-tree-panel .devis-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.75rem;
}

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

.devis-toolbar h3,
.config-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.devis-toolbar-actions,
.config-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.estimate-manager {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
    padding-bottom: 1rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.estimate-manager-main {
    min-width: 0;
}

.estimate-manager-main label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.estimate-manager-main small {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.76rem;
}

.estimate-manager-main small strong {
    color: var(--text);
}

.estimate-manager-progress {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.45rem;
}

.estimate-manager-progress .estimate-progress-track {
    max-width: 260px;
}

.estimate-manager-progress strong {
    color: var(--text);
    font-size: 0.8rem;
    white-space: nowrap;
}

.estimate-manager-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.estimate-manager-meta {
    display: grid;
    grid-template-columns: minmax(150px, 190px) minmax(140px, 170px) minmax(220px, 1fr);
    align-items: start;
    gap: 0.65rem;
    margin-top: 0.55rem;
}

.estimate-manager-meta label {
    margin-bottom: 0.2rem;
    white-space: nowrap;
}

.estimate-manager-meta select,
.estimate-manager-meta input,
.estimate-manager-meta textarea {
    width: 100%;
    min-height: 34px;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    font-size: 0.84rem;
}

.estimate-payment-terms {
    min-width: 0;
}

.estimate-payment-terms textarea {
    resize: vertical;
}

.estimate-template-modal {
    max-width: 760px;
    border-radius: 8px;
}

.estimate-template-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.estimate-template-header h3 {
    margin: 0.2rem 0 0;
}

.estimate-template-form {
    display: grid;
    gap: 1rem;
}

.estimate-template-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.estimate-template-option {
    position: relative;
    display: block;
    cursor: pointer;
}

.estimate-template-option input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.estimate-template-option span {
    display: block;
    min-height: 104px;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.estimate-template-option strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.estimate-template-option small {
    display: block;
    color: var(--text-muted);
    line-height: 1.4;
}

.estimate-template-option input:checked + span {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.estimate-template-option.is-disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.estimate-template-option.is-disabled input {
    cursor: not-allowed;
}

.estimate-template-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.estimate-view-picker {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 220px;
}

.estimate-view-picker select {
    min-height: 36px;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    font-size: 0.875rem;
}

.estimate-project-total {
    color: #4b5563;
    font-size: 0.82rem;
    white-space: nowrap;
}

.estimate-project-total strong {
    color: #111;
}

.estimate-version-row {
    align-items: flex-start;
}

.estimate-version-row span {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.estimate-version-row small {
    color: var(--text-muted);
    font-size: 0.74rem;
}

.estimate-document-row {
    border-left: 3px solid var(--success);
}

.estimate-document-row a {
    align-self: flex-end;
    margin-top: 0.25rem;
}

.estimate-version-actions {
    align-items: flex-end;
}

.estimate-compare-table {
    display: grid;
    gap: 0.35rem;
    margin-top: 1rem;
}

.estimate-compare-head,
.estimate-compare-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(80px, 1fr));
    gap: 0.5rem;
    align-items: center;
}

.estimate-compare-head {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.estimate-compare-row {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 0.5rem 0.6rem;
    font-size: 0.82rem;
}

.estimate-compare-row span,
.estimate-compare-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audit-toolbar-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.audit-toolbar-button > span {
    display: inline-grid;
    min-width: 1.35rem;
    height: 1.35rem;
    place-items: center;
    border-radius: 999px;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.7rem;
    font-weight: 800;
}

.audit-readiness {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.6rem;
    align-items: center;
    margin-top: 0.75rem;
}

.audit-summary,
.estimate-change-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}

.audit-count,
.estimate-change-summary span,
.estimate-change-label {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 800;
}

.audit-count-error,
.change-removed {
    background: #fee2e2;
    color: #b91c1c;
}

.audit-count-warning,
.change-modified {
    background: #fef3c7;
    color: #92400e;
}

.change-added {
    background: #dcfce7;
    color: #166534;
}

.audit-issue-list,
.estimate-compare-sections,
.estimate-compare-items {
    display: grid;
    gap: 0.65rem;
}

.audit-issue {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.7rem;
    align-items: start;
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: 8px;
    padding: 0.75rem;
    background: #fff;
}

.audit-issue-error {
    border-left-color: #dc2626;
}

.audit-issue-warning {
    border-left-color: #d97706;
}

.audit-issue-marker {
    display: grid;
    width: 1.5rem;
    height: 1.5rem;
    place-items: center;
    border-radius: 999px;
    background: #f1f5f9;
    font-size: 0.75rem;
    font-weight: 900;
}

.audit-issue strong,
.audit-issue p {
    display: block;
    margin: 0;
}

.audit-issue p {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

.audit-success {
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 1rem;
    background: #f0fdf4;
    color: #166534;
}

.audit-success p {
    margin: 0.35rem 0 0;
}

.estimate-compare-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 0.8rem 0;
}

.estimate-compare-summary > div {
    display: grid;
    gap: 0.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem;
    background: #fff;
}

.estimate-compare-summary span {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.estimate-compare-summary strong {
    font-size: 0.82rem;
}

.is-positive {
    color: #166534;
}

.is-negative {
    color: #b91c1c;
}

.estimate-compare-section {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.estimate-compare-section summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.65rem;
    align-items: center;
    cursor: pointer;
    padding: 0.7rem;
    font-size: 0.76rem;
}

.estimate-compare-section[open] summary {
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.estimate-compare-items {
    padding: 0.6rem;
}

.estimate-compare-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.65rem;
    align-items: center;
    border-left: 3px solid #cbd5e1;
    padding: 0.55rem 0.65rem;
    background: #f8fafc;
    font-size: 0.74rem;
}

.estimate-compare-item.change-added {
    border-left-color: #16a34a;
    background: #f0fdf4;
}

.estimate-compare-item.change-removed {
    border-left-color: #dc2626;
    background: #fef2f2;
}

.estimate-compare-item.change-modified {
    border-left-color: #d97706;
    background: #fffbeb;
}

.estimate-compare-item > div {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.estimate-compare-item small {
    color: var(--text-muted);
}

.estimate-compare-item b {
    white-space: nowrap;
}

.estimate-compare-item.change-added .estimate-change-label {
    background: #dcfce7;
    color: #166534;
}

.estimate-compare-item.change-removed .estimate-change-label {
    background: #fee2e2;
    color: #b91c1c;
}

.estimate-compare-item.change-modified .estimate-change-label {
    background: #fef3c7;
    color: #92400e;
}

.estimate-compare-item.change-unchanged .estimate-change-label {
    background: #e2e8f0;
    color: #475569;
}

.devis-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.devis-tree {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.devis-section-node {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition), background var(--transition);
}

.devis-section-node.active {
    border-color: #93c5fd;
    background: #f8fbff;
}

.devis-section-node.active > .devis-section-row {
    background: #eff6ff;
}

.devis-section-node.selected,
.devis-section-node.active:has(.devis-work-node.selected) {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px #dbeafe, 0 10px 22px rgba(37, 99, 235, 0.1);
    animation: activeBlockIn 0.24s ease-out;
}

.devis-section-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
    background: #f8fafc;
}

.devis-section-main,
.devis-work-node,
.sidebar-section-add,
.config-list-item {
    font-family: var(--font);
}

.devis-section-main {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.devis-section-index {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 700;
    font-size: 0.8rem;
    flex: 0 0 auto;
}

.devis-section-copy,
.devis-work-copy {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.devis-section-copy strong,
.devis-work-copy strong {
    font-size: 0.9rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.devis-section-copy small,
.devis-work-copy small {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.devis-section-toggle {
    width: 42px;
    border: 0;
    border-left: 1px solid var(--border);
    background: #fff;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.devis-section-toggle:hover {
    background: var(--primary-50);
}

.devis-section-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -3px;
}

.devis-section-node.is-collapsed .devis-section-row {
    border-bottom: 0;
}

.devis-work-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.55rem 0.65rem 0.65rem 2.5rem;
}

.devis-work-list[hidden] {
    display: none;
}

.devis-work-list.drag-over-end::after {
    content: "";
    height: 3px;
    border-radius: 999px;
    background: #2563eb;
    box-shadow: 0 0 0 3px #dbeafe;
}

.devis-work-node {
    border: 1px solid transparent;
    background: #fff;
    border-radius: 6px;
    padding: 0.55rem 0.65rem;
    display: grid;
    grid-template-columns: 20px 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.devis-work-node.draggable {
    cursor: grab;
}

.devis-work-node.draggable:active,
.devis-work-node.is-dragging {
    cursor: grabbing;
}

.devis-work-node.is-dragging {
    opacity: 0.45;
    transform: translateX(4px) scale(0.99);
}

.devis-work-node.drag-over-before {
    box-shadow: 0 -3px 0 #2563eb, 0 -6px 0 #dbeafe;
}

.devis-work-node::before {
    content: "";
    position: absolute;
    left: 0;
    top: 7px;
    bottom: 7px;
    width: 3px;
    border-radius: 0 999px 999px 0;
    background: #2563eb;
    opacity: 0;
    transform: scaleY(0.35);
    transition: opacity var(--transition), transform var(--transition);
}

.devis-work-node:hover,
.devis-work-node.selected {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.devis-work-node:hover {
    transform: translateX(1px);
}

.devis-work-node.selected {
    border-color: #2563eb;
    background: #dbeafe;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
    transform: translateX(2px);
}

.devis-work-node.selected::before {
    opacity: 1;
    transform: scaleY(1);
}

.devis-work-node.pending .devis-work-copy small {
    color: var(--warning);
}

.devis-work-branch {
    width: 16px;
    height: 18px;
    border-left: 1px solid #cbd5e1;
    border-bottom: 1px solid #cbd5e1;
    border-bottom-left-radius: 4px;
}

.devis-work-drag-handle {
    width: 18px;
    height: 22px;
    border-radius: 4px;
    background:
        radial-gradient(circle, #94a3b8 1.4px, transparent 1.5px) 0 0 / 6px 6px;
    opacity: 0.75;
    pointer-events: none;
}

.devis-work-node.draggable:hover .devis-work-drag-handle,
.devis-work-node.is-dragging .devis-work-drag-handle {
    opacity: 1;
}

.devis-work-index {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sidebar-section-palette {
    margin: 0.75rem 0.375rem 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.sidebar-section-title {
    padding: 0 0.5rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-section-add {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    padding: 0.48rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
    font-size: 0.82rem;
    cursor: pointer;
}

.sidebar-section-add:hover {
    background: #ecfdf5;
    color: #047857;
}

.sidebar-section-plus {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dcfce7;
    color: #15803d;
    font-weight: 800;
    flex: 0 0 auto;
}

.config-panel-header {
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.config-form .form-group {
    margin-bottom: 0.85rem;
}

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

.config-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.config-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1rem;
}

.config-list-item,
.config-list-static,
.material-preview div {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 0.55rem 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--text);
    font-size: 0.85rem;
}

.config-list-item {
    cursor: pointer;
    text-align: left;
}

.config-list-item:hover {
    background: #f8fafc;
    border-color: #bfdbfe;
}

.config-list-item.selected {
    background: #eff6ff;
    border-color: #2563eb;
    box-shadow: inset 3px 0 0 #2563eb;
}

.config-list-static strong,
.config-list-item strong,
.material-preview strong {
    white-space: nowrap;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.config-muted,
.config-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.material-preview {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1rem;
}

.custom-material-editor,
.fee-lines-editor,
.manual-material-lines {
    display: grid;
    gap: 0.65rem;
    margin: 1rem 0;
}

.custom-material-title {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.custom-material-row,
.fee-line-row,
.manual-material-row {
    display: grid;
    grid-template-columns: minmax(120px, 1.1fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr) auto;
    gap: 0.5rem;
    align-items: end;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.custom-material-row-tile {
    grid-template-columns: minmax(120px, 1.1fr) repeat(4, minmax(78px, 0.7fr));
}

.fee-line-row {
    grid-template-columns: minmax(140px, 1fr) minmax(110px, 0.7fr) auto;
}

.manual-material-row {
    grid-template-columns: minmax(140px, 1.25fr) minmax(72px, 0.45fr) minmax(90px, 0.65fr) minmax(100px, 0.7fr) auto;
}

.custom-material-name {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    min-width: 0;
}

.custom-material-name strong {
    font-size: 0.82rem;
    line-height: 1.25;
}

.custom-material-name span {
    color: var(--text-muted);
    font-size: 0.74rem;
}

.custom-material-row .form-group,
.fee-line-row .form-group,
.manual-material-row .form-group {
    margin-bottom: 0;
}

.calc-note-compact {
    margin-top: 0.85rem;
}

.calc-panel-header {
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.calc-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.calc-note {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 0.82rem;
    line-height: 1.45;
}

.calc-block {
    margin-top: 1rem;
}

.calc-block h4 {
    margin: 0 0 0.55rem;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.calc-row,
.calc-total div,
.calc-material {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.82rem;
}

.calc-row span,
.calc-material span,
.calc-total span {
    color: var(--text-muted);
}

.calc-row strong,
.calc-total strong,
.calc-material em {
    color: var(--text);
    font-style: normal;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.calc-steps {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text);
    font-size: 0.82rem;
    line-height: 1.45;
}

.calc-steps li + li {
    margin-top: 0.35rem;
}

.calc-material {
    align-items: start;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
}

.calc-material-main {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.12rem;
}

.calc-material strong {
    color: var(--text);
    font-size: 0.82rem;
}

.calc-material span {
    font-size: 0.74rem;
}

.calc-material-values {
    display: grid;
    gap: 0.15rem;
    min-width: 150px;
}

.calc-material-values span {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    line-height: 1.25;
}

.calc-material-values small {
    color: var(--text-muted);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.calc-material-values strong {
    color: var(--text);
    font-size: 0.74rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.calc-total {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
}

.calc-total div {
    border-bottom-color: rgba(99, 102, 241, 0.18);
}

.calc-total div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

/* =====================================================
   Estimate / Print
   ===================================================== */
.print-layout {
    background: #fff;
    padding: 2rem;
}

.print-actions {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 1000;
}

.print-container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
}

.estimate-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--primary);
}

.estimate-company h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
}

.estimate-company p {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.estimate-meta {
    text-align: right;
}

.estimate-meta .estimate-number {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
}

.estimate-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.estimate-table th,
.estimate-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.estimate-table th {
    background: var(--primary-50);
    font-weight: 600;
    color: var(--primary-dark);
}

.estimate-table td.numeric,
.estimate-table th.numeric {
    text-align: right;
}

.estimate-total {
    display: flex;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 2px solid var(--primary);
}

.estimate-total-box {
    text-align: right;
}

.estimate-total-box .total-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.estimate-total-box .total-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* =====================================================
   Tables
   ===================================================== */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
}

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

.subscription-admin-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.subscription-admin-hero .card-header {
    align-items: flex-start;
    gap: 1rem;
}

.subscription-admin-hero .card-header > div span {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.subscription-admin-hero p {
    max-width: 760px;
    margin: 0;
    color: var(--text-muted);
}

.subscription-admin-table td {
    vertical-align: top;
}

.subscription-admin-table td strong,
.subscription-admin-table td span,
.subscription-admin-table td small {
    display: block;
}

.subscription-admin-table td small {
    margin-top: 0.2rem;
    color: var(--text-muted);
}

.subscription-admin-form {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) minmax(100px, 0.75fr) 130px 130px auto;
    gap: 0.5rem;
    align-items: center;
    min-width: 760px;
}

.subscription-admin-form select,
.subscription-admin-form input[type="date"] {
    min-height: 36px;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 0.82rem;
}

.subscription-admin-renew {
    min-height: 36px;
    align-items: center;
    white-space: nowrap;
}

/* =====================================================
   Modals
   ===================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay .modal {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.modal-overlay .modal.estimate-template-modal {
    max-width: 760px;
    border-radius: 8px;
}

/* =====================================================
   Animations
   ===================================================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes editorPanelIn {
    from { opacity: 0.86; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes activeBlockIn {
    from { transform: translateY(2px); }
    to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .devis-config-panel,
    .devis-calc-panel,
    .devis-section-node.selected,
    .devis-section-node.active:has(.devis-work-node.selected) {
        animation: none;
    }

    .devis-section-node,
    .devis-section-main,
    .devis-section-toggle,
    .devis-work-node,
    .devis-work-node::before {
        transition: none;
    }
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 1280px) {
    .has-workspace-aside .main-content {
        margin-right: 0;
    }

    .workspace-aside {
        display: none;
    }
}

@media (max-width: 1100px) {
    .devis-workbench {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .devis-calc-panel {
        grid-column: 1 / -1;
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    .has-workspace-aside .main-content {
        margin-right: 0;
    }
    .sidebar-toggle {
        display: flex;
    }
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .editor-sidebar {
        position: static;
    }
    .devis-workbench {
        grid-template-columns: 1fr;
    }
    .editor-estimate-manager .estimate-manager {
        grid-template-columns: 1fr;
    }
    .devis-config-panel,
    .devis-calc-panel {
        position: static;
        max-height: none;
    }
    .calc-material {
        grid-template-columns: 1fr;
    }
    .calc-material-values {
        width: 100%;
    }
    .devis-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .estimate-manager {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    .estimate-manager-actions {
        justify-content: flex-start;
    }
    .estimate-manager-meta {
        align-items: flex-start;
        grid-template-columns: 1fr;
    }
    .estimate-manager-meta select,
    .estimate-manager-meta input,
    .estimate-manager-meta textarea {
        max-width: none;
        width: 100%;
    }
    .estimate-template-modal {
        max-height: calc(100vh - 1rem);
        padding: 1rem;
    }
    .estimate-template-header,
    .estimate-template-actions {
        align-items: stretch;
        flex-direction: column;
    }
    .estimate-template-grid {
        grid-template-columns: 1fr;
    }
    .estimate-template-option span {
        min-height: 0;
    }
    .estimate-compare-head {
        display: none;
    }
    .estimate-compare-row {
        grid-template-columns: 1fr;
    }
    .estimate-compare-row span,
    .estimate-compare-row strong {
        white-space: normal;
    }
    .estimate-view-picker {
        width: 100%;
        min-width: 0;
    }
    .estimate-actionbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .devis-toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .custom-material-row,
    .custom-material-row-tile,
    .fee-line-row,
    .manual-material-row {
        grid-template-columns: 1fr;
    }
    .company-logo-settings {
        align-items: flex-start;
        flex-direction: column;
    }
    .project-detail-grid,
    .project-access-shortcuts,
    .project-finance-grid,
    .project-budget-summary,
    .project-alert-list,
    .project-schedule-summary,
    .project-site-log-summary,
    .project-quality-summary,
    .project-stakeholder-summary,
    .project-document-register-summary,
    .project-risk-summary,
    .project-procurement-summary,
    .project-stock-summary {
        grid-template-columns: 1fr;
    }
    .project-reminder-item {
        grid-template-columns: 1fr;
    }
    .project-expense-form-grid {
        grid-template-columns: 1fr;
    }
    .project-schedule-form-grid {
        grid-template-columns: 1fr;
    }
    .project-site-log-form-grid,
    .project-site-log-notes,
    .project-site-log-meta,
    .project-site-log-notes-grid,
    .project-quality-form-grid,
    .project-stakeholder-form-grid,
    .project-document-register-form-grid,
    .project-risk-form-grid,
    .project-quality-notes,
    .project-risk-notes {
        grid-template-columns: 1fr;
    }
    .project-finance-header {
        flex-direction: column;
    }
    .project-finance-header > strong {
        white-space: normal;
    }
    .project-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 0.5rem;
    }
    .project-tab-button {
        width: 100%;
        min-height: 40px;
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.2;
    }
    .subscription-admin-hero .card-header {
        flex-direction: column;
    }
    .subscription-admin-form {
        min-width: 0;
        grid-template-columns: 1fr;
    }
    .subscription-admin-form select,
    .subscription-admin-form input[type="date"],
    .subscription-admin-form .btn {
        width: 100%;
    }
    .subscription-admin-renew {
        white-space: normal;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .topbar {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

.estimate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.estimate-table th,
.estimate-table td {
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
}
.estimate-table th {
    background: #f3f4f6;
    font-weight: 600;
    text-align: left;
}
.estimate-table td strong {
    color: var(--text);
}

@media print {
    .no-print { display: none !important; }
    .sidebar, .topbar { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
    .print-container { max-width: 100%; }
    .project-commercial-doc {
        width: 100%;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
    }
    .project-commercial-table tr,
    .project-commercial-meta div,
    .project-commercial-signatures div {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* =====================================================
   Client portal
   ===================================================== */
.client-public-body,
.client-portal-body {
    background: #f8fafc;
}

.client-public-shell {
    width: min(1120px, calc(100% - 2rem));
    min-height: 100vh;
    margin: 0 auto;
    padding: 3rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.client-login-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
    gap: 1.5rem;
    align-items: stretch;
}

.client-login-copy,
.client-login-card,
.client-section,
.client-project-card,
.client-estimate-card,
.client-estimate-document,
.client-estimate-aside .client-side-panel,
.project-client-access-block,
.project-people-access-block {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.client-login-copy {
    padding: 2rem;
}

.project-people-access-block {
    padding: 1rem;
}

.project-people-access-block p {
    margin: 0.25rem 0 1rem;
    color: var(--text-muted);
}

.project-access-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-access-shortcuts a {
    display: grid;
    gap: 0.35rem;
    padding: 0.95rem;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: var(--radius-sm);
    background: var(--primary-50);
    color: var(--text);
    text-decoration: none;
}

.project-access-shortcuts strong {
    color: var(--primary);
}

.project-access-shortcuts span {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.project-work-assignments-block {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}

.project-work-assignment-form {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.95rem;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: var(--radius-sm);
    background: #f8fbff;
}

.project-work-assignment-grid {
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(280px, 1.4fr) minmax(180px, 1fr);
    gap: 0.75rem;
}

.project-work-assignment-list {
    display: grid;
    gap: 0.65rem;
}

.project-work-assignment-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.project-work-assignment-main {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.project-work-assignment-main strong {
    color: var(--text);
}

.project-work-assignment-main small,
.project-work-assignment-main p {
    color: var(--text-muted);
}

.project-work-assignment-main p {
    margin: 0.2rem 0 0;
}

.project-work-assignment-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.project-work-assignment-actions form {
    margin: 0;
}

.project-work-assignment-actions select {
    min-height: 34px;
    max-width: 160px;
}

.client-login-copy h1 {
    font-size: 2.5rem;
    margin: 0.5rem 0 1rem;
}

.client-login-copy p {
    max-width: 760px;
    color: var(--text-muted);
}

.client-kicker {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.client-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.client-feature-grid div,
.client-summary-grid div,
.project-client-estimates label {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    background: var(--bg);
}

.client-feature-grid strong,
.client-feature-grid span {
    display: block;
}

.client-feature-grid span {
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.client-login-card {
    padding: 2rem;
}

.client-login-card h2 {
    margin: 0 0 0.5rem;
}

.client-login-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

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

.client-portal-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    text-decoration: none;
}

.client-portal-brand:hover {
    text-decoration: none;
}

.client-portal-mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--primary);
    font-weight: 800;
}

.client-portal-brand span:last-child {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

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

.client-portal-nav,
.client-portal-nav form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.client-portal-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 600;
}

.client-portal-nav a:hover,
.client-portal-nav a.active,
.client-portal-nav a[aria-current="page"] {
    background: var(--primary-50);
    color: var(--primary);
    text-decoration: none;
}

.client-portal-main {
    width: min(1280px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.client-page-heading,
.client-section-header,
.project-client-access-grid,
.project-client-item,
.client-work-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.client-page-heading {
    margin-bottom: 1rem;
}

.client-project-hero,
.client-estimate-hero {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1.2rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}

.client-project-hero h1,
.client-estimate-hero h1 {
    margin: 0.25rem 0;
    color: #0f172a;
    font-size: 1.8rem;
}

.client-project-hero p,
.client-estimate-hero p {
    margin: 0;
    color: #64748b;
}

.client-project-hero-card {
    display: grid;
    align-content: center;
    min-width: 230px;
    padding: 1rem;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 8px;
    background: #eff6ff;
}

.client-project-hero-card span,
.client-project-hero-card small {
    color: #1d4ed8;
    font-size: 0.82rem;
    font-weight: 700;
}

.client-project-hero-card strong {
    margin: 0.25rem 0;
    color: #0f172a;
    font-size: 1.25rem;
}

.client-welcome-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #ffffff;
}

.client-welcome-panel h2 {
    margin: 0.2rem 0;
    color: #0f172a;
}

.client-welcome-panel p {
    margin: 0;
    color: #64748b;
}

.client-next-actions,
.client-card-actions,
.client-document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.client-card-actions {
    margin-top: 0.85rem;
}

.client-message-grid {
    display: grid;
    gap: 0.75rem;
}

.client-tab-panel {
    scroll-margin-top: 92px;
}

.client-page-heading span,
.client-section-header span,
.client-summary-grid span,
.client-project-card span,
.client-estimate-card span,
.client-work-summary span,
.project-client-identity span,
.project-client-identity small {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.client-page-heading h1 {
    margin: 0.25rem 0;
    font-size: 1.75rem;
}

.client-page-heading p {
    margin: 0;
    color: var(--text-muted);
}

.client-page-heading > strong {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    background: var(--primary-50);
    color: var(--primary);
    white-space: nowrap;
}

.client-back-link {
    display: inline-flex;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.client-project-grid,
.client-estimate-grid,
.client-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.client-project-card,
.client-estimate-card,
.client-section,
.project-client-access-block {
    padding: 1rem;
}

.client-project-card h2,
.client-estimate-card h3,
.client-section-header h2,
.project-client-access-block h3 {
    margin: 0.25rem 0;
}

.client-project-card p,
.client-estimate-card p {
    color: var(--text-muted);
}

.client-project-metrics,
.client-estimate-card-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.client-project-metrics div,
.client-estimate-card-meta {
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.client-estimate-mini-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.client-estimate-mini-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
}

.client-plan-upload {
    display: grid;
    grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 8px;
    background: #f8fbff;
}

.client-plan-upload h3 {
    margin: 0.25rem 0 0;
    color: #0f172a;
}

.client-plan-form {
    display: grid;
    grid-template-columns: minmax(160px, 0.9fr) minmax(180px, 1fr) minmax(200px, 1.1fr) auto;
    gap: 0.75rem;
    align-items: end;
}

.client-plan-form textarea {
    min-height: 42px;
    resize: vertical;
}

.client-plan-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.client-plan-card {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}

.client-plan-preview {
    display: grid;
    place-items: center;
    min-height: 132px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: #eef2f7;
    color: #1d4ed8;
    font-weight: 800;
    text-decoration: none;
}

.client-plan-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.client-plan-preview.is-pdf {
    background: linear-gradient(135deg, #fff7ed 0%, #fee2e2 100%);
    color: #b91c1c;
}

.client-plan-content {
    min-width: 0;
}

.client-plan-content h3 {
    margin: 0.45rem 0 0;
    color: #0f172a;
}

.client-plan-content p {
    min-height: 1.25rem;
    margin: 0.45rem 0 0;
    color: var(--text-muted);
}

.client-section {
    margin-top: 1rem;
}

.client-summary-grid {
    margin-bottom: 1rem;
}

.client-summary-grid div strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.125rem;
}

.client-summary-grid div small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.client-quote-primary-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 0 0 1rem;
    position: sticky;
    top: 72px;
    z-index: 20;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.client-quote-primary-actions-readonly {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.client-quote-action {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 0 0.55rem;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem;
    background: #fff;
    color: var(--text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.client-quote-action:hover,
.client-quote-action:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.client-quote-action > span {
    grid-row: 1 / 3;
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: 999px;
    background: var(--primary-50);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 900;
}

.client-quote-action strong {
    font-size: 0.82rem;
}

.client-quote-action small {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.client-quote-action-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.client-quote-action-primary > span {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.client-quote-action-primary small {
    color: rgba(255, 255, 255, 0.78);
}

.client-view-only-note {
    margin-bottom: 1rem;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 0.82rem;
}

.client-estimate-card .estimate-progress {
    margin: 0.75rem 0 0.65rem;
}

.client-estimate-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1rem;
    align-items: flex-start;
}

.client-estimate-viewer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 1rem;
    align-items: flex-start;
}

.client-estimate-viewer-single {
    grid-template-columns: minmax(0, 1fr);
}

.client-estimate-document-shell {
    display: grid;
    gap: 1rem;
    justify-items: center;
}

.client-estimate-document-shell .public-estimate-document {
    width: min(100%, 980px);
}

.client-technical-details {
    width: min(100%, 980px);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}

.client-technical-details summary {
    cursor: pointer;
    padding: 1rem;
    color: #0f172a;
    font-weight: 800;
    list-style: none;
}

.client-technical-details summary::-webkit-details-marker {
    display: none;
}

.client-technical-details[open] summary {
    border-bottom: 1px solid var(--border);
}

.client-technical-details .client-estimate-section {
    margin: 1rem;
}

.client-estimate-document {
    padding: 1rem;
}

.client-estimate-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.client-estimate-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.client-work-detail {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    margin-top: 0.75rem;
}

.client-work-summary {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(120px, 0.5fr));
    align-items: center;
}

.client-technical-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 1rem;
    margin-top: 1rem;
}

.client-param-grid {
    display: grid;
    gap: 0.5rem;
}

.client-param-grid div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.client-material-lines {
    font-size: 0.8125rem;
}

.client-estimate-aside {
    display: grid;
    gap: 1rem;
    position: sticky;
    top: 88px;
}

.client-estimate-aside .client-side-panel {
    padding: 1rem;
}

.client-action-panel {
    position: relative;
    border-color: #bfdbfe;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.12);
}

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

.client-panel-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 1.2rem;
    cursor: pointer;
}

.client-advanced-note {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.8rem;
}

.client-advanced-note summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.client-advanced-note .config-form {
    margin-top: 0.8rem;
}

.client-decision-confirmed {
    margin-bottom: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.9rem;
    background: #f8fafc;
}

.client-decision-confirmed.decision-accepted {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.client-decision-confirmed.decision-rejected {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.client-decision-confirmed p {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
}

.project-client-access-block,
.project-client-messages-block {
    margin-top: 1rem;
}

.project-client-access-grid {
    align-items: stretch;
}

.project-client-form,
.project-client-estimate-form {
    flex: 1;
}

.project-client-form {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.project-client-form h4 {
    margin-top: 0;
}

.project-client-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.project-client-estimates {
    display: grid;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.project-client-estimates label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.project-client-estimates.compact {
    margin: 0;
}

.project-client-estimates.compact label {
    padding: 0.5rem;
}

.project-client-estimates label.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.project-client-estimates small {
    color: var(--text-muted);
}

.project-client-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.project-client-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
}

.project-client-identity {
    min-width: 220px;
}

.project-client-pin-form {
    flex: 0 0 auto;
}

.project-client-messages-block {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

.project-client-message-list {
    display: grid;
    gap: 0.75rem;
}

.project-client-message-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    background: var(--bg);
}

.project-client-message-item > div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.project-client-message-item small {
    color: var(--text-muted);
}

.project-client-message-item p {
    margin: 0;
}

@media (max-width: 980px) {
    .client-login-grid,
    .client-estimate-layout,
    .client-estimate-viewer,
    .project-client-access-grid,
    .client-technical-grid,
    .project-document-attachment-grid,
    .client-plan-upload,
    .client-plan-form {
        grid-template-columns: 1fr;
    }

    .client-project-grid,
    .client-estimate-grid,
    .client-plan-grid,
    .client-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .client-estimate-aside {
        position: static;
    }

    .client-work-summary {
        grid-template-columns: 1fr 1fr;
    }

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

    .client-quote-primary-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        position: static;
    }
}

@media (max-width: 640px) {
    .client-public-shell,
    .client-portal-main {
        width: min(100% - 1rem, 100%);
    }

    .client-portal-header,
    .client-page-heading,
    .client-project-hero,
    .client-estimate-hero,
    .client-welcome-panel,
    .project-client-item {
        flex-direction: column;
    }

    .client-portal-header {
        align-items: stretch;
        padding: 0.875rem;
    }

    .client-portal-nav {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .client-feature-grid,
    .client-project-grid,
    .client-estimate-grid,
    .client-plan-grid,
    .client-summary-grid,
    .client-project-metrics,
    .client-work-summary,
    .client-plan-card {
        grid-template-columns: 1fr;
    }

    .client-quote-primary-actions,
    .estimate-compare-summary {
        grid-template-columns: 1fr;
    }

    .estimate-compare-section summary,
    .estimate-compare-item,
    .audit-issue {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media print {
    .client-portal-header,
    .client-estimate-hero,
    .client-summary-grid,
    .client-estimate-aside,
    .client-technical-details,
    .alert,
    .no-print {
        display: none !important;
    }

    .client-portal-body {
        background: #ffffff;
    }

    .client-portal-main {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .client-estimate-viewer,
    .client-estimate-document-shell,
    .client-estimate-document-shell .public-estimate-document {
        display: block;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }
}

.estimate-page .card {
    background: transparent;
    border: 0;
    box-shadow: none;
}

.estimate-page .card-body {
    padding: 18px 0 0;
}

.estimate-document-shell {
    width: min(100%, 980px);
}

.estimate-workspace-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    width: min(100%, 1380px);
    margin: 0 auto;
}

.estimate-page > .estimate-actionbar {
    width: min(100%, 1380px);
}

.estimate-calculation-sidebar {
    display: grid;
    gap: 16px;
    width: min(100%, 980px);
}

.estimate-document-shell .estimate-section-row,
.estimate-document-shell .client-clickable-work {
    cursor: pointer;
}

.estimate-document-shell .client-clickable-work:hover td,
.estimate-document-shell .client-selected-work td {
    background: #eef6ff;
}

.estimate-document-shell .client-selected-work td:first-child {
    box-shadow: inset 4px 0 0 #2563eb;
}

.estimate-actionbar {
    width: min(100%, 980px);
    margin: 0 auto 16px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fff;
    border: 1px solid #d8dce3;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
}

.estimate-actionbar strong {
    font-size: 14px;
    color: #111;
}

.estimate-actionbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

@media (min-width: 1700px) {
    .estimate-workspace-grid {
        align-items: start;
        grid-template-columns: 980px minmax(320px, 360px);
        justify-content: center;
    }

    .estimate-calculation-sidebar {
        position: sticky;
        top: 18px;
        width: 100%;
    }
}

.project-commercial-page {
    width: 100%;
}

.project-commercial-doc {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 46px 56px 58px;
    background: #fff;
    color: #111827;
    border: 1px solid #d8dce3;
    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.06);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.35;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.project-commercial-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
    gap: 24px;
    align-items: start;
    padding-bottom: 18px;
    border-bottom: 2px solid #111827;
}

.project-commercial-brand {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.project-commercial-brand img {
    width: 78px;
    height: 78px;
    object-fit: contain;
    flex: 0 0 auto;
}

.project-commercial-brand h1 {
    margin: 0 0 8px;
    font-size: 22px;
    line-height: 1.1;
    color: #111827;
}

.project-commercial-brand p {
    margin: 3px 0;
    color: #4b5563;
}

.project-commercial-title {
    text-align: right;
}

.project-commercial-title span {
    display: block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #047857;
}

.project-commercial-title strong {
    display: block;
    margin-top: 5px;
    font-size: 24px;
    color: #111827;
}

.project-commercial-title small {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 8px;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #15803d;
    font-weight: 700;
}

.project-commercial-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.project-commercial-meta div {
    padding: 10px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}

.project-commercial-meta span {
    display: block;
    margin-bottom: 4px;
    color: #6b7280;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-commercial-meta strong {
    display: block;
    color: #111827;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.project-commercial-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    color: #111827;
}

.project-commercial-table th,
.project-commercial-table td {
    border: 1px solid #d1d5db;
    padding: 7px 8px;
    vertical-align: top;
}

.project-commercial-table th {
    background: #111827;
    color: #fff;
    font-size: 11px;
    text-transform: uppercase;
}

.project-commercial-table th:first-child,
.project-commercial-table td:first-child {
    width: 42px;
    text-align: center;
}

.project-commercial-table th:nth-child(3),
.project-commercial-table th:nth-child(4),
.project-commercial-table th:nth-child(5),
.project-commercial-table th:nth-child(6),
.project-commercial-table td:nth-child(3),
.project-commercial-table td:nth-child(4),
.project-commercial-table td:nth-child(5),
.project-commercial-table td:nth-child(6) {
    text-align: right;
    white-space: nowrap;
}

.project-commercial-section td {
    background: #e0f2fe;
    color: #075985;
    font-weight: 800;
    text-transform: uppercase;
}

.project-commercial-work td {
    background: #f8fafc;
    font-weight: 700;
}

.project-commercial-material td {
    color: #374151;
    font-size: 11px;
}

.project-commercial-material td:nth-child(2) {
    padding-left: 24px;
}

.project-commercial-table tfoot td {
    background: #f3f4f6;
    font-weight: 800;
}

.project-commercial-table tfoot tr:last-child td {
    background: #dcfce7;
    color: #14532d;
    font-size: 13px;
}

.project-payment-progress {
    height: 8px;
    margin: -4px 0 18px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.project-payment-progress span {
    display: block;
    height: 100%;
    background: #16a34a;
}

.project-payment-section,
.project-payment-form {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
}

.project-payment-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.project-payment-header span {
    display: block;
    margin-bottom: 3px;
    color: #6b7280;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-payment-header h2 {
    margin: 0;
    color: #111827;
    font-size: 16px;
}

.project-payment-header > strong {
    white-space: nowrap;
    color: #14532d;
}

.project-payment-list {
    display: grid;
    gap: 8px;
}

.project-payment-row {
    display: grid;
    grid-template-columns: minmax(120px, 0.8fr) minmax(140px, 1fr);
    gap: 10px;
    padding: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.project-payment-row span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.project-payment-row small,
.project-payment-empty {
    color: #6b7280;
}

.project-payment-row p {
    grid-column: 1 / -1;
    margin: 0;
    color: #4b5563;
}

.project-payment-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.project-payment-form input,
.project-payment-form select,
.project-payment-form textarea {
    width: 100%;
}

.project-commercial-notes {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #d1d5db;
    color: #374151;
}

.project-commercial-notes p {
    margin: 0 0 9px;
}

.project-commercial-signatures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    margin-top: 46px;
}

.project-commercial-signatures div {
    position: relative;
    min-height: 82px;
    border-top: 1px solid #111827;
    padding-top: 8px;
    color: #374151;
    font-weight: 700;
}

.project-commercial-seal {
    position: absolute;
    right: 10px;
    bottom: 16px;
    width: 96px;
    height: 96px;
    object-fit: contain;
    transform: rotate(-8deg);
    opacity: 0.92;
}

.project-commercial-contact {
    margin-top: 24px;
    padding-top: 10px;
    border-top: 2px solid #111827;
    color: #374151;
    text-align: center;
    font-size: 11px;
    line-height: 1.35;
}

.project-commercial-contact p {
    margin: 0 0 3px;
}

@media (max-width: 768px) {
    .estimate-actionbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .estimate-actionbar-actions {
        justify-content: flex-start;
    }

    .project-commercial-doc {
        padding: 24px 18px;
    }

    .project-commercial-head,
    .project-commercial-meta,
    .project-commercial-signatures,
    .project-payment-form-grid,
    .project-payment-row {
        grid-template-columns: 1fr;
    }

    .project-commercial-title {
        text-align: left;
    }
}

.iconic-estimate-doc {
    --iconic-purple: #6f2aa1;
    --iconic-purple-dark: #7d009b;
    --iconic-purple-mid: #aa70d4;
    --iconic-purple-soft: #ead0fb;
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 58px 68px 78px;
    background: #fff;
    color: #111;
    border: 1px solid #1f1f1f;
    font-family: Arial, Helvetica, sans-serif;
    font-size: var(--estimate-font-size, 12px);
    line-height: 1.22;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.iconic-estimate-head {
    margin-bottom: 24px;
}

.iconic-brand {
    width: 230px;
    margin-bottom: 10px;
    color: var(--iconic-purple-dark);
}

.iconic-brand-img {
    max-width: 220px;
    max-height: 88px;
    object-fit: contain;
}

.iconic-brand-mark {
    position: relative;
    width: 104px;
    height: 48px;
    margin-left: 52px;
}

.iconic-brand-mark span {
    position: absolute;
    display: block;
    height: 14px;
    border-radius: 12px;
    background: linear-gradient(90deg, #8f00ad, #5b168f);
    transform: rotate(-47deg);
}

.iconic-brand-mark span:nth-child(1) {
    width: 58px;
    left: 0;
    top: 25px;
}

.iconic-brand-mark span:nth-child(2) {
    width: 70px;
    left: 31px;
    top: 20px;
}

.iconic-brand-mark span:nth-child(3) {
    width: 44px;
    left: 57px;
    top: 30px;
}

.iconic-brand-name {
    font-size: 26px;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0;
}

.iconic-rule {
    height: 0;
    border-top: 14px solid var(--iconic-purple);
}

.iconic-rule-sub {
    border-top-width: 5px;
}

.iconic-legal {
    margin: 4px 0 3px;
    padding: 0 30px;
    font-size: 10px;
    text-align: center;
    color: #111;
    overflow-wrap: anywhere;
}

.iconic-title {
    margin-top: 42px;
    padding: 10px;
    background: var(--iconic-purple);
    color: #fff;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0;
}

.iconic-estimate-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.55rem;
    color: #111;
    font-size: 11px;
    font-weight: 700;
}

.iconic-estimate-meta .estimate-number {
    color: var(--iconic-purple-dark);
}

.iconic-estimate-terms {
    margin-top: 18px;
    color: #111;
    font-size: 11px;
    line-height: 1.35;
}

.iconic-estimate-terms p {
    margin: 0 0 6px;
}

.iconic-estimate-decision {
    margin-top: 16px;
    border: 1px solid #111;
    border-left: 5px solid #111;
    padding: 10px 12px;
    color: #111;
    font-size: 11px;
    line-height: 1.35;
}

.iconic-estimate-decision.accepted {
    border-left-color: #16a34a;
}

.iconic-estimate-decision.rejected {
    border-left-color: #dc2626;
}

.iconic-estimate-decision p {
    margin: 0 0 5px;
}

.iconic-estimate-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 22px;
    margin-bottom: 0;
    font-size: var(--estimate-font-size, 12px);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.iconic-estimate-table th,
.iconic-estimate-table td {
    border: 0 !important;
    padding: 2px 4px !important;
    color: #111;
    vertical-align: middle;
}

.iconic-estimate-table th {
    background: var(--iconic-purple) !important;
    color: #fff !important;
    font-weight: 800;
    text-align: left;
    box-shadow: inset 0 0 0 999px var(--iconic-purple);
}

.iconic-estimate-table .col-work-no {
    width: 6%;
}

.iconic-estimate-table .col-material-no {
    width: 6%;
}

.iconic-estimate-table .col-designation {
    width: 38%;
}

.iconic-estimate-table .col-unit,
.iconic-estimate-table .col-qty,
.iconic-estimate-table .col-pu,
.iconic-estimate-table .col-pt {
    width: 12.5%;
}

.iconic-estimate-table .col-work-no,
.iconic-estimate-table .col-material-no,
.iconic-estimate-table .col-unit,
.iconic-estimate-table .col-qty,
.iconic-estimate-table .col-pu,
.iconic-estimate-table .col-pt,
.iconic-estimate-table td.amount {
    text-align: right;
}

.iconic-estimate-table td.num {
    text-align: right;
    padding-right: 6px !important;
}

.iconic-section-row td {
    padding-top: 18px !important;
    background: var(--iconic-purple-mid);
    color: #111;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: inset 0 0 0 999px var(--iconic-purple-mid);
}

.iconic-work-row td:nth-child(n+3) {
    background: linear-gradient(90deg, #8c00a8, #7e009a);
    color: #fff;
    box-shadow: inset 0 0 0 999px #8500a1;
}

.iconic-work-row .work-num {
    font-weight: 700;
}

.iconic-work-row .work-title {
    font-weight: 400;
}

.iconic-work-row .work-note {
    display: block;
    font-size: 0.92em;
    color: #fff;
}

.iconic-material-row td {
    background: #fff;
}

.iconic-material-row td:nth-child(3) {
    padding-left: 14px !important;
}

.iconic-subtotal-row td:nth-child(n+3) {
    background: var(--iconic-purple-soft);
    box-shadow: inset 0 0 0 999px var(--iconic-purple-soft);
}

.iconic-subtotal-row td {
    font-weight: 400;
}

.iconic-subtotal-row td:last-child {
    font-weight: 800;
}

.iconic-empty-row td {
    height: 16px;
    padding: 0 !important;
    background: #fff;
}

.iconic-section-materials-row td {
    background: linear-gradient(90deg, #8c00a8, #7e009a);
    color: #fff;
    box-shadow: inset 0 0 0 999px #8500a1;
}

.iconic-section-labor-row td {
    background: #fff;
}

.iconic-section-grand-row td {
    background: var(--iconic-purple-mid);
    font-weight: 800;
    box-shadow: inset 0 0 0 999px var(--iconic-purple-mid);
}

.iconic-execution-row td {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    background: var(--iconic-purple);
    color: #fff;
    font-size: 1.08em;
    font-weight: 800;
    box-shadow: inset 0 0 0 999px var(--iconic-purple);
}

.iconic-tax-row td {
    background: var(--iconic-purple-soft);
    font-weight: 700;
    box-shadow: inset 0 0 0 999px var(--iconic-purple-soft);
}

.iconic-total-general-row td {
    background: var(--iconic-purple);
    color: #fff;
    font-size: 1.08em;
    font-weight: 800;
    box-shadow: inset 0 0 0 999px var(--iconic-purple);
}

.iconic-signature {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    min-height: 150px;
    margin-top: 36px;
    padding-right: 130px;
}

.iconic-stamp {
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
    border: 3px solid #243b91;
    border-radius: 50%;
    color: #243b91;
    font-size: 13px;
    line-height: 1.1;
    text-align: center;
    transform: rotate(-10deg);
    opacity: 0.86;
}

.iconic-stamp-img {
    width: 126px;
    height: 126px;
    object-fit: contain;
    transform: rotate(-8deg);
}

.iconic-signature-copy {
    position: relative;
    min-width: 210px;
    padding-top: 20px;
}

.iconic-signature-copy::before {
    content: "";
    position: absolute;
    left: 26px;
    right: 0;
    top: 34px;
    height: 34px;
    border-top: 3px solid rgba(36, 59, 145, 0.65);
    border-radius: 50%;
    transform: rotate(-10deg);
}

.iconic-signature-copy strong,
.iconic-signature-copy span {
    position: relative;
    display: block;
}

.iconic-signature-copy strong {
    font-size: 20px;
}

.iconic-signature-copy span {
    margin-top: 58px;
    font-size: 15px;
    font-style: italic;
    font-weight: 700;
}

.iconic-footer-contact {
    margin-top: 22px;
    padding-top: 8px;
    border-top: 5px solid var(--iconic-purple);
    color: #111;
    text-align: center;
    font-size: 10px;
    line-height: 1.35;
}

.iconic-footer-contact p {
    margin: 0 0 2px;
}

.public-estimate-body {
    background: #f6f7f9;
    color: #111;
}

.public-estimate-shell {
    --estimate-sheet-width: 980px;
    --client-side-width: 380px;
    margin: 0 auto;
    padding: 24px;
}

.public-estimate-shell > .estimate-actionbar {
    width: min(100%, 1760px);
}

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

.public-estimate-header h1 {
    margin: 0;
    font-size: 28px;
}

.public-estimate-header p {
    margin: 6px 0 0;
    color: #4b5563;
}

.public-estimate-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.public-estimate-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    width: min(100%, 1760px);
    margin: 0 auto;
}

.public-estimate-document {
    width: min(100%, var(--estimate-sheet-width));
    background: transparent;
    border: 0;
    padding: 0;
}

.public-annotations {
    display: grid;
    gap: 16px;
    width: min(100%, var(--estimate-sheet-width));
    margin: 0;
}

.client-side-panel {
    background: #fff;
    border: 1px solid #d1d5db;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.05);
}

.client-panel-heading {
    display: grid;
    gap: 3px;
    margin-bottom: 14px;
}

.client-panel-heading span {
    color: #6b7280;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.client-panel-heading h2,
.public-annotations h2 {
    margin: 0;
    color: #111827;
    font-size: 1rem;
    line-height: 1.25;
}

.decision-form {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 14px;
    padding-bottom: 14px;
}

.decision-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.decision-list {
    display: grid;
    gap: 10px;
    max-height: 260px;
    overflow: auto;
}

.decision-item {
    border: 1px solid #e5e7eb;
    border-left-width: 4px;
    padding: 10px;
    background: #fafafa;
}

.decision-accepted {
    border-left-color: #16a34a;
}

.decision-rejected {
    border-left-color: #dc2626;
}

.decision-item p {
    margin: 5px 0;
}

.decision-item small {
    color: #6b7280;
}

.annotation-list {
    display: grid;
    gap: 10px;
    max-height: 340px;
    margin-top: 18px;
    overflow: auto;
}

.annotation-item {
    border: 1px solid #e5e7eb;
    padding: 10px;
    background: #fafafa;
}

.annotation-item p {
    margin: 6px 0;
}

.annotation-item small {
    color: #6b7280;
}

.public-estimate-document .estimate-section-row,
.public-estimate-document .client-clickable-work {
    cursor: pointer;
}

.public-estimate-document .client-clickable-work:hover td,
.public-estimate-document .client-selected-work td {
    background: #eef6ff;
}

.public-estimate-document .client-selected-work td:first-child {
    box-shadow: inset 4px 0 0 #2563eb;
}

.client-calculation-detail {
    display: grid;
    gap: 12px;
}

.client-calc-header {
    display: grid;
    gap: 4px;
}

.client-calc-header span {
    color: #6b7280;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.client-calc-header h3 {
    margin: 0;
    color: #111827;
    font-size: 1.05rem;
    line-height: 1.25;
}

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

.client-material-table th,
.client-material-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 6px 4px;
    text-align: left;
}

.client-material-table th {
    color: #6b7280;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.client-material-table .amount {
    text-align: right;
    white-space: nowrap;
}

.client-calc-total {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    padding: 10px;
}

.client-calc-total div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    font-size: 0.86rem;
}

.client-calc-total div + div {
    border-top: 1px solid #dbeafe;
}

.client-calc-total span {
    color: #1e3a8a;
}

.client-calc-total strong {
    color: #111827;
    white-space: nowrap;
}

.selected-work-annotations {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.selected-work-annotations h3 {
    margin: 0;
    color: #374151;
    font-size: 0.86rem;
}

.annotation-item-compact p {
    margin: 0 0 5px;
}

@media (min-width: 1460px) {
    .estimate-actionbar {
        width: min(100%, 1760px);
    }

    .public-estimate-grid {
        align-items: start;
        grid-template-columns: var(--estimate-sheet-width) minmax(340px, var(--client-side-width));
        justify-content: center;
    }

    .public-annotations {
        position: sticky;
        top: 18px;
        width: 100%;
    }
}

@media (min-width: 1680px) {
    .public-estimate-grid {
        grid-template-columns: var(--estimate-sheet-width) minmax(340px, 390px) minmax(340px, 390px);
    }

    .public-annotations {
        position: static;
        align-self: start;
        grid-column: span 2;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        width: 100%;
    }

    .client-calculation-panel {
        grid-row: span 2;
    }

    .client-note-panel,
    .client-decision-panel {
        align-self: start;
    }
}

@media (max-width: 960px) {
    .public-estimate-shell {
        padding: 12px;
    }

    .estimate-actionbar {
        align-items: stretch;
        flex-direction: column;
    }

    .estimate-actionbar-actions {
        justify-content: flex-start;
    }

    .iconic-estimate-doc {
        padding: 28px 22px 42px;
    }

    .iconic-legal {
        white-space: normal;
        padding: 0 8px;
    }

    .iconic-signature {
        padding-right: 0;
    }
}

@media print {
    .public-estimate-header,
    .public-annotations {
        display: none !important;
    }

    .public-estimate-shell,
    .public-estimate-document {
        max-width: none;
        margin: 0;
        padding: 0;
        border: 0;
        background: #fff;
    }

    .public-estimate-grid {
        display: block;
    }

.iconic-estimate-doc {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    }
}

.company-staff-page .card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}

.company-people-page {
    display: grid;
    gap: 1rem;
}

.people-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    padding: 1.15rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}

.people-hero h2 {
    margin: 0.2rem 0 0.35rem;
    color: #0f172a;
    font-size: 1.45rem;
}

.people-hero p {
    margin: 0;
    color: #475569;
    max-width: 760px;
}

.people-hero .people-focus-note {
    margin-top: 0.65rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 0.88rem;
    font-weight: 600;
}

.people-focus-note strong {
    color: #1d4ed8;
}

.people-focus-warning {
    border-color: rgba(245, 158, 11, 0.24) !important;
    background: #fffbeb !important;
    color: #92400e !important;
}

.people-project-gate,
.project-access-lock {
    border: 1px solid rgba(245, 158, 11, 0.24);
    border-radius: 8px;
    background: #fffbeb;
}

.people-project-gate {
    display: grid;
    gap: 1rem;
    padding: 1rem;
}

.people-project-gate h3 {
    margin: 0.2rem 0 0.35rem;
}

.people-project-gate p {
    margin: 0;
    color: #78350f;
}

.people-project-link-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.65rem;
}

.people-project-link-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem;
    border: 1px solid rgba(245, 158, 11, 0.24);
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    text-decoration: none;
}

.people-project-link-list span,
.people-project-link-list small {
    display: block;
}

.people-project-link-list small {
    color: #92400e;
    font-weight: 700;
}

.project-access-lock {
    display: grid;
    gap: 0.25rem;
    margin-top: 0.75rem;
    padding: 0.8rem;
    color: #78350f;
}

.project-access-lock strong {
    color: #92400e;
}

.project-access-lock p {
    margin: 0;
}

.people-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(86px, 1fr));
    gap: 0.5rem;
}

.people-stats div {
    min-height: 70px;
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #f8fafc;
}

.people-stats strong,
.people-stats span {
    display: block;
}

.people-stats strong {
    color: #0f172a;
    font-size: 1.25rem;
}

.people-stats span {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
}

.people-nav {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.people-tab-button.active,
.people-tab-button[aria-selected="true"] {
    border-color: rgba(37, 99, 235, 0.22);
    background: var(--primary-50);
    color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.10);
}

.people-section {
    display: grid;
    gap: 1rem;
    scroll-margin-top: 1rem;
}

.people-section[hidden] {
    display: none !important;
}

.people-access-item {
    display: block;
    cursor: default;
}

.people-item-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.people-danger-form {
    margin-top: 0.75rem;
}

.people-estimate-form {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.85rem;
    padding: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #f8fafc;
}

.people-estimate-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.people-estimate-heading strong {
    color: #0f172a;
}

.people-estimate-heading span {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 700;
}

.is-focus-project {
    outline: 2px solid rgba(37, 99, 235, 0.24);
    outline-offset: -2px;
    background: rgba(239, 246, 255, 0.7);
}

.project-client-shortcut {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
}

.project-client-central-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.85rem;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 8px;
    background: #eff6ff;
}

.project-client-central-note p {
    margin: 0;
    color: #334155;
}

.project-client-estimates.readonly {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.4rem 0 0.65rem;
}

.project-client-estimates.readonly span:not(.config-muted) {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 700;
}

.company-staff-page .form-section {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(255, 255, 255, 0.95));
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    padding: 1rem;
}

.company-staff-page .form-section + .form-section {
    margin-top: 1rem;
}

.company-staff-page .data-table td {
    vertical-align: top;
}

.staff-permission-grid,
.company-staff-page td > div[style*="grid-template-columns"] {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.35rem;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    padding: 0.65rem;
}

.company-staff-page details {
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    padding-top: 0.85rem;
}

.company-staff-page summary {
    list-style: none;
}

.company-staff-page summary::-webkit-details-marker {
    display: none;
}

.staff-credentials-panel {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 1.1rem;
    padding: 1rem;
    border: 1px solid rgba(22, 163, 74, 0.28);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(240, 253, 244, 0.95), rgba(255, 255, 255, 0.98));
}

.staff-credentials-panel span {
    display: block;
    color: #15803d;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.staff-credentials-panel h4 {
    margin: 0.2rem 0;
    color: #0f172a;
}

.staff-credentials-panel p {
    margin: 0;
    color: #475569;
}

.staff-credentials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.staff-credentials-grid label,
.staff-password-reset label {
    display: grid;
    gap: 0.3rem;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 700;
}

.staff-credentials-grid input {
    color: #0f172a;
    font-weight: 800;
}

.staff-password-reset {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: end;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.staff-password-reset label {
    min-width: 240px;
    flex: 1 1 260px;
}

.company-clients-page .client-access-heading,
.company-clients-page .client-access-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.company-clients-page .client-access-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.company-clients-page .client-access-actions {
    justify-content: flex-start;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.company-clients-page .client-access-item details {
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    padding-top: 0.85rem;
}

.client-access-intro {
    margin: 0.25rem 0 0;
    color: #64748b;
    font-size: 0.88rem;
}

.client-directory-tools {
    display: grid;
    gap: 0.35rem;
    max-width: 420px;
    margin-bottom: 1rem;
}

.client-directory-tools label {
    color: #334155;
    font-size: 0.82rem;
    font-weight: 800;
}

.client-access-details > summary {
    display: inline-flex;
    cursor: pointer;
}

.client-access-details[open] > summary {
    margin-bottom: 1rem;
}

.client-access-workspace {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 10px;
    background: #f8fbff;
}

.client-access-workspace-heading,
.client-project-access-header,
.client-estimate-picker-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.client-access-workspace-heading h4 {
    margin: 0.15rem 0 0.25rem;
    color: #0f172a;
}

.client-access-workspace-heading p,
.client-estimate-picker-heading small {
    margin: 0;
    color: #64748b;
}

.client-access-save-hint {
    padding: 0.4rem 0.6rem;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    font-size: 0.78rem;
    font-weight: 800;
}

.client-project-access-list {
    display: grid;
    gap: 0.75rem;
}

.client-project-access-card {
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 10px;
    background: #fff;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.client-project-access-card.is-authorized {
    border-color: rgba(22, 163, 74, 0.34);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.client-project-access-header {
    align-items: center;
    padding: 0.85rem 1rem;
}

.client-project-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.client-project-toggle input {
    width: 20px;
    height: 20px;
}

.client-project-toggle strong,
.client-project-toggle small {
    display: block;
}

.client-project-toggle strong {
    color: #0f172a;
}

.client-project-toggle small {
    margin-top: 0.15rem;
    color: #64748b;
}

.client-project-access-body {
    display: grid;
    gap: 0.85rem;
    padding: 0.9rem 1rem 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    background: #f8fafc;
}

.client-project-access-body[hidden] {
    display: none;
}

.client-estimate-picker {
    display: grid;
    gap: 0.65rem;
}

.client-estimate-picker-heading {
    align-items: baseline;
}

.client-estimate-picker-heading strong {
    color: #0f172a;
}

.building-special-levels,
.estimate-special-levels {
    display: grid;
    gap: 0.45rem;
    align-content: start;
}

.building-special-levels > label:first-child {
    margin-bottom: 0.1rem;
}

.building-special-levels small {
    margin: -0.25rem 0 0.2rem 1.65rem;
    color: #64748b;
    line-height: 1.35;
}

.estimate-special-levels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 0.7rem;
    padding: 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: #f8fafc;
}

@media (max-width: 768px) {
    .people-hero,
    .people-item-heading,
    .project-client-central-note {
        display: grid;
    }

    .people-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .people-stats div {
        min-width: 0;
    }

    .company-clients-page .client-access-heading,
    .company-clients-page .client-access-actions,
    .client-access-workspace-heading,
    .client-project-access-header,
    .client-estimate-picker-heading {
        display: grid;
    }

    .estimate-special-levels {
        grid-template-columns: 1fr;
    }
}

.is-readonly-access {
    position: relative;
}

.is-readonly-access::before {
    content: "Lecture seule";
    display: inline-flex;
    align-items: center;
    margin: 0.25rem 0 0.75rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.is-readonly-access input:disabled,
.is-readonly-access select:disabled,
.is-readonly-access textarea:disabled,
.is-readonly-access button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.nav-item-with-badge {
    position: relative;
}

.nav-item-with-badge em {
    min-width: 1.45rem;
    height: 1.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 800;
}

.notifications-page,
.project-internal-messages-block,
.project-backups-block,
.project-audit-log-block {
    display: grid;
    gap: 1rem;
}

.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem;
}

.notifications-header span,
.project-internal-messages-block .project-finance-header span,
.project-backups-block .project-finance-header span,
.project-audit-log-block .project-finance-header span {
    color: #2563eb;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.notifications-header h3,
.notifications-header p {
    margin: 0.2rem 0 0;
}

.notifications-header p {
    color: #64748b;
    max-width: 720px;
}

.notifications-count {
    min-width: 120px;
    padding: 0.85rem;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 8px;
    background: #eff6ff;
    text-align: center;
}

.notifications-count strong {
    display: block;
    color: #1d4ed8;
    font-size: 1.8rem;
}

.notifications-count span {
    color: #475569;
    font-size: 0.82rem;
    font-weight: 700;
}

.notifications-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
    gap: 1rem;
    align-items: start;
}

.notification-list,
.project-internal-message-list,
.project-backup-list,
.project-audit-list {
    display: grid;
    gap: 0.75rem;
}

.notification-item,
.project-internal-message-item,
.project-backup-item,
.project-audit-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: #fff;
}

.notification-item.is-unread {
    border-color: rgba(37, 99, 235, 0.3);
    background: #f8fbff;
}

.notification-type {
    display: inline-flex;
    margin-bottom: 0.35rem;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.notification-item h4,
.notification-item p,
.project-internal-message-item p,
.project-audit-item strong {
    margin: 0;
}

.notification-item p,
.project-internal-message-item p {
    color: #475569;
    line-height: 1.45;
}

.notification-meta,
.notification-actions,
.project-internal-message-item > div,
.project-backup-item > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.notification-meta {
    margin-top: 0.5rem;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
}

.notification-actions {
    justify-content: flex-end;
    min-width: 130px;
}

.notification-preferences {
    position: sticky;
    top: 1rem;
}

.notification-preferences-form,
.project-internal-message-form {
    display: grid;
    gap: 0.85rem;
}

.toggle-row {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #f8fafc;
}

.toggle-row input {
    width: 18px;
    height: 18px;
    margin-top: 0.15rem;
}

.toggle-row strong,
.toggle-row small,
.project-backup-item small,
.project-audit-item small,
.project-internal-message-item small {
    display: block;
}

.toggle-row small,
.project-backup-item small,
.project-audit-item small,
.project-internal-message-item small {
    color: #64748b;
    font-size: 0.78rem;
}

.project-internal-message-grid {
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    gap: 0.85rem;
    align-items: start;
}

.project-internal-message-item {
    display: grid;
}

.project-internal-message-item > div {
    justify-content: space-between;
}

.project-backup-item {
    width: 100%;
    text-align: left;
}

.project-audit-item {
    display: grid;
}

.project-audit-item span {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 0.35rem;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

@media (max-width: 900px) {
    .notifications-layout,
    .project-internal-message-grid {
        grid-template-columns: 1fr;
    }

    .notification-preferences {
        position: static;
    }

    .notifications-header,
    .notification-item,
    .project-backup-item {
        display: grid;
    }

    .notification-actions {
        justify-content: flex-start;
        min-width: 0;
    }
}
