/* Màu và kích thước lấy từ mockup (docs/mockup). Nút chính đen, xanh lục cho logo, mục đang chọn, link. */
:root {
    --ink: #15181D;
    --ink-2: #3A424D;
    --muted: #5B6470;
    --line: #E4E7EB;
    --line-input: #D5D9DF;
    --line-soft: #EEF0F3;
    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --chip: #F0F2F5;
    --brand: #0F766E;
    --brand-hover: #0B5A54;
    --brand-soft: #E6F2F1;
    --brand-softer: #F2F8F7;
    --danger: #B91C1C;
    --danger-soft: #FDECEC;
    --warn: #B45309;
    --warn-soft: #FEF3E2;
    --ok: #166534;
    --ok-soft: #E8F5EC;
    --group-sales: #B45309;
    --group-booth: #1D4ED8;
    --group-manage: #7C3AED;
    --manager: #5B21B6;
    --manager-soft: #EDE9FE;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Be Vietnam Pro', system-ui, sans-serif;
    font-size: 14px;
}

a { color: var(--brand); }
a:hover { color: var(--brand-hover); }
button, input, select, textarea { font: inherit; }
h1:focus { outline: none; }

/* ---- Logo ---- */
.logo-mark {
    width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #FFFFFF;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex: 0 0 auto;
}
.logo-mark.small { width: 34px; height: 34px; border-radius: 9px; font-size: 16px; }

/* ---- Trang đăng nhập (thẻ giữa màn hình) ---- */
.auth-page {
    min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 40px 16px;
}
.auth-column { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 24px; }
.auth-column.wide { max-width: 440px; }
.auth-column.terms { max-width: 640px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 700; font-size: 18px; }
.auth-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px;
    display: flex; flex-direction: column; gap: 18px; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.auth-card h1 { margin: 0; font-size: 22px; font-weight: 700; }
