﻿/* =====================================================================
   TinySystem – giao diện tối giản
   Ưu tiên điện thoại (iPhone 12 Pro: 390 × 844); màn hình lớn hơn thì giãn theo.
     < 992px  : menu trái ẩn, bấm ☰ để mở (trượt ra, có nền mờ, nút ✕ để đóng)
     >= 992px : menu trái luôn hiện, bấm ☰ để thu gọn / mở lại (nhớ lựa chọn)
   ===================================================================== */
:root {
    --accent: #4f46e5;
    --accent-600: #4338ca;
    --accent-soft: #eef2ff;
    --ink: #111827;
    --ink-2: #374151;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(17,24,39,.04), 0 1px 3px rgba(17,24,39,.06);
    --sidebar-w: 248px;
    --topbar-h: 56px;
    --app-max: 100%;
    --app-narrow: 640px;
    --gutter: 16px;

    --bs-body-font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--line);
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: var(--accent-600);
    --bs-link-hover-color-rgb: 67, 56, 202;
    --bs-primary: var(--accent);
    --bs-primary-rgb: 79, 70, 229;
}
.area-ag { --accent: #0f766e; --accent-600: #115e59; --accent-soft: #ecfdf5;
           --bs-link-color-rgb: 15, 118, 110; --bs-link-hover-color-rgb: 17, 94, 89; --bs-primary-rgb: 15, 118, 110; }
@media (min-width: 768px)  { :root { --app-max: 760px; --gutter: 24px; } }
@media (min-width: 1200px) { :root { --app-max: 1080px; --gutter: 32px; } }

html, body { background: var(--bg); }
body {
    font-size: 16px; /* >= 16px để iOS không tự phóng to ô nhập */
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -.005em;
}
h1, .h1, h2, .h2, h3, .h3, h4, .h4 { font-weight: 650; letter-spacing: -.015em; }

.ico { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8;
       stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Menu trái ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    width: var(--sidebar-w); max-width: 86vw;
    display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform .25s ease;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; }
