:root {
    --brand: #e20074;
    --brand-dark: #c1005f;
    --text: #2f3441;
    --muted: #6f7785;
    --line: #e7e9ef;
    --bg: #f5f5f8;
    --card: #ffffff;
}

.quote-line-item {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid #dfe4eb;
    border-radius: 12px;
    background: #f9fafc;
}

.quote-line-title {
    grid-column: span 2;
}

.quote-line-description {
    grid-column: span 4;
}

.quote-line-field label {
    display: block;
    margin-bottom: 4px;
    color: #556273;
    font-size: 12px;
}

.quote-line-field input,
.quote-line-field textarea {
    width: 100%;
}

.quote-line-field textarea {
    min-height: 42px;
    resize: vertical;
}

.quote-line-actions {
    grid-column: span 2;
    align-self: end;
}

.quote-line-actions button {
    width: 100%;
}

@media (max-width: 1180px) {
    .quote-line-item {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quote-line-title,
    .quote-line-description {
        grid-column: span 2;
    }

    .quote-line-actions {
        grid-column: span 2;
    }
}

@media (max-width: 620px) {
    .quote-line-item {
        grid-template-columns: minmax(0, 1fr);
    }

    .quote-line-description {
        grid-column: auto;
    }

    .quote-line-title,
    .quote-line-actions {
        grid-column: auto;
    }

    .quote-line-actions button {
        width: 100%;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
}

body.app-ready {
    background: var(--bg);
}

body.app-ready > .root-wrap {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
}

.root-wrap {
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 18px;
}

.container {
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 18px;
}

.card {
    background: var(--card);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.hidden {
    display: none !important;
}

.login-card {
    max-width: 420px;
    margin: 30px auto 0;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.login-logo {
    width: 92px;
    height: 92px;
    display: block;
    margin: 0 auto 14px;
}

.login-title {
    margin: 0;
    text-align: center;
    color: var(--brand);
    font-size: 28px;
}

.login-subtitle {
    margin: 8px 0 16px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-legal-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px 14px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.login-legal-links a {
    color: var(--muted);
    font-size: 12px;
    text-decoration: none;
}

.login-legal-links a:hover {
    color: var(--brand);
    text-decoration: underline;
}

.header {
    background: #fff;
    border-bottom: 3px solid var(--brand);
    padding: 15px 20px;
    padding-top: max(15px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1200;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    gap: 12px;
    overflow: visible;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
    flex: 1 1 auto;
}

.logo-small {
    width: 50px;
    height: 50px;
}

.header-title h1 {
    color: var(--brand);
    font-size: 15px;
    margin: 0 0 2px;
}

.header-title p {
    color: #666;
    font-size: 13px;
    margin: 0;
}

.workspace-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    margin: 2px 0 0;
    background: #eceff6;
    color: #425063;
    width: fit-content;
    border: 1px solid #d5d9e1;
}

.workspace-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #d7dde7;
    background: #fff;
}

.workspace-switch-label {
    font-size: 12px;
    color: #5b6676;
    font-weight: 600;
}

.workspace-switch select {
    min-width: 150px;
    border-radius: 999px;
    padding: 8px 12px;
    border: 1px solid #d7dde7;
    background: #fff;
    font-weight: 600;
}

body.workspace-franchiseur .workspace-label {
    background: #fde7f2;
    border-color: #f3bfd7;
    color: #8f1d57;
}

body.workspace-franchises .workspace-label {
    background: #e8f7f0;
    border-color: #bce7d2;
    color: #0f6c4b;
}

body.workspace-franchiseur .workspace-switch {
    border-color: #f3bfd7;
    background: #fff5fa;
}

body.workspace-franchises .workspace-switch {
    border-color: #bce7d2;
    background: #f3fbf7;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.header-right > * {
    min-width: 0;
    max-width: 100%;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
    flex-wrap: nowrap;
    position: relative;
    z-index: 2;
}

.header-actions a,
.header-actions button,
.topbar-dropdown button,
.topbar-menu-item {
    pointer-events: auto;
    touch-action: manipulation;
}

.topbar-dropdown {
    position: relative;
    max-width: 100%;
}

.topbar-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid #d7dde7;
    border-radius: 10px;
    min-width: 240px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    padding: 8px;
    z-index: 110;
}

.topbar-menu-item {
    width: 100%;
    display: block;
    text-align: left;
    background: #fff;
    color: #3d4654;
    border: 0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}

.topbar-menu-item:hover,
.topbar-menu-item.active {
    background: #f4f6fb;
    color: #17202f;
}

.btn-calendar,
.btn-add,
.btn-refresh,
.btn-notifications,
.btn-logout {
    color: #fff;
    border: 0;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 600;
}

.btn-calendar {
    background: #4285f4;
}

.btn-calendar:hover {
    background: #3367d6;
}

.btn-add {
    background: #2196f3;
}

.btn-add:hover {
    background: #1976d2;
}

.btn-refresh {
    background: var(--brand);
}

.btn-refresh:hover {
    background: var(--brand-dark);
}

.btn-notifications {
    background: #f5f5f5;
    color: #666;
}

.btn-notifications:hover {
    background: #e0e0e0;
}

.btn-notifications.active {
    background: #4caf50;
    color: #fff;
}

.btn-logout {
    background: #f5f5f5;
    color: #666;
}

.btn-logout:hover {
    background: #e0e0e0;
}

input,
select,
textarea,
button {
    padding: 10px 11px;
    border-radius: 10px;
    border: 1px solid #d5d9e1;
    font-size: 14px;
}

button {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    font-weight: 600;
}

button.secondary {
    background: #fff;
    color: #4f5c6e;
    border-color: #d7dde7;
}

.topbar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #d92d20;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.workspace-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.workspace-choice-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-height: 144px;
    padding: 18px;
    border: 1px solid #d7dde7;
    border-radius: 16px;
    background: linear-gradient(180deg, #fff 0%, #f7f8fc 100%);
    color: #273142;
    cursor: pointer;
    text-align: left;
}

.workspace-choice-card:hover {
    border-color: var(--brand);
    box-shadow: 0 10px 22px rgba(226, 0, 116, 0.12);
    transform: translateY(-1px);
}

.workspace-choice-card strong {
    font-size: 18px;
}

.workspace-choice-card span {
    color: #556273;
    line-height: 1.45;
}

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

.messages-sidebar,
.messages-main {
    min-height: 520px;
}

.messages-main {
    display: grid;
    gap: 16px;
}

.messages-sidebar .message-thread-list {
    max-height: calc(100vh - 260px);
    overflow: auto;
    padding-right: 4px;
}

.message-compose-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.message-compose-grid .full-width {
    grid-column: 1 / -1;
}

.message-compose-grid > div {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-compose-grid input,
.message-compose-grid select,
.message-compose-grid textarea {
    width: 100%;
}

.message-compose-actions {
    display: flex;
    justify-content: flex-end;
}

.message-thread-list {
    display: grid;
    gap: 10px;
}

.message-thread-item {
    width: 100%;
    border: 1px solid #d7dde7;
    border-radius: 14px;
    background: #fff;
    color: #273142;
    padding: 14px;
    text-align: left;
    cursor: pointer;
}

.message-thread-item:hover,
.message-thread-item.active {
    border-color: var(--brand);
    box-shadow: 0 8px 20px rgba(226, 0, 116, 0.08);
}

.message-thread-item.unread {
    border-left: 4px solid var(--brand);
}

.message-thread-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
    color: #556273;
    font-size: 12px;
}

.message-thread-subject {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.message-priority {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.message-priority.normal {
    background: #eef2ff;
    color: #3949ab;
}

.message-priority.urgent {
    background: #fdecea;
    color: #b42318;
}

.message-post-list {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
}

.message-post {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 14px;
    background: #fff;
}

.message-post.mine {
    background: #fff3f9;
    border-color: #f3c3dc;
}

.message-post-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: #556273;
    font-size: 12px;
}

.message-post-body {
    white-space: pre-wrap;
    line-height: 1.5;
    color: #273142;
}

.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.message-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f5f7fb;
    color: #334155;
    text-decoration: none;
    font-size: 13px;
}

.message-empty {
    color: #6b7280;
    text-align: center;
    padding: 36px 18px;
}

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

    .message-compose-grid {
        grid-template-columns: 1fr;
    }
}

.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 7px 10px;
    border-radius: 8px;
    background: #2196f3;
    color: #fff;
    border: 1px solid #1976d2;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.btn-link:hover {
    background: #1976d2;
    color: #fff;
}

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

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

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-label {
    color: #666;
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--brand);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2,
.section-header h3 {
    margin: 0;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    color: #49505e;
}

.filter-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
}