.stack-4 { display: flex; flex-direction: column; gap: 4px; }
.stack-6 { display: flex; flex-direction: column; gap: 6px; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.stack-10 { display: flex; flex-direction: column; gap: 10px; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.strong { font-weight: 600; }

/* ---- Ô nhập ---- */
.field-label { font-weight: 600; }
.input {
    height: 46px; padding: 0 14px; border: 1px solid var(--line-input); border-radius: 10px; width: 100%;
    background: var(--surface); color: var(--ink);
}
.input.compact { height: 44px; padding: 0 12px; }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 52px; }
.password-toggle {
    position: absolute; right: 4px; top: 4px; width: 38px; height: 38px; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check-row input, .chip-check input, .radio-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.radio-row { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.chip-check {
    display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line-input);
    border-radius: 999px; cursor: pointer;
}
fieldset.plain { border: 0; margin: 0; padding: 0; }
fieldset.plain legend { font-weight: 600; padding: 0; margin-bottom: 8px; }

.otp-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp-grid input {
    height: 52px; border: 1px solid var(--line-input); border-radius: 10px; text-align: center;
    font-size: 20px; font-weight: 600; width: 100%; padding: 0;
}
.otp-grid input:focus { outline: none; border: 2px solid var(--brand); }

/* ---- Nút ---- */
.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 18px;
    border: 0; border-radius: 10px; background: var(--ink); color: #FFFFFF; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary.compact { height: 44px; padding: 0 16px; }
.btn-primary:disabled { background: #9AA3AE; cursor: not-allowed; }
.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 16px;
    border: 1px solid var(--line-input); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer;
}
.btn-dashed {
    display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; border: 1px dashed #9AA3AE;
    border-radius: 10px; background: var(--surface); color: var(--brand); font-weight: 600; cursor: pointer;
}
.btn-link { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-link.danger { color: var(--danger); }
.btn-icon {
    flex: 0 0 auto; width: 36px; height: 36px; border: 0; border-radius: 8px; background: var(--chip); color: var(--ink-2);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ---- Thông báo ---- */
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* ---- Khung trang sau đăng nhập ---- */
.shell { position: relative; min-height: 100vh; display: flex; flex-wrap: wrap; }
.sidebar {
    flex: 1 1 230px; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px;
    display: flex; flex-direction: column; gap: 18px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.sidebar-brand .name { font-weight: 700; font-size: 15px; }
.sidebar nav { display: flex; flex-direction: column; gap: 14px; }
.nav-top {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--ink-2);
    font-weight: 500; text-decoration: none;
}
.nav-top.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.branch-button {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 12px;
    border: 1px solid var(--line-input); border-radius: 10px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer;
}
.branch-button .caption { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title {
    display: flex; align-items: center; gap: 8px; padding: 0 12px 4px; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.06em; font-weight: 700;
}
.nav-group-title .swatch { width: 8px; height: 8px; border-radius: 2px; }
.nav-item { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.nav-item:hover { color: var(--ink); background: var(--bg); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.account-area { margin-top: auto; position: relative; }
.account-button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; border: 1px solid var(--line);
    border-radius: 10px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer;
}
.avatar {
    flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; background: var(--line-soft); color: var(--ink-2);
    display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.account-menu {
    position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16); padding: 6px; display: flex; flex-direction: column; gap: 2px; z-index: 5;
}
.account-menu a, .account-menu button {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--ink);
    font-weight: 500; text-decoration: none; border: 0; background: none; cursor: pointer; text-align: left; width: 100%;
}
.account-menu a:hover, .account-menu button:hover { background: var(--bg); }
.account-menu .danger { color: var(--danger); }
.account-menu .divider { height: 1px; background: var(--line-soft); margin: 4px 6px; }

.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 20px; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.page-header h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.breadcrumb { font-size: 13px; color: var(--muted); }

.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px;
    display: flex; flex-direction: column; gap: 12px;
}
.card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.card.editing { border: 2px solid var(--brand); padding: 22px 24px; gap: 16px; max-width: 860px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; position: relative; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
    font-weight: 600; padding: 8px 10px;
}
table.data td { padding: 12px 10px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
table.data th:first-child, table.data td:first-child { padding-left: 0; }
table.data th:last-child, table.data td:last-child { padding-right: 0; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.danger-text { color: var(--danger); }

.pill { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--chip); color: var(--ink-2); }
.pill.manager { background: var(--manager-soft); color: var(--manager); }
.pill.staff { background: var(--brand-soft); color: var(--brand); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.locked { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* ---- Hộp thoại ---- */
.overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; justify-content: center;
    align-items: flex-start; padding: 100px 16px 16px; z-index: 20; overflow-y: auto;
}
.dialog {
    width: 100%; max-width: 460px; background: var(--surface); border-radius: 14px; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    padding: 22px; display: flex; flex-direction: column; gap: 16px;
}
.dialog h2 { margin: 0; font-size: 18px; font-weight: 700; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.choice {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px; border-radius: 10px;
    color: var(--ink); cursor: pointer; background: var(--surface); border: 1px solid var(--line); text-align: left;
}
.choice.selected { background: var(--brand-soft); border: 2px solid var(--brand); }
.choice .radio { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #9AA3AE; }
.choice.selected .radio { border: 6px solid var(--brand); }
.branch-link {
    display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 12px 16px; border: 1px solid var(--line-input);
    border-radius: 12px; color: var(--ink); text-decoration: none; background: var(--surface); cursor: pointer; width: 100%; text-align: left;
}

.placeholder {
    background: var(--surface); border: 1px dashed #9AA3AE; border-radius: 12px; padding: 28px; color: var(--muted);
}

.impersonation-bar {
    width: 100%; background: var(--warn-soft); color: var(--warn); padding: 10px 16px; display: flex;
    justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 600;
}

.terms-text { white-space: pre-wrap; max-height: 260px; overflow-y: auto; padding: 14px; background: var(--bg); border-radius: 10px; line-height: 1.6; }
.qr-box { display: flex; justify-content: center; }
.qr-box svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: 0.06em; background: var(--bg); padding: 10px 12px; border-radius: 8px; text-align: center; }

/* ---- Lỗi Blazor và màn hình tải ---- */
#blazor-error-ui {
    background: var(--warn-soft); color: var(--warn); bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.app-loading { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* ---- Điện thoại (mockup Mobile, MobileMenu, M*): thanh trên + 5 tab dưới đáy thay menu trái ---- */
.mobile-top, .mobile-tabs, .only-mobile { display: none; }
.mobile-top {
    position: sticky; top: 0; z-index: 4; height: 60px; padding: 8px 16px; align-items: center; justify-content: space-between;
    gap: 10px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.mobile-top .branch {
    display: flex; align-items: center; gap: 8px; height: 44px; min-width: 0; padding: 0 12px; border: 1px solid var(--line-input);
    border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.mobile-top .branch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-top .avatar { width: 40px; height: 40px; text-decoration: none; }
.mobile-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; height: 72px; padding: 6px 4px 10px; background: var(--surface);
    border-top: 1px solid var(--line); grid-template-columns: repeat(var(--tabs, 5), minmax(0, 1fr));
}
.mobile-tabs a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px;
    text-decoration: none; color: var(--muted); font-weight: 500;
}
.mobile-tabs a.active { color: var(--brand); font-weight: 600; }
.menu-list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.menu-list a, .menu-list button {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; border: 0; border-top: 1px solid var(--line-soft);
    background: none; color: var(--ink); font: inherit; text-decoration: none; text-align: left; cursor: pointer;
}
.menu-list > :first-child { border-top: 0; }
.menu-list a.active { color: var(--brand); font-weight: 600; }

@media (max-width: 767px) {
    .sidebar, .only-desktop { display: none !important; }
    .only-mobile { display: flex; }
    .only-mobile.grid { display: grid; }
    .mobile-top { display: flex; flex: 1 1 100%; }
    .mobile-tabs { display: grid; }
    .shell { flex-direction: column; flex-wrap: nowrap; }
    .main { flex: 1 1 auto; padding: 16px 16px 96px; gap: 16px; }
    .page-header h1 { font-size: 24px; }
    .card { padding: 14px 16px; }
    .impersonation-bar { flex: 1 1 100%; }
}

/* Siêu admin */
.super-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
.super-nav { display: flex; align-items: center; gap: 4px 20px; flex-wrap: wrap; }
.super-nav a, .super-nav button { color: var(--ink-2); font-weight: 600; text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.super-nav a.active { color: var(--brand); border-bottom-color: var(--brand); }
.super-nav a.tab { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.super-nav a.tab.active { background: var(--brand-soft); border-color: var(--brand); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 20px; }
@media (max-width: 767px) {
    .super-bar { padding: 12px 16px; }
}
