/* v20260529-bbktdx */
:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #64748b;
    --border: #dbe2ef;
    --primary: #0f766e;
    --warning: #d97706;
    --danger: #b91c1c;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top right, #e1f0ff 0%, #f7fbff 45%, #f8fafc 100%);
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px 1fr;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.auth-layout {
    display: block;
}

.sidebar {
    background: #0b253a;
    color: #e2e8f0;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.mobile-nav-backdrop,
.mobile-nav-toggle {
    display: none;
}

.sidebar h1 {
    margin: 0 0 18px;
    font-size: 22px;
}

.user-menu {
    position: relative;
}

.user-menu-toggle {
    background: #ffffff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.user-menu-toggle:hover {
    border-color: #b7c6df;
}

.user-menu-items {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 180px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    padding: 6px;
    z-index: 30;
}

.user-menu.open .user-menu-items {
    display: grid;
}

.chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(45deg) translateY(-1px);
    transition: transform 0.15s ease;
}

.user-menu.open .chevron {
    transform: rotate(-135deg) translateY(-1px);
}

.user-menu-items a {
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 6px;
}

.user-menu-items a:hover {
    background: #eff6ff;
    color: #1e3a8a;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar a {
    color: #d6e6ff;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
}

.sidebar a:hover {
    background: #1f3d57;
}

.sidebar a.active {
    background: #2f5374;
    color: #ffffff;
    font-weight: 600;
}

/* ── Nav group (collapsible section) ────────────────────────── */
.nav-group {
    display: grid;
    gap: 0;
}

.nav-group-toggle {
    width: 100%;
    text-align: left;
    background: transparent;
    color: #d6e6ff;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    font-weight: 400;
    min-height: unset;
    box-shadow: none;
    transition: background .15s;
}

.nav-group-toggle:hover {
    background: #1f3d57;
    opacity: 1;
    box-shadow: none;
}

.nav-group-toggle.active {
    color: #ffffff;
    font-weight: 600;
}

.nav-group-toggle[aria-expanded='true'] {
    background: #132f47;
}

