/* ==========================================================================
   Trung tâm hội thoại & ticket đa sàn — hệ thống thiết kế
   Nền sáng, thanh điều hướng navy đậm, nhấn hồng cho hành động chính.
   ========================================================================== */

:root {
    --pink: #ff2d55;
    --pink-soft: #ffe4ea;
    --navy: #0f1e3d;
    --navy-900: #0b1526;
    --rail: #101c33;
    --teal: #0fb9a4;
    --teal-soft: #dcf7f2;
    --amber: #f5a524;
    --amber-soft: #fff2d9;
    --violet: #8b5cf6;
    --violet-soft: #ece5ff;
    --green: #12b886;
    --green-soft: #d9f7ea;
    --red: #e5304c;
    --red-soft: #ffe1e5;
    --slate: #64748b;
    --slate-soft: #eef2f8;

    --page: #f4f6fa;
    --card: #ffffff;
    --line: #e7ecf4;
    --line-soft: #f1f4f9;
    --ink: #0f1e3d;
    --muted: #7a8aa3;

    --radius: 14px;
    --radius-sm: 9px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px rgba(15, 30, 61, .04), 0 8px 24px rgba(15, 30, 61, .05);
    --rail-w: 78px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
h1, h2, h3, h4 { margin: 0; }

/* ── Khung ứng dụng ─────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.rail {
    width: var(--rail-w);
    background: var(--rail);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 0;
    gap: 8px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
}

.rail .brand {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: var(--pink);
    display: grid; place-items: center;
    color: #fff; font-size: 20px;
    margin-bottom: 14px;
}

.rail-link {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid; place-items: center;
    color: #7d8ba6;
    font-size: 19px;
    transition: background .15s, color .15s;
}
.rail-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.rail-link.active { background: rgba(15, 185, 164, .16); color: var(--teal); }

.rail-spacer { flex: 1; }

.rail-me {
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center;
    background: #22334f; color: #fff; font-weight: 700; font-size: 13px;
}

.shell { flex: 1; margin-left: var(--rail-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 0 26px;
    height: 66px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 15;
}
.topbar h1 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.topbar .spacer { flex: 1; }

.page { padding: 22px 26px 40px; }

/* ── Thành phần nhỏ ─────────────────────────────────────────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px; font-weight: 600;
    background: var(--slate-soft); color: var(--slate);
    border: 1px solid transparent;
}
.chip.pink { background: var(--pink-soft); color: var(--pink); }
.chip.teal { background: var(--teal-soft); color: #0a8b7c; }
.chip.amber { background: var(--amber-soft); color: #a9701a; }
.chip.violet { background: var(--violet-soft); color: #6b41d8; }
.chip.green { background: var(--green-soft); color: #0b8a63; }
.chip.navy { background: #e5e9f2; color: var(--navy); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.outline { background: #fff; border-color: var(--line); color: var(--ink); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.tiktok { background: var(--pink); }
.dot.brand { background: var(--teal); }
.dot.shopee { background: #f5820b; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 12px;
    flex: 0 0 auto;
}
.avatar.lg { width: 42px; height: 42px; font-size: 14px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line);
    background: #fff; color: var(--ink);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: filter .15s, background .15s;
}
.btn:hover { background: var(--line-soft); }
.btn-primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn-primary:hover { background: #e82449; }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: #16294d; }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-teal:hover { background: #0ba593; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    font: inherit; color: var(--ink);
    outline: none;
}
.field:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 45, 85, .1); }
select.field { appearance: auto; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.card-dark {
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: var(--radius);
}
.card-dark .muted { color: #93a3bd; }

.section-title {
    font-size: 11px; font-weight: 800; letter-spacing: .12em;
    text-transform: uppercase; color: var(--muted);
    margin-bottom: 10px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.grid { display: grid; gap: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-col { display: flex; flex-direction: column; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

/* ── Bảng ───────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--muted);
    padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbfcfe; }
.table.dark-head thead { background: var(--navy); }
.table.dark-head thead th { color: #a8b6cd; border-bottom: none; }
.table-scroll { overflow-x: auto; }

/* ── Chỉ số ─────────────────────────────────────────────────────────────── */
.kpi {
    background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px 18px;
}
.kpi .label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; }
.kpi .foot { font-size: 12px; margin-top: 4px; }