.brand:hover { color: var(--ink); }
.brand-mark {
    width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
    background: var(--accent); color: #fff; font-size: .95rem; font-weight: 700;
}
.brand-text { font-size: 1.05rem; letter-spacing: -.02em; }
.sidebar-label {
    margin: 4px 10px 6px; font-size: .72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1 1 auto; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm);
    color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem;
    background: transparent; border: 0; text-align: left;
    transition: background-color .15s ease, color .15s ease;
}
.nav-item .ico { color: var(--muted); transition: color .15s ease; }
.nav-item:hover { background: #f3f4f6; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-600); font-weight: 600; }
.nav-item.active .ico { color: var(--accent); }
.nav-logout:hover { background: #fef2f2; color: #b91c1c; }
.nav-logout:hover .ico { color: #b91c1c; }

.me { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.me-name { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: .78rem; color: var(--muted); }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center; font-weight: 650; font-size: .9rem;
    background: var(--accent-soft); color: var(--accent-600); text-decoration: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: .85rem; }
a.avatar:hover { color: var(--accent-600); filter: brightness(.97); }

.icon-btn {
    width: 40px; height: 40px; border-radius: var(--radius-sm); border: 0;
    display: inline-grid; place-items: center; background: transparent; color: var(--ink-2);
    transition: background-color .15s ease;
}
.icon-btn:hover { background: #f3f4f6; }
.icon-btn .ico { width: 22px; height: 22px; }

.sidebar-backdrop {
    position: fixed; inset: 0; z-index: 1030; background: rgba(17,24,39,.35);
    opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease;
}

/* Điện thoại / tablet: mở menu dạng trượt */
body.sidebar-open { overflow: hidden; }
body.sidebar-open .sidebar { transform: none; box-shadow: 0 10px 40px rgba(17,24,39,.18); }
body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

/* Máy tính: menu luôn hiện, thu gọn được */
@media (min-width: 992px) {
    .sidebar { transform: none; }
    .sidebar-close, .sidebar-backdrop { display: none; }
    body.has-sidebar .app-content { margin-left: var(--sidebar-w); transition: margin-left .25s ease; }
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    body.sidebar-collapsed .app-content { margin-left: 0; }
    body.sidebar-open { overflow: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar, .sidebar-backdrop, body.has-sidebar .app-content { transition: none; }
}

/* ---------- Thanh trên ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 8px;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
    background: rgba(255,255,255,.85);
    -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Nội dung ---------- */
.app-shell {
    max-width: var(--app-max); margin: 0 auto;
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.app-main { padding-top: 18px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); animation: app-fade .2s ease-out; }
.app-main.app-narrow { max-width: var(--app-narrow); }
@media (min-width: 768px) { .app-main { padding-top: 28px; } }
@keyframes app-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .app-main { animation: none; } }

.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.alert { border-radius: var(--radius-sm); border: 0; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-info    { background: var(--accent-soft); color: var(--accent-600); }
.alert-warning { background: #fffbeb; color: #92400e; }
.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }

/* Nút & ô nhập: đủ to để bấm 1 tay */
.btn, .form-control, .form-select { min-height: 48px; border-radius: 12px; }
.btn-sm { min-height: 36px; border-radius: 10px; }
/* Căn giữa chữ / icon trong nút theo cả 2 chiều (min-height lớn hơn chiều cao chữ) */
.btn { font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.2; }
.btn .ico { width: 18px; height: 18px; }
.btn-sm .ico { width: 16px; height: 16px; stroke-width: 2.2; }
.btn-primary {
    --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-600); --bs-btn-hover-border-color: var(--accent-600);
    --bs-btn-active-bg: var(--accent-600); --bs-btn-active-border-color: var(--accent-600);
    --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent);
}
.btn-dark { --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); }
.form-control, .form-select { border-color: var(--line); background-color: #fff; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), .15);
}
.form-label { font-weight: 500; color: var(--ink-2); }
@media (min-width: 768px) { .btn, .form-control, .form-select { min-height: 44px; } }

/* ---------- Trang đăng nhập ---------- */
.no-chrome .app-main { padding-top: env(safe-area-inset-top); }
.auth-wrap {
    min-height: calc(100vh - 40px);
    display: flex; flex-direction: column; justify-content: center;
    max-width: 400px; margin: 0 auto;
}
.auth-title { font-weight: 700; font-size: 1.6rem; margin-bottom: .25rem; letter-spacing: -.02em; }
.auth-title::before {
    content: "T"; display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 18px;
    border-radius: 13px; background: var(--accent); color: #fff; font-size: 1.2rem;
}
.auth-sub { color: var(--muted); margin-bottom: 1.25rem; }

/* Ô nhập 1 chữ số Security Code */
.digit-input { width: 64px; height: 64px; font-size: 1.75rem; text-align: center; font-weight: 600; }
.digit-label { font-size: .85rem; color: var(--muted); }

/* Spinner khi nút đang xử lý */
.btn.is-busy, .nav-item.is-busy { pointer-events: none; opacity: .85; }
.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; margin: 0; }
.nav-item .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }

/* ---------- Danh sách thẻ ---------- */
.list-cards { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface); }
.list-cards .list-group-item { border-left: 0; border-right: 0; padding: 14px 16px; }
.list-cards .list-group-item:first-child { border-top: 0; }
.list-cards .list-group-item:last-child { border-bottom: 0; }
.list-cards a.list-group-item { min-height: 56px; }
@media (min-width: 768px) {
    .list-cards.grid-md {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
        overflow: visible; box-shadow: none; border: 0; border-radius: 0; background: transparent;
    }
    .list-cards.grid-md .list-group-item {
        border: 1px solid var(--line); border-radius: var(--radius) !important; box-shadow: var(--shadow); margin: 0;
    }
}
@media (min-width: 1200px) { .list-cards.grid-md { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Bảng dữ liệu (grid) ---------- */
.data-grid-card { overflow: hidden; }
.data-grid { font-size: .95rem; --bs-table-hover-bg: #f9fafb; }
.data-grid thead th {
    position: sticky; top: 0; z-index: 1;
    background: #f9fafb; color: var(--muted); font-weight: 600; font-size: .74rem;
    text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
.data-grid th, .data-grid td { padding: .75rem .8rem; border-color: #f0f1f3; }
.data-grid tbody tr:last-child td { border-bottom: 0; }
.data-grid tbody tr[data-href] { cursor: pointer; }
.data-grid .grid-name { max-width: 140px; }
@media (min-width: 768px) { .data-grid .grid-name { max-width: 260px; } }

/* Mã trong lưới: link nổi bật nhẹ */
.data-grid .grid-code { color: var(--accent-600); font-weight: 600; text-decoration: none; }
.data-grid .grid-code:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Nút Thêm: cân đối 2 bên icon */
.btn-add { padding: 0 14px 0 11px; }

/* Nút Sửa trong lưới */
.data-grid .grid-actions { width: 1%; white-space: nowrap; padding-top: .45rem; padding-bottom: .45rem; }
.btn-edit {
    display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px;
    border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-weight: 600;
}
.btn-edit .ico { width: 16px; height: 16px; }
.btn-edit:hover { border-color: var(--accent); color: var(--accent-600); background: var(--accent-soft); }

.data-grid .grid-note { max-width: 220px; }

/* Nút chọn dạng phân đoạn (Mở / Đóng) */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: #f3f4f6; border-radius: 12px; }
.seg-item {
    min-width: 88px; min-height: 40px; padding: 0 16px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; color: var(--muted); cursor: pointer; user-select: none;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg .btn-check:checked + .seg-item { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg .btn-check:focus-visible + .seg-item { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Thanh điều hướng: Đại lý / mã đại lý / Thành viên */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; }
.crumbs a:hover { color: var(--accent-600); background: var(--accent-soft); }
.crumbs .sep { color: #d1d5db; }
.crumbs .current { color: var(--ink); font-weight: 600; }
.min-w-0 { min-width: 0; }

.info-list dt { font-weight: 500; color: var(--muted); }
.info-list dd { margin-bottom: .45rem; }
.renew-calc { font-size: .95rem; }

/* ---------- Tab cấu hình (Thông tin / Giá / Giới hạn / Chặn) ---------- */
.tabs {
    display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
    border-bottom: 1px solid var(--line); margin-left: -2px; margin-right: -2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 0 0 auto; padding: 10px 14px; margin-bottom: -1px;
    color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap;
    border-bottom: 2px solid transparent; transition: color .15s ease, border-color .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-600); border-bottom-color: var(--accent); }

/* Chọn miền dạng link + dạng radio full chiều ngang */
.seg-links .seg-item { text-decoration: none; }
.seg-links .seg-item.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg-full { display: flex; width: 100%; }
.seg-full .seg-item { flex: 1 1 0; min-width: 0; padding: 0 8px; }

/* Bảng nhập liệu (giá, giới hạn) */
.form-grid td { padding-top: .45rem; padding-bottom: .45rem; }
.form-control-num { text-align: right; max-width: 150px; margin-left: auto; min-height: 42px; font-variant-numeric: tabular-nums; }
.form-grid tr.grid-section td {
    background: #f9fafb; color: var(--muted); font-size: .78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em; padding-top: .55rem; padding-bottom: .55rem;
}

/* Nút xóa trong lưới */
.btn-del:hover { border-color: #fca5a5; color: #b91c1c; background: #fef2f2; }

/* Ô số liệu */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .stat-grid .stat-wide { grid-column: span 2; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat-wide { grid-column: 1 / -1; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pos { color: #047857; }
.neg { color: #b91c1c; }
.data-grid td.text-end { font-variant-numeric: tabular-nums; }
.data-grid tr.group-first td { border-top: 1px solid var(--line); }

/* Tin nhắn */
.msg-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; line-height: 1.5; min-height: 150px; }
.msg-text { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; }
.data-grid .msg-cell { min-width: 160px; max-width: 420px; }

/* Danh sách chọn khách cho nhóm */
.check-row { cursor: pointer; }
.check-row .form-check-input { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; }
.check-row .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.font-sans { font-family: var(--bs-body-font-family); }

/* Trang chính thành viên */
.home-link { display: flex; flex-direction: column; gap: 2px; }
.home-link b { font-weight: 600; color: var(--ink); }
.home-link span { font-size: .85rem; color: var(--muted); }

/* Ô tùy chọn không dùng theo cách tính hiện tại */
.is-muted { opacity: .45; transition: opacity .15s ease; }

/* Bảng giới hạn: dòng = kiểu, cột = MN / MT / MB */
.limit-grid th, .limit-grid td { padding-left: .4rem; padding-right: .4rem; }
.limit-grid th:first-child, .limit-grid td:first-child { padding-left: .8rem; width: 34%; }
.limit-grid .form-control-num { max-width: none; width: 100%; min-width: 56px; padding: .35rem .5rem; min-height: 40px; }
@media (min-width: 768px) { .limit-grid th:first-child, .limit-grid td:first-child { width: 40%; } }

/* Trang chặn: 4 cụm riêng */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
    color: var(--ink-2); font-size: .88rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent-600); }
.chip-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: #f3f4f6; color: var(--muted); font-size: .75rem; text-align: center; }
.block-section { scroll-margin-top: calc(var(--topbar-h) + 12px); }
.block-head { margin-bottom: 12px; }
.block-list { border-top: 1px solid var(--line); margin-left: -1rem; margin-right: -1rem; }
.block-list .data-grid th:first-child, .block-list .data-grid td:first-child { padding-left: 1rem; }
.block-list .data-grid thead th { position: static; }
.block-section:target { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

/* Ô tích "MN → MT, MB" trên đầu cột MN */
.copy-toggle {
    display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 4px;
    font-size: .68rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--accent-600);
    cursor: pointer; white-space: nowrap; user-select: none;
}
.copy-toggle .form-check-input { width: 1rem; height: 1rem; margin: 0; }
.copy-toggle .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* Chọn thứ áp dụng cho chặn: Tất cả | T2 … CN */
.day-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chip {
    min-width: 42px; min-height: 36px; padding: 0 10px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); background: #fff; color: var(--ink-2);
    font-weight: 600; font-size: .88rem; cursor: pointer; user-select: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.day-chip.day-all { padding: 0 12px; }
.day-picker .btn-check:checked + .day-chip { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-picker .btn-check:focus-visible + .day-chip { outline: 2px solid var(--accent); outline-offset: 1px; }
.block-list tr.grid-section td {
    background: #f9fafb; color: var(--ink-2); font-size: .8rem; font-weight: 700;
    padding-top: .5rem; padding-bottom: .5rem;
}

/* Chặn đài: mỗi thứ 1 dòng, các đài là ô tích */
.dai-days { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.dai-day { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.dai-day + .dai-day { border-top: 1px solid var(--line); }
.dai-day-label { flex: 0 0 72px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.dai-chip { min-width: 52px; text-transform: lowercase; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.block-list tr.is-current td { background: var(--accent-soft); }
.block-list tr.is-editing td { background: #fffbeb; }
.is-editing-section { box-shadow: 0 0 0 2px #f59e0b, var(--shadow); }
.block-msg { min-height: 90px; }
.sample-text { display: block; margin-top: 2px; font-size: .82rem; color: var(--ink-2); background: #f9fafb; border-radius: 8px; padding: 6px 8px; }

/* ----- Kết quả xử lý tin ----- */
.result-card { position: relative; border: 1px solid var(--line, #e5e7eb); border-left-width: 4px; border-radius: 12px; background: #fff; padding: 10px 12px; }
.result-ok { border-left-color: #16a34a; }
.result-excess { border-left-color: #d97706; background: #fffbeb; }
.result-err { border-left-color: #dc2626; background: #fef2f2; }
.result-head { font-weight: 600; color: #b91c1c; margin-bottom: 6px; }
.result-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.5; padding-right: 56px; }
.result-copy { position: absolute; top: 8px; right: 8px; }
.result-errors { margin: 8px 0 0; padding-left: 18px; font-size: .85rem; color: #991b1b; }
.msg-marked { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; background: #fff; border-radius: 8px; padding: 8px 10px; }
mark.msg-err { background: #fecaca; color: #991b1b; padding: 0 2px; border-radius: 3px; text-decoration: underline wavy #dc2626; text-underline-offset: 3px; }
.result-inline { padding: 8px 10px; border-radius: 10px; }
.result-inline .result-text { font-size: .85rem; }
/* Tin mới nhập: tin nhắn là chính, kết quả nhỏ bên dưới */
.msg-card { padding: 10px 12px; }
.msg-card-head { display: flex; align-items: center; gap: 8px; font-size: .82rem; margin: 0 2px 4px; }
.msg-card-text { font-size: .95rem; color: var(--ink, #111827); }
.msg-card-sum { margin: 6px 2px 0; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; color: #6b7280; line-height: 1.45; }
/* Mỗi tin 1 khối riêng */
.msg-item { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 10px 12px 12px; box-shadow: 0 1px 2px rgba(17,24,39,.04); }
.msg-item .msg-card { background: #f9fafb; border-color: #e5e7eb; }
.msg-item .msg-card-head { margin: 0 0 6px; }
.msg-item .msg-card-sum { margin: 8px 2px 0; }
/* Danh sách khách */
.grid-stt { width: 44px; }
.badge-toggle { cursor: pointer; font-size: .78rem; padding: .4em .7em; }
.badge-toggle:hover { filter: brightness(.92); }
/* Spinner trong nút trạng thái (badge) và mọi phần tử đang chờ: nhỏ theo cỡ chữ */
.is-busy .spinner-border { width: 1em; height: 1em; border-width: .14em; vertical-align: -.125em; }
.badge.is-busy { pointer-events: none; opacity: .85; }
.badge .spinner-border { width: .75em; height: .75em; border-width: .12em; margin-right: .3em; vertical-align: -.05em; }
/* Tin đã nhập */
.pre-line { white-space: pre-line; }
.msg-grid .msg-cell { min-width: 220px; max-width: 420px; }
.msg-grid .msg-sum-cell { min-width: 130px; }
.msg-grid .msg-card-sum { margin: 0; }
.btn-copy-sm { flex: none; padding: 1px 8px; font-size: .75rem; line-height: 1.5; }
/* Tin dư dưới kết quả */
.msg-excess { margin-top: 8px; border-left: 3px solid #d97706; background: #fffbeb; border-radius: 8px; padding: 6px 8px; }
.msg-excess-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .75rem; font-weight: 600; color: #b45309; margin-bottom: 2px; }
.msg-excess-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; color: #78350f; line-height: 1.45; }
/* Ngày làm việc (thanh trên) */
.workdate { display: flex; align-items: center; gap: 6px; margin: 0; flex: none; }
.workdate-label { font-size: .75rem; color: var(--ink-2, #6b7280); }
.workdate input { width: 138px; padding: 3px 8px; font-size: .85rem; }
.workdate.not-today input { border-color: #f59e0b; background: #fffbeb; color: #92400e; font-weight: 600; }
@media (max-width: 380px) { .workdate-label { display: none; } .workdate input { width: 124px; } }
/* Số tiền của tin: Xác · Sau cò · Trúng · Còn lại */
.msg-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.msg-stats .ms { display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .78rem; line-height: 1.4; border: 1px solid transparent; }
.msg-stats .ms-l { font-size: .7rem; opacity: .8; }
.msg-stats .ms b { font-variant-numeric: tabular-nums; font-weight: 700; }
.msg-stats .ms-xac { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.msg-stats .ms-thu { background: #eef2ff; color: #3730a3; border-color: #e0e7ff; }
.msg-stats .ms-trung { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.msg-stats .ms-con { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.msg-stats .ms-bu { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
/* Còn lại: bù khách (≥ 0) xanh dương, thu khách (< 0) đỏ */
.msg-stats .ms-bu-khach { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.msg-stats .ms-thu-khach { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
/* "Còn lại" ở mép phải dòng tiêu đề tin */
.msg-card-head .ms-conlai { margin-left: auto; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .82rem; font-variant-numeric: tabular-nums; border: 1px solid transparent; white-space: nowrap; }
.msg-card-head .ms-auto ~ .ms-conlai { margin-left: 8px; }
.ms-conlai.ms-bu-khach { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ms-conlai.ms-thu-khach { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
/* Khung tin: nút Chép nằm cùng hàng, canh giữa theo chiều dọc (không lệch xuống dưới) */
.result-card.msg-card { display: flex; align-items: flex-start; gap: 10px; padding-top: 8px; padding-bottom: 8px; }
.result-card.msg-card .result-text { flex: 1 1 auto; min-width: 0; padding-right: 0; order: 1; }
.result-card.msg-card .result-copy { position: static; flex: none; order: 2; align-self: flex-start; }
/* Canh dòng đầu của tin ngang giữa nút Chép */
.result-card.msg-card .result-text { padding-top: 4px; }
/* Tin đã nhập: lưới khối – 1 cột trên điện thoại, 2 cột trên máy tính */
.msg-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
@media (min-width: 992px) { .msg-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .msg-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.msg-cards .msg-item { margin: 0; height: 100%; display: flex; flex-direction: column; }
.msg-cards .msg-item > .d-flex:last-child { margin-top: auto !important; padding-top: 8px; }
/* Nút nhanh Hôm qua / Hôm nay cạnh ô ngày làm việc */
.workdate .wd-quick { flex: none; border: 1px solid var(--line, #e5e7eb); background: #fff; color: var(--ink-2, #4b5563); border-radius: 8px; padding: 3px 8px; font-size: .75rem; line-height: 1.4; white-space: nowrap; }
.workdate .wd-quick:hover { background: #f3f4f6; }
.workdate .wd-quick.active { background: var(--accent, #4f46e5); border-color: var(--accent, #4f46e5); color: #fff; }
.workdate .wd-quick .spinner-border { display: none; }
@media (max-width: 430px) { .workdate input { width: 118px; padding: 3px 6px; font-size: .8rem; } .workdate .wd-quick { padding: 3px 6px; font-size: .7rem; } .workdate-label { display: none; } }
/* Tin thu gọn: chỉ còn dòng tiêu đề (MN T1 ... Còn lại); bấm tiêu đề để mở / thu */
.msg-collapsible > .msg-card-head { cursor: pointer; user-select: none; }
.msg-item.collapsed .msg-body { display: none; }
.msg-item.collapsed > .msg-card-head { margin-bottom: 0; }

/* Danh sách tin 1 cột (Tin mới nhập, báo cáo khách) */
.msg-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.msg-list .msg-item, .msg-cards .msg-item { margin: 0; }
.msg-cards .msg-item .msg-body { flex: 1 1 auto; display: flex; flex-direction: column; }
.msg-cards .msg-item .msg-actions { margin-top: auto !important; padding-top: 8px; }
.msg-cards .msg-item.collapsed { height: auto; }
.msg-collapsible > .msg-card-head { cursor: pointer; user-select: none; }
.msg-body > .msg-excess:first-child { margin-top: 0; }
/* Báo cáo: Còn lại / Thầu – > 0 xanh dương, <= 0 đỏ */
.v-blue { color: #1d4ed8 !important; }
.v-red { color: #b91c1c !important; }

/* Tên đài của miền theo ngày (trang Nhập tin) */
.station-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; min-height: 1.6rem; align-items: center; }
.station-chip { font-size: .8rem; padding: .15rem .55rem; border-radius: 999px; background: #eef4ff; color: #1d4ed8; border: 1px solid #cfe0ff; white-space: nowrap; }
.station-chip:first-child { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

/* Chọn nhiều tin dư (trang Tin dư) */
.msg-pick { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; cursor: pointer; }
.pick-bar { padding: .4rem .6rem; border: 1px solid #e5e7eb; border-radius: .5rem; background: #f9fafb; }

/* Kết quả bên trái, Số trúng bên phải */
.msg-sum-row { display: flex; align-items: flex-start; gap: 12px 28px; flex-wrap: wrap; margin-top: 8px; }
.msg-sum-row .msg-card-sum { margin: 0 2px; }
.msg-sum-row .msg-sotrung { color: #15803d; }
.msg-sum-row .msg-sotrung b { color: #166534; font-weight: 600; }

/* Dòng Sum cuối bảng báo cáo */
.data-grid tfoot .grid-sum td { font-weight: 700; background: #f3f4f6; border-top: 2px solid #9ca3af; border-bottom: 0; }

/* Security Code: 6 ô, chỉ 2 ô được hỏi nhập được */
.digit-row .digit-input { width: 46px; height: 54px; font-size: 1.5rem; padding: 0; }
.digit-row .digit-ask { border: 2px solid #2563eb; background: #fff; }
.digit-row .digit-off { background: #e5e7eb; border-color: #e5e7eb; cursor: not-allowed; }
@media (max-width: 380px) { .digit-row .digit-input { width: 40px; height: 48px; } .digit-row { gap: .35rem !important; } }

/* Báo cáo: mũi tên sổ các miền của khách */
.btn-expand { border: 0; background: transparent; padding: 2px; width: 24px; height: 24px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: #6b7280; flex: none; }
.btn-expand:hover { background: #eef2ff; color: #1d4ed8; }
.btn-expand svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.btn-expand[aria-expanded="true"] svg { transform: rotate(90deg); }
.data-grid tr.mien-row td { background: #f8fafc; font-size: .85rem; }

.btn-sotrung { color: #15803d; }

/* Nút icon gọn (báo cáo: Chi tiết / Sao chép / Số trúng) */
.btn-icon { width: 30px; height: 30px; padding: 0; border: 1px solid #e5e7eb; background: #fff; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #4b5563; flex: none; }
.btn-icon:hover { background: #eef2ff; border-color: #c7d2fe; color: #1d4ed8; }
.btn-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon.btn-sotrung { color: #15803d; }
.btn-icon.btn-sotrung:hover { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.btn-icon.copied { background: #dcfce7; border-color: #86efac; color: #15803d; }

/* Thẻ nhỏ dưới Đăng xuất (thành viên): hạn dùng + số khách đang dùng / tối đa */
.acc-card { margin: 10px 2px 2px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(180deg, #f8fafc, #f1f5f9);
            border: 1px solid #e2e8f0; font-size: .78rem; color: #334155; }
.acc-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acc-k { color: #64748b; }
.acc-days { font-size: .7rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: #dcfce7; color: #166534; white-space: nowrap; }
.acc-date { font-size: 1rem; font-weight: 700; color: #0f172a; margin: 1px 0 8px; letter-spacing: .2px; }
.acc-card.acc-exp-warn .acc-days { background: #ffedd5; color: #9a3412; }
.acc-card.acc-exp-red .acc-days { background: #fee2e2; color: #b91c1c; }
.acc-card.acc-exp-red .acc-date { color: #b91c1c; }
.acc-cust { display: block; padding-top: 8px; border-top: 1px dashed #cbd5e1; color: inherit; text-decoration: none; }
.acc-cust:hover { color: inherit; }
.acc-cust:hover .acc-k { color: #1d4ed8; }
.acc-num { font-size: .95rem; font-weight: 700; color: #0f172a; }
.acc-num small { font-size: .75rem; font-weight: 600; color: #64748b; }
.acc-bar { display: block; height: 5px; margin-top: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.acc-bar > span { display: block; height: 100%; border-radius: 999px; background: #3b82f6; }
.acc-bar.acc-bar-warn > span { background: #f59e0b; }
.acc-bar.acc-bar-red > span { background: #ef4444; }
/* Menu thu gọn (máy tính): ẩn thẻ */
body.sidebar-collapsed .acc-card { display: none; }

/* ===== Trang Kết quả xổ số (/kqxs) ===== */
.kq-wrap { overflow-x: auto; }
.kq { width: 100%; border-collapse: collapse; background: #fff; min-width: 320px; }
.kq th, .kq td { border: 1px solid #dee2e6; padding: 4px 10px; }
.kq thead th { background: #f1f3f5; text-align: center; font-weight: 700; padding: 6px 10px; }
.kq thead th.kq-g { width: 64px; color: #212529; }
.kq tbody tr:nth-child(even) { background: #f8f9fa; }
.kq td.kq-g { width: 64px; text-align: center; font-size: .85rem; color: #333; background: #f8f9fa; }
.kq-dai { color: #1d4ed8; text-decoration: underline; font-weight: 600; }
.kq-mn td.kq-n { text-align: right; vertical-align: middle; }
.kq-mn .kq-num { display: block; }
.kq-num { font-family: Arial, Helvetica, sans-serif; font-size: 1.6rem; font-weight: 700; color: #111; line-height: 1.25; letter-spacing: .5px; }
.kq-red .kq-num { color: #ef1f1f; }
.kq-db .kq-num { font-size: 1.85rem; }
.kq-mb td.kq-n { text-align: center; }
.kq-grid { display: grid; gap: 2px 8px; justify-items: center; }
.kq-cnt { font-size: .75rem; font-weight: 400; }
.kq-datebar { width: 290px; }
@media (max-width: 575.98px) {
    .kq-datebar { width: 100%; margin-left: 0 !important; }
    .kq-quick { flex: 1 1 0; }
    #kqBody { --bs-gutter-y: .6rem; }
    #kqBody .card { padding: .5rem !important; }
    #kqBody h2 { font-size: .9rem; }
    .kq { min-width: 0; }
    .kq th, .kq td { padding: 2px 4px; }
    .kq thead th { padding: 4px; font-size: .82rem; }
    .kq thead th.kq-g, .kq td.kq-g { width: 34px; font-size: .7rem; }
    .kq-num { font-size: 1.05rem; letter-spacing: 0; }
    .kq-db .kq-num { font-size: 1.2rem; }
    .kq-grid { gap: 1px 4px; }
}
/* Admin sửa kết quả: ô nhập số */
.kq-input { display: block; width: 100%; max-width: 7.5em; margin: 2px 0 2px auto; padding: 1px 6px; text-align: right;
            font-family: Arial, Helvetica, sans-serif; font-size: 1.2rem; font-weight: 700; letter-spacing: .5px;
            border: 1px solid #fcd34d; border-radius: 6px; background: #fffbeb; color: #111; }
.kq-mb .kq-input { margin: 2px auto; text-align: center; }
.kq-red .kq-input { color: #ef1f1f; }
.kq-input:focus { outline: 2px solid #f59e0b; outline-offset: 0; }
.kq-input.changed { background: #dbeafe; border-color: #3b82f6; }
.kq-input.invalid { border-color: #ef4444; background: #fef2f2; }
@media (max-width: 575.98px) { .kq-input { font-size: .95rem; padding: 1px 3px; } }
/* Trang hết hạn: nội dung do Admin / Đại lý cài */
.expired-msg { white-space: pre-line; word-break: break-word; }
.kq-input.kq-new { background: #fff; border-style: dashed; }
.kq-input::placeholder { color: #cbd5e1; letter-spacing: 2px; }
/* Báo cáo: hệ số (1) / (-1) cạnh tên khách */
.heso-tag { font-size: .75rem; font-weight: 600; color: #64748b; white-space: nowrap; }
.heso-tag.heso-neg { color: #b91c1c; }

/* ===== Liên kết Telegram ===== */
.tg-code { padding: 4px 0; }
.tg-code-label { font-weight: 600; color: var(--ink, #111827); }
.tg-code-value { font-size: 2.6rem; font-weight: 800; letter-spacing: .14em; line-height: 1.2; margin: 6px 0 14px; color: #111827; font-variant-numeric: tabular-nums; }
.tg-open { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; padding: 10px 18px; border-radius: 12px; }
.tg-open svg { width: 20px; height: 20px; }
.tg-code-alt { margin-top: 12px; color: var(--ink-2, #4b5563); font-size: .9rem; }
.tg-code-alt code { color: #be185d; }
.tg-code-note { margin-top: 6px; color: var(--ink-3, #6b7280); font-size: .85rem; }