.nav-group-chevron {
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    transition: transform 0.18s ease;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-group-toggle[aria-expanded='true'] .nav-group-chevron {
    transform: rotate(-135deg) translateY(-1px);
}

.nav-group-items {
    display: grid;
    gap: 4px;
    padding: 4px 0 4px 12px;
    border-left: 2px solid #1f3d57;
    margin-left: 12px;
    margin-top: 2px;
    overflow: hidden;
    transition: opacity 0.15s ease;
}

.nav-group-items.collapsed {
    display: none;
}

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

.content {
    padding: 24px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    position: sticky;
    top: 0;
    z-index: 35;
    background: #f8fafc;
    padding-bottom: 4px;
}

.topbar-left {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.topbar-center {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.topbar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

.mobile-nav-toggle {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    border-radius: 10px;
    flex-direction: column;
    gap: 5px;
}

.chat-directory-topbar-button {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    border-radius: 10px;
    align-items: center;
    justify-content: center;
}

.chat-directory-topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.chat-directory-topbar-icon svg {
    width: 18px;
    height: 18px;
}

.chat-directory-topbar-button[aria-expanded='true'] {
    background: #eefbf8;
    border-color: #9fd7cc;
    color: var(--primary);
}

.mobile-nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #0f172a;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

body.sidebar-open .mobile-nav-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

body.sidebar-open .mobile-nav-toggle span:nth-child(2) {
    opacity: 0;
}

body.sidebar-open .mobile-nav-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 490; /* ngay dưới sidebar (500) */
    border: 0;
    padding: 0;
}

.content-auth {
    width: 100vw;
    min-height: 100vh;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

h2 {
    margin: 0 0 16px;
}

h3 {
    margin-top: 0;
}

.header-row,
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    border: none;
    padding: 0 6px 0 0;
    margin-right: 2px;
    text-decoration: none;
    transition: color .15s;
    vertical-align: middle;
}
.btn-back:hover {
    color: var(--primary);
}
.btn-back svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.header-row h2,
.page-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.page-actions,
.form-actions,
.detail-meta,
.header-copy {
    display: flex;
    gap: 10px;
}

.page-actions,
.form-actions {
    align-items: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.detail-meta {
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 32px;
}

.header-copy {
    flex-direction: column;
    gap: 4px;
}

.header-copy p {
    margin: 0;
    color: var(--muted);
}

.section-note,
.muted {
    color: var(--muted);
}

.section-note {
    margin: 0 0 12px;
}

.field-readonly {
    background: #f3f6fb !important;
    color: #64748b !important;
}

.inline-action-form {
    display: inline;
}

.grow-input {
    flex: 1;
}

.index-col {
    width: 40px;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.card h3 {
    font-size: 15px;
    line-height: 1.35;
    margin-bottom: 6px;
}

.card p {
    margin: 10px 0 0;
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
}

.card.warning p {
    color: var(--danger);
}

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

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    min-width: 0;
}

.narrow-panel {
    max-width: 520px;
}

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

.form.inline {
    grid-template-columns: 1fr 1fr auto;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    min-height: calc(100vh - 140px);
}

.chat-sidebar,
.chat-window {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.06);
}

.chat-sidebar {
    overflow: hidden;
}

.chat-directory-desktop {
    display: block;
}

.chat-directory-mobile {
    display: none;
}

.chat-directory {
    display: block;
}

.chat-directory-toggle {
    display: none;
}

.chat-sidebar-header,
.chat-window-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.chat-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-header-meta {
    min-width: 0;
}

.chat-header-meta strong {
    display: block;
    font-size: 16px;
}

.chat-sync-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.chat-sync-status.is-error {
    background: #fef2f2;
    color: #b91c1c;
}

.chat-sidebar-header p,
.chat-window-header p,
.chat-contact-meta,
.chat-message-time,
.chat-empty p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-contact-list {
    display: grid;
    gap: 0;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.chat-directory-panel-header {
    display: none;
}

.chat-directory:not([open]) .chat-contact-list {
    display: grid;
}

.chat-contact-card {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid #eef2f7;
}

.chat-contact-card:hover,
.chat-contact-card.active {
    background: #f0fdfa;
}

.chat-contact-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.chat-contact-content {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #dbeafe, #ccfbf1);
    color: #0f172a;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
}

.chat-avatar-lg {
    width: 44px;
    height: 44px;
    font-size: 15px;
}

.chat-contact-name {
    display: block;
    font-weight: 700;
}

.chat-contact-note {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.chat-contact-preview {
    display: block;
    color: #334155;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-contact-side {
    display: grid;
    justify-items: end;
    align-content: space-between;
    gap: 8px;
    min-width: 68px;
}

.chat-contact-time {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.chat-contact-unread {
    display: inline-flex;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

.chat-window {
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.chat-message-list {
    display: grid;
    gap: 12px;
    padding: 18px;
    align-content: start;
    overflow-y: auto;
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.06), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, #f5f9ff 46%, #f3f9f8 100%);
}

.chat-message {
    max-width: 72%;
    padding: 12px 14px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid #d9e3f0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.chat-message.mine {
    margin-left: auto;
    background: #0f766e;
    border-color: #0f766e;
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
}

.chat-message-author {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
}

.chat-message-body {
    white-space: pre-wrap;
    line-height: 1.5;
}

.chat-message-time {
    margin-top: 8px;
    font-size: 11px;
    font-style: italic;
}

.chat-message.mine .chat-message-time,
.chat-message.mine .chat-message-author {
    color: rgba(255, 255, 255, 0.82);
}

.chat-compose {
    padding: 16px 18px 18px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.chat-compose-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}

.chat-compose textarea {
    min-height: 110px;
    resize: vertical;
}

.chat-compose-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.chat-compose-actions .btn:disabled,
.chat-compose button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.chat-empty {
    display: grid;
    place-items: center;
    min-height: 320px;
    padding: 24px;
    text-align: center;
}

label {
    display: grid;
    gap: 6px;
    font-size: 14px;
}

input,
select,
textarea,
button {
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    padding: 10px;
    background: #fff;
}

textarea {
    line-height: 1.5;
}

button,
.btn {
    background: var(--primary);
    color: #fff;
    border: none;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, box-shadow .15s, opacity .15s;
    white-space: nowrap;
}

button:hover,
.btn:hover {
    opacity: .88;
    box-shadow: 0 2px 8px rgba(15,118,110,.18);
}

.btn.ghost {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid var(--border);
}

.btn.ghost:hover {
    background: #e2e8f0;
    box-shadow: none;
    opacity: 1;
}

.actions {
    display: flex;
    gap: 10px;
}

.filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 14px;
}

.report-filters {
    grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
    align-items: end;
}

.report-filters label {
    font-size: 13px;
}

.login-wrap {
    width: min(420px, calc(100vw - 32px));
    display: grid;
    gap: 20px;
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.login-logo-mark {
    width: 52px;
    height: 52px;
    background: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(15, 118, 110, 0.30);
}

.login-logo-mark svg {
    width: 28px;
    height: 28px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-logo-name {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.4px;
}

.login-logo-sub {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.login-panel {
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.09);
}

.login-panel h2 {
    font-size: 18px;
    margin-bottom: 6px;
}

.login-panel p {
    color: var(--muted);
    margin: 0 0 18px;
    font-size: 13px;
}

.settings-form {
    max-width: 740px;
}

.staff-account-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    min-width: 280px;
}

.staff-account-form input,
.staff-account-form select,
.staff-account-form button {
    padding: 7px 8px;
    font-size: 13px;
}

.open-account-modal {
    min-width: 150px;
}

.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.action-buttons form {
    margin: 0;
}

.icon-btn {
    width: 32px;
    height: 30px;
    min-width: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    box-sizing: border-box;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s;
}

.icon-btn:hover {
    background: #f1f5f9;
    border-color: var(--border);
    color: var(--text);
    opacity: 1;
    box-shadow: none;
}

.icon-btn.btn-danger { color: var(--danger); background: transparent; }
.icon-btn.btn-danger:hover { background: #fee2e2; border-color: #fca5a5; }

.icon-btn svg {
    width: 15px;
    height: 15px;
}
.btn:not(.icon-btn) svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.account-dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    width: min(460px, 96vw);
    padding: 16px;
}

.account-dialog::backdrop {
    background: rgba(15, 23, 42, 0.35);
}

.account-dialog-close-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.delete-account-form {
    margin-top: 8px;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.checkbox-inline input {
    width: 16px;
    height: 16px;
    padding: 0;
}

.btn.btn-danger {
    background: var(--danger);
}
.btn.btn-danger.icon-btn {
    background: #f1f5f9;
    color: var(--danger);
    border-color: var(--border);
}
.btn.btn-danger.icon-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    opacity: 1;
    box-shadow: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.table-scroll {
    width: 100%;
    max-width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 9px 11px;
    vertical-align: middle;
}

td,
td a,
td span {
    font-size: inherit;
    line-height: 1.45;
}

th {
    background: #f1f5f9;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #475569;
    white-space: nowrap;
}

tbody tr {
    transition: background .12s;
}

tbody tr:hover {
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: none;
}

.alerts {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 60;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 24px));
}

.alert {
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.alert.is-hiding {
    opacity: 0;
    transform: translateY(-8px);
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.alert.danger {
    background: #fee2e2;
    color: #991b1b;
}

.info-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0;
}

.info-list li {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.5;
}

.info-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-list li strong {
    min-width: 110px;
    flex-shrink: 0;
    color: var(--muted);
    font-weight: 600;
}

.warning-row {
    background: #fffbeb;
}

.warning-row td:first-child {
    border-left: 3px solid #f59e0b;
}

.danger-row {
    background: #fef2f2;
}

.danger-row td:first-child {
    border-left: 3px solid #ef4444;
}

@media (max-width: 980px) {
    html,
    body {
        font-size: 14px;
        width: 100%;
        grid-template-columns: 1fr;
        overflow-x: hidden;
    }

    body {
        line-height: 1.5;
    }

    h2 {
        font-size: 20px;
        line-height: 1.3;
        margin-bottom: 14px;
    }

    h3 {
        font-size: 16px;
        line-height: 1.35;
        margin-bottom: 10px;
    }

    main,
    section,
    .content,
    .panel,
    .panel-grid,
    .cards,
    .header-row,
    .page-header,
    .filters,
    .topbar {
        min-width: 0;
        max-width: 100%;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        /* dvh: dynamic viewport height — bao gồm vùng sau thanh địa chỉ browser */
        height: 100dvh;
        height: 100vh; /* fallback cho browser cũ */
        height: 100dvh;
        width: min(290px, calc(100vw - 56px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 500;
        box-shadow: 4px 0 32px rgba(2, 6, 23, 0.22);
        transform: translateX(-100%);
        transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .mobile-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-nav-toggle,
    .chat-directory-topbar-button,
    .mobile-nav-backdrop {
        display: inline-flex;
    }

    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 35;
        padding: 0 14px;
        height: 56px;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid rgba(219, 226, 239, 0.7);
        box-shadow: 0 1px 10px rgba(15, 23, 42, 0.07);
        margin-bottom: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .topbar-center {
        display: block;
    }

    .content {
        padding: 16px;
        padding-top: 72px;
        overflow-x: hidden;
    }

    .chat-page-header {
        display: none;
    }

    .sidebar h1 {
        font-size: 20px;
    }

    .sidebar a,
    .user-menu-toggle,
    .user-menu-items a,
    label,
    input,
    select,
    textarea,
    button,
    .btn,
    th,
    td,
    .badge,
    .chat-contact-note,
    .chat-sidebar-header p,
    .chat-window-header p,
    .chat-contact-meta,
    .chat-message-time,
    .chat-empty p,
    .info-list,
    .checkbox-inline,
    .report-item-num {
        font-size: 14px;
    }

    .nav-badge,
    .chat-contact-unread,
    .chat-message-author,
    .chat-directory-label {
        font-size: 12px;
    }

    .chat-directory-current,
    .chat-contact-name,
    .card h3,
    .report-filters label,
    .header-copy p,
    .section-note,
    .muted,
    .chat-message,
    .chat-message-body {
        font-size: 14px;
    }

    .card {
        padding: 12px;
    }

    .card p {
        font-size: 24px;
    }

    .header-row,
    .page-header {
        align-items: flex-start;
        flex-direction: column;
        flex-wrap: wrap;
        margin-bottom: 14px;
    }

    .header-row > *,
    .page-header > * {
        max-width: 100%;
    }

    .header-row > .btn,
    .header-row > .page-actions,
    .header-row > .page-header-actions,
    .header-row > .form-actions,
    .page-header > .btn,
    .page-header > .page-actions,
    .page-header > .page-header-actions,
    .page-header > .form-actions {
        width: 100%;
    }

    .page-actions,
    .form-actions,
    .actions,
    .inline-form,
    .chat-compose-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .page-actions .btn,
    .form-actions .btn,
    .actions .btn,
    .inline-form .btn,
    .header-row > .btn,
    .page-header > .btn,
    .chat-compose-actions button {
        width: 100%;
    }

    .page-actions .icon-btn,
    .form-actions .icon-btn,
    .actions .icon-btn {
        width: 38px;
    }

    .page-actions form,
    .form-actions form,
    .actions form {
        width: 100%;
    }

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

    .panel {
        padding: 12px;
        border-radius: 10px;
    }

    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        min-height: auto;
        position: relative;
    }

    .chat-sidebar,
    .chat-window,
    .chat-directory {
        border-radius: 14px;
    }

    .chat-sidebar {
        overflow: visible;
        background: transparent;
        border: 0;
        box-shadow: none;
        align-self: start;
    }

    .chat-sidebar-header {
        display: none;
    }

    .chat-directory-desktop {
        display: none;
    }

    .chat-directory-mobile {
        display: block;
    }

    .chat-directory {
        position: relative;
        width: 100%;
        max-width: none;
        border: 0;
        border-radius: 0;
        background: transparent;
        overflow: visible;
    }

    .chat-directory-toggle {
        display: none;
    }

    .chat-directory-toggle::-webkit-details-marker {
        display: none;
    }

    .chat-directory-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        color: #0f766e;
    }

    .chat-directory-icon svg {
        width: 22px;
        height: 22px;
    }

    .chat-directory[open] .chat-directory-toggle {
        background: transparent;
    }

    .chat-directory-label {
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--muted);
    }

    .chat-directory-current {
        font-size: 15px;
        font-weight: 700;
        color: var(--text);
    }

    .chat-directory-mobile {
        background: transparent;
        border: 0;
    }

    .chat-directory-mobile[open] {
        border: 0;
        border-radius: 0;
        background: transparent;
        overflow: visible;
        box-shadow: none;
    }

    .chat-contact-list {
        max-height: 320px;
    }

    .chat-directory-mobile .chat-contact-list {
        display: none;
    }

    .chat-directory-mobile[open] .chat-directory-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 14px 8px;
    }

    .chat-directory-panel-header strong {
        font-size: 15px;
    }

    .chat-directory-close {
        min-height: 34px;
        padding: 0 12px;
        border-radius: 999px;
        background: #e2e8f0;
        color: #0f172a;
        font-size: 13px;
        font-weight: 700;
    }

    .chat-directory-mobile[open] .chat-contact-list {
        display: grid;
        position: static;
        width: 100%;
        max-height: calc(100vh - 260px);
        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
        overflow-y: auto;
        z-index: 30;
    }

    .chat-layout.is-directory-open .chat-window {
        display: none;
    }

    .chat-layout.is-directory-open .chat-sidebar {
        width: 100%;
    }

    .chat-contact-card {
        padding: 12px 14px;
    }

    .chat-contact-side {
        min-width: 58px;
    }

    .chat-directory:not([open]) .chat-contact-list {
        display: none;
    }

    .chat-message {
        max-width: 88%;
        padding: 10px 12px;
        font-size: 14px;
    }

    .chat-sidebar-header,
    .chat-window-header,
    .chat-message-list,
    .chat-compose {
        padding: 14px;
    }

    .chat-window-header {
        align-items: center;
        flex-direction: row;
        gap: 10px;
        padding: 10px 12px;
    }

    .chat-header-user {
        width: 100%;
        gap: 8px;
    }

    .chat-sync-status {
        flex-shrink: 0;
        padding: 4px 8px;
        font-size: 10px;
        white-space: nowrap;
    }

    .chat-window-header strong {
        font-size: 15px;
        line-height: 1.2;
    }

    .chat-header-meta p {
        display: none;
    }

    .chat-avatar-lg {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .chat-window {
        min-height: calc(100vh - 170px);
        grid-template-rows: auto 1fr;
    }

    .chat-message-list {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    }

    .chat-message-time {
        font-size: 8px;
        font-style: italic;
        letter-spacing: 0.02em;
    }

    .chat-compose {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        padding: 10px 12px;
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
        z-index: 25;
    }

    .chat-compose-row {
        grid-template-columns: 1fr auto;
        gap: 8px;
    }

    .chat-compose textarea {
        min-height: 44px;
        max-height: 92px;
        padding: 10px 12px;
        border-radius: 14px;
        resize: none;
    }

    .chat-compose button {
        min-width: 72px;
        align-self: stretch;
        border-radius: 14px;
        padding: 0 16px;
    }

    .filters {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .report-filters {
        grid-template-columns: 1fr;
    }

    .grid-2,
    .form.inline {
        grid-template-columns: 1fr;
    }

    .form {
        gap: 12px;
    }

    input,
    select,
    textarea,
    button,
    .btn {
        min-height: 44px;
    }

    button,
    .btn {
        border-radius: 10px;
    }

    input,
    select {
        border-radius: 10px;
        padding: 10px 14px;
    }

    .card {
        border-radius: 14px;
        box-shadow: 0 2px 14px rgba(15, 23, 42, 0.07);
    }

    .panel {
        box-shadow: 0 2px 14px rgba(15, 23, 42, 0.07);
    }

    .alerts {
        top: 62px;
        right: 10px;
    }

    .table-scroll {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
        overscroll-behavior-x: contain;
    }

    .table-scroll table {
        width: max-content;
        min-width: 100%;
        border: none;
        border-radius: 0;
    }

    .table-scroll th,
    .table-scroll td {
        padding: 7px 10px;
        line-height: 1.45;
        vertical-align: middle;
        white-space: nowrap;
    }

    .table-scroll .cell-wrap {
        white-space: normal;
        word-break: break-word;
        line-height: 1.45;
        overflow: visible;
    }

    .table-scroll td a,
    .table-scroll .cell-wrap,
    .table-scroll .cell-wrap a,
    .table-scroll .cell-wrap-wide,
    .table-scroll .cell-wrap-wide a {
        font-size: 14px;
        line-height: 1.45;
    }

    .table-scroll .cell-wrap-wide {
        white-space: normal;
        word-break: break-word;
        overflow: visible;
    }

.cell-actions {
    width: 1%;
    text-align: right;
    padding: 5px 8px !important;
    white-space: nowrap;
    vertical-align: middle;
}

th.cell-actions {
    text-align: right;
    padding: 9px 11px !important;
}

.cell-actions .action-buttons {
    justify-content: flex-end;
}

    .report-item-inputs input[type="text"],
    .report-item-inputs textarea {
        font-size: 14px;
    }

    .report-item-row {
        grid-template-columns: 24px 1fr 36px;
        gap: 8px;
        padding: 10px;
    }

    .detail-meta {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 16px;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .pagination a {
        min-width: 40px;
    }

    .inline-form {
        flex-wrap: wrap;
    }

    body {
        background: #eef2f7;
    }

    .sidebar h1 {
        font-size: 19px;
        font-weight: 800;
        letter-spacing: -0.4px;
        padding-bottom: 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        margin-bottom: 6px;
    }

    .sidebar a,
    .nav-group-toggle {
        min-height: 44px;
        border-radius: 10px;
        font-size: 15px;
    }

    .module-card {
        border-radius: 16px;
        box-shadow: 0 2px 14px rgba(15, 23, 42, 0.07);
    }

    .filters button,
    .filters .btn {
        width: 100%;
        justify-content: center;
    }

    .account-dialog {
        max-height: 88dvh;
        overflow-y: auto;
        padding: 14px;
        border-radius: 14px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        border-radius: 8px;
    }

    .info-list li strong {
        min-width: 100px;
    }

    .login-panel {
        padding: 22px;
    }
}

/* --- Báo cáo công tác ngày --- */
.report-item-row {
    display: grid;
    grid-template-columns: 28px 1fr 36px;
    gap: 10px;
    align-items: start;
    margin-bottom: 10px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.report-item-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    padding-top: 9px;
    text-align: center;
}

.report-item-inputs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.report-item-inputs input[type="text"] {
    font-weight: 600;
    font-size: 15px;
}

.report-item-inputs textarea {
    resize: vertical;
    min-height: 60px;
}

.remove-item-btn {
    flex-shrink: 0;
    margin-top: 4px;
}

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

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-muted   { background: #f1f5f9; color: #64748b; }

.muted-row td { opacity: 0.5; }

.pagination {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}

.pagination a {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
    text-align: center;
}

.pagination a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* OCR Upload */
.ocr-btn-row {
    display: flex;
    gap: .6rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}
.ocr-action-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .45rem .9rem;
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    color: var(--primary);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--surface);
    transition: background .18s, color .18s;
    user-select: none;
}
.ocr-action-btn:hover {
    background: var(--primary);
    color: #fff;
}
.ocr-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: .4rem;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: .65;
    transition: opacity .2s;
    vertical-align: middle;
    line-height: 1;
}
.ocr-icon-btn:hover { opacity: 1; }
.ocr-upload-section {
    margin-bottom: 1rem;
}
.ocr-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 2rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: var(--surface);
}
.ocr-drop-zone:hover, .ocr-drop-zone.drag-over {
    border-color: var(--primary);
    background: #f0fdf4;
}
.ocr-drop-icon { font-size: 2rem; }
.ocr-drop-text { color: var(--muted); font-size: .9rem; }
.ocr-preview {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-top: .5rem;
}
.ocr-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid var(--border);
    object-fit: contain;
}
.ocr-status {
    margin-top: .75rem;
    padding: .75rem 1rem;
    border-radius: 8px;
    font-size: .9rem;
}
.ocr-status.loading {
    background: #fef3c7;
    color: #92400e;
}
.ocr-status.success {
    background: #d1fae5;
    color: #065f46;
}

/* ── Nhân khẩu / Đối tượng modules ─────────────────────────────── */

.nk-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.nk-stat-tab {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, background .15s, box-shadow .15s;
    box-shadow: 0 1px 4px rgba(15,23,42,.04);
}

.nk-stat-tab:hover {
    border-color: #93c5fd;
    background: #f0f9ff;
    box-shadow: 0 4px 12px rgba(15,118,110,.08);
}

.nk-stat-tab.active {
    border-color: var(--primary);
    background: #f0fdfa;
    box-shadow: 0 4px 14px rgba(15,118,110,.12);
}

.nk-stat-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

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

.nk-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

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

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

.result-info {
    font-size: .875rem;
    color: var(--muted);
    margin: 0 0 10px;
    padding: 0 2px;
}

.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-primary { background: #eff6ff; color: #1d4ed8; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: .02em;
}

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

.module-empty-icon {
    font-size: 2.5rem;
    margin-bottom: .5rem;
    opacity: .6;
}

@media (max-width: 980px) {
    .nk-stats {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .nk-stat-tab {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 14px;
    }
    .nk-stat-value {
        font-size: 22px;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar input,
    .filter-bar select,
    .filter-bar .btn {
        width: 100%;
    }
}
.ocr-status.error {
    background: #fee2e2;
    color: var(--danger);
}
.hint {
    font-size: .85rem;
    color: var(--muted);
    margin-top: .25rem;
}

/* ── Module card wrapper ─────────────────────────────────────── */
.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 20px;
}

/* ── Page/section header action group ───────────────────────── */
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Section sub-header (h3 + action) ───────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.section-header h3 { margin: 0; }

/* ── Utility: tabular-numeric (IDs, codes) ───────────────────── */
.mono {
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
    white-space: nowrap;
}

/* ── Utility: index/number column cell ──────────────────────── */
.cell-num {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
    padding-right: 12px !important;
}

/* ── Utility: italic text ────────────────────────────────────── */
.text-italic { font-style: italic; }

/* ── Subtabs ─────────────────────────────────────────────────── */
.subtabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.subtabs a {
    padding: 10px 16px;
    text-decoration: none;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.subtabs a:hover { color: var(--primary); }
.subtabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.subtabs a .badge { margin-left: 6px; font-size: 11px; vertical-align: middle; }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 14px;
}
.toolbar .grow { flex: 1; min-width: 220px; }
.toolbar .grow > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
}
.toolbar .grow input[type=search],
.toolbar .grow input[type=text] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.toolbar .grow input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,118,110,.12);
}

/* ── Filter toggle badge ─────────────────────────────────────── */
.filter-wrap { position: relative; }
.filter-toggle { position: relative; }
.filter-count {
    position: absolute;
    top: -6px; right: -6px;
    background: var(--primary);
    color: #fff;
    font-size: 11px; font-weight: 700;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    pointer-events: none;
}

/* ── Inline filter bar ───────────────────────────────────────── */
.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px 10px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 8px;
    margin-bottom: 12px;
}
.filter-bar-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filter-bar-item > label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.filter-bar-item > select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, background .15s;
    line-height: 1.4;
}
.filter-bar-item > select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,118,110,0.10);
}
.filter-bar-item > select.filter-active {
    border-color: var(--primary);
    background: #f0fdf9;
    color: #065f46;
    font-weight: 600;
}
.hidden { display: none !important; }