th,
td {
    border-bottom: 1px solid #eef1f6;
    padding: 10px 8px;
    text-align: left;
    font-size: 13px;
    vertical-align: middle;
}

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5e6878;
    background: #f8f9fc;
}

tr.row-selected td {
    background: #fff0f8;
}

tr.lead-clickable-row {
    cursor: pointer;
}

tr.lead-clickable-row:hover td {
    background: #f8fbff;
}

.status-chip {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.source-chip {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 6px;
    border: 1px solid #d9dde8;
    background: #fff;
    color: #3b4455;
}

.source-chip.source-axonaut {
    border-color: #cfe1ff;
    background: #eef5ff;
    color: #1f4aa8;
}

.source-chip.source-google_drive {
    border-color: #ffe0ee;
    background: #fff0f8;
    color: #a0004f;
}

.source-chip.source-crm {
    border-color: #d9f3e7;
    background: #effaf5;
    color: #0b6b3a;
}

.franchise-chip {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #dce4f2;
    background: #f4f7fc;
    color: #445168;
}

.pill {
    display: inline-block;
    background: #eceff6;
    border-radius: 999px;
    padding: 3px 8px;
    margin-right: 4px;
    font-size: 12px;
    color: #4f5a6a;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 14px;
}

.detail-card {
    border: 1px solid #e7e9ef;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
}

.detail-line {
    font-size: 13px;
    color: #4b5565;
    margin-bottom: 8px;
}

.detail-line strong {
    color: #1f2937;
}

.line-summary-wrap {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 10px;
    background: #f8f9fc;
    border: 1px solid #e5e9f1;
}

.line-summary-title {
    font-size: 12px;
    color: #556273;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.line-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    font-size: 13px;
    color: #334155;
    padding: 4px 0;
    border-bottom: 1px dashed #e3e8f2;
}

.line-summary-item:last-child {
    border-bottom: 0;
}

.line-summary-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-action {
    padding: 8px 10px;
    border: 0;
    border-radius: 0;
    font-size: 12px;
    margin-right: 0;
    width: 100%;
    min-width: 96px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 700;
    cursor: pointer;
}

.btn-call {
    background: #2196f3;
    color: #fff;
}

.btn-devis {
    background: #ff4081;
    color: #fff;
}

.btn-edit {
    background: #2196f3;
    color: #fff;
}

.lead-actions-stack {
    display: inline-flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(2, 6, 23, 0.12);
}

.lead-actions-stack .btn-action + .btn-action {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.action-icon {
    font-size: 13px;
    line-height: 1;
}

.action-label {
    line-height: 1;
}

.error {
    color: #b00020;
}

.dashboard-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-list-header h3 {
    margin: 0;
}

.lead-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.lead-summary-line {
    color: #5e6878;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.lead-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 14px;
}

.lead-kv {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #eef1f6;
}

.lead-kv span {
    color: #6f7785;
    font-size: 13px;
}

.lead-kv strong {
    color: #1f2937;
    font-size: 13px;
    font-weight: 600;
}

.lead-action-grid {
    display: grid;
    gap: 12px;
}

.tag-list {
    margin-top: 8px;
}

.tag-remove-btn {
    border: 0;
    background: transparent;
    color: #5e6878;
    cursor: pointer;
    padding: 0 0 0 4px;
    font-size: 11px;
}

.timeline-item {
    border-left: 3px solid #d5deea;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #f8fafe;
    border-radius: 8px;
}

.timeline-head {
    font-size: 12px;
    color: #556273;
    margin-bottom: 4px;
    font-weight: 600;
}

.doc-row {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) auto auto auto;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid #eef1f6;
    padding: 8px 0;
    font-size: 13px;
}

.doc-file-name {
    color: #6a7280;
    font-size: 12px;
}

.lead-doc-upload-rows {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.lead-doc-upload-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr);
    gap: 8px;
    align-items: center;
}

