/* Shared CRM module chrome — Khách hàng, Pipeline, Social */
.oa-crm-page {
    --border: #d4e2f0;
    --muted: #64748b;
    --text: #0f172a;
    --blue: #2196f3;
    --blue-dark: #1565c0;
    --blue-deep: #0d47a1;
    --bg: #e8f0fa;
    background: var(--bg);
    min-height: 100vh;
    font-family: 'Be Vietnam Pro', system-ui, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.oa-crm-top {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.oa-crm-top-left {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    flex: 1;
}

.oa-crm-back {
    color: var(--blue-dark);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.oa-crm-module-switch {
    display: inline-flex; align-items: center; gap: 2px; padding: 3px;
    background: #e8eef5; border-radius: 10px; flex-shrink: 0;
}
.oa-crm-module-switch-item {
    display: inline-flex; align-items: center; padding: 7px 12px;
    border-radius: 8px; font-size: 0.78rem; font-weight: 700;
    color: #64748b; text-decoration: none; white-space: nowrap;
}
.oa-crm-module-switch-item:hover { color: #0f172a; }
.oa-crm-module-switch-item.is-active {
    background: #fff; color: #1565c0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.oa-crm-top-left > div {
    min-width: 0;
}

.oa-crm-kicker {
    display: block;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}

.oa-crm-top h1 {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oa-crm-top-right {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    flex-shrink: 0;
}

.oa-crm-user {
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.oa-crm-link-muted {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}
.oa-crm-link-muted:hover {
    color: var(--blue-dark);
    text-decoration: underline;
}

.oa-crm-logout {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

.oa-crm-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px 48px;
}

.oa-crm-input,
.oa-crm-select {
    font-family: inherit;
    font-size: 13px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    min-height: 38px;
}

.oa-crm-input:focus,
.oa-crm-select:focus {
    outline: none;
    border-color: #90caf9;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.oa-crm-btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 16px;
    border-radius: 9px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.2;
}

.oa-crm-btn-primary {
    background: #1565c0;
    color: #fff;
    box-shadow: 0 1px 3px rgba(21, 101, 192, 0.25);
}

.oa-crm-btn-primary:hover {
    background: #0d47a1;
}

.oa-crm-btn-ghost {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
}

.oa-crm-btn-ghost:hover {
    background: #f8fbff;
    border-color: #90caf9;
}

.oa-crm-btn-danger {
    background: #fff;
    border: 1px solid #fecaca;
    color: #c62828;
}

.oa-crm-btn-danger:hover {
    background: #fef2f2;
    border-color: #ef9a9a;
}

/* Shared data tables */
.oa-crm-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.oa-crm-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.82rem;
    table-layout: auto;
}

.oa-crm-table thead th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.75rem;
    white-space: nowrap;
    vertical-align: middle;
}

.oa-crm-table tbody td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #eef2f7;
    color: var(--text);
    vertical-align: middle;
}

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

.oa-crm-table tbody tr:hover td {
    background: #f8fbff;
}

.oa-crm-form {
    padding: 18px 22px 22px;
    display: grid;
    gap: 12px;
}

.oa-crm-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

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

/* Modal overlay pattern (Pipeline) */
.oa-crm-modal[hidden] {
    display: none !important;
}

.oa-crm-modal:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.oa-crm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    border: none;
    cursor: pointer;
}

.oa-crm-modal-panel {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: min(560px, 100%);
    max-height: 92vh;
    overflow: auto;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
    z-index: 1;
}

.oa-crm-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
}

.oa-crm-modal-head h2,
.oa-crm-modal-head h3 {
    font-size: 17px;
    font-weight: 800;
    margin: 0;
}

.oa-crm-modal-close,
.oa-crm-modal-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 22px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    color: #64748b;
    padding: 0;
    flex-shrink: 0;
}
.oa-crm-modal-close:hover,
.oa-crm-modal-x:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Inline help / hướng dẫn sử dụng */
.oa-crm-guide {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 1rem;
    overflow: hidden;
}
.oa-crm-guide > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.85rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--blue-deep);
    user-select: none;
}
.oa-crm-guide > summary::-webkit-details-marker { display: none; }
.oa-crm-guide > summary::before {
    content: '▸';
    font-size: 0.75rem;
    color: var(--muted);
    transition: transform 0.15s ease;
}
.oa-crm-guide[open] > summary::before { transform: rotate(90deg); }
.oa-crm-guide > summary:hover { background: #f8fbff; }
.oa-crm-guide-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    background: #e3f2fd;
    color: var(--blue-dark);
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
}
.oa-crm-guide-body {
    padding: 0 1.15rem 1.15rem;
    border-top: 1px solid #eef2f7;
}
.oa-crm-guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
    padding-top: 1rem;
}
.oa-crm-guide-col h3 {
    margin: 0 0 0.45rem;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--text);
}
.oa-crm-guide-col p,
.oa-crm-guide-col li {
    margin: 0 0 0.4rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--muted);
}
.oa-crm-guide-col ul {
    margin: 0;
    padding-left: 1.1rem;
}
.oa-crm-guide-col ol {
    margin: 0;
    padding-left: 1.15rem;
}
.oa-crm-guide-col ol li { margin-bottom: 0.35rem; }
.oa-crm-guide-note {
    margin-top: 0.85rem;
    padding: 0.65rem 0.8rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #475569;
}
.oa-crm-guide-note strong { color: var(--text); }
.oa-crm-guide-terms {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.oa-crm-guide-term {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: 0.5rem;
    font-size: 0.78rem;
    line-height: 1.4;
}
.oa-crm-guide-term dt {
    margin: 0;
    font-weight: 700;
    color: var(--blue-dark);
}
.oa-crm-guide-term dd {
    margin: 0;
    color: var(--muted);
}

@media (max-width: 768px) {
    .oa-crm-top {
        flex-wrap: wrap;
        align-items: stretch;
        padding: 10px 12px;
        gap: 10px;
    }
    .oa-crm-top-left {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap;
        gap: 8px;
        min-width: 0;
    }
    .oa-crm-top-right {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
    }
    .oa-crm-module-switch {
        order: -1;
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .oa-crm-module-switch::-webkit-scrollbar { display: none; }
    .oa-crm-module-switch-item {
        flex: 1 0 auto;
        justify-content: center;
        padding: 8px 10px;
        font-size: 0.75rem;
        min-height: 40px;
    }
    .oa-crm-top-left > div {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
        max-width: 100%;
    }
    .oa-crm-kicker {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .oa-crm-top h1 {
        font-size: 1.05rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .oa-crm-user { display: none; }
    .oa-crm-top-sep { display: none; }
    .oa-crm-guide-grid { grid-template-columns: 1fr; }
    .oa-crm-guide-term { grid-template-columns: 1fr; gap: 0.15rem; }
}