/* ── Active filter chips ──────────────────────────────────────── */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 10px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 10px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.chip-remove {
    color: #93c5fd;
    font-size: 15px;
    line-height: 1;
    text-decoration: none;
    font-weight: 700;
    margin-left: 1px;
}
.chip-remove:hover { color: #1d4ed8; }

/* ── Result summary line ──────────────────────────────────────── */
.result-summary {
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 10px;
    padding: 0 2px;
}

/* ── Name cell with alias sub-line ───────────────────────────── */
.cell-name-stack { display: flex; flex-direction: column; gap: 1px; }
.cell-alias { font-size: 11.5px; color: var(--muted); font-style: italic; line-height: 1.3; }

/* ── Status pill active variant ──────────────────────────────── */
.pill-active {
    background: #dcfce7;
    color: #15803d;
}

/* ── List footer: page-size selector + pager ─────────────────── */
.list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.page-size-form {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.page-size-form label { margin: 0; font-weight: 500; display: inline; }
.page-size-form select { padding: 5px 8px; min-width: 60px; width: auto; }

/* ── Pager ───────────────────────────────────────────────────── */
.pager {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 16px 0 0;
}
.pager a, .pager span {
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--muted);
    background: #fff;
    font-size: 13px;
    min-width: 32px;
    text-align: center;
    transition: background .15s, border-color .15s;
}
.pager a:hover { background: var(--bg); border-color: #b7c6df; color: var(--text); }
.pager .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.pager .disabled { color: #cbd5e1; background: var(--bg); cursor: not-allowed; }

/* ── Fieldset sections (detail pages) ───────────────────────── */
fieldset.section {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px 18px;
    margin: 0 0 16px;
    background: var(--surface);
}
fieldset.section legend {
    padding: 3px 12px;
    font-size: 12px; font-weight: 700;
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ── Detail grid ─────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 6px 16px;
}
.detail-grid .full { grid-column: 1 / -1; }
.detail-item {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}
.detail-item .lbl {
    display: block;
    font-size: 11px; font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-bottom: 2px;
}
.detail-item .val { color: var(--text); word-break: break-word; }
.detail-item .val:empty::after { content: '—'; color: #94a3b8; }

@media (max-width: 980px) {
    .module-card { padding: 14px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .grow { min-width: 0; }
    .filter-bar { grid-template-columns: repeat(2, 1fr); }
    .list-footer { flex-direction: column; align-items: flex-start; }
}

/* ── Detail page: horizontal lbl/val (≥480px) ─────────────────── */
@media (min-width: 480px) {
    .detail-item { display: flex; align-items: baseline; gap: 0; padding: 5px 0; }
    .detail-item .lbl {
        min-width: 140px; width: 140px;
        flex-shrink: 0; margin-bottom: 0;
        padding-right: 8px; box-sizing: border-box;
    }
    .detail-item .val { flex: 1; min-width: 0; }
}

/* ── Detail page: side-by-side fieldsets (tablet ≥768px) ─────── */
@media (min-width: 768px) {
    .detail-sections {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 16px;
        align-items: start;
    }
    .detail-sections > fieldset.section.wide { grid-column: 1 / -1; }
    .detail-sections > fieldset.section:not(.wide) .detail-grid { grid-template-columns: 1fr; }
    .detail-sections > fieldset.section.wide .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Đối tượng detail: identity card ─────────────────────────── */
.dt-id-card {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--surface);
}
.dt-id-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 14px;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}
.dt-id-row.dt-id-full { grid-column: 1 / -1; }
.dt-id-lbl {
    min-width: 120px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    flex-shrink: 0;
}
.dt-id-val { color: var(--text); word-break: break-word; flex: 1; }
.dt-id-val.mono { font-variant-numeric: tabular-nums; letter-spacing: .04em; }

/* ── Đối tượng detail: tiền án tiền sự box ───────────────────── */
.dt-tats-section {
    border: 2px solid #fca5a5;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}
.dt-tats-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #b91c1c;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 10px 16px;
}
.dt-tats-body {
    background: #fff7f7;
    padding: 16px;
    min-height: 80px;
}
.dt-tats-pre {
    margin: 0;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.75;
    color: #7f1d1d;
    white-space: pre-wrap;
    word-break: break-word;
}
.dt-tats-empty {
    margin: 0;
    font-size: 13px;
    color: #94a3b8;
    font-style: italic;
}

/* ── AI Agent ─────────────────────────────────────────────────────── */

/* Tabs */
.aia-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.aia-tab {
    padding: 8px 20px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 6px 6px 0 0;
    transition: color .15s, border-color .15s;
}
.aia-tab:hover { color: var(--primary); }
.aia-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: #f0faf9; }

/* Panels */
.aia-panel { display: none; }
.aia-panel.active { display: block; }

/* Chat wrap */
.aia-chat-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

/* Pipeline */
.aia-pipeline-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}
.aia-optional { font-weight: 400; font-size: 12px; color: var(--muted); opacity: .7; }
.aia-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.aia-textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    resize: vertical;
    outline: none;
    transition: border-color .15s;
    box-sizing: border-box;
}
.aia-textarea:focus { border-color: var(--primary); }
.aia-pipeline-options {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.aia-select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
}
.aia-pipeline-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}
.aia-btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
.aia-btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.aia-btn-ghost { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.aia-btn-ghost:hover { background: var(--bg); }
.aia-btn-danger-sm { background: none; border: 1px solid #fca5a5; border-radius: 6px; padding: 4px 8px; font-size: 12px; color: var(--danger); cursor: pointer; }
.aia-btn-danger-sm:hover { background: #fef2f2; }
.aia-tab,
.aia-btn-primary, .aia-btn-step, .aia-btn-ghost,
.aia-btn-newidea, .aia-btn-history, .aia-btn-sched,
.aia-btn-connect, .aia-btn-publish,
.aia-scene-run-btn, .aia-scene-mini-btn, .aia-path-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.aia-tab svg, .aia-btn-primary svg, .aia-btn-step svg, .aia-btn-ghost svg,
.aia-btn-newidea svg, .aia-btn-history svg, .aia-btn-sched svg,
.aia-btn-connect svg, .aia-btn-publish svg,
.aia-scene-run-btn svg, .aia-scene-mini-btn svg, .aia-path-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
.aia-hint { font-size: 13px; color: var(--muted); }
.aia-char-header { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; margin-bottom: 4px; }
.aia-char-header .aia-label { margin: 0; }
.aia-char-select-row { display: flex; gap: 8px; margin-bottom: 6px; }
.aia-char-manager { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 8px; }
.aia-char-manager-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.aia-char-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.aia-char-form-actions { display: flex; gap: 8px; }
.aia-input-text { border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 14px; width: 100%; }
.aia-char-list { display: flex; flex-direction: column; gap: 8px; }
.aia-char-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.aia-char-item-name { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.aia-char-item-prompt { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.5; }
.aia-char-item-actions { display: flex; gap: 6px; }
.aia-char-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 12px; }

/* Steps */
.aia-steps { display: flex; flex-direction: column; gap: 12px; }
.aia-step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.aia-step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-wrap: wrap;
}
.aia-step-num {
    width: 26px;
    height: 26px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.aia-step-title { font-weight: 600; font-size: 14px; flex: 1; }
.aia-step-btns { display: flex; gap: 6px; align-items: center; flex-shrink: 0; margin-left: auto; }
.aia-btn-step {
    background: var(--surface);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.aia-btn-step:hover { background: #e8f4f3; }
.aia-step-status {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: #f1f5f9;
    color: var(--muted);
    min-width: 60px;
    text-align: center;
}
.aia-step-status.loading { background: #fef9c3; color: #854d0e; }
.aia-step-status.done { background: #dcfce7; color: #166534; }
.aia-step-status.error { background: #fee2e2; color: var(--danger); }
.aia-step-body { padding: 16px; min-height: 80px; }
.aia-step-editor {
    width: 100%;
    min-height: 120px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.65;
    resize: vertical;
    box-sizing: border-box;
    background: var(--bg);
    color: var(--text);
}
.aia-img-placeholder, .aia-audio-placeholder, .aia-video-placeholder {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px dashed var(--border);
}
.aia-img-placeholder.aia-error,
.aia-audio-placeholder.aia-error,
.aia-video-placeholder.aia-error { border-color: #fca5a5; color: var(--danger); background: #fef2f2; }
.aia-result-img { max-width: 100%; border-radius: 8px; display: block; }
.aia-result-video { max-width: 100%; border-radius: 8px; display: block; }
.aia-audio { width: 100%; }
.aia-caption { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.aia-pre {
    margin: 0;
    padding: 16px;
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    background: #1e293b;
    color: #e2e8f0;
}

/* Shared message styles (layout) */
.aia-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);
    min-height: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.aia-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.aia-welcome {
    margin: auto;
    text-align: center;
    max-width: 520px;
    padding: 16px 0;
}
.aia-welcome-icon {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 12px;
}
.aia-welcome strong {
    display: block;
    font-size: 18px;
    margin-bottom: 6px;
}
.aia-welcome p {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 16px;
}
.aia-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.aia-chip {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.aia-chip:hover {
    background: #e8f4f3;
    border-color: var(--primary);
    color: var(--primary);
}
.aia-msg {
    display: flex;
    gap: 10px;
    max-width: 820px;
}
.aia-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.aia-msg--agent { align-self: flex-start; }
.aia-msg--error { align-self: flex-start; }
.aia-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.aia-agent-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.aia-bubble {
    background: var(--primary);
    color: #fff;
    padding: 10px 14px;
    border-radius: 18px 18px 4px 18px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    max-width: 600px;
}
.aia-bubble--agent {
    background: var(--bg);
    color: var(--text);
    border-radius: 4px 18px 18px 18px;
    border: 1px solid var(--border);
}
.aia-bubble--error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fca5a5;
    border-radius: 8px;
}
.aia-bubble code { background: rgba(0,0,0,.1); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.aia-bubble--agent code { background: #e2e8f0; }
.aia-bubble pre { margin: 8px 0 0; }
.aia-bubble--agent pre { background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.aia-code-block { font-family: "Courier New", monospace; }
.aia-code-output {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
}
.aia-code-output pre { margin: 4px 0 0; font-family: "Courier New", monospace; white-space: pre-wrap; }
.aia-tool-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    font-size: 14px;
    max-width: 640px;
}
.aia-tool-summary {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}
.aia-tool-summary::-webkit-details-marker { display: none; }
.aia-tool-summary::before {
    content: "▶";
    font-size: 10px;
    transition: transform .15s;
}
details[open] .aia-tool-summary::before { transform: rotate(90deg); }
.aia-tool-body { padding: 10px 14px 12px; }
.aia-tool-error { color: var(--danger); margin: 0; font-size: 13px; }
.aia-img {
    max-width: 100%;
    border-radius: 8px;
    display: block;
}
.aia-audio {
    width: 100%;
    margin-top: 4px;
}
.aia-video {
    max-width: 100%;
    border-radius: 8px;
    display: block;
}
.aia-caption { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.aia-search-results { font-size: 13px; line-height: 1.7; color: var(--text); }
.aia-search-results strong { color: var(--primary); }

/* Compose */
.aia-compose {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--surface);
}
.aia-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    outline: none;
    transition: border-color .15s;
    overflow-y: hidden;
}
.aia-input:focus { border-color: var(--primary); }
.aia-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity .15s;
}
.aia-send-btn:disabled { opacity: .45; cursor: not-allowed; }
.aia-send-btn svg { width: 18px; height: 18px; }

/* Loading dots */
.aia-loading-dots {
    display: flex;
    gap: 5px;
    padding: 10px 4px;
    align-items: center;
}
.aia-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    opacity: .4;
    animation: aia-pulse 1.2s ease-in-out infinite;
}
.aia-loading-dots span:nth-child(2) { animation-delay: .2s; }
.aia-loading-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes aia-pulse {
    0%, 80%, 100% { opacity: .3; transform: scale(.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ── Affiliate Tab Styles ────────────────────────────────────── */
.aff-section { background: #fff; border: 1px solid #e0e0e0; border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.aff-section h3 { font-size: 15px; font-weight: 700; margin: 0 0 14px; color: #1a237e; display: flex; align-items: center; gap: 8px; }
.aff-platform-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.aff-badge-shopee { background: #ff5722; color: #fff; }
.aff-badge-tiktokshop { background: #000; color: #fff; }
.aff-badge-lazada { background: #7b1fa2; color: #fff; }
.aff-badge-tiktok { background: #111; color: #fff; }
.aff-badge-facebook { background: #1565c0; color: #fff; }
.aff-badge-instagram { background: linear-gradient(135deg, #f06292, #ce93d8); color: #fff; }
.aff-status-draft { color: #888; }
.aff-status-scheduled { color: #1565c0; }
.aff-status-posted { color: #2e7d32; }
.aff-card { border: 1px solid #e8eaf6; border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; background: #fafafa; }
.aff-card:hover { background: #f3f4fd; border-color: #9fa8da; }
.aff-icon-btn { height: 28px; padding: 0 10px; border: none; border-radius: 7px; cursor: pointer; font-size: 11px; font-weight: 600; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 4px; line-height: 1; white-space: nowrap; flex-shrink: 0; transition: filter .15s, transform .1s; }
.aff-icon-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.aff-icon-btn:hover { filter: brightness(.88); transform: scale(1.04); }
.aff-icon-btn:active { transform: scale(.96); }
.aff-stat-box { text-align: center; background: #f3f4fd; border-radius: 10px; padding: 14px 10px; flex: 1; }
.aff-stat-box .aff-stat-val { font-size: 22px; font-weight: 800; color: #3949ab; }
.aff-stat-box .aff-stat-lbl { font-size: 11px; color: #888; margin-top: 2px; }
.aff-content-box { background: #f8f9ff; border: 1px solid #c5cae9; border-radius: 10px; padding: 14px; margin-bottom: 10px; white-space: pre-wrap; font-size: 13px; line-height: 1.6; }
.aff-platform-tab { cursor: pointer; padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; border: 1.5px solid #c5cae9; background: #fff; color: #555; }
.aff-platform-tab.active { background: #3949ab; color: #fff; border-color: #3949ab; }
/* Config toggle switch */
.cfg-toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.cfg-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.cfg-toggle-track { position: absolute; inset: 0; background: #ccc; border-radius: 24px; transition: background .25s; cursor: pointer; }
.cfg-toggle-track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .25s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.cfg-toggle input:checked + .cfg-toggle-track { background: #43a047; }
.cfg-toggle input:checked + .cfg-toggle-track::before { transform: translateX(20px); }
/* Post edit modal */
#post-edit-modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(520px, 96vw); max-height: 88vh; overflow-y: auto; background: #fff; border-radius: 16px; box-shadow: 0 8px 48px rgba(0,0,0,.25); z-index: 2101; padding: 0; }

/* ── Affiliate: stats bar ────────────────────────────────────── */
.aff-stats-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

/* ── Affiliate: product form 2-col grid ─────────────────────── */
.aff-product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ── Affiliate: character voice 3-col grid ──────────────────── */
.aff-char-voice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 6px;
}

@media (max-width: 980px) {
    .aia-layout { height: calc(100vh - 110px); }
    .aia-tool-card { max-width: calc(100vw - 80px); }

    /* ── Tabs ── */
    .aia-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 2px;
    }
    .aia-tabs::-webkit-scrollbar { display: none; }
    .aia-tab {
        padding: 8px 14px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ── Pipeline input ── */
    .aia-pipeline-input {
        padding: 14px;
    }
    .aia-pipeline-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .aia-btn-primary {
        width: 100%;
        padding: 12px 20px;
        font-size: 15px;
    }
    .aia-pipeline-options {
        flex-direction: column;
        gap: 8px;
    }
    .aia-pipeline-options .aia-select {
        width: 100%;
    }

    /* ── Character form voice grid → 1 column ── */
    .aff-char-voice-grid {
        grid-template-columns: 1fr;
    }

    /* ── Affiliate stats bar → 3×2 grid ── */
    .aff-stats-bar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 14px;
    }
    .aff-stat-box {
        padding: 10px 6px;
    }
    .aff-stat-box .aff-stat-val {
        font-size: 18px;
    }

    /* ── Affiliate section ── */
    .aff-section {
        padding: 14px;
        border-radius: 10px;
        margin-bottom: 14px;
    }
    .aff-section h3 {
        flex-wrap: wrap;
        gap: 6px;
        font-size: 14px;
        margin-bottom: 10px;
    }

    /* ── Product form grid → 1 column ── */
    .aff-product-grid {
        grid-template-columns: 1fr;
    }

    /* ── Affiliate card ── */
    .aff-card {
        padding: 12px;
    }

    /* ── Post planner header buttons ── */
    #aff-posts-list + div,
    #aff-scheduler-bar {
        font-size: 11px;
    }

    /* ── Step body padding ── */
    .aia-step-body {
        padding: 12px;
    }
    .aia-step-header {
        padding: 10px 12px;
        gap: 8px;
    }
    .aia-step-title {
        font-size: 13px;
    }
    .aia-btn-step {
        padding: 5px 10px;
        font-size: 12px;
    }

    /* ── Chat layout on mobile ── */
    .aia-chat-wrap {
        height: calc(100vh - 160px);
    }
    .aia-messages {
        padding: 14px 12px 8px;
    }

    /* ── Config modal tabs scrollable ── */
    #aff-config-modal [style*="display:flex;border-bottom"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Modals → bottom-sheet on mobile ── */
    #aff-config-modal,
    #aff-schedule-modal,
    #post-edit-modal,
    #post-create-modal,
    #aff-script-modal {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(92dvh - env(safe-area-inset-bottom, 0px)) !important;
        border-radius: 20px 20px 0 0 !important;
        overflow-y: auto !important;
    }

    /* ── History drawer full-width ── */
    #historyDrawer {
        width: 100% !important;
    }

    /* ── Chat bubble wider on narrow screens ── */
    .aia-bubble {
        max-width: calc(100vw - 60px);
    }

    /* ── Sub-section action buttons go full-width ── */
    .aia-sub-head {
        gap: 6px;
    }
    .aia-sub-head-right {
        width: 100%;
    }
    .aia-sub-head-right .aia-btn-step,
    .aia-sub-head-right .aia-scene-run-btn {
        flex: 1;
    }

    /* ── Cost total full-width ── */
    .aia-cost-total {
        margin-left: 0;
        width: 100%;
        padding-top: 4px;
        border-top: 1px solid #e1bee7;
    }

    /* ── Scheduler row stacks ── */
    .aia-sched-row {
        flex-direction: column;
        align-items: stretch;
    }
    .aia-sched-row select,
    .aia-sched-row input[type="datetime-local"] {
        width: 100%;
    }
}


/* ── Stats bar 2-col on very small screens ── */
@media (max-width: 400px) {
    .aff-stats-bar {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Step 4: Video path selector tabs ── */
.aia-path-tabs {
    display: flex;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 14px;
}
.aia-path-btn {
    flex: 1;
    padding: 10px 14px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    background: #f5f5f5;
    color: #555;
    transition: background .2s, color .2s;
}

/* ── Sub-section header (voice / video-AI inside step 4) ── */
.aia-sub-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.aia-sub-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}
.aia-sub-head-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Scene selector mini controls */
.aia-scene-mini-btn {
    font-size: 11px;
    padding: 2px 8px;
    border: 1px solid #c5cae9;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
}
.aia-scene-run-btn {
    background: #7b1fa2;
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.aia-scene-run-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Pipeline extra action buttons */
.aia-btn-newidea {
    padding: 8px 16px;
    background: var(--surface);
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.aia-btn-newidea:hover { background: #e6f4f3; }
.aia-btn-history {
    padding: 8px 14px;
    background: var(--surface);
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.aia-btn-history:hover { background: #e6f4f3; }

/* Cost estimate box */
.aia-cost-box {
    background: #fdf6ff;
    border: 1px solid #e1bee7;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 10px;
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    align-items: center;
}
.aia-cost-total {
    font-weight: 700;
    color: #7b1fa2;
    margin-left: auto;
    font-size: 13px;
}

/* Scheduler box inside publish step */
.aia-sched-box {
    margin-top: 16px;
    background: #f8f9ff;
    border: 1px solid #c5cae9;
    border-radius: 10px;
    padding: 14px;
}
.aia-sched-box-title {
    font-size: 13px;
    font-weight: 700;
    color: #3949ab;
    margin: 0 0 10px;
}
.aia-sched-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.aia-btn-sched {
    padding: 6px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
}
.aia-btn-sched:hover { opacity: .88; }

/* Caption fields (Step 5) */
.aia-caption-fields { display: flex; flex-direction: column; gap: 8px; }
.aia-caption-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.aia-caption-input {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; background: var(--bg); color: var(--text); outline: none; box-sizing: border-box;
}
.aia-caption-input:focus { border-color: var(--primary); }
.aia-caption-textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; background: var(--bg); color: var(--text); outline: none; resize: vertical; box-sizing: border-box;
    font-family: inherit; line-height: 1.5;
}
.aia-caption-textarea:focus { border-color: var(--primary); }

/* ── Lập biên bản – document-style form ─────────────────────── */
.bb-doc-wrap {
    max-width: 820px;
}

.bb-type-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
}
.bb-type-bar label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
    margin: 0;
    display: inline-flex;
}
.bb-type-bar input[type="radio"] {
    width: 16px;
    height: 16px;
    min-height: unset;
    padding: 0;
    border: 1px solid var(--border);
    accent-color: var(--primary);
    cursor: pointer;
}

.bb-doc {
    background: #ffffff;
    border: 1px solid #c8d3e0;
    border-radius: 10px;
    padding: 40px 52px;
    box-shadow: 0 6px 28px rgba(15, 23, 42, 0.07);
    line-height: 2.1;
    font-size: 14px;
    margin-bottom: 16px;
}

.bb-doc-header {
    text-align: center;
    margin-bottom: 24px;
}
.bb-doc-header p {
    margin: 1px 0;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .04em;
}
.bb-doc-rule {
    color: var(--muted);
    font-weight: 400 !important;
    letter-spacing: .1em;
    margin: 6px 0 !important;
}
.bb-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 10px 0 4px !important;
}

.bb-doc > p { margin: 0 0 2px; }

/* ── Inline field (underline style) ─────────────────────────── */
.bb-field {
    display: inline-block;
    border: none;
    border-bottom: 2px solid #94a3b8;
    border-radius: 3px 3px 0 0;
    background: rgba(148, 163, 184, 0.07);
    padding: 0 5px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.7;
    vertical-align: baseline;
    min-height: unset;
    transition: border-color .18s, background .18s;
}

/* Empty = orange */
.bb-field:placeholder-shown {
    border-bottom-color: #f97316;
    background: rgba(249, 115, 22, 0.06);
}
/* Filled = teal */
.bb-field:not(:placeholder-shown) {
    border-bottom-color: var(--primary);
    background: rgba(15, 118, 110, 0.06);
}
/* Focus = blue */
.bb-field:focus {
    outline: none;
    border-bottom-color: #2563eb;
    background: rgba(37, 99, 235, 0.07);
    box-shadow: none;
}

.bb-field-xs   { width: 54px;  text-align: center; }
.bb-field-sm   { width: 90px;  }
.bb-field-md   { width: 160px; }
.bb-field-lg   { width: 240px; }
.bb-field-xl   { width: 360px; }
.bb-field-year { width: 72px;  text-align: center; }
.bb-field-date { width: 110px; }

/* Block textarea */
.bb-field-block {
    display: block;
    width: 100%;
    border: 2px solid #94a3b8;
    border-radius: 6px;
    background: #fafbfc;
    padding: 8px 12px;
    resize: vertical;
    box-sizing: border-box;
    margin: 4px 0 10px;
    line-height: 1.7;
    font-family: inherit;
    font-size: inherit;
    min-height: unset;
    transition: border-color .18s, background .18s;
}
.bb-field-block:placeholder-shown {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.04);
}
.bb-field-block:not(:placeholder-shown) {
    border-color: var(--primary);
    background: rgba(15, 118, 110, 0.04);
}
.bb-field-block:focus {
    outline: none;
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.05);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Static (auto-filled from record) */
.bb-static {
    display: inline-block;
    color: var(--text);
    border-bottom: 1px dashed #94a3b8;
    padding: 0 5px;
    min-width: 40px;
}

.bb-divider {
    border: none;
    border-top: 1px dashed #cbd5e1;
    margin: 14px 0;
}

/* Legend */
.bb-legend {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.bb-legend-dot {
    display: inline-block;
    width: 28px;
    height: 3px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 3px;
}
.bb-legend-empty  { background: #f97316; }
.bb-legend-filled { background: var(--primary); }
.bb-legend-static { background: #94a3b8; border-bottom: 1px dashed #94a3b8; height: 1px; margin-top: 1px; }

/* Signature rows */
.bb-sig-row {
    display: flex;
    gap: 0;
    margin-top: 28px;
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
}
.bb-sig-cell {
    flex: 1;
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    padding: 0 8px;
    min-height: 72px;
}
.bb-sig-cell em {
    display: block;
    font-style: italic;
    font-weight: 400;
    font-size: 11.5px;
    margin-top: 3px;
}

/* Annotation / fixed-value labels */
.bb-static-note {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
}
.bb-static-fixed {
    display: inline-block;
    border-bottom: 1px solid #94a3b8;
    padding: 0 4px;
    color: var(--text);
    min-width: 80px;
}

@media (max-width: 980px) {
    .bb-doc {
        padding: 24px 16px;
        line-height: 2;
    }
    .bb-field-lg  { width: 160px; }
    .bb-field-xl  { width: 100%;  display: block; margin: 2px 0; }
    .bb-field-md  { width: 120px; }
}

/* ── Biên bản kiểm tra đột xuất ── */
.bbktdx-header-tbl { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.bbktdx-header-tbl td { width: 50%; padding: 0 8px; vertical-align: bottom; font-size: 13px; }
.bbktdx-header-tbl td:first-child { border-right: 1px solid #e2e8f0; }

.bbktdx-scanner-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 12px 0; }
.bbktdx-scanner-bar  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bbktdx-scan-status  { font-size: 13px; color: var(--muted); }
.bbktdx-scan-status.ok   { color: var(--primary); }
.bbktdx-scan-status.warn { color: #f97316; }


.bbktdx-manual-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-top: 12px; }
.bbktdx-manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
@media (max-width: 640px) { .bbktdx-manual-grid { grid-template-columns: 1fr; } }

.bbktdx-people-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.bbktdx-people-tbl th { background: var(--bg); color: var(--muted); font-weight: 600; text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.bbktdx-people-tbl td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.bbktdx-del-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 4px; }
.bbktdx-del-btn:hover { color: var(--danger, #ef4444); background: rgba(239,68,68,.08); }

/* Publish grid (Step 6) */
.aia-publish-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .aia-publish-grid { grid-template-columns: 1fr; } }
.aia-publish-card {
    border: 1px solid var(--border); border-radius: 10px; padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.aia-publish-logo { font-size: 15px; font-weight: 700; }
.aia-publish-yt { color: #ff0000; }
.aia-publish-fb { color: #1877f2; }
.aia-publish-connect { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aia-btn-connect {
    font-size: 12px; padding: 4px 10px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); text-decoration: none; cursor: pointer;
}
.aia-btn-connect:hover { border-color: var(--primary); color: var(--primary); }
.aia-btn-publish {
    padding: 8px 14px; border-radius: 8px; border: none; cursor: pointer;
    background: var(--primary); color: #fff; font-size: 13px; font-weight: 600;
}
.aia-btn-publish:hover { opacity: .88; }
.aia-btn-publish:disabled { opacity: .45; cursor: not-allowed; }
.aia-publish-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.aia-publish-note code { background: var(--border); padding: 1px 4px; border-radius: 3px; font-size: 11px; }