.lead-doc-upload-row strong {
    font-size: 12px;
    color: #4f5c6e;
    word-break: break-word;
}

.lead-linked-card {
    margin-top: 14px;
}

.lead-linked-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.lead-linked-caption {
    color: #6a7280;
    font-size: 12px;
}

.lead-linked-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.lead-linked-section {
    border: 1px solid #e7ebf3;
    border-radius: 10px;
    padding: 10px;
    background: #fbfcff;
}

.lead-linked-section h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #1f2937;
}

.lead-linked-list {
    display: grid;
    gap: 8px;
}

.lead-linked-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid #edf1f7;
    border-radius: 8px;
    background: #fff;
}

.lead-linked-main {
    display: grid;
    gap: 2px;
}

.lead-linked-main strong {
    font-size: 13px;
    color: #1f2937;
}

.lead-linked-main span {
    font-size: 12px;
    color: #6a7280;
}

.lead-linked-meta {
    display: grid;
    justify-items: end;
    gap: 2px;
    font-size: 12px;
    color: #4b5563;
}

.lead-picker {
    position: relative;
}

.lead-picker-top {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
}

.lead-picker-input {
    min-width: 220px;
}

.lead-picker-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d7dde7;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
    z-index: 300;
    max-height: 260px;
    overflow-y: auto;
}

