/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Màu thương hiệu VuTuyen (lấy từ logo) */
    --green: #0E5C36;
    --green-dark: #0A3D26;
    --green-light: #E7F2EC;
    --green-mid: #8BC6A2;
    --gold: #C9A13B;
    --gold-light: #F7EFD9;
    --amber: #BA7517;
    --amber-light: #FAEEDA;
    --red: #A32D2D;
    --red-light: #FCEBEB;
    --blue: #185FA5;
    --blue-light: #E6F1FB;
    --gray-50: #F8F9FA;
    --gray-100: #F1F3F5;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #CED4DA;
    --gray-500: #ADB5BD;
    --gray-600: #6C757D;
    --gray-700: #495057;
    --gray-800: #343A40;
    --gray-900: #212529;
    --sidebar-w: 240px;
    --topbar-h: 56px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.14);
    --font: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: .18s ease;
}

html, body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-100);
    height: 100%;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.crm-root {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform var(--transition);
}

.sidebar-header {
    /* Chừa khoảng trống cho tai thỏ/status bar khi mở như app chuẩn (Thêm vào MH chính trên iPhone) */
    padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 26px; }
.logo-title { font-size: 15px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.logo-sub { font-size: 11px; color: var(--gray-500); }
.sidebar-close { display: none; background: none; border: none; font-size: 16px; cursor: pointer; color: var(--gray-500); }

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

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gray-400);
    padding: 0.75rem 1rem 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 1rem;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    position: relative;
}
.nav-link:hover { background: var(--gray-50); color: var(--gray-900); }
.nav-link.active {
    background: var(--green-light);
    color: var(--green-dark);
    font-weight: 600;
    border-left: 3px solid var(--green);
    padding-left: calc(1rem - 3px);
}
.nav-icon { font-size: 15px; }

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

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--green-light);
    color: var(--green-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--gray-500); }
.sidebar-footer-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.btn-change-pwd {
    display: block;
    width: 100%;
    padding: 7px;
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-600);
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
}
.btn-change-pwd:hover { background: var(--gray-50); color: var(--blue); border-color: var(--blue); }
.btn-change-pwd.active { color: var(--blue); }

.btn-logout {
    width: 100%;
    padding: 7px;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
}
.btn-logout:hover { background: var(--gray-50); color: var(--red); border-color: var(--red); }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
}

/* ── Main content ────────────────────────────────────────────────────────── */
.crm-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* chặn page scroll ngang — đặt ở đây, không ở crm-content */
}

.topbar {
    min-height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
    /* Chừa khoảng trống cho tai thỏ/status bar khi mở như app chuẩn (Thêm vào MH chính trên iPhone) */
    padding: env(safe-area-inset-top, 0px) 1.5rem 0;
    position: sticky; top: 0; z-index: 100;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-600);
    padding: 4px;
}
.topbar-breadcrumb { font-size: 15px; font-weight: 600; color: var(--gray-800); }

.crm-content {
    padding: 1.5rem;
    flex: 1;
    min-width: 0;       /* flex child phải shrink được, không thì nó giãn theo table */
    overflow-x: hidden; /* chặn page scroll ngang, chỉ table-wrap mới scroll */
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px;
    font-size: 13.5px; font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

/* Size modifiers */
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }

/* Solid colors */
.btn-primary   { background: var(--green);    color: #fff; border-color: var(--green); }
.btn-primary:hover   { background: var(--green-dark);  border-color: var(--green-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-success   { background: #059669; color: #fff; border-color: #059669; }
.btn-success:hover   { background: #047857; border-color: #047857; }
.btn-success:disabled { opacity: .6; cursor: not-allowed; }

.btn-info      { background: var(--blue);     color: #fff; border-color: var(--blue); }
.btn-info:hover      { background: #134e8f;    border-color: #134e8f; }
.btn-info:disabled    { opacity: .6; cursor: not-allowed; }

.btn-warning   { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover   { background: #b45309; border-color: #b45309; }
.btn-warning:disabled { opacity: .6; cursor: not-allowed; }

.btn-danger    { background: var(--red);      color: #fff; border-color: var(--red); }
.btn-danger:hover    { background: #7B1D1D;    border-color: #7B1D1D; }
.btn-danger:disabled  { opacity: .6; cursor: not-allowed; }

.btn-teal      { background: #0d9488; color: #fff; border-color: #0d9488; }
.btn-teal:hover      { background: #0f766e; border-color: #0f766e; }
.btn-teal:disabled    { opacity: .6; cursor: not-allowed; }

.btn-purple    { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.btn-purple:hover    { background: #6d28d9; border-color: #6d28d9; }
.btn-purple:disabled  { opacity: .6; cursor: not-allowed; }

.btn-secondary { background: var(--gray-600); color: #fff; border-color: var(--gray-600); }
.btn-secondary:hover { background: var(--gray-700); border-color: var(--gray-700); }
.btn-secondary:disabled { opacity: .6; cursor: not-allowed; }

.btn-dark      { background: var(--gray-800); color: #fff; border-color: var(--gray-800); }
.btn-dark:hover      { background: var(--gray-900); border-color: var(--gray-900); }
.btn-dark:disabled    { opacity: .6; cursor: not-allowed; }

/* Outline variants */
.btn-outline         { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover   { background: var(--gray-50); border-color: var(--gray-400); }
.btn-outline-primary { background: #fff; color: var(--green);    border-color: var(--green); }
.btn-outline-primary:hover { background: var(--green-light); }
.btn-outline-danger  { background: #fff; color: var(--red);      border-color: var(--red); }
.btn-outline-danger:hover  { background: var(--red-light); }
.btn-outline-info    { background: #fff; color: var(--blue);     border-color: var(--blue); }
.btn-outline-info:hover    { background: var(--blue-light); }
.btn-outline-warning { background: #fff; color: #d97706;         border-color: #d97706; }
.btn-outline-warning:hover { background: #fffbeb; }

.btn-link { background: none; border: none; color: var(--green); cursor: pointer; font-size: inherit; text-decoration: underline; }

.btn-icon {
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 4px 7px;
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
    margin-left: 4px;
}
.btn-icon:hover { background: var(--gray-100); }
.btn-icon--danger:hover { background: var(--red-light); border-color: var(--red); }
.btn-icon--warning:hover { background: var(--amber-light); border-color: var(--amber); }
.btn-icon--success:hover { background: var(--green-light); border-color: var(--green); }

/* ── Stats grid ──────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--gray-900); }
.stat-sub { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.stat-card--danger .stat-value { color: var(--red); }
.stat-card--warning .stat-value { color: var(--amber); }
.stat-card--success .stat-value { color: var(--green-dark); }
.stat-card--info .stat-value { color: var(--blue); }
.stat-card--teal .stat-value { color: #0d9488; }

.stats-grid--3 { grid-template-columns: repeat(3, 1fr); }

.section-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .6rem;
}

/* ── Charts ──────────────────────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 1.5rem;
}
.chart-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 1rem; }

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.bar-label {
    font-size: 12px;
    color: var(--gray-600);
    width: 130px;
    flex-shrink: 0;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bar-track {
    flex: 1;
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    transition: width .4s ease;
}
.bar-count { font-size: 12px; color: var(--gray-500); width: 30px; text-align: right; flex-shrink: 0; }

/* ── Agent grid ──────────────────────────────────────────────────────────── */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 0.5rem;
}
.agent-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}
.agent-card:hover { background: var(--green-light); border-color: var(--green-mid); }
.agent-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--green-light);
    color: var(--green-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    margin: 0 auto 8px;
}
.agent-name { font-size: 12.5px; font-weight: 600; color: var(--gray-800); margin-bottom: 2px; }
.agent-count { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.agent-sub { font-size: 11px; color: var(--gray-500); }

/* ── Page actions bar ────────────────────────────────────────────────────── */
.page-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1rem;
}
.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    flex: 1;
    max-width: 320px;
}
.search-icon { color: var(--gray-400); font-size: 14px; }
.search-input {
    border: none;
    outline: none;
    font-family: var(--font);
    font-size: 13.5px;
    color: var(--gray-800);
    background: transparent;
    flex: 1;
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}
.filter-select {
    padding: 5px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--gray-700);
    cursor: pointer;
    font-family: var(--font);
    min-width: 0;
}
/* Bọc 2 ô ngày để chúng luôn nằm cạnh nhau và không overflow */
.date-filter-row {
    display: flex;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}
.date-filter-row .filter-select {
    flex: 1 1 0;
    min-width: 0;
    width: 0; /* flex sẽ kéo giãn — tránh iOS date input dùng min-content width */
}
.result-count {
    font-size: 12.5px;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* scrollbar luôn hiện, không ẩn theo OS */
    scrollbar-width: thin;
    scrollbar-color: var(--gray-400) var(--gray-100);
}
.table-wrap::-webkit-scrollbar        { height: 7px; }
.table-wrap::-webkit-scrollbar-track  { background: var(--gray-100); }
.table-wrap::-webkit-scrollbar-thumb  { background: var(--gray-400); border-radius: 4px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--gray-600); }

.crm-table {
    width: 100%;
    min-width: 950px; /* tổng chiều rộng tất cả cột, nhỏ hơn thì scroll */
    border-collapse: collapse;
    font-size: 13px;
}
.crm-table thead th {
    background: var(--gray-50);
    color: var(--gray-500);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.crm-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background var(--transition);
}
.crm-table tbody tr:last-child { border-bottom: none; }
.crm-table tbody tr:hover { background: var(--gray-50); }
.crm-table td { padding: 10px 14px; color: var(--gray-800); }
.td-name { font-weight: 500; }
.td-phone { color: var(--gray-500); font-size: 12px; }
.td-date { color: var(--gray-500); font-size: 12px; white-space: nowrap; }
.td-action { text-align: right; white-space: nowrap; }
.th-action { text-align: right; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
}
.status-new       { background: var(--blue-light); color: var(--blue); }
.status-contact   { background: #E6F1FB; color: #185FA5; }
.status-nocontact { background: #F3E8FF; color: #6B21A8; }
.status-care      { background: var(--amber-light); color: var(--amber); }
.status-hold      { background: var(--green-light); color: var(--green-dark); }
.status-cook      { background: #FAECE7; color: #993C1D; }
.status-reject    { background: var(--red-light); color: var(--red); }
.status-default   { background: var(--gray-100); color: var(--gray-600); }

.pot-badge { display: inline-block; font-size: 12px; font-weight: 600; }
.pot-high  { color: #993C1D; }
.pot-mid   { color: var(--amber); }
.pot-low   { color: var(--green-dark); }
.pot-default { color: var(--gray-400); }

.agent-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 11.5px;
    font-weight: 500;
}
.view-only-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 7px;
    border-radius: 100px;
    background: #fff3cd;
    color: #856404;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}
.team-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 7px;
    border-radius: 100px;
    background: #d1ecf1;
    color: #0c5460;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 500;
}
.role-manager { background: #F0E6FF; color: #6B21A8; }
.role-staff   { background: var(--blue-light); color: var(--blue); }
.role-sales {
    background: #fff3cd;
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .78rem;
    font-weight: 600;
}

/* ── Assign / member picker rows (Users, Teams) ─────────────────────────────── */
.assign-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .45rem .5rem;
    border-bottom: 1px solid #f0f2f5;
    gap: .5rem;
}
.assign-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    flex: 1;
}
.assign-name {
    font-weight: 600;
    font-size: .875rem;
}
.assign-role {
    font-size: .78rem;
    color: #888;
}

/* ── Permission checkbox grid (Users) ────────────────────────────────────────── */
.perm-section {
    margin-top: 1rem;
    padding: .75rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.perm-title {
    font-weight: 600;
    font-size: .85rem;
    color: #444;
    margin-bottom: .6rem;
}
.perm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem .75rem;
}
.perm-item {
    display: flex;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
    font-size: .875rem;
    color: #333;
}
.perm-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
}
.active-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 500;
}
.active-yes { background: var(--green-light); color: var(--green-dark); }
.active-no  { background: var(--red-light); color: var(--red); }

/* ── Drawer (detail panel) ───────────────────────────────────────────────── */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 300;
    display: flex;
    justify-content: flex-end;
}
.drawer {
    width: 480px;
    max-width: 95vw;
    background: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.drawer-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.drawer-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.drawer-close {
    background: none; border: none;
    font-size: 18px; cursor: pointer; color: var(--gray-400);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.drawer-close:hover { background: var(--gray-100); color: var(--gray-700); }
/* drawer-info: thông tin cơ bản — chiều cao tự nhiên, gọn */
.drawer-info {
    padding: .75rem 1.5rem .75rem;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

/* tab bar */
.drawer-tab-bar {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    background: var(--gray-50);
    flex-shrink: 0;
}
.detail-tab-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: color .15s, border-color .15s, background .15s;
}
.detail-tab-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.detail-tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); background: #fff; font-weight: 600; }

/* badge đếm trong tab */
.tab-count {
    display: inline-block;
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.5;
}
.detail-tab-btn.active .tab-count { background: #dbeafe; color: var(--blue); }
.tab-vip-badge {
    display: inline-block;
    background: #f39c12;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.5;
}

/* nội dung tab — chiếm hết phần còn lại */
.drawer-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: .75rem 1.5rem 1rem;
}
.tab-empty {
    padding: .75rem 0;
    color: var(--gray-400);
    font-size: .85rem;
}

/* history items (dùng trong cả 2 tab) */
.history-item {
    padding: .75rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.history-item:last-child { border-bottom: none; }
.history-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.history-date { font-size: 11px; color: var(--gray-400); }
.history-who  { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.history-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.history-followup { font-size: 11.5px; color: var(--gray-500); }
.history-note {
    margin-top: 5px;
    font-size: 12.5px;
    color: var(--gray-700);
    line-height: 1.6;
}
.history-note span { font-weight: 600; color: var(--gray-500); margin-right: 4px; }
.need-note     { background: #f0fdf4; padding: 4px 8px; border-radius: 4px; }
.progress-note { background: #eff6ff; padding: 4px 8px; border-radius: 4px; }

.drawer-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--gray-200);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}
.detail-row {
    background: #fff;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.detail-key { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; }
.detail-val { font-size: 13.5px; font-weight: 500; color: var(--gray-800); }

/* compact trong drawer-info */
.drawer-info .detail-grid { margin-bottom: .6rem; }
.drawer-info .detail-row { padding: 5px 12px; gap: 1px; }
.drawer-info .detail-key { font-size: 10px; }
.drawer-info .detail-val { font-size: 12.5px; }

.detail-section { margin-bottom: 1rem; }
.detail-section-label { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.detail-text { font-size: 13.5px; color: var(--gray-700); line-height: 1.7; }

/* khối ghi chú ở đầu mỗi tab */
.tab-note-block {
    padding: 0 0 .75rem;
    margin-bottom: .5rem;
    border-bottom: 1px solid var(--gray-100);
}
.tab-note-block .detail-section-label { margin-bottom: 4px; }
.tab-note-block .detail-text { font-size: 13px; }

.tab-note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.btn-quick-edit {
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: 5px;
    padding: 2px 8px;
    font-size: .75rem;
    color: var(--gray-500);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.btn-quick-edit:hover { color: var(--blue); border-color: var(--blue); }

.quick-progress-edit textarea { margin-bottom: .5rem; }

.quick-progress-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.tab-empty-inline {
    font-size: .82rem;
    color: var(--gray-400);
    font-style: italic;
}
.progress-text {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    white-space: pre-wrap;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 600px;
    max-width: 96vw;
    /* flex column: header + body(scroll) + footer luôn hiển thị */
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    max-height: min(92vh, 92dvh); /* dvh = dynamic viewport, hỗ trợ iOS 15.4+ */
    animation: popIn .18s ease;
}
.modal--sm { width: 420px; }
.modal--lg { width: 960px; }
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0; /* không bị thu nhỏ */
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;   /* chỉ body scroll */
    flex: 1;
    min-height: 0;      /* cần thiết để flex child scroll đúng */
    -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
}
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex; gap: 8px; justify-content: flex-end;
    flex-shrink: 0; /* không bị thu nhỏ */
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}
.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}
.form-row .form-group,
.form-row-4 .form-group { margin-bottom: 0; }
label { font-size: 12.5px; font-weight: 600; color: var(--gray-700); }
.form-control {
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13.5px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}
.form-control:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(29,158,117,.15);
}
textarea.form-control { resize: vertical; min-height: 90px; }
.required { color: var(--red); }

.kbd-hint {
    display: inline-block;
    font-size: .62rem;
    font-family: ui-monospace, monospace;
    background: rgba(0,0,0,.07);
    border: 1px solid rgba(0,0,0,.18);
    border-bottom-width: 2px;
    border-radius: 3px;
    padding: 1px 5px;
    color: inherit;
    opacity: .7;
    margin-left: 5px;
    vertical-align: middle;
    line-height: 1.6;
    letter-spacing: .01em;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    font-size: 13.5px;
    color: var(--gray-700);
}
.form-check input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--green); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
}
.alert-danger { background: var(--red-light); color: var(--red); border: 1px solid #F7C1C1; }
.alert-success { background: var(--green-light); color: var(--green-dark); border: 1px solid var(--green-mid); }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffe69c; }

/* ── Loading / Empty ─────────────────────────────────────────────────────── */
.loading-state {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 3rem;
    justify-content: center;
    color: var(--gray-500);
}
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--gray-500);
}
.empty-icon { font-size: 48px; margin-bottom: 1rem; }

.not-found { text-align: center; padding: 4rem; }
.text-muted { color: var(--gray-500); font-size: 13px; margin-top: 4px; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--green-light) 0%, #fff 60%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.login-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-icon { font-size: 52px; display: block; margin-bottom: 10px; }
.login-title { font-size: 22px; font-weight: 800; color: var(--gray-900); margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--gray-500); }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 1rem; }
.btn-login {
    padding: 11px;
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition);
    margin-top: 4px;
}
.btn-login:hover { background: var(--green-dark); }
.login-hint {
    text-align: center;
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 1rem;
    line-height: 1.8;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; }
    .sidebar-close { display: block; }
    .sidebar-overlay { display: block; }
    .crm-main { margin-left: 0; }
    .menu-btn { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .crm-content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .filter-bar { flex-direction: column; }
    .filter-select { width: 100%; min-width: 0; }
    /* Giữ 2 ô ngày cạnh nhau, mỗi cái 50% — tránh iOS date overflow */
    .date-filter-row { width: 100%; flex: none; }
    .date-filter-row .filter-select { width: 0; } /* flex: 1 1 0 đã xử lý */
    .modal-overlay {
        padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
                 env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
        align-items: flex-end; /* modal hiện từ dưới lên trên mobile */
    }
    .modal {
        max-height: calc(96vh  - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        max-height: calc(96dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        border-radius: var(--radius) var(--radius) 0 0;
        max-width: 100%;
        width: 100%;
    }
    .modal .modal-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
    }
    .drawer { width: 100%; }
    .page-actions .search-wrap { max-width: 100%; width: 100%; }
    .page-actions .btn { font-size: 12.5px; padding: 6px 10px; }
    .form-row-4 { grid-template-columns: 1fr; }
}

/* ── Banner tự kết nối lại Blazor Server (thay overlay mặc định) ──────────── */
#components-reconnect-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 99999;
    padding: 10px 16px;
    text-align: center;
    font-size: 13.5px;
    background: #fff3cd;
    color: #856404;
    border-bottom: 1px solid #ffe69c;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: block;
}
#components-reconnect-modal .reconnect-msg { display: none; }
#components-reconnect-modal.components-reconnect-show .reconnect-msg--connecting { display: inline-flex; align-items: center; gap: 8px; }
#components-reconnect-modal.components-reconnect-failed .reconnect-msg--failed { display: inline; }
#components-reconnect-modal.components-reconnect-rejected .reconnect-msg--rejected { display: inline; }
#components-reconnect-modal.components-reconnect-show .reconnect-msg--connecting::before {
    content: '';
    display: inline-block;
    width: 12px; height: 12px;
    border: 2px solid #856404;
    border-top-color: transparent;
    border-radius: 50%;
    animation: reconnect-spin .8s linear infinite;
}
@keyframes reconnect-spin { to { transform: rotate(360deg); } }
#components-reconnect-modal button {
    margin-left: 8px;
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid #856404;
    background: #fff;
    color: #856404;
    cursor: pointer;
    font-size: 12.5px;
}


/* ════════════════════════════════════════════════════════════════════════════
   VuTuyen Admin — bổ sung giao diện
   ════════════════════════════════════════════════════════════════════════════ */

/* Sidebar tông xanh ngọc, điểm nhấn vàng */
.sidebar { background: var(--green-dark); border-right: none; }
.sidebar-header { border-bottom-color: rgba(255,255,255,.08); }
.logo { text-decoration: none; }
.logo-img { height: 38px; width: auto; }
.logo-title { color: var(--gold); font-family: Georgia, serif; font-size: 17px; }
.logo-sub { color: rgba(255,255,255,.55); }
.sidebar-close { color: rgba(255,255,255,.7); }
.nav-section-label { color: rgba(255,255,255,.4); }
.nav-link { color: rgba(255,255,255,.78); }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(201,161,59,.16); color: var(--gold); border-left-color: var(--gold); }
.sidebar-footer { border-top-color: rgba(255,255,255,.08); }
.user-name { color: #fff; }
.user-role { color: rgba(255,255,255,.5); }
.user-avatar { background: var(--gold); color: var(--green-dark); }
.sidebar .btn-change-pwd { color: rgba(255,255,255,.75); }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 5px;
    border-radius: 9px; font-size: .7rem; font-weight: 700; margin-left: auto; line-height: 1; }
.nav-badge--warn { background: var(--gold); color: var(--green-dark); }

/* Trang */
.page-title { font-size: 1.35rem; font-weight: 700; color: var(--gray-900); margin: 0; }
.page-actions { justify-content: space-between; }
.page-actions__right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-hint { margin: -.25rem 0 1rem; font-size: 13px; }
.btn-link { background: none; border: none; color: var(--green); text-decoration: none; font-size: 13px; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.small { font-size: 12px; }
.text-muted { color: var(--gray-500); }
.spacer { flex: 1; }

.panel { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: .75rem; flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 700; color: var(--gray-800); margin: 0 0 .75rem; }
.panel-header .panel-title { margin: 0; }
.panel-actions { display: flex; gap: 8px; align-items: center; }
.split-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.split-2 > * { min-width: 0; }

.form-row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.form-control--lg { font-size: 16px; font-weight: 600; padding: 10px 12px; }
.form-control--sm { padding: 5px 8px; font-size: 12.5px; }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13px; }
.form-check label { font-weight: 500; }

.filter-bar { align-items: center; margin-bottom: 1rem; }
.filter-bar .search-input, .search-input--sm { border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 5px 10px; min-width: 220px; background: #fff; }
.filter-select--lg { padding: 8px 12px; font-size: 14px; min-width: 260px; }
.stats-grid--4 { grid-template-columns: repeat(4, 1fr); }

.status-tabs { display: flex; gap: 4px; margin-bottom: .75rem; flex-wrap: wrap; }
.status-tab { background: #fff; border: 1px solid var(--gray-200); padding: 6px 14px; border-radius: 100px; cursor: pointer; font-size: 13px; color: var(--gray-600); font-family: var(--font); }
.status-tab.active { background: var(--green); color: #fff; border-color: var(--green); }

.thumb { width: 72px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--gray-100); }
.thumb-sm { width: 48px; height: 32px; object-fit: contain; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 600; margin-left: 4px; vertical-align: middle; }
.badge-gold { background: var(--gold-light); color: #8A6A17; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 100px; color: #fff; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.row-selected td { background: var(--green-light) !important; }
.row-error td { background: #FEF2F2; }

.article-status { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.article-status--published { background: var(--green-light); color: var(--green); }
.article-status--pending { background: var(--gold-light); color: #8A6A17; }
.article-status--draft { background: var(--gray-100); color: var(--gray-600); }

.role-admin { background: var(--gold-light); color: #8A6A17; }
.role-editor { background: var(--green-light); color: var(--green); }
.role-member { background: var(--gray-100); color: var(--gray-600); }

/* Trang soạn thảo */
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.edit-side { position: sticky; top: 1rem; }
.serp-preview { border: 1px dashed var(--gray-300); border-radius: var(--radius-sm); padding: 10px; margin-top: 10px; font-family: Arial, sans-serif; }
.serp-title { color: #1a0dab; font-size: 16px; line-height: 1.3; }
.serp-url { color: #006621; font-size: 12px; margin: 2px 0; }
.serp-desc { color: #4d5156; font-size: 12.5px; }
.seo-box__title { font-weight: 700; margin-bottom: .5rem; }
.seo-box:not(.panel) { border-top: 1px solid var(--gray-200); padding-top: .75rem; margin-top: .75rem; }
.check-list { max-height: 240px; overflow: auto; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 6px 8px; margin-top: 6px; }
.check-list .form-check { margin-bottom: 4px; font-weight: 400; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 100px; padding: 2px 8px; font-size: 11.5px; cursor: pointer; font-family: var(--font); }
.chip:hover { background: var(--green-light); border-color: var(--green-mid); }
.map-preview { width: 100%; height: 280px; border: 0; border-radius: var(--radius-sm); margin-top: 6px; }

.image-picker { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.image-picker__preview { position: relative; }
.image-picker__preview img { max-width: 100%; max-height: 180px; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); }
.image-picker__preview .btn-icon { position: absolute; top: 4px; right: 4px; background: #fff; }

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.album-item { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.album-item img { width: 100%; height: 110px; object-fit: cover; border-radius: 4px; }
.album-item__actions { display: flex; justify-content: space-between; }

.dash-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.dash-row a { color: var(--gray-800); text-decoration: none; }
.dash-row a:hover { color: var(--green); }
a.stat-card { text-decoration: none; display: block; }

/* Bảng hàng */
.unit-stat { text-align: left; font-family: var(--font); border-left: 4px solid var(--gray-300); }
.unit-stat.active { box-shadow: 0 0 0 2px var(--green) inset; }
.unit-stat--available { border-left-color: #16A34A; }
.unit-stat--reserved { border-left-color: var(--gold); }
.unit-stat--sold { border-left-color: #B91C1C; }
.unit-stat--locked { border-left-color: var(--gray-500); }
.unit-status { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.unit-status--available { background: #DCFCE7; color: #166534; }
.unit-status--reserved { background: var(--gold-light); color: #8A6A17; }
.unit-status--sold { background: #FEE2E2; color: #991B1B; }
.unit-status--locked { background: var(--gray-200); color: var(--gray-700); }
.unit-btn { border: 1px solid var(--gray-300); background: #fff; }
.unit-btn--available { color: #166534; }
.unit-btn--reserved { color: #8A6A17; }
.unit-btn--sold { color: #991B1B; }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--gold-light); border: 1px solid #E6C878; border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: .75rem; font-size: 13px; }

.pagination-bar { display: flex; align-items: center; gap: 4px; margin-top: 1rem; flex-wrap: wrap; }
.pg-btn { min-width: 36px; padding: 4px 10px; font-size: .85rem; }
.pg-info { margin-left: 8px; font-size: 12px; }
.tab-empty { text-align: center; color: var(--gray-500); padding: 2rem !important; }
.tab-count { display: inline-block; background: var(--gray-100); color: var(--gray-600); border-radius: 100px; padding: 0 8px; font-size: 11px; margin-left: 4px; }

/* Đăng nhập */
.login-wrapper { background: radial-gradient(circle at 20% 20%, #13603B 0%, var(--green-dark) 60%); }
.login-card { border-top: 4px solid var(--gold); }
.login-logo-img { height: 90px; width: auto; margin-bottom: .5rem; }
.login-title { font-family: Georgia, serif; color: var(--green-dark); }
.btn-login { background: var(--green); }
.btn-login:hover { background: var(--green-dark); }

@media (max-width: 1100px) {
    .edit-layout { grid-template-columns: 1fr; }
    .edit-side { position: static; }
    .split-2 { grid-template-columns: 1fr; }
    .stats-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

/* Đăng ký thành viên / khu thành viên */
.register-card { max-width: 480px; }
.register-steps { margin: .5rem 0 1rem 1.2rem; font-size: 13.5px; line-height: 1.7; }
.register-link { display: block; text-align: center; text-decoration: none; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.login-hint a { color: var(--green); font-weight: 600; }
.member-info { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 1rem 0; font-size: 14px; }
.member-info dt { color: var(--gray-500); }
.member-info dd { margin: 0; font-weight: 600; }

/* Blazor FocusOnNavigate focus vào h1 — không hiện viền */
h1:focus { outline: none; }

/* Khu tài khoản cuối sidebar: Hồ sơ của tôi / Đổi mật khẩu / Đăng xuất */
a.user-chip { text-decoration: none; border-radius: var(--radius-sm); padding: 4px; margin: -4px -4px 6px; transition: background var(--transition); }
a.user-chip:hover { background: rgba(255,255,255,.06); }
.sidebar .btn-change-pwd { border-color: rgba(255,255,255,.25); background: transparent; }
.sidebar .btn-change-pwd:hover { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.5); }
.sidebar .btn-change-pwd.active { color: var(--gold); border-color: var(--gold); background: rgba(201,161,59,.12); }

/* Link dạng nút (vd. "Đổi mật khẩu" trong trang Hồ sơ) không gạch chân */
a.btn, a.btn:hover { text-decoration: none; }

/* ════════════════════════════════════════════════════════════════════════════
   Thống kê truy cập — biểu đồ (palette đã kiểm định bằng validate_palette.js, nền sáng)
   ════════════════════════════════════════════════════════════════════════════ */
:root {
    --viz-series: #2a78d6;      /* 1 chuỗi: lượt xem */
    --viz-mobile: #1baf7a;      /* Điện thoại */
    --viz-desktop: #2a78d6;     /* Máy tính */
    --viz-tablet: #eb6834;      /* Máy tính bảng */
    --viz-grid: #e9ecef;
    --viz-text-2: #52514e;
}
.viz-tip { display: none; position: absolute; z-index: 20; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: #1C1F1E; color: #fff; padding: 8px 10px; border-radius: 6px; font-size: 12px; line-height: 1.5; white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0,0,0,.2); pointer-events: none; }
.viz-tip strong, .viz-tip span { display: block; }

/* Cột theo ngày */
.viz-daily__plot { position: relative; height: 240px; margin: 8px 0 28px 44px; }
.viz-daily__grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.viz-daily__gridline { border-top: 1px solid var(--viz-grid); position: relative; height: 0; }
.viz-daily__gridline span { position: absolute; left: -44px; top: -8px; width: 38px; text-align: right; font-size: 11px; color: var(--viz-text-2); }
.viz-daily__bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.viz-daily__col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.viz-daily__bar { position: relative; width: 100%; max-width: 28px; background: var(--viz-series); border-radius: 4px 4px 0 0; transition: filter .15s; }
.viz-daily__col:hover .viz-daily__bar, .viz-daily__col:focus .viz-daily__bar { filter: brightness(1.15); }
.viz-daily__col:hover .viz-tip, .viz-daily__col:focus .viz-tip { display: block; }
.viz-daily__col:hover::before { content: ""; position: absolute; inset: 0; background: rgba(42,120,214,.06); border-radius: 4px; }
.viz-daily__x { position: absolute; bottom: -22px; font-size: 11px; color: var(--viz-text-2); white-space: nowrap; }
.viz-table-toggle summary { cursor: pointer; font-size: 12.5px; color: var(--green); font-weight: 600; margin-top: 4px; }
.viz-table-toggle table { margin-top: 8px; }

/* Thiết bị: thanh xếp chồng 100% + chú giải */
.viz-device__bar { display: flex; gap: 2px; height: 28px; border-radius: 6px; background: var(--gray-100); margin-bottom: 12px; }
.viz-device__bar--mini { height: 10px; margin: 0; border-radius: 4px; }
.viz-device__seg { position: relative; height: 100%; outline: none; min-width: 3px; }
.viz-device__seg:first-child { border-radius: 6px 0 0 6px; }
.viz-device__seg:last-child { border-radius: 0 6px 6px 0; }
.viz-device__seg:only-child { border-radius: 6px; }
.viz-device__seg--mobile { background: var(--viz-mobile); }
.viz-device__seg--desktop { background: var(--viz-desktop); }
.viz-device__seg--tablet { background: var(--viz-tablet); }
.viz-device__seg:hover .viz-tip, .viz-device__seg:focus .viz-tip { display: block; }
.viz-device__legend { width: 100%; border-collapse: collapse; font-size: 13px; }
.viz-device__legend th { text-align: left; font-size: 11px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; padding: 4px 6px; }
.viz-device__legend td { padding: 6px; border-top: 1px solid var(--gray-100); }
.viz-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.viz-swatch--mobile { background: var(--viz-mobile); }
.viz-swatch--desktop { background: var(--viz-desktop); }
.viz-swatch--tablet { background: var(--viz-tablet); }

.viz-content .num { text-align: right; white-space: nowrap; }
.viz-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 1rem; }
.viz-kpi { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 14px 16px; }
.viz-kpi__label { font-size: 12px; color: var(--gray-500); font-weight: 600; }
.viz-kpi__value { font-size: 26px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.viz-kpi__sub { font-size: 12px; color: var(--gray-500); }
.viz-ranges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 1rem; }
.viz-ranges input[type=date] { padding: 5px 8px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-family: var(--font); }
.viz-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.viz-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
.viz-name-list { width: 100%; border-collapse: collapse; font-size: 13px; }
.viz-name-list td { padding: 6px 4px; border-top: 1px solid var(--gray-100); }
.viz-name-list td.num { text-align: right; white-space: nowrap; }
@media (max-width: 1100px) {
    .viz-kpis { grid-template-columns: repeat(2, 1fr); }
    .viz-grid-2, .viz-grid-3 { grid-template-columns: 1fr; }
}

.viz-name-list .bar-track { width: 100%; min-width: 70px; height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.viz-name-list .bar-fill { height: 100%; background: var(--viz-series); border-radius: 4px; }

/* Chọn nhiều loại sản phẩm (form dự án) */
.type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 100px; cursor: pointer;
    border: 1px solid var(--gray-300); background: #fff; color: var(--gray-700); font: 500 13px var(--font); transition: all var(--transition); }
.type-chip:hover { border-color: var(--green); color: var(--green); }
.type-chip.is-on { background: var(--green-light); border-color: var(--green); color: var(--green-dark); font-weight: 600; }
.type-chip__main { background: var(--gold); color: var(--green-dark); border-radius: 100px; padding: 0 7px; font-size: 10.5px; font-weight: 700; }

/* ── Thư viện ảnh (media-library.js) — nằm trên hộp thoại TinyMCE (z-index 1300) ── */
.image-picker__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.media-lib { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center;
    padding: 24px; background: rgba(10, 20, 15, .55); }
.media-lib.is-open { display: flex; }
.media-lib__dialog { width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; background: #fff;
    border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.media-lib__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--gray-200); }
.media-lib__head h3 { margin: 0; font-size: 1.05rem; color: var(--green-dark); }
.media-lib__close { width: 34px; height: 34px; border: none; border-radius: 50%; background: var(--gray-100); cursor: pointer; font-size: 1rem; }
.media-lib__close:hover { background: var(--gray-200); }
.media-lib__filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 12px 18px; background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200); }
.media-lib__filters label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--gray-600); }
.media-lib__filters .form-control { min-width: 150px; padding: 6px 10px; }
.media-lib__quick { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.media-lib__quick button { padding: 5px 12px; border: 1px solid var(--gray-300); border-radius: 999px; background: #fff; cursor: pointer;
    font: inherit; font-size: .85rem; color: var(--gray-700); }
.media-lib__quick button.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.media-lib__info { padding: 8px 18px 0; font-size: .85rem; color: var(--gray-600); }
.media-lib__grid { flex: 1 1 auto; min-height: 200px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px; padding: 10px 18px 14px; align-content: start; }
.media-lib__item { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 2px solid var(--gray-200); border-radius: var(--radius-sm);
    background: #fff; cursor: pointer; text-align: left; font: inherit; transition: border-color var(--transition), box-shadow var(--transition); }
.media-lib__item:hover { border-color: var(--green-mid); }
.media-lib__item.is-selected { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.media-lib__thumb { display: block; aspect-ratio: 4 / 3; border-radius: 4px; overflow: hidden; background: var(--gray-100); }
.media-lib__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-lib__meta { display: flex; justify-content: space-between; gap: 6px; font-size: .75rem; color: var(--gray-700); }
.media-lib__folder { font-size: .72rem; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-lib__more { text-align: center; padding: 0 18px 10px; }
.media-lib__more[hidden], .media-lib__more button[hidden] { display: none; }
.media-lib__foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--gray-200); }
.media-lib__picked { margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
    .media-lib { padding: 0; }
    .media-lib__dialog { height: 100%; border-radius: 0; }
    .media-lib__grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ── Mặt bằng dự án (ProjectLayouts.razor) ─────────────────────────────── */
.panel-subtitle { font-size: 13px; font-weight: 700; color: var(--gray-700); margin: 0; }
td.actions { white-space: nowrap; text-align: right; }
.crm-table--compact td, .crm-table--compact th { padding: 6px 8px; }
.btn-danger-outline { color: var(--red); border-color: var(--red-light); }
.btn-danger-outline:hover { background: var(--red-light); border-color: var(--red); }
.layout-thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--gray-200); display: block; }
.layout-chip { display: inline-block; min-width: 34px; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; text-align: center; }
.building-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.building-tab { display: flex; flex-direction: column; align-items: flex-start; padding: 8px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    background: #fff; cursor: pointer; font: inherit; font-weight: 700; color: var(--gray-800); }
.building-tab span { font-size: 11.5px; font-weight: 500; color: var(--gray-600); }
.building-tab.is-active { border-color: var(--green); background: var(--green-light); color: var(--green-dark); box-shadow: inset 0 -3px 0 var(--green); }
.building-head { display: flex; gap: 16px; align-items: flex-start; padding: 12px; margin-bottom: 14px; background: var(--gray-50); border-radius: var(--radius-sm); }
.building-head__img { width: 200px; max-height: 150px; object-fit: contain; background: #fff; border: 1px solid var(--gray-200); border-radius: 4px; }
.building-head__info h3 { margin: 0 0 4px; font-size: 16px; color: var(--green-dark); }
.building-head__info p { margin: 0 0 8px; }
.layout-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }   /* layout tầng trên, bố trí căn dưới — đủ chỗ cho cột thao tác */
.layout-cols > div { min-width: 0; overflow-x: auto; }
@media (max-width: 900px) { .building-head { flex-direction: column; } }
.layout-matrix-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); }
.layout-matrix { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.layout-matrix th, .layout-matrix td { padding: 2px; text-align: center; border-bottom: 1px solid var(--gray-100); }
.layout-matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--gray-100); padding: 6px 4px; min-width: 44px; }
.layout-matrix tbody th { position: sticky; left: 0; z-index: 1; background: var(--gray-50); padding: 0 8px; font-weight: 700; }
.layout-matrix__plan { min-width: 120px; max-width: 160px; text-align: left !important; color: var(--gray-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px !important; }
.layout-cell { width: 100%; min-width: 40px; height: 24px; border: none; border-radius: 4px; cursor: pointer; font: inherit; font-weight: 700; }
.layout-cell:hover { outline: 2px solid var(--gray-700); }
.layout-cell--empty { background: repeating-linear-gradient(45deg, #fff, #fff 4px, var(--gray-100) 4px, var(--gray-100) 8px); color: var(--gray-500); }
/* Mặt bằng: loại hình tòa / khu + trình nhập từng tầng của mẫu nhà thấp tầng */
.kind-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.kind-badge--apartment { background: var(--blue-light); color: var(--blue); }
.kind-badge--lowrise { background: var(--gold-light); color: #8A6A17; }
.kind-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.kind-switch__opt { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    cursor: pointer; font-weight: 600; font-size: 13px; }
.kind-switch__opt.is-on { border-color: var(--green); background: var(--green-light); color: var(--green-dark); }
.floors-editor { margin: 4px 0 14px; padding: 12px; border: 1px dashed var(--gray-300); border-radius: var(--radius-sm); background: var(--gray-50); }
.floor-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 12px; padding: 10px; margin-top: 8px; background: #fff;
    border: 1px solid var(--gray-200); border-radius: var(--radius-sm); }
.floor-row__fields { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 10px; align-items: end; }
.floor-row__fields .form-group { margin: 0; }
.floor-row__move { display: flex; gap: 4px; padding-bottom: 2px; }
.floor-row__img .image-picker__preview img { max-height: 110px; }
@media (max-width: 760px) { .floor-row, .floor-row__fields { grid-template-columns: 1fr; } }
/* Mặt bằng: đánh số bước */
.step-no { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%;
    background: var(--green); color: #fff; font-size: 12px; font-weight: 700; vertical-align: 1px; }
.step-hint { margin: -4px 0 10px; }
/* Bảng hàng ⇄ Mặt bằng */
.unit-kind { font-size: 12px; }
.layout-chip { background: var(--gray-100); color: var(--gray-700); }
.layout-chip--linked { background: var(--green-light); color: var(--green-dark); }
.match-box { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 14px; padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--gray-50); border: 1px dashed var(--gray-300); font-size: 13px; color: var(--gray-700); }
.match-box--ok { background: var(--green-light); border: 1px solid var(--green-mid); color: var(--green-dark); }
.match-box img { width: 90px; height: 64px; object-fit: contain; background: #fff; border-radius: 4px; border: 1px solid var(--gray-200); }
.nowrap, .layout-chip { white-space: nowrap; }
.modal .form-control:disabled { background: var(--green-light); color: var(--green-dark); border-color: var(--green-mid); cursor: not-allowed; opacity: 1; }
.auto-create { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
    background: #fff; border: 1px solid var(--gold); color: var(--gray-800); cursor: pointer; font-size: 13px; }
.auto-create input { margin-top: 3px; }
.search-input--sm { width: 180px; min-width: 0; padding: 5px 10px; font-size: 13px; }
/* Bảng trong cột chia đôi (Thành phố / Quận huyện, Danh mục...): bỏ min-width 950px để hiện đủ cột thao tác */
.split-2 .crm-table { min-width: 0; }
.split-2 .crm-table td.td-phone { word-break: break-all; }
/* Dự án: lọc thiếu thông tin + link nguồn */
.filter-select--warn.is-on { border-color: var(--amber); background: var(--amber-light); color: #7A4A0B; font-weight: 600; }
.missing-tags { margin-top: 2px; font-size: 11.5px; color: var(--amber); }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn .form-control { flex: 1; min-width: 0; }
.input-with-btn .btn { white-space: nowrap; }
/* Ô chọn có tìm kiếm (SearchSelect) */
.ss { position: relative; min-width: 220px; }
.ss--lg { min-width: 360px; }
.ss__control { position: relative; }
.ss__input { width: 100%; padding-right: 48px !important; cursor: text; }
.ss__input:not(:focus) { text-overflow: ellipsis; }
.ss__arrow { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-500); pointer-events: none; font-size: 12px; }
.ss__clear { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; padding: 0; border: none; border-radius: 50%;
    background: var(--gray-200); color: var(--gray-700); font-size: 10px; line-height: 18px; cursor: pointer; }
.ss__clear:hover { background: var(--gray-300); }
.ss__list { position: absolute; z-index: 1200; left: 0; right: 0; top: calc(100% + 4px); max-height: 320px; overflow-y: auto; margin: 0; padding: 4px;
    list-style: none; background: #fff; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); min-width: 280px; }
.ss__item { padding: 7px 10px; border-radius: 4px; cursor: pointer; font-size: 13.5px; color: var(--gray-800); }
.ss__item:hover, .ss__item.is-active { background: var(--green-light); color: var(--green-dark); }
.ss__item.is-selected { font-weight: 700; }
.ss__item--empty { color: var(--gray-600); font-style: italic; border-bottom: 1px solid var(--gray-100); }
.ss__note { padding: 7px 10px; font-size: 12.5px; color: var(--gray-500); }
.filter-bar .ss { flex: 0 1 260px; }
/* Dán toạ độ */
.coord-paste__msg { margin-top: 4px; font-size: 12.5px; }
.coord-paste__msg.is-ok { color: var(--green); }
.coord-paste__msg.is-bad { color: var(--red); }

/* Gán backlink */
.label-with-action { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.label-with-action label { margin: 0; }
.backlink-tools { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 10px; font-size: 13px; }
.backlink-tools label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.backlink-table tr.is-off td { opacity: .45; }
.backlink-table mark { background: var(--gold-light); color: var(--gray-900); font-weight: 700; padding: 0 2px; border-radius: 2px; }
.backlink-kind { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.backlink-kind--project { background: var(--green-light); color: var(--green-dark); }
.backlink-kind--dev { background: var(--blue-light); color: var(--blue); }
.backlink-kind--tag { background: var(--gold-light); color: #8A6A17; }

.legal-tabs { display: flex; gap: 8px; margin-bottom: 10px; }

.title-warn { margin-top: 6px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--amber-light); color: #6B4508; font-size: 12.5px; line-height: 1.5; }
.title-warn .btn { margin-left: 6px; vertical-align: middle; }
