/* Giao diện công nợ: trung tính, rõ chữ, ít bo góc và ít hiệu ứng. */
:root {
  --ui-blue: #415a77;
  --ui-blue-dark: #2e435e;
  --ui-text: #202833;
  --ui-muted: #5e6874;
  --ui-border: #dfe3e8;
  --ui-canvas: #f7f8fa;
  background: var(--ui-canvas);
  color: var(--ui-text);
}
body, .workspace { background: var(--ui-canvas); }
button, input, select, textarea { font: inherit; }
::selection { background: #d8e0e8; color: #202833; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 15px; border-radius: 4px; background: #fff; color: var(--ui-blue-dark); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.sidebar { width: 252px; padding: 26px 17px 20px; background: #fafbfc; border-right: 1px solid var(--ui-border); color: var(--ui-text); }
.brand { padding: 0 13px; gap: 12px; }
.brand strong { color: #202833; font-size: 18px; font-weight: 740; }
.brand small { color: #697584; font-size: 12px; }
.brand-mark { border-radius: 5px; background: #415a77; box-shadow: none; }
.brand-mark span { background: #fff; }
.nav-label { margin-top: 52px; color: #7b8794; font-size: 11px; }
.nav { gap: 4px; }
.nav-item { min-height: 44px; border-radius: 4px; color: #394553; font-size: 14px; font-weight: 560; transition: background .12s ease, color .12s ease; }
.nav-item:hover { background: #edf0f3; color: #202833; }
.nav-item.active, .nav-item.active:hover { background: #e8edf2; color: #263f5b; box-shadow: none; }
.nav-item .nav-icon { display: grid; place-items: center; flex: none; width: 21px; }
.nav-count { background: #e6e9ed; color: #405063; }
.sidebar-bottom { border-top: 1px solid var(--ui-border); padding-top: 14px; }
.sidebar .logout-button { width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid #c9d0d8; border-radius: 4px; background: #fff; color: #344253; font-size: 13px; font-weight: 700; text-align: center; justify-content: center; }
.sidebar .logout-button:hover { border-color: #aebbc8; background: #edf0f3; color: #202833; }

main { max-width: 1600px; padding: 36px clamp(24px, 3vw, 50px) 76px; }
.page-heading { align-items: flex-start; margin-bottom: 26px; }
.eyebrow { color: #667586; font-size: 11px; letter-spacing: .1em; }
.page-heading h1, #view-customers .page-heading h1 { color: #202833; font-size: clamp(26px, 2.3vw, 32px); line-height: 1.2; letter-spacing: -.025em; }
.page-heading p { max-width: 780px; color: var(--ui-muted); font-size: 14px; line-height: 1.55; }
#view-connections .eyebrow { display: block; }
#view-connections .page-heading { margin-bottom: 26px; }
#view-connections .page-heading h1 { font-size: clamp(26px, 2.3vw, 32px); }
.overview-section-heading { align-items: center; margin: 27px 0 12px; }
.overview-section-heading:first-of-type { margin-top: 0; }
.overview-section-heading h2 { color: #344253; font-size: 15px; }
.overview-section-heading span { color: var(--ui-muted); font-size: 12px; }

.panel, .metric-card { border: 1px solid var(--ui-border); border-radius: 5px; background: #fff; box-shadow: none; }
.metric-card { min-height: 142px; padding: 20px 22px; overflow: hidden; }
.metric-card:hover { border-color: #b8c4d0; box-shadow: none; transform: none; }
.metric-card.accent { background: #f2f5f7; border-color: #d9e1e8; }
.metric-label { color: #536172; font-size: 13px; font-weight: 620; }
.metric-value { margin: 17px 0 5px; color: #202833; font-size: clamp(24px, 2vw, 31px); font-weight: 760; font-variant-numeric: tabular-nums; }
.metric-hint { color: #677481; font-size: 12px; line-height: 1.4; }
.panel-heading h2, .qr-form-panel h2, .connection-heading h2 { color: #2c3a4b; }
.recent-row:hover, .attention-item:hover { background: #f7f8fa; }

.primary-button, .secondary-button, .icon-button, .pagination button, .logout-button { transition: background .12s ease, border-color .12s ease; }
.primary-button { min-height: 42px; border-radius: 4px; background: #415a77; box-shadow: none; color: #fff; font-size: 13px; }
.primary-button:hover { background: #2e435e; box-shadow: none; transform: none; }
.secondary-button { min-height: 40px; border: 1px solid #c9d0d8; border-radius: 4px; color: #344e6b; background: #fff; font-size: 13px; }
.secondary-button:hover { border-color: #aebbc8; background: #f3f5f7; }
button:disabled { transform: none !important; box-shadow: none !important; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid #71869e; outline-offset: 2px; }

.table-panel { overflow: hidden; }
.table-toolbar { min-height: 77px; gap: 12px; }
.search-wrap input, .table-toolbar select { height: 44px; border-radius: 4px; background: #fff; font-size: 14px; }
.table-panel th, .customer-head, .customer-head button { background: #f2f4f6; color: #4c5968; font-size: 12px; font-weight: 720; }
.table-panel td { height: 62px; border-bottom-color: #e9ecef; font-size: 13px; }
.table-panel tbody tr:hover, .customer-row:hover { background: #f7f8fa; }
.customer-row { border-bottom-color: #e9ecef; }
.customer-row .customer-name strong { color: #263342; font-weight: 690; }
.customer-messenger-state { font-weight: 720; }
.pagination-bar, .table-footer { background: #fff; border-top-color: #e9ecef; }

.settings-form label, .qr-form-panel label, .customer-messenger-field { color: #344253; }
.settings-form input, .settings-form select, .settings-form textarea, .qr-form-panel input, .detail-form input, .detail-form textarea, .customer-messenger-field input, .customer-messenger-field select { min-height: 44px; border-color: #cdd4dc; border-radius: 4px; background: #fff; color: var(--ui-text); font-size: 14px; }
.settings-form input:focus, .settings-form select:focus, .settings-form textarea:focus, .qr-form-panel input:focus { border-color: #8395a8; box-shadow: 0 0 0 2px #71869e24; }
.settings-form small, .settings-note, .connection-field > small { color: var(--ui-muted); line-height: 1.55; }
.settings-form .settings-switch, .messenger-panel .settings-switch { border-color: #dfe3e8; border-radius: 4px; background: #fafbfc; }
.settings-switch input { accent-color: #415a77; }
.connection-feedback, .settings-result, .connection-state { border-radius: 4px; }
.connection-panel, .messenger-panel, #view-connections .panel { border-radius: 5px; }
#view-connections .connection-panel { padding: 24px 26px; }
#view-connections .settings-form input, #view-connections .settings-form select { height: 44px; }
#view-connections .connection-fields { gap: 14px 18px; }
#view-connections .connection-group, #view-connections .connection-provider-fields, #view-connections .connection-webhook-box { padding-top: 19px; margin-top: 11px; }
#view-connections .primary-button, #view-connections .secondary-button { min-height: 40px; }

.messenger-item { border-color: #e0e4e8; border-radius: 4px; }
.history-panel { padding: 22px; }
.history-filter { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) repeat(2, minmax(145px, 1fr)); gap: 12px; align-items: end; }
.history-filter .connection-field { margin: 0; }
.history-filter input, .history-filter select { width: 100%; min-height: 40px; }
.history-filter-actions { display: flex; gap: 8px; grid-column: 1 / -1; }
.history-panel > .settings-note { margin: 18px 0 0; }
.history-pages { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 18px; font-size: 13px; }
.sidebar-top { min-height: 0; overflow-y: auto; }
.sidebar-bottom { flex: none; }
.sidebar-dev { margin-top: 16px; color: #697584; font-size: 11px; line-height: 1.5; }
@media (max-width: 950px) { .history-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .history-filter { grid-template-columns: 1fr; } .history-panel { padding: 16px; } }
@media (max-width: 720px) { .sidebar-top { overflow: visible; } }
.messenger-receipt-resolution { width: 100%; padding: 10px 12px; border: 1px solid #d8dce1; border-left: 3px solid #8a9098; border-radius: 3px; background: #f8f9fa; }
.messenger-receipt-resolution summary { color: #44515f; font-weight: 670; cursor: pointer; }
.messenger-receipt-resolution textarea { width: 100%; min-height: 64px; padding: 10px 12px; resize: vertical; border: 1px solid #cdd4dc; border-radius: 3px; font: inherit; }
.messenger-receipt-resolution .settings-actions { margin-top: 10px; }
.notice, .toast { border-radius: 4px; }
.detail-drawer { background: #fff; }
.toast { padding: 13px 17px; box-shadow: 0 5px 15px #26334224; }
.app-confirm { width: min(430px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px; border: 1px solid #cdd4dc; border-radius: 5px; background: #fff; color: var(--ui-text); box-shadow: 0 18px 50px #20283330; }
.app-confirm::backdrop { background: #20283366; }
.app-confirm h2 { margin: 0 0 9px; font-size: 19px; line-height: 1.3; }
.app-confirm p { margin: 0; color: var(--ui-muted); font-size: 14px; line-height: 1.55; }
.app-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.app-confirm-actions button { min-width: 100px; }

.login-screen { background: #f5f6f7; }
.login-card { border-color: #dfe3e8; border-radius: 6px; box-shadow: 0 8px 24px #26334212; }
.login-card h1 { color: #202833; }
.login-kicker { color: #667586; }
.login-card p, .login-foot { color: var(--ui-muted); }

@media (max-width: 1050px) {
  .sidebar { position: sticky; top: 0; z-index: 10; width: 100%; padding: 11px 17px 0; border: 0; border-bottom: 1px solid var(--ui-border); box-shadow: none; }
  .sidebar .nav { padding: 3px 0 9px; }
  .sidebar .nav-item { color: #394553; }
  .sidebar .nav-item.active, .sidebar .nav-item.active:hover { color: #263f5b; background: #e8edf2; }
  .sidebar .nav-item:hover { color: #202833; }
  .sidebar-bottom { display: block; position: absolute; top: 9px; right: 16px; padding: 0; border: 0; }
  .sidebar .logout-button { width: auto; min-height: 36px; padding: 8px 12px; white-space: nowrap; }
  .sidebar-dev { display: none; }
  main { padding: 28px 22px 56px; }
}
@media (max-width: 720px) {
  .page-heading { flex-wrap: wrap; gap: 14px; }
  .page-heading h1, #view-customers .page-heading h1 { font-size: 25px; }
  .page-heading .primary-button { min-height: 40px; font-size: 13px; }
  .metric-card { min-height: 130px; padding: 17px; }
  .metric-value { white-space: normal; overflow-wrap: anywhere; font-size: 24px; }
  .table-toolbar { min-height: 0; }
  .messenger-panel, #view-connections .connection-panel { padding: 20px; }
  .connection-heading { flex-wrap: wrap; }
  .settings-actions > button { white-space: normal; text-align: center; }
}
.account-panel { max-width: 580px; padding: 20px; }
.account-panel h2 { margin: 0 0 6px; font-size: 17px; }
.account-panel > .settings-note { display: block; margin-bottom: 16px; font-size: 13px; }
.account-panel .settings-form { gap: 14px; }
.account-panel .settings-form label { font-size: 13px; }
.account-panel .settings-form input { height: 42px; font-size: 14px; }
.account-panel .settings-form small { font-size: 12px; }
.account-panel .settings-actions { margin-top: 2px; }
.form-error.success { color: #236b45; }
@media (max-width: 720px) {
  .account-panel { padding: 16px; }
  .account-panel .settings-actions button { width: 100%; }
}
@media (max-width: 520px) {
  .sidebar { padding-inline: 12px; }
  .sidebar .brand strong { font-size: 15px; }
  .sidebar .nav-item { font-size: 13px; }
  main { padding: 22px 13px 44px; }
  .metrics-grid { grid-template-columns: minmax(0, 1fr); }
  .metric-card { min-height: 112px; }
  .overview-section-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
  .page-heading .primary-button { width: 100%; }
  .login-card { padding: 30px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Mật độ và căn lề thống nhất giữa các trang. */
main { max-width: none; padding: 22px clamp(18px, 2vw, 32px) 48px; }
.page-heading, #view-connections .page-heading, #view-customers .page-heading { margin-bottom: 16px; }
.eyebrow { margin-bottom: 4px; }
.page-heading h1, #view-customers .page-heading h1, #view-connections .page-heading h1 { font-size: clamp(25px, 2vw, 29px); line-height: 1.18; }
.page-heading p, #view-connections .page-heading p { margin-top: 4px; line-height: 1.4; }
.overview-section-heading { margin: 17px 0 9px; }
.metrics-grid { gap: 12px; margin-bottom: 14px; }
.metric-card { min-height: 116px; padding: 16px 18px; }
.metric-value { margin: 10px 0 3px; }
.panel-heading { padding: 17px 18px 12px; }
.recent-list, .attention-list { padding-inline: 18px; }
.recent-row, .attention-item { padding-block: 11px; }
.table-toolbar { min-height: 0; padding: 12px 16px; }
.table-panel td { height: auto; padding: 11px 16px; }
.table-panel th { padding: 11px 16px; }
.customer-toolbar { padding: 12px 16px; }
.qr-form-panel { padding: 21px; }
.qr-form-panel form, .qr-form-panel #qr-form { margin-top: 16px; }
.qr-form-panel .transfer-prefix-form { margin-top: 12px; padding-bottom: 12px; }
.qr-preview-panel { min-height: 360px; }
.bank-info { margin-top: 20px; padding-top: 14px; }
.messenger-panel, #view-connections .connection-panel { padding: 18px 20px; }
.messenger-panel .connection-heading, #view-connections .connection-heading { margin-bottom: 12px; }
#view-connections .automation-panel { padding: 14px 20px; }
#view-connections .connection-fields { gap: 10px 14px; }
#view-connections .connection-group, #view-connections .connection-provider-fields, #view-connections .connection-webhook-box { padding-top: 14px; margin-top: 8px; }
.settings-actions { margin-top: 10px; }
.settings-form input, .settings-form select, .qr-form-panel input { min-height: 40px; height: 40px; }
.history-panel { padding: 16px 18px; }
.history-filter { grid-template-columns: minmax(190px, 2fr) minmax(160px, 1fr) minmax(130px, .8fr) minmax(130px, .8fr) auto; gap: 10px; }
.history-filter .connection-field > label { margin-bottom: 4px; font-size: 13px; font-weight: 600; }
.history-filter input, .history-filter select { height: 40px; min-height: 40px; padding: 0 10px; border: 1px solid #cdd4dc; border-radius: 4px; background: #fff; color: var(--ui-text); font-size: 13px; }
.history-filter-actions { grid-column: auto; flex-wrap: nowrap; }
.history-filter-actions .primary-button, .history-filter-actions .secondary-button { min-height: 38px; padding: 8px 12px; }
.history-panel > .settings-note { margin: 10px 0 7px; }
.history-panel .messenger-list { gap: 0; margin-top: 0; border: 1px solid var(--ui-border); border-radius: 4px; }
.history-panel .messenger-item { display: block; border: 0; border-bottom: 1px solid var(--ui-border); border-radius: 0; padding: 9px 12px; }
.history-panel .messenger-item:last-child { border-bottom: 0; }
.history-panel .messenger-item-info { display: grid; grid-template-columns: minmax(230px, 1.2fr) 160px minmax(260px, 1.5fr); align-items: center; gap: 14px; min-width: 0; }
.history-panel .messenger-item-info strong, .history-panel .messenger-item-info p { font-size: 13px; line-height: 1.35; }
.history-panel .messenger-item-info small { font-size: 12px; }
.history-panel .messenger-item-info p { margin: 0; }
.history-panel .messenger-receipt-resolution { margin-top: 10px; }
.history-pages { margin-top: 12px; }
@media (max-width: 1100px) {
  .history-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-filter-actions { grid-column: 1 / -1; }
  .history-panel .messenger-item-info { grid-template-columns: minmax(0, 1fr) 160px; gap: 4px 12px; }
  .history-panel .messenger-item-info p { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  main { padding: 18px 14px 40px; }
  .history-filter { grid-template-columns: minmax(0, 1fr); }
  .history-filter-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-column: 1; }
  .history-filter-actions button { width: 100%; min-width: 0; }
  #view-customers .customer-toolbar-actions #customer-sort { min-height: 40px; border-radius: 4px; }
  .history-panel .messenger-item-info { grid-template-columns: minmax(0, 1fr); }
  .history-panel .messenger-item-info p { grid-column: 1; }
  .history-panel { padding: 13px; }
  .messenger-panel, #view-connections .connection-panel { padding: 16px; }
  .pagination-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
  .pagination-bar .page-size { width: 100%; justify-content: center; }
  .pagination-bar .page-size select { min-width: 72px; height: 40px; }
  .pagination-bar .pagination { display: flex; width: 100%; justify-content: center; gap: 4px; }
  .pagination-bar .pagination button { flex: 0 0 36px; width: 36px; min-width: 36px; height: 40px; border: 1px solid var(--ui-border); border-radius: 4px; }
  .pagination-bar .page-number { width: 48px; height: 40px; margin: 0; border-radius: 4px; }
  .pagination-bar .page-total { min-width: 26px; text-align: center; }
  .pagination-bar .page-range { width: 100%; text-align: center; white-space: normal; }
  .app-confirm { padding: 19px; }
  .app-confirm-actions button { flex: 1; min-width: 0; }
}