.lead-picker-item {
    width: 100%;
    border: 0;
    background: #fff;
    color: #1f2937;
    display: grid;
    gap: 2px;
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid #eef1f6;
    cursor: pointer;
}

.lead-picker-item strong {
    font-size: 13px;
}

.lead-picker-item span {
    font-size: 12px;
    color: #647084;
}

.lead-picker-item.active,
.lead-picker-item:hover {
    background: #f5f8ff;
}

.lead-picker-empty {
    padding: 10px;
    color: #647084;
    font-size: 12px;
}

.lead-picker-selected {
    margin-top: 6px;
    font-size: 12px;
    color: #374152;
}

.client-selected-summary {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 10px 11px;
    border: 1px solid #d5d9e1;
    border-radius: 10px;
    background: #f8f9fc;
    color: #374152;
    font-size: 13px;
}

.intervention-form-card {
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    border: 1px solid #dfe9f4;
}

.intervention-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.intervention-field {
    margin-bottom: 10px;
}

.intervention-field label {
    display: block;
    font-size: 12px;
    color: #556273;
    margin-bottom: 5px;
    font-weight: 600;
}

.photo-rows {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
}

.photo-row {
    display: grid;
    grid-template-columns: 120px 1fr 1fr auto;
    gap: 8px;
}

.photo-list-row {
    display: grid;
    grid-template-columns: 90px 1fr 1fr auto;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #eef1f6;
    font-size: 13px;
}

.dashboard-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.stats-filters {
    align-items: flex-end;
}

.stats-filters > * {
    min-width: 170px;
}

.stats-bar-row {
    display: grid;
    grid-template-columns: 170px 1fr 120px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.stats-bar-label {
    color: #4f5c6e;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-bar-track {
    height: 14px;
    background: #edf2fb;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid #d7dde7;
}

.stats-bar-track span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2196f3, #0d47a1);
}

.stats-bar-value {
    text-align: right;
    font-weight: 600;
    color: #1f2937;
}

.google-ads-intro {
    margin: 5px 0 0;
    color: #667085;
    font-size: 14px;
}

