/* ==========================================
   DevisProdigious - Styles V1
   ========================================== */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --bg: #f8fafc;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --sidebar-active: #4f46e5;
    --card: #ffffff;
    --text: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --border-focus: #4f46e5;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --purple: #8b5cf6;
    --purple-bg: #f5f3ff;
    --teal: #14b8a6;
    --teal-bg: #f0fdfa;
    --orange: #f97316;
    --orange-bg: #fff7ed;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --sidebar-width: 260px;
    --transition: 0.2s ease;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

body {
    display: flex;
    overflow: hidden;
}

/* ---- Sidebar ---- */

#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    color: var(--sidebar-text);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.3px;
}

.brand-sub {
    font-size: 11px;
    color: var(--sidebar-text);
    opacity: 0.7;
}

#nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #ffffff;
}

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

.nav-item.active svg,
.nav-item:hover svg {
    opacity: 1;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    display: none;
}

.nav-badge.visible {
    display: inline-block;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 8px 14px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer label {
    display: block;
    font-size: 11px;
    color: var(--sidebar-text);
    opacity: 0.6;
    margin-bottom: 6px;
}

.sidebar-footer select {
    width: 100%;
    background: var(--sidebar-hover);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
}

.sidebar-footer select option {
    background: var(--sidebar-bg);
}

/* ---- Main Content ---- */

#main {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    padding: 28px 32px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.page-header-actions {
    display: flex;
    gap: 10px;
}

/* ---- Stats Cards ---- */

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

.stat-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -1px;
}

.stat-card .stat-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card.highlight {
    border-left: 4px solid var(--primary);
}

.stat-card.warning {
    border-left: 4px solid var(--warning);
}

.stat-card.success {
    border-left: 4px solid var(--success);
}

.stat-card.purple {
    border-left: 4px solid var(--purple);
}

/* ---- Cards ---- */

.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.card-body {
    padding: 20px;
}

/* ---- Tables ---- */

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

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

thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

thead th.sortable {
    cursor: pointer;
}

thead th.sortable:hover {
    color: var(--primary);
}

tbody tr {
    cursor: pointer;
    transition: background var(--transition);
}