.stat-tile {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; display: flex; align-items: center; gap: 16px;
}
.stat-tile .bar { width: 4px; height: 34px; border-radius: 3px; }
.stat-tile .n { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.stat-tile .cap { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.meter { height: 8px; border-radius: 6px; background: var(--line-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 6px; }

/* ── Hộp thư ────────────────────────────────────────────────────────────── */
.inbox {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr) 330px;
    gap: 16px;
    align-items: start;
}
@media (max-width: 1440px) {
    .inbox { grid-template-columns: 300px minmax(0, 1fr) 288px; gap: 12px; }
}
@media (max-width: 1180px) {
    .inbox { grid-template-columns: 300px minmax(0, 1fr); }
    .inbox .ctx { display: none; }
}

.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-pill);
    background: #fff; border: 1px solid var(--line);
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.filter-btn .n { font-size: 11px; font-weight: 700; color: var(--muted); }
.filter-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter-btn.active .n { color: #9fb0cb; }

.ticket-list { max-height: calc(100vh - 250px); overflow-y: auto; }
.ticket-item {
    display: block; padding: 14px 16px;
    border-bottom: 1px solid var(--line-soft);
    border-left: 3px solid transparent;
    cursor: pointer;
}
.ticket-item:hover { background: #fbfcfe; }
.ticket-item.active { background: #fff6f8; border-left-color: var(--pink); }
.ticket-item .code { font-size: 12px; font-weight: 800; color: var(--navy); }
.ticket-item .subject { color: var(--muted); font-size: 13px; margin-top: 2px; }
.unread {
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: var(--radius-pill); background: var(--pink); color: #fff;
    font-size: 11px; font-weight: 700; display: grid; place-items: center;
}

.lock-strip {
    background: #f8fafd; border-top: 1px solid var(--line);
    padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
    border-radius: 0 0 var(--radius) var(--radius);
}

.chat { display: flex; flex-direction: column; min-height: 520px; }
.chat-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.chat-body { padding: 18px; flex: 1; overflow-y: auto; max-height: 46vh; }
.bubble-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-end; }
.bubble-row.out { justify-content: flex-end; }
.bubble {
    max-width: 62%; padding: 12px 15px; border-radius: 14px;
    background: var(--slate-soft); color: var(--ink); line-height: 1.55;
}
.bubble-row.out .bubble { background: var(--navy); color: #fff; }
.bubble-time { font-size: 11px; color: var(--muted); margin-top: 5px; }

.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; }
.timeline-item { position: relative; padding-bottom: 12px; }
.timeline-item::before {
    content: ""; position: absolute; left: -23px; top: 5px;
    width: 9px; height: 9px; border-radius: 50%; background: var(--slate);
    box-shadow: 0 0 0 3px #fff;
}
.timeline-item.pink::before { background: var(--pink); }
.timeline-item.navy::before { background: var(--navy); }
.timeline-item.amber::before { background: var(--amber); }
.timeline-item.teal::before { background: var(--teal); }
.timeline-item.violet::before { background: var(--violet); }
.timeline-item.green::before { background: var(--green); }
.timeline-item.red::before { background: var(--red); }

.composer { border-top: 1px solid var(--line); padding: 14px 18px; }

.track-step { display: flex; gap: 12px; padding-bottom: 14px; position: relative; }
.track-step:not(:last-child)::after {
    content: ""; position: absolute; left: 8px; top: 20px; bottom: 0;
    width: 2px; background: var(--line);
}
.track-dot {
    width: 18px; height: 18px; border-radius: 50%; flex: 0 0 18px;
    display: grid; place-items: center; font-size: 10px; color: #fff; z-index: 1;
}
.track-dot.done { background: var(--green); }
.track-dot.current { background: var(--pink); }
.track-dot.pending { background: #cbd5e1; }

/* ── Cấu hình ───────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tab {
    padding: 10px 18px; border-radius: var(--radius-pill);
    background: #fff; border: 1px solid var(--line);
    font-size: 13px; font-weight: 600;
}
.tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.rule {
    background: #16294a; border: 1px solid #22385e; border-radius: var(--radius);
    padding: 15px 17px; display: flex; justify-content: space-between; gap: 14px; align-items: flex-start;
}
.rule.mandatory { border-color: var(--teal); box-shadow: 0 0 0 1px rgba(15, 185, 164, .35); }
.rule .name { font-weight: 700; color: #fff; }
.rule .desc { font-size: 12px; color: #93a3bd; margin-top: 3px; }

.switch {
    width: 44px; height: 24px; border-radius: var(--radius-pill);
    background: #2c4269; border: none; position: relative; cursor: pointer; flex: 0 0 44px;
}
.switch.on { background: var(--green); }
.switch::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border-radius: 50%; background: #fff;
    transition: transform .18s;
}
.switch.on::after { transform: translateX(20px); }
.switch.locked { cursor: not-allowed; }

.roster { width: 100%; border-collapse: separate; border-spacing: 6px; }
.roster th { font-size: 11px; color: var(--muted); font-weight: 700; }
.roster td { text-align: center; }
.roster .cell {
    border-radius: var(--radius-sm); padding: 11px 0;
    font-size: 12px; font-weight: 700; color: #fff;
}
.roster .cell.thin { opacity: .45; }

.step-card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 15px 17px; display: flex; gap: 13px; align-items: flex-start;
}
.step-num {
    width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
    display: grid; place-items: center; font-weight: 800; font-size: 12px;
    background: var(--navy); color: #fff;
}

/* ── Đăng nhập ──────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
@media (max-width: 900px) { .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; } }
.login-hero { background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-box { width: 100%; max-width: 400px; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-info { background: var(--teal-soft); color: #0a8b7c; }

/* ── Biểu đồ ────────────────────────────────────────────────────────────── */
.chart { width: 100%; height: 250px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.bar-row { display: grid; grid-template-columns: 130px 1fr 46px; align-items: center; gap: 12px; }
.bar-track { height: 9px; border-radius: 6px; background: var(--line-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }

/* ── Khối mã / JSON ─────────────────────────────────────────────────────── */
.code-block {
    background: var(--navy-900); color: #d6e2f5;
    border-radius: var(--radius-sm); padding: 14px 16px;
    font: 12px/1.55 Consolas, "Cascadia Mono", "Courier New", monospace;
    overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0;
}
.code-input { font: 12px/1.5 Consolas, "Cascadia Mono", "Courier New", monospace; resize: vertical; }