.google-ads-state {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.google-ads-state-item {
    display: grid;
    gap: 5px;
    padding: 14px;
    border: 1px solid #dfe5ed;
    border-radius: 10px;
    background: #f8fafc;
}

.google-ads-state-item span {
    color: #667085;
    font-size: 12px;
}

.google-ads-state-item strong {
    color: #1f2937;
}

.google-ads-state-item .is-success {
    color: #087443;
}

.google-ads-state-item .is-warning,
.google-ads-mapping-badge.is-warning {
    color: #9a3412;
}

.google-ads-config-warning {
    grid-column: 1 / -1;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #fed7aa;
    border-radius: 9px;
    background: #fff7ed;
    color: #9a3412;
}

.google-ads-admin-table td:first-child strong,
.google-ads-comparison-table td:first-child strong {
    display: block;
}

.google-ads-admin-table td:first-child small,
.google-ads-comparison-table td:first-child small {
    display: block;
    margin-top: 3px;
    color: #778195;
}

.google-ads-franchise-select {
    min-width: 190px;
}

.google-ads-mapping-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #e8f5ef;
    color: #087443;
    font-size: 12px;
    font-weight: 700;
}

.google-ads-empty {
    padding: 24px !important;
    text-align: center;
    color: #667085;
}

.google-ads-statistics {
    margin-top: 22px;
    border-top: 4px solid #e20074;
}

.google-ads-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.google-ads-kpi-grid .stat-value {
    font-size: clamp(21px, 2vw, 29px);
}

.google-ads-ratio-card {
    background: linear-gradient(135deg, #0c262c, #153f45);
}

.google-ads-ratio-card .stat-label,
.google-ads-ratio-card .stat-value {
    color: #fff;
}

.google-ads-ratio-explanation {
    margin: -8px 0 10px;
    padding: 14px 16px;
    border-left: 4px solid #e20074;
    border-radius: 8px;
    background: #fff1f7;
    color: #8f164c;
    font-weight: 650;
}

.google-ads-freshness {
    color: #667085;
    font-size: 13px;
}

.google-ads-warning {
    margin: 12px 0;
    padding: 12px 14px;
    border: 1px solid #fed7aa;
    border-radius: 9px;
    background: #fff7ed;
    color: #9a3412;
}

.google-ads-warning a {
    color: inherit;
    font-weight: 700;
}

.google-ads-comparison-table th button {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.google-ads-comparison-table th button::after {
    content: ' ↕';
    opacity: 0.55;
}

.google-ads-correlation-note {
    margin: 18px 0 0;
    padding-top: 12px;
    border-top: 1px solid #e3e8ef;
    color: #667085;
    font-size: 12px;
}

#googleAdsCampaignDetail {
    margin-top: 20px;
}

.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2200;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 24px));
}

.toast-item {
    border-radius: 10px;
    padding: 10px 12px;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-item.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #2e7d32;
}

.toast-error {
    background: #b00020;
}

.toast-info {
    background: #455a64;
}

.debug-output {
    display: none;
}

body.debug-on .debug-output {
    display: block;
}

.file-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-input-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.file-input-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 11px;
    border-radius: 10px;
    border: 1px solid #d7dde7;
    background: #fff;
    color: #4f5c6e;
    font-weight: 600;
    user-select: none;
}

.file-input-btn:hover {
    background: #f5f7fb;
}

.file-input-btn:active {
    transform: translateY(1px);
}

.file-input-label {
    font-size: 13px;
    color: #556273;
}

.upload-progress {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.upload-progress-track {
    height: 10px;
    border-radius: 999px;
    background: #eef2f8;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--brand), #ff5aa7);
}

.upload-progress-text {
    min-width: 48px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: #4f5c6e;
}

.upload-progress-processing .upload-progress-bar {
    width: 100% !important;
    background: linear-gradient(90deg, #e20074, #ff87c4, #e20074);
    background-size: 220% 100%;
    animation: upload-processing-wave 1.2s linear infinite;
}

.upload-progress-processing .upload-progress-text {
    min-width: 260px;
    font-weight: 600;
    color: #374152;
}

#adminMediaCreateBtn:disabled {
    background: #b8bec8;
    border-color: #b8bec8;
    color: #ffffff;
    cursor: not-allowed;
}

@keyframes upload-processing-wave {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -20% 0;
    }
}

.preview-modal {
    position: fixed;
    inset: 0;
    z-index: 2300;
}

.beta-feedback-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2290;
    width: 54px;
    height: 54px;
    border-radius: 999px;
    border: 0;
    background: linear-gradient(135deg, var(--brand), #ff4fa4);
    color: #fff;
    box-shadow: 0 12px 26px rgba(226, 0, 116, 0.35);
    font-size: 22px;
    cursor: pointer;
}