tbody tr:hover {
    background: #f1f5f9;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}

.td-client {
    font-weight: 600;
    color: var(--text);
}

.td-title {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.td-date {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ---- Status Badges ---- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}

.badge-new        { background: var(--info-bg); color: var(--info); }
.badge-analyzing  { background: #eef2ff; color: #6366f1; }
.badge-sent_provider { background: var(--orange-bg); color: var(--orange); }
.badge-quote_received { background: var(--warning-bg); color: #b45309; }
.badge-awaiting_sandrine { background: var(--purple-bg); color: var(--purple); }
.badge-validated  { background: var(--success-bg); color: #059669; }
.badge-sent_client { background: var(--teal-bg); color: #0d9488; }
.badge-accepted   { background: #ecfdf5; color: #047857; }
.badge-refused    { background: var(--danger-bg); color: var(--danger); }
.badge-completed  { background: #f1f5f9; color: #475569; }

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: white;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

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

.btn-success:hover {
    background: #059669;
}

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

.btn-danger:hover {
    background: var(--danger-bg);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 6px 10px;
}

.btn-ghost:hover {
    color: var(--text);
    background: #f1f5f9;
}

.btn-coeff {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font);
    transition: all var(--transition);
}

.btn-coeff:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ---- Forms ---- */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group label .required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--text);
    transition: border var(--transition);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input[type="number"] {
    font-variant-numeric: tabular-nums;
}

.form-section {
    margin-bottom: 24px;
}

.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.form-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.form-inline .form-group {
    flex: 1;
}

/* ---- Filter Bar ---- */

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-bar .form-group {
    flex: 0 0 auto;
    min-width: 160px;
}

.filter-bar input[type="search"] {
    min-width: 220px;
}

/* ---- Tabs ---- */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    font-family: var(--font);
    position: relative;
    transition: color var(--transition);
}

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

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ---- Detail View ---- */

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.detail-header-left h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.detail-header-left .detail-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.detail-header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-field.full {
    grid-column: 1 / -1;
}

.detail-field dt {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-field dd {
    font-size: 14px;
    color: var(--text);
}

/* ---- Timeline / History ---- */

.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 16px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-item .tl-date {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.timeline-item .tl-action {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.timeline-item .tl-detail {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.timeline-item .tl-user {
    font-size: 11.5px;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 2px;
}

/* ---- Quote Generator ---- */

.quote-preview {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 13.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    font-family: var(--font);
    max-height: 400px;
    overflow-y: auto;
}

.quote-templates {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.quote-template-btn {
    padding: 6px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: white;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.quote-template-btn:hover,
.quote-template-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* ---- Margin Calculator ---- */

.margin-display {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.margin-item {
    text-align: center;
    flex: 1;
}

.margin-item .margin-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.margin-item .margin-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    margin-top: 2px;
}

.margin-item .margin-value.positive {
    color: var(--success);
}

.margin-item .margin-value.negative {
    color: var(--danger);
}

/* ---- Modal ---- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ---- Toast ---- */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    background: var(--sidebar-bg);
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

.toast.success {
    background: #065f46;
}

.toast.error {
    background: #991b1b;
}

.toast.fadeout {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

/* ---- Sandrine Validation Card ---- */

.validation-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--purple);
    padding: 20px;
    margin-bottom: 16px;
    transition: box-shadow var(--transition);
}

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

.validation-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.validation-card-title {
    font-size: 15px;
    font-weight: 700;
}

.validation-card-client {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.validation-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.validation-field-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.validation-field-value {
    font-size: 16px;
    font-weight: 700;
    margin-top: 2px;
}

/* ---- Settings ---- */

.settings-list {
    list-style: none;
}

.settings-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.settings-list li:last-child {
    border-bottom: none;
}

/* ---- Empty State ---- */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ---- Status Progress Bar ---- */

.status-progress {
    display: flex;
    gap: 2px;
    margin: 16px 0;
}

.status-step {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    transition: background var(--transition);
}

.status-step.done {
    background: var(--primary);
}

.status-step.current {
    background: var(--primary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .detail-info-grid {
        grid-template-columns: 1fr;
    }
    .validation-card-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 220px;
    }
    #main {
        padding: 20px 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ---- Client Cards ---- */

.client-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.client-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.client-card-info h4 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
}

.client-card-info .client-meta {
    font-size: 12.5px;
    color: var(--text-secondary);
    display: flex;
    gap: 14px;
}

.client-card-stats {
    display: flex;
    gap: 24px;
    text-align: center;
}

.client-card-stats .client-stat {
    display: flex;
    flex-direction: column;
}

.client-card-stats .client-stat-value {
    font-size: 18px;
    font-weight: 800;
}

.client-card-stats .client-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* ---- Discussion Thread ---- */

.collab-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.collab-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 3px;
    background: #f1f5f9;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.collab-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
}

.collab-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    margin-left: 2px;
}

.collab-remove:hover {
    color: var(--danger);
}

.collab-add-select {
    padding: 4px 8px;
    border: 1px dashed var(--border);
    border-radius: 20px;
    font-size: 12px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font);
}

.collab-add-select:focus {
    outline: none;
    border-color: var(--primary);
}

.discussion-thread {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.discussion-msg {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.discussion-msg:last-child {
    border-bottom: none;
}

.discussion-msg.msg-unread {
    background: #fffbeb;
    margin: 0 -20px;
    padding: 12px 20px;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.msg-content {
    flex: 1;
    min-width: 0;
}

.msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.msg-author {
    font-size: 13px;
    font-weight: 700;
}

.msg-date {
    font-size: 11px;
    color: var(--text-secondary);
}

.msg-text {
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.msg-attachments {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.msg-attachment {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.msg-system {
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    border-bottom: 1px solid var(--border);
}

.unread-separator {
    text-align: center;
    padding: 8px 0;
    font-size: 11px;
    color: var(--warning);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.unread-separator::before,
.unread-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--warning);
    opacity: 0.3;
}

.discussion-reply {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.discussion-reply textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    resize: vertical;
    min-height: 60px;
    color: var(--text);
}

.discussion-reply textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.reply-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ---- Quote Chrono ---- */

.quote-chrono {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.quote-chrono.urgent {
    background: #fef2f2;
    border-color: #fecaca;
}

.quote-chrono.expired {
    background: #fef2f2;
    border-color: #fecaca;
}

.chrono-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.chrono-sent {
    color: var(--text-secondary);
}

.chrono-remaining {
    font-weight: 700;
    color: var(--success);
}

.quote-chrono.urgent .chrono-remaining,
.quote-chrono.expired .chrono-remaining {
    color: var(--danger);
}

.chrono-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.chrono-progress {
    height: 100%;
    background: var(--success);
    border-radius: 2px;
    transition: width 0.3s;
}

.quote-chrono.urgent .chrono-progress {
    background: var(--danger);
}

/* ---- Unread Indicators ---- */

.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-right: 6px;
}

.unread-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    padding: 0 4px;
    margin-left: 4px;
}

/* ---- Documentation ---- */

.doc-section {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

.doc-section-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background var(--transition);
}

.doc-section-header:hover {
    background: #f8fafc;
}

.doc-section-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-section-header .doc-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.doc-section-header .doc-chevron {
    transition: transform 0.2s;
    color: var(--text-secondary);
}

.doc-section.open .doc-chevron {
    transform: rotate(180deg);
}

.doc-section-body {
    padding: 24px;
    display: none;
}

.doc-section.open .doc-section-body {
    display: block;
}

.doc-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    max-width: 800px;
}

.doc-text p {
    margin-bottom: 12px;
}

.doc-text strong {
    color: var(--text);
}

.doc-text ul, .doc-text ol {
    margin: 8px 0 12px 20px;
}

.doc-text li {
    margin-bottom: 6px;
}

/* Workflow Diagram */

.workflow-diagram {
    overflow-x: auto;
    padding: 20px 0;
}

.wf-container {
    display: flex;
    align-items: flex-start;
    gap: 0;
    min-width: 900px;
    padding: 10px 0;
}

.wf-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 95px;
    position: relative;
}

.wf-node {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: relative;
    z-index: 2;
}

.wf-label {
    margin-top: 10px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    line-height: 1.3;
    max-width: 90px;
}

.wf-sublabel {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    margin-top: 2px;
    max-width: 90px;
}

.wf-arrow {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding-top: 0;
    margin-top: 16px;
    color: var(--border);
}

.wf-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.wf-branch-line {
    width: 2px;
    height: 20px;
    background: var(--border);
}

.wf-branch-options {
    display: flex;
    gap: 16px;
}

.wf-branch-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.wf-mini-node {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.wf-mini-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Role cards */

.doc-roles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.doc-role-card {
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
}

.doc-role-card h4 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-role-card .role-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.doc-role-card ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.doc-role-card li {
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.doc-role-card li::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Feature cards */

.doc-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.doc-feature-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
}

.doc-feature-card h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-feature-card .feat-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.doc-feature-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Status legend */

.doc-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

/* ---- Utility ---- */

.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.clickable { cursor: pointer; }
