.traffic-page {
  --traffic-navy: #13294b;
  --traffic-navy-soft: #e9eef5;
  --traffic-teal: #168aad;
  --traffic-line: #e6eaf0;
  --traffic-muted: #667085;
  --traffic-success: #0f9d58;
  --traffic-danger: #d93025;
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  gap: clamp(12px, 1.2vw, 18px);
  color: #172033;
  container-type: inline-size;
  container-name: traffic-page;
}
.traffic-page > *,
.traffic-chart-card,
.traffic-table-card,
.traffic-report-detail-grid { min-width: 0; max-width: 100%; }
.traffic-page button, .traffic-page input, .traffic-page select { font: inherit; }
.traffic-page-head, .traffic-card-head, .traffic-period-bar, .traffic-periods,
.traffic-period-chips, .traffic-report-actions, .traffic-url-filters, .traffic-source-meta {
  display: flex;
  align-items: center;
}
.traffic-page-head {
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  margin-bottom: -6px;
  padding: 0 2px 3px;
  border-bottom: 1px solid var(--traffic-line);
}
.traffic-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--traffic-line);
  border-radius: 12px;
  background: #f7f9fc;
}
.traffic-tabs button {
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #667085;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.traffic-tabs button.active { color: var(--traffic-navy); background: #fff; box-shadow: 0 3px 12px rgba(19, 41, 75, .1); }
.traffic-tabs button:disabled { cursor: not-allowed; opacity: .58; }
.traffic-page-head > .traffic-tabs { gap: 13px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.traffic-page-head > .traffic-tabs button {
  position: relative;
  min-height: 27px;
  padding: 3px 2px 6px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.traffic-page-head > .traffic-tabs button.active::after { content: ''; position: absolute; right: 0; bottom: -4px; left: 0; height: 2px; background: var(--traffic-navy); }
.traffic-source-meta {
  align-items: center;
  flex-direction: row;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--traffic-line);
  border-radius: 7px;
  background: #fff;
  white-space: nowrap;
}
.traffic-source-meta small { color: var(--traffic-muted); font-size: 10px; }
.traffic-source-meta small::before { content: '\00b7'; margin-right: 6px; color: #98a2b3; }
.traffic-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #344054;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}
.traffic-source-badge::before { display: none; }
.traffic-source-badge:hover { border-color: #8eb1ff; background: #f4f7ff; color: #174ea6; }
.traffic-source-badge:focus-visible { outline: 0; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .16); }
.traffic-source-badge:disabled { cursor: wait; opacity: .72; }
.traffic-source-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #98a2b3; box-shadow: 0 0 0 3px rgba(152, 162, 179, .13); }
.traffic-source-badge.is-connected { border-color: #a7d7ba; background: #f2fbf6; color: #08783e; }
.traffic-source-badge.is-connected .traffic-source-dot { background: #12a05c; box-shadow: 0 0 0 3px rgba(18, 160, 92, .13); }
.traffic-source-badge.is-disconnected { border-color: #b8caff; background: #f5f7ff; color: #175cd3; }
.traffic-source-badge.is-disconnected .traffic-source-dot { background: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .13); }
.traffic-source-badge.is-error { border-color: #f6b9b4; background: #fff5f4; color: #b42318; }
.traffic-source-badge.is-error .traffic-source-dot { background: #d92d20; box-shadow: 0 0 0 3px rgba(217, 45, 32, .12); }
.traffic-source-badge.is-loading .traffic-source-dot { animation: traffic-source-pulse 1s ease-in-out infinite alternate; }
@keyframes traffic-source-pulse { to { opacity: .35; transform: scale(.72); } }
.traffic-card { background: #fff; border: 1px solid var(--traffic-line); border-radius: 12px; box-shadow: 0 7px 24px rgba(19, 41, 75, .05); }
.traffic-period-bar { justify-content: space-between; gap: 10px 14px; padding: 10px 12px; flex-wrap: wrap; }
.traffic-periods { min-width: 0; flex: 1 1 580px; gap: 6px; flex-wrap: wrap; }
.traffic-periods > strong { width: 100%; flex: 0 0 100%; color: var(--traffic-navy); font-size: 12px; line-height: 1.2; white-space: nowrap; }
.traffic-periods > strong small { color: var(--traffic-muted); font-weight: 600; }
.traffic-period-chips { gap: 6px; flex-wrap: wrap; }
.traffic-period-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 3px 5px 3px 8px;
  border: 1px solid #dce3ec;
  border-radius: 9px;
  background: #f8fafc;
  color: #344054;
  font-size: 11px;
}
.traffic-period-chip strong { color: var(--traffic-navy); }
.traffic-period-chip button { border: 0; background: transparent; color: #98a2b3; cursor: pointer; font-size: 14px; line-height: 1; }
.traffic-period-add { position: relative; flex: 0 0 auto; }
.traffic-period-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: min(260px, calc(100vw - 40px));
  max-height: 310px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(19, 41, 75, .16);
}
.traffic-period-menu[hidden] { display: none; }
.traffic-period-menu > button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  color: #344054;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.traffic-period-menu > button:hover { background: #f2f5f9; }
.traffic-period-menu > button:disabled { color: #98a2b3; cursor: default; background: #f8fafc; }
.traffic-period-menu span, .traffic-period-menu strong, .traffic-period-menu small { display: block; }
.traffic-period-menu strong { color: var(--traffic-navy); font-size: 12px; }
.traffic-period-menu small { margin-top: 2px; color: #98a2b3; font-size: 10px; }
.traffic-period-menu em { color: var(--traffic-success); font-size: 10px; font-style: normal; font-weight: 800; white-space: nowrap; }
.traffic-report-actions { min-width: 0; flex: 1 1 450px; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.traffic-report-actions .traffic-select-wrap select { min-height: 32px; max-width: 145px; padding-block: 5px; font-size: 11px; }
.traffic-select-wrap select, .traffic-url-filters select, .traffic-search input {
  min-height: 38px;
  border: 1px solid #d8dee8;
  border-radius: 9px;
  background: #fff;
  color: #344054;
  padding: 8px 10px;
  outline: none;
}
.traffic-select-wrap select:focus, .traffic-url-filters select:focus, .traffic-search input:focus { border-color: var(--traffic-navy); box-shadow: 0 0 0 3px rgba(19, 41, 75, .08); }
.traffic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.traffic-btn-primary { color: #fff; background: var(--traffic-navy); border-color: var(--traffic-navy); }
.traffic-btn-primary:hover { background: #1b3a67; }
.traffic-btn-outline { color: var(--traffic-navy); background: #fff; border-color: var(--traffic-navy); }
.traffic-btn-outline:hover { background: #f2f5f9; }
.traffic-btn:disabled { opacity: .6; cursor: wait; }
.traffic-segment {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 32px;
  padding: 3px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #f8fafc;
}
.traffic-segment > span { padding: 0 4px; color: var(--traffic-muted); font-size: 10px; font-weight: 700; }
.traffic-segment > strong { padding: 4px 7px; border-radius: 6px; background: #fff; color: var(--traffic-navy); font-size: 10px; font-weight: 800; box-shadow: 0 1px 4px rgba(19, 41, 75, .08); }
.traffic-segment button {
  min-height: 24px;
  padding: 4px 7px;
  border: 0;
  border-radius: 6px;
  color: #667085;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}
.traffic-segment button.active { color: var(--traffic-navy); background: #fff; box-shadow: 0 2px 8px rgba(19, 41, 75, .1); }
.traffic-switch { display: inline-flex; align-items: center; gap: 6px; color: #475467; font-size: 11px; font-weight: 700; cursor: pointer; }
.traffic-switch input { position: absolute; opacity: 0; pointer-events: none; }
.traffic-switch span { position: relative; width: 32px; height: 18px; border-radius: 999px; background: #cbd5e1; transition: .2s; }
.traffic-switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.traffic-switch input:checked + span { background: var(--traffic-navy); }
.traffic-switch input:checked + span::after { transform: translateX(14px); }
.traffic-spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: traffic-spin .7s linear infinite; }
.traffic-btn.is-loading .traffic-spinner { display: inline-block; }
@keyframes traffic-spin { to { transform: rotate(360deg); } }
.traffic-feedback {
  display: none;
  padding: 13px 15px;
  border: 1px solid #cfe2f3;
  border-radius: 10px;
  color: #1f4f78;
  background: #f0f7fb;
  font-size: 13px;
  font-weight: 700;
}
.traffic-feedback.is-visible { display: block; }
.traffic-feedback.is-error { color: #a61b13; background: #fff1f0; border-color: #f4c7c3; }
.traffic-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.traffic-kpi {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 78px;
  padding: 9px 48px 9px 12px;
  border: 1px solid var(--traffic-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 7px 24px rgba(19, 41, 75, .05);
}
.traffic-kpi::after { display: none; }
.traffic-kpi small { display: block; color: var(--traffic-muted); font-size: 10px; line-height: 1.15; font-weight: 700; }
.traffic-kpi strong { display: inline-block; margin-top: 4px; color: var(--traffic-navy); font-size: 20px; line-height: 1; letter-spacing: -.03em; }
.traffic-growth { display: inline-flex; margin-left: 5px; padding: 2px 5px; border-radius: 999px; font-size: 9px; line-height: 1.2; font-weight: 800; vertical-align: 2px; }
.traffic-growth.up { color: var(--traffic-success); background: #e8f5ee; }
.traffic-growth.down { color: var(--traffic-danger); background: #fdeceb; }
.traffic-kpi p { margin-top: 4px; color: #98a2b3; font-size: 9px; line-height: 1.2; }
.traffic-kpi-icon { position: absolute; right: 12px; top: 50%; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: #2563eb; background: #edf3ff; transform: translateY(-50%); }
.traffic-kpi-icon svg { display: block; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.traffic-trend-kpi { padding-right: 78px; }
.traffic-trend-kpi b { display: block; margin-top: 2px; color: var(--traffic-success); font-size: 9px; line-height: 1.15; }
.traffic-trend-kpi strong { margin-top: 3px; color: var(--traffic-success); font-size: 16px; }
.traffic-trend-kpi .traffic-sparkline { position: absolute; right: 11px; bottom: 12px; width: 60px; height: 21px; }
.traffic-trend-kpi::after { display: none; }
.traffic-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(12px, 1.2vw, 18px); }
.traffic-chart-card,
.traffic-table-card { overflow: hidden; }
.traffic-card-head { justify-content: space-between; gap: 16px; padding: 17px 18px; border-bottom: 1px solid var(--traffic-line); }
.traffic-card-head h2 { color: var(--traffic-navy); font-size: 16px; }
.traffic-card-head p { margin: 4px 0 0; color: var(--traffic-muted); font-size: 12px; }
.traffic-card-kicker { display: block; margin-bottom: 5px; color: var(--traffic-teal); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.traffic-chart-canvas { position: relative; width: 100%; min-width: 0; height: clamp(250px, 20vw, 290px); padding: 10px 12px 12px; }
.traffic-chart-fallback { display: grid; place-items: center; height: 100%; color: var(--traffic-muted); font-size: 13px; text-align: center; }
.traffic-summary-head { align-items: flex-end; }
.traffic-tabs-small button { min-height: 31px; padding: 5px 10px; font-size: 11px; }
.traffic-table-wrap { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-gutter: stable; }
.traffic-table { width: 100%; min-width: 820px; border-collapse: collapse; border-spacing: 0; }
.traffic-table th, .traffic-table td { padding: 12px 13px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: middle; }
.traffic-table th { background: #f8fafc; color: #667085; font-size: 10px; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
.traffic-table td { color: #344054; font-size: 12px; }
.traffic-table th.traffic-number, .traffic-table td.traffic-number { text-align: right; font-variant-numeric: tabular-nums; }
.traffic-table tbody tr:hover td { background: #fbfcfe; }
.traffic-table tfoot td { color: var(--traffic-navy); background: #f2f5f9; font-weight: 800; border-bottom: 0; }
.traffic-delta { font-weight: 800; }
.traffic-delta.up { color: var(--traffic-success); }
.traffic-delta.down { color: var(--traffic-danger); }
.traffic-sparkline { display: block; width: 74px; height: 25px; margin-left: auto; }
.traffic-sparkline polyline { fill: none; stroke: var(--traffic-teal); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.traffic-url-head { min-height: 46px; align-items: center; padding: 9px 12px; }
.traffic-url-head h2 { font-size: 13px; }
.traffic-url-head .traffic-btn { min-height: 29px; padding: 5px 9px; font-size: 10px; }
.traffic-url-filters { display: grid; grid-template-columns: minmax(180px, 1.15fr) repeat(3, minmax(170px, .9fr)); align-items: center; gap: 8px 10px; padding: 9px 12px; border-bottom: 1px solid var(--traffic-line); background: #fff; }
.traffic-search { position: relative; display: flex; min-width: 0; align-items: center; }
.traffic-search span { position: absolute; left: 9px; color: #98a2b3; font-size: 14px; }
.traffic-search input { width: 100%; min-width: 0; min-height: 31px; padding: 5px 8px 5px 29px; font-size: 10px; }
.traffic-filter-field { display: grid; grid-template-columns: auto minmax(84px, 1fr); align-items: center; gap: 6px; min-width: 0; color: #667085; font-size: 9px; font-weight: 700; white-space: nowrap; }
.traffic-filter-field select { width: 100%; min-width: 0; min-height: 31px; padding: 5px 8px; font-size: 10px; }
.traffic-url-table { min-width: 1080px; }
.traffic-url-table th,
.traffic-url-table td { padding: 8px 9px; font-size: 10px; line-height: 1.3; }
.traffic-url-table th { font-size: 9px; letter-spacing: .025em; }
.traffic-url-cell { max-width: 185px; color: #1f4f78; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.traffic-title-cell { min-width: 180px; max-width: 230px; line-height: 1.35; }
.traffic-keywords-cell { max-width: 160px; color: #667085; line-height: 1.35; }
.traffic-status { display: inline-flex; justify-content: center; min-width: 43px; padding: 4px 7px; border-radius: 999px; font-size: 11px; font-weight: 900; }
.traffic-status.ok { color: #0b7a44; background: #e6f4ec; }
.traffic-status.redirect { color: #9a6700; background: #fff3cf; }
.traffic-status.error { color: #b42318; background: #feeceb; }
.traffic-url-table .traffic-status { min-width: 38px; padding: 3px 6px; font-size: 9px; }
.traffic-table-note { color: var(--traffic-muted); font-size: 9px; }
.traffic-url-footer { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 12px; }
.traffic-pagination { display: inline-flex; align-items: center; gap: 5px; }
.traffic-pagination button,
.traffic-pagination > span { display: inline-grid; place-items: center; width: 27px; height: 27px; padding: 0; border: 1px solid #dce3ec; border-radius: 7px; color: #667085; background: #fff; font-size: 10px; font-weight: 800; }
.traffic-pagination > span { color: #fff; background: var(--traffic-navy); border-color: var(--traffic-navy); }
.traffic-pagination button { cursor: pointer; }
.traffic-pagination button:disabled { opacity: .38; cursor: not-allowed; }
.traffic-pagination select { min-height: 29px; margin-left: 6px; padding: 4px 25px 4px 8px; border: 1px solid #dce3ec; border-radius: 7px; color: #344054; background: #fff; font-size: 10px; font-weight: 700; }
.traffic-report-detail-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(420px, 1.15fr); gap: clamp(12px, 1.2vw, 18px); align-items: stretch; }
.traffic-summary-card { min-width: 0; overflow: hidden; }
.traffic-summary-card .traffic-table { min-width: 0; table-layout: auto; }
.traffic-summary-card .traffic-table th,
.traffic-summary-card .traffic-table td { padding: 10px 7px; font-size: 11px; line-height: 1.4; }
.traffic-summary-card .traffic-table th { color: #667085; font-size: 10px; font-weight: 800; letter-spacing: .025em; white-space: normal; }
.traffic-summary-card .traffic-table tbody td:first-child strong { color: #475467; font-size: 11.5px; font-weight: 750; }
.traffic-summary-card .traffic-table tfoot td { font-size: 11.5px; font-weight: 850; }
.traffic-summary-card .traffic-table th:first-child,
.traffic-summary-card .traffic-table td:first-child { min-width: 92px; padding-left: 12px; }
.traffic-summary-card .traffic-table th:last-child,
.traffic-summary-card .traffic-table td:last-child { padding-right: 10px; }
.traffic-summary-card .traffic-delta { font-size: 10px; font-weight: 800; white-space: nowrap; }
.traffic-summary-card .traffic-sparkline { width: 48px; height: 21px; }
.traffic-monthly-card { min-width: 0; overflow: hidden; }
.traffic-monthly-head { align-items: center; }
.traffic-monthly-head h2 { font-size: 18px; font-weight: 850; letter-spacing: -.02em; }
.traffic-monthly-head .traffic-card-kicker { font-size: 10.5px; font-weight: 850; }
.traffic-monthly-actions { display: flex; align-items: center; gap: 8px; }
.traffic-monthly-range { display: inline-flex; min-height: 34px; align-items: center; gap: 7px; padding: 3px 5px 3px 10px; border: 1px solid #dce3ec; border-radius: 9px; color: #667085; background: #fff; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.traffic-monthly-range select { min-height: 27px; padding: 3px 25px 3px 8px; border: 0; border-radius: 7px; outline: 0; color: var(--traffic-navy); background-color: #f4f7fb; font-size: 11px; font-weight: 800; cursor: pointer; }
.traffic-monthly-copy { min-height: 34px; gap: 6px; padding: 6px 10px; border-color: #cfd8e6; font-size: 10.5px; font-weight: 800; }
.traffic-monthly-copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.traffic-monthly-copy.is-copied { color: #067647; border-color: #86d5ae; background: #ecfdf3; }
.traffic-monthly-note { margin: 10px 18px 0; color: var(--traffic-muted); font-size: 11px; font-weight: 500; }
.traffic-monthly-chart { position: relative; height: 320px; padding: 10px 15px 14px 9px; }
.traffic-empty-state { grid-column: 1 / -1; padding: 34px; text-align: center; }
.traffic-empty-state strong { color: var(--traffic-navy); }
.traffic-empty-state p, .traffic-period-empty { color: var(--traffic-muted); font-size: 12px; }
.traffic-empty-cell { padding: 30px !important; text-align: center !important; color: var(--traffic-muted) !important; }

/* Phản ứng theo chiều rộng thật còn lại sau sidebar, không theo viewport thô. */
@container traffic-page (max-width: 1180px) {
  .traffic-report-detail-grid { grid-template-columns: 1fr; }
  .traffic-monthly-chart { height: 290px; }
  .traffic-summary-card .traffic-table { min-width: 720px; table-layout: auto; }
  .traffic-summary-card .traffic-table th,
  .traffic-summary-card .traffic-table td { padding: 11px 10px; font-size: 11px; }
  .traffic-summary-card .traffic-delta { font-size: 10px; }
  .traffic-summary-card .traffic-sparkline { width: 66px; height: 23px; }
}
@container traffic-page (min-width: 1101px) {
  .traffic-period-bar { align-items: flex-end; flex-wrap: nowrap; }
  .traffic-periods { flex: 1 1 auto; }
  .traffic-report-actions { flex: 0 0 auto; flex-wrap: nowrap; }
}
@container traffic-page (max-width: 1100px) {
  .traffic-chart-grid { grid-template-columns: 1fr; }
  .traffic-chart-canvas { height: 300px; }
  .traffic-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .traffic-periods,
  .traffic-report-actions { flex-basis: 100%; }
  .traffic-report-actions { justify-content: flex-start; }
}
@container traffic-page (max-width: 900px) {
  .traffic-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .traffic-url-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .traffic-search { grid-column: 1 / -1; }
}
@container traffic-page (max-width: 720px) {
  .traffic-page-head { align-items: flex-start; flex-direction: column; }
  .traffic-source-meta { width: 100%; flex-wrap: wrap; white-space: normal; }
  .traffic-tabs { max-width: 100%; overflow-x: auto; }
  .traffic-card-head,
  .traffic-summary-head,
  .traffic-url-head { align-items: flex-start; flex-direction: column; }
  .traffic-report-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .traffic-report-actions > *,
  .traffic-select-wrap select,
  .traffic-report-actions .traffic-btn { width: 100%; }
  .traffic-segment,
  .traffic-switch { justify-content: center; }
  .traffic-summary-card .traffic-table { min-width: 650px; }
  .traffic-monthly-actions { width: 100%; flex-wrap: wrap; }
  .traffic-monthly-range { flex: 1 1 auto; justify-content: space-between; }
  .traffic-url-footer { align-items: flex-start; flex-direction: column; }
}
@container traffic-page (max-width: 560px) {
  .traffic-kpis,
  .traffic-url-filters,
  .traffic-report-actions { grid-template-columns: 1fr; }
  .traffic-search { grid-column: auto; min-width: 0; }
  .traffic-periods > strong { width: 100%; }
  .traffic-period-chip { max-width: 100%; }
  .traffic-period-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .traffic-chart-canvas { height: 270px; padding-inline: 8px; }
  .traffic-trend-kpi { padding-right: 78px; }
}

/* Fallback cho trình duyệt chưa hỗ trợ container query. */
@media (max-width: 1439px) {
  .traffic-period-bar { align-items: flex-start; flex-direction: column; }
  .traffic-periods { width: 100%; }
  .traffic-report-actions { width: 100%; justify-content: flex-start; }
}
@media (max-width: 1199px) {
  .traffic-chart-grid { grid-template-columns: 1fr; }
  .traffic-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .traffic-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .traffic-page-head { align-items: flex-start; flex-direction: column; }
  .traffic-source-meta { align-items: center; flex-wrap: wrap; white-space: normal; }
}
@media (max-width: 640px) {
  .traffic-tabs { width: 100%; overflow-x: auto; }
  .traffic-tabs button { flex: 0 0 auto; }
  .traffic-kpis { grid-template-columns: 1fr; }
  .traffic-card-head, .traffic-summary-head, .traffic-url-head { align-items: flex-start; flex-direction: column; }
  .traffic-report-actions > * { width: 100%; }
  .traffic-select-wrap select, .traffic-report-actions .traffic-btn { width: 100%; }
  .traffic-segment, .traffic-switch { justify-content: center; }
  .traffic-url-filters { grid-template-columns: 1fr; }
  .traffic-url-filters > *, .traffic-url-filters select { width: 100%; min-width: 0; }
  .traffic-chart-canvas { height: 300px; }
}