.beta-feedback-fab:hover {
    transform: translateY(-1px);
}

.beta-feedback-panel {
    position: relative;
    z-index: 1;
    margin: 10vh auto;
    width: min(640px, calc(100vw - 24px));
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr;
}

.beta-feedback-form {
    display: grid;
    gap: 8px;
    padding: 14px;
}

.beta-feedback-form textarea {
    resize: vertical;
}

.preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.preview-panel {
    position: relative;
    z-index: 1;
    margin: 3vh auto;
    width: min(1100px, calc(100vw - 24px));
    height: min(92vh, 900px);
    background: #fff;
    border-radius: 12px;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.banner-crop-panel {
    width: min(980px, calc(100vw - 24px));
    height: auto;
    max-height: 92vh;
}

.banner-crop-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 16px;
    padding: 12px;
    overflow: auto;
}

.banner-crop-canvas-wrap {
    background: #f5f7fb;
    border: 1px solid #d7dde8;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#bannerCropCanvas {
    width: 100%;
    height: auto;
    max-height: 70vh;
    border-radius: 10px;
    background: #111;
    cursor: grab;
}

#bannerCropCanvas.dragging {
    cursor: grabbing;
}

.banner-crop-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.banner-crop-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .banner-crop-body {
        grid-template-columns: 1fr;
    }
}

.lead-create-panel {
    position: relative;
    z-index: 1;
    margin: 8vh auto;
    width: min(520px, calc(100vw - 24px));
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr;
}

.lead-quick-edit-panel {
    position: relative;
    z-index: 1;
    margin: 6vh auto;
    width: min(620px, calc(100vw - 24px));
    max-height: 88vh;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr;
}

.lead-quick-edit-body {
    display: grid;
    gap: 8px;
    padding: 12px;
    overflow: auto;
}

.lead-quick-edit-name {
    font-size: 16px;
    font-weight: 700;
    color: #2c3441;
}

.lead-quick-edit-message {
    border: 1px solid #d5e8fa;
    background: #eef6ff;
    border-radius: 8px;
    padding: 10px;
    min-height: 48px;
    color: #314357;
    white-space: pre-wrap;
}

.lead-quick-edit-notes-history {
    border: 1px solid #e3e7ef;
    border-radius: 8px;
    background: #f9fbff;
    padding: 8px;
    max-height: 180px;
    overflow: auto;
}

.lead-quick-edit-note-item {
    padding: 8px 0;
    border-bottom: 1px solid #ebeff6;
}

.lead-quick-edit-note-item:last-child {
    border-bottom: 0;
}

.lead-quick-edit-note-meta {
    font-size: 12px;
    color: #6c7584;
    margin-bottom: 4px;
}

.lead-quick-edit-note-text {
    font-size: 13px;
    color: #2e3746;
    white-space: pre-wrap;
}

.lead-create-form {
    display: grid;
    gap: 8px;
    padding: 12px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #e7e9ef;
}

.preview-header h3 {
    margin: 0;
    font-size: 15px;
}

.preview-body {
    padding: 10px;
    overflow: auto;
    background: #f7f9fd;
}

.preview-frame,
.preview-image {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.preview-image {
    object-fit: contain;
}

.preview-video {
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
    border-radius: 8px;
}

.photo-thumb {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #dbe2ed;
    cursor: pointer;
}

.signature-block {
    border: 1px solid #d8e1ee;
    border-radius: 10px;
    background: #fff;
    padding: 8px;
}

.signature-pad {
    width: 100%;
    height: 160px;
    border: 1px dashed #b8c6dc;
    border-radius: 8px;
    touch-action: none;
    background: #fff;
}

.signature-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.accordion {
    display: grid;
    gap: 8px;
}

.accordion-item {
    border: 1px solid #dfe5ef;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.accordion-toggle {
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid #e8edf5;
    border-radius: 0;
    background: #f8fbff;
    color: #223043;
    font-weight: 700;
    padding: 11px 12px;
    cursor: pointer;
}

.accordion-toggle.open {
    background: #edf4ff;
}

.accordion-content {
    padding: 12px;
}

.schema-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.schema-canvas-wrap {
    border: 1px solid #d7e0ec;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.schema-canvas {
    width: 100%;
    height: 260px;
    display: block;
    touch-action: none;
    background:
        linear-gradient(90deg, rgba(221, 229, 241, 0.4) 1px, transparent 1px) 0 0/24px 24px,
        linear-gradient(rgba(221, 229, 241, 0.4) 1px, transparent 1px) 0 0/24px 24px,
        #ffffff;
}

.schema-preview {
    width: 100%;
    max-height: 340px;
    object-fit: contain;
    border: 1px solid #dfe5ef;
    border-radius: 10px;
    background: #fff;
}

.stat-delta-positive {
    color: #1b5e20;
    font-weight: 700;
}

.stat-delta-negative {
    color: #b71c1c;
    font-weight: 700;
}

.admin-template-section {
    border-top: 1px solid #e7e9ef;
    padding-top: 12px;
    margin-top: 12px;
}

.admin-template-section h5 {
    margin: 0 0 8px;
    font-size: 14px;
}

.admin-checklist {
    border: 1px solid #d8e1ee;
    border-radius: 10px;
    background: #fafcff;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 6px;
}

.admin-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #2f3b4d;
}

.admin-template-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.admin-template-item {
    border: 1px solid #e1e7f2;
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    background: #fff;
}

.admin-template-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-draggable-item.dragging {
    opacity: 0.6;
    border-color: #b6c4dd;
    background: #f2f5fb;
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px dashed #c6d1e2;
    color: #7a8797;
    font-size: 14px;
    cursor: grab;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.admin-template-item-main {
    display: grid;
    gap: 4px;
}

.admin-template-item-main strong {
    font-size: 13px;
    color: #1f2937;
}

.admin-template-item-main span {
    font-size: 12px;
    color: #556273;
}

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

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

    .intervention-grid {
        grid-template-columns: 1fr;
    }

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

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

    .lead-doc-upload-row {
        grid-template-columns: 1fr;
    }

    .lead-picker-top {
        grid-template-columns: 1fr;
    }

    .lead-linked-grid {
        grid-template-columns: 1fr;
    }

    .lead-linked-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-panel {
        width: calc(100vw - 10px);
        height: calc(100vh - 10px);
        margin: 5px;
    }

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

    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: wrap;
        align-items: center;
    }

    #workspaceSwitch {
        order: 1;
        flex: 1 1 auto;
    }

    #btnLogout {
        order: 2;
        margin-left: auto;
    }

    .header-actions {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        gap: 8px;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .workspace-switch {
        padding: 5px 8px;
    }

    .workspace-switch select {
        min-width: 120px;
        padding: 7px 10px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 10px;
        flex-wrap: wrap;
    }

    .header-right {
        gap: 8px;
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .header-actions {
        width: 100%;
        gap: 8px;
        flex-wrap: wrap;
    }

    .btn-text,
    .refresh-text,
    #notificationsText {
        display: none;
    }

    .btn-calendar,
    .btn-add,
    .btn-refresh,
    .btn-notifications,
    .btn-logout {
        padding: 10px;
        min-width: 40px;
    }

    .workspace-switch-label {
        display: none;
    }

    .workspace-switch select {
        min-width: 105px;
    }

    .topbar-menu {
        right: auto;
        left: 0;
        min-width: 180px;
    }

    .header-title {
        display: none;
    }

    .logo-small {
        width: 40px;
        height: 40px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 10px;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 10px;
    }

    .google-ads-state {
        grid-template-columns: 1fr;
    }

    .google-ads-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .google-ads-franchise-select {
        min-width: 155px;
    }
}

@media (max-width: 1180px) {
    .btn-text,
    .refresh-text,
    #notificationsText {
        display: none;
    }

    .btn-calendar,
    .btn-add,
    .btn-refresh,
    .btn-notifications,
    .btn-logout {
        padding: 9px 10px;
        min-width: 40px;
        justify-content: center;
    }

    .workspace-switch select {
        min-width: 120px;
    }
}
