:root {
  /* Bảng màu nền và chữ (Surface and text palette) */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --ink: #0f1720;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;

  /* Màu thương hiệu (Brand) */
  --brand: #0f766e;
  --brand-ink: #0d5f58;
  --brand-soft: #ecfdf9;

  /* Màu trạng thái, mỗi loại có nền nhạt và viền riêng
     (Semantic states, each with a soft background and border) */
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-line: #fecdca;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-line: #fde68a;
  --good: #047857;
  --good-soft: #ecfdf5;
  --good-line: #a7f3d0;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --info-line: #bfdbfe;

  --r: 10px;
  --r-sm: 6px;
  --sh-1: 0 1px 2px rgba(15, 23, 32, 0.06);
  --sh-2: 0 4px 12px rgba(15, 23, 32, 0.08);
  --sh-3: 0 12px 32px rgba(15, 23, 32, 0.12);

  /* Tên cũ giữ lại để CSS hiện có không vỡ
     (Legacy aliases so existing rules keep working) */
  --accent: var(--brand);
  --accent-2: #e34d42;
  --bad: var(--danger);
  --shadow: var(--sh-2);
  --radius: var(--r);
}

[data-theme="dark"] {
  --bg: #0b1016;
  --surface: #121924;
  --surface-2: #171f2b;
  --surface-3: #1d2734;
  --ink: #e8eef5;
  --ink-2: #c3cedb;
  --muted: #8b9aab;
  --line: #25303e;
  --line-2: #33404f;

  --brand: #2dd4bf;
  --brand-ink: #5eead4;
  --brand-soft: #10312e;

  --danger: #fca5a5;
  --danger-soft: #2a1413;
  --danger-line: #5b2a26;
  --warn: #fcd34d;
  --warn-soft: #2a2010;
  --warn-line: #5c4718;
  --good: #6ee7b7;
  --good-soft: #0d2a21;
  --good-line: #1f5344;
  --info: #93c5fd;
  --info-soft: #111f36;
  --info-line: #274063;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 4px 12px rgba(0, 0, 0, 0.45);
  --sh-3: 0 12px 32px rgba(0, 0, 0, 0.55);

  --accent-2: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(23, 111, 93, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(227, 77, 66, 0.08), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 111, 93, 0.65);
  box-shadow: 0 0 0 3px rgba(23, 111, 93, 0.12);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(23, 111, 93, 0.7);
  outline-offset: 2px;
}

input[type="checkbox"] {
  width: auto;
  min-width: 16px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 40;
  padding: 8px 11px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.sensitive-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.sensitive-control-textarea {
  align-items: stretch;
}

.sensitive-toggle {
  min-height: 38px;
  white-space: nowrap;
}

textarea.sensitive-input:not(.sensitive-revealed) {
  color: transparent;
  caret-color: transparent;
}

textarea.sensitive-input:not(.sensitive-revealed)::selection {
  color: transparent;
  background: rgba(23, 111, 93, 0.18);
}

textarea.sensitive-input.sensitive-revealed {
  color: var(--ink);
  caret-color: auto;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.nav-toggle {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav a {
  padding: 10px 11px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 700;
}

.nav a.active,
.nav a:hover {
  background: var(--ink);
  color: #fff;
}

.shell {
  min-height: 100vh;
  margin-left: 244px;
  padding: 30px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.page-stack {
  display: grid;
  gap: 20px;
  max-width: 1280px;
}

.page-header,
.panel-head,
.button-row,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-header {
  min-height: 70px;
}

.page-header h1,
.panel h2,
.login-copy h1 {
  margin: 0;
  letter-spacing: 0;
}

.page-header h1 {
  font-size: 32px;
}

.panel h2 {
  font-size: 18px;
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(216, 224, 230, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  min-height: 112px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  border: 1px solid rgba(216, 224, 230, 0.9);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.primary {
  background: var(--accent);
  color: #fff;
  padding: 9px 14px;
  font-weight: 800;
}

.danger {
  background: var(--accent-2);
  color: #fff;
  padding: 9px 14px;
  font-weight: 800;
}

.ghost,
.button-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 800;
}

.full {
  width: 100%;
}

.toolbar {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.toolbar label {
  min-width: 180px;
}

.file-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.file-field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.file-picker {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.file-picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-picker-button {
  min-height: 40px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.file-picker-input:focus-visible + .file-picker-button {
  outline: 3px solid rgba(23, 111, 93, 0.7);
  outline-offset: 2px;
}

.file-picker-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding-top: 2px;
}

.schedule-list {
  display: grid;
  gap: 10px;
}

.manual-upload-outcomes {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.manual-upload-outcome-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.manual-upload-outcome-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
}

.manual-upload-outcome-list li > span:first-child,
.manual-upload-outcome-list li > span:last-child {
  overflow-wrap: anywhere;
}

.manual-upload-outcome-list li > span:last-child {
  grid-column: 1 / -1;
}

.schedule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 170px) minmax(120px, 140px);
  gap: 12px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.schedule-item {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.schedule-item strong {
  overflow-wrap: anywhere;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td.actions {
  width: 1%;
  white-space: nowrap;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.actions-row button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.good {
  background: rgba(13, 122, 70, 0.12);
  color: var(--good);
}

.badge.bad {
  background: rgba(180, 35, 24, 0.12);
  color: var(--bad);
}

.badge.warn {
  background: rgba(182, 106, 0, 0.14);
  color: var(--warn);
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--bad);
}

.time-24h {
  font-variant-numeric: tabular-nums;
}

.time-24h[aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.login-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 28px;
  align-items: center;
}

.login-copy h1 {
  margin-top: 8px;
  font-size: 52px;
}

.login-copy p {
  max-width: 520px;
  color: var(--muted);
  font-size: 18px;
}

.login-form {
  padding: 24px;
}

.mini-grid {
  display: grid;
  gap: 8px;
}

.saved-pages-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.saved-pages-toolbar label {
  width: min(420px, 100%);
}

.youtube-content-filter-heading,
.youtube-content-filter-cell {
  min-width: 188px;
}

.youtube-content-filter {
  display: block;
  min-width: 0;
}

.youtube-content-filter select {
  width: 100%;
  min-width: 176px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.35;
}

.youtube-content-filter select:disabled {
  cursor: progress;
  opacity: 0.72;
}

.affiliate-editor {
  display: grid;
  gap: 18px;
  margin-top: 4px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 18px;
}

.affiliate-summary {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(160px, 0.75fr));
  gap: 18px;
}

.affiliate-summary > div,
.affiliate-fields,
.affiliate-preview-wrap {
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.affiliate-form {
  display: grid;
  gap: 16px;
  max-width: 100%;
}

.affiliate-help,
.affiliate-link-check-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.affiliate-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 24px;
  align-items: start;
  max-width: 100%;
}

.affiliate-fields {
  display: grid;
  gap: 14px;
}

.affiliate-fieldset {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.affiliate-fieldset legend {
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.affiliate-source-textarea {
  min-height: 148px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.affiliate-url-textarea {
  min-height: 118px;
}

.affiliate-source-textarea[aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.affiliate-link-status {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.affiliate-link-status-panel {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.affiliate-link-status-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}

.affiliate-link-status-panel summary::marker {
  color: var(--accent);
}

.affiliate-link-status-tools {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.affiliate-link-status-tools label {
  width: min(420px, 100%);
}

.affiliate-link-status-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.affiliate-link-status-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.affiliate-url-disclosure {
  min-width: 0;
  max-width: 100%;
}

.affiliate-link-status-url {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.affiliate-link-status-full,
.affiliate-link-status-error {
  min-width: 0;
  overflow-wrap: anywhere;
}

.affiliate-link-status-full {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.affiliate-link-copy {
  min-height: 32px;
  margin-top: 8px;
  padding: 5px 8px;
  font-size: 12px;
}

.affiliate-link-status-label {
  font-size: 12px;
  font-weight: 800;
}

.affiliate-link-status-error {
  grid-column: 1 / -1;
  color: var(--bad);
  font-size: 12px;
}

.affiliate-preview-wrap {
  padding-left: 20px;
  border-left: 3px solid var(--accent);
}

.affiliate-preview-head,
.affiliate-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.affiliate-preview-head {
  justify-content: space-between;
}

.affiliate-preview-head .field-label {
  margin: 0;
}

.affiliate-preview {
  display: grid;
  gap: 12px;
  min-height: 120px;
  margin-top: 14px;
  color: var(--ink);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.affiliate-preview-comment,
.affiliate-preview-url {
  min-width: 0;
  max-width: 100%;
}

.affiliate-actions {
  min-height: 40px;
  max-width: 100%;
}

.detail-stack {
  display: grid;
  gap: 24px;
}

.detail-section {
  min-width: 0;
}

.detail-section + .detail-section {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
  letter-spacing: 0;
}

.reschedule-dialog,
.facebook-token-editor-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.reschedule-dialog::backdrop,
.facebook-token-editor-dialog::backdrop {
  background: rgba(23, 32, 38, 0.38);
}

.reschedule-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.facebook-token-editor-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.comment-message {
  width: min(360px, 40vw);
  min-width: 220px;
  overflow-wrap: anywhere;
}

.preline {
  white-space: pre-wrap;
}

.schedule-export-form {
  width: min(820px, 100%);
}

.schedule-export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.time-slot-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.time-slot-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.time-slot-heading > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.time-slot-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.time-slot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: end;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
}

.schedule-export-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.export-status {
  min-height: 22px;
  margin: 0;
  overflow-wrap: anywhere;
}

.analytics-page {
  max-width: 1440px;
}

.analytics-filter-panel {
  gap: 12px;
}

.analytics-filter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.05fr) minmax(0, 1.45fr) minmax(0, 0.75fr) auto;
  gap: 16px;
  align-items: end;
}

.analytics-page-picker {
  position: relative;
  min-width: 0;
}

.analytics-account-picker {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.analytics-account-picker select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
}

.analytics-account-picker > .muted {
  margin: 0;
  font-size: 12px;
}

.analytics-page-picker .muted {
  display: block;
  margin: 7px 0 0;
  font-size: 12px;
}

.analytics-page-picker input,
.analytics-fieldset input,
.analytics-trend-select select {
  min-height: 44px;
}

.analytics-page-options {
  position: absolute;
  z-index: 12;
  top: calc(100% - 3px);
  right: 0;
  left: 0;
  display: grid;
  max-height: 276px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.analytics-page-option {
  min-height: 44px;
  padding: 9px 11px;
  display: grid;
  gap: 2px;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.analytics-page-option + .analytics-page-option {
  border-top: 1px solid var(--line);
}

.analytics-page-option:hover,
.analytics-page-option.active,
.analytics-page-option[aria-selected="true"] {
  background: var(--surface-2);
}

.analytics-page-option strong,
.analytics-page-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.analytics-page-option span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.analytics-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.analytics-fieldset legend {
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.analytics-segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.analytics-segmented button {
  min-height: 44px;
  padding: 8px 10px;
}

.analytics-segmented button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.analytics-date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.analytics-filter-actions {
  display: flex;
  align-items: end;
}

.analytics-filter-actions .primary {
  min-height: 44px;
  white-space: nowrap;
}

.analytics-live-region {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.analytics-kpi {
  min-width: 0;
  min-height: 128px;
}

.analytics-kpi strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 26px;
  line-height: 1.15;
}

.analytics-kpi-state {
  min-height: 18px;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.analytics-kpi[data-metric-state="unavailable"] .analytics-kpi-state,
.analytics-kpi[data-metric-state="unsupported"] .analytics-kpi-state {
  color: var(--bad);
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.analytics-insight-column {
  display: grid;
  gap: 20px;
}

.analytics-trend-panel {
  min-height: 436px;
}

.analytics-trend-head {
  align-items: end;
}

.analytics-trend-head > div {
  min-width: 0;
}

.analytics-trend-head .muted,
.analytics-ranked-head .muted {
  margin: 5px 0 0;
}

.analytics-trend-select {
  min-width: 148px;
}

.analytics-trend-chart {
  min-height: 274px;
  display: grid;
  align-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.analytics-trend-chart > .muted {
  padding: 18px;
  text-align: center;
}

.analytics-trend-chart svg {
  width: 100%;
  height: 274px;
  display: block;
}

.analytics-chart-grid line {
  stroke: var(--line);
  stroke-width: 1;
}

.analytics-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.analytics-chart-labels text {
  fill: var(--muted);
  font-size: 11px;
}

.analytics-trend-table-details {
  color: var(--muted);
}

.analytics-trend-table-details summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}

.analytics-trend-table {
  margin-top: 8px;
}

.analytics-cadence-panel,
.analytics-signals-panel {
  min-width: 0;
}

.analytics-cadence-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.analytics-cadence-facts div {
  min-width: 0;
}

.analytics-cadence-facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.analytics-cadence-facts dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 20px;
  font-weight: 800;
}

.analytics-weekday-counts {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.analytics-weekday-counts li {
  min-width: 0;
  padding: 9px 7px;
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.analytics-weekday-counts li + li {
  border-left: 1px solid var(--line);
}

.analytics-weekday-counts span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.analytics-weekday-counts strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.analytics-signals-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.analytics-signals-list li {
  display: grid;
  gap: 4px;
  padding: 11px 0;
  overflow-wrap: anywhere;
}

.analytics-signals-list li + li {
  border-top: 1px solid var(--line);
}

.analytics-signals-list span {
  color: var(--muted);
}

.analytics-ranked-panel {
  min-width: 0;
}

.analytics-ranked-posts {
  table-layout: fixed;
}

.analytics-ranked-posts th:nth-child(1) {
  width: 29%;
}

.analytics-ranked-posts th:nth-child(2) {
  width: 15%;
}

.analytics-ranked-posts th:nth-child(3) {
  width: 20%;
}

.analytics-ranked-posts th:nth-child(4) {
  width: 12%;
}

.analytics-ranked-posts th:nth-child(5) {
  width: 14%;
}

.analytics-ranked-posts th:nth-child(6) {
  width: 10%;
}

.analytics-post-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.analytics-post-format {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.analytics-engagements {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.analytics-money {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.analytics-ranked-posts .link-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.analytics-empty-row td {
  color: var(--muted);
  text-align: center;
}

.analytics-loading [data-analytics-kpis],
.analytics-loading .analytics-grid,
.analytics-loading .analytics-ranked-panel {
  opacity: 0.68;
}

.facebook-oauth-panel .muted,
.monetization-picker-panel .muted,
.monetization-tracked-panel .muted {
  margin: 5px 0 0;
}

.facebook-oauth-status {
  min-height: 20px;
  margin: 0;
}

.monetization-dashboard {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 20px;
}

.monetization-heading {
  align-items: end;
}

.monetization-heading h2,
.monetization-picker-panel h3,
.monetization-tracked-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.monetization-heading h2 {
  font-size: 24px;
}

.monetization-picker-panel h3,
.monetization-tracked-panel h3 {
  font-size: 18px;
}

.monetization-picker-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.85fr) auto;
  gap: 16px;
  align-items: end;
}

.monetization-page-picker {
  position: relative;
  min-width: 0;
}

.monetization-page-picker input {
  min-height: 44px;
}

.monetization-page-picker > .muted {
  display: block;
  font-size: 12px;
}

.monetization-page-options {
  position: absolute;
  z-index: 12;
  top: calc(100% - 3px);
  right: 0;
  left: 0;
  max-height: 276px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.monetization-page-option {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  display: grid;
  gap: 2px;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.monetization-page-option + .monetization-page-option {
  border-top: 1px solid var(--line);
}

.monetization-page-option:hover,
.monetization-page-option.active,
.monetization-page-option[aria-selected="true"] {
  background: var(--surface-2);
}

.monetization-page-option strong,
.monetization-page-option span,
.monetization-selected-page strong,
.monetization-selected-page span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.monetization-page-option span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.monetization-selected-page {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: end;
}

.monetization-selected-page strong {
  font-size: 16px;
}

.monetization-notices {
  min-height: 20px;
}

.monetization-notice {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.monetization-notice[data-monetization-state="stale"] {
  color: var(--warn);
}

.monetization-notice[data-monetization-state="error"] {
  color: var(--bad);
}

.monetization-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.monetization-metric {
  min-width: 0;
  min-height: 124px;
}

.monetization-metric strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 26px;
  line-height: 1.15;
}

.monetization-estimate-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.monetization-selected-track {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 0.85fr) minmax(0, 1.35fr) auto;
  gap: 16px;
  align-items: end;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--line);
}

.monetization-selected-track > div:first-child,
.monetization-selected-track strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.monetization-detail-grid {
  min-width: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.monetization-detail-grid div {
  min-width: 0;
}

.monetization-detail-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.monetization-detail-grid dd {
  min-width: 0;
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.monetization-track-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.monetization-track-controls button {
  min-height: 40px;
}

.monetization-tracked-pages {
  table-layout: fixed;
}

.monetization-tracked-pages th:nth-child(1) {
  width: 28%;
}

.monetization-tracked-pages th:nth-child(2) {
  width: 22%;
}

.monetization-tracked-pages th:nth-child(3) {
  width: 25%;
}

.monetization-tracked-pages th:nth-child(4) {
  width: 25%;
}

.monetization-tracked-pages tr.is-selected td {
  background: rgba(23, 111, 93, 0.05);
}

.monetization-track-select {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.monetization-track-select:hover {
  color: var(--accent);
}

.monetization-row-toggle {
  min-height: 32px;
  padding: 0 2px;
  color: var(--ink);
  white-space: nowrap;
}

.monetization-tracked-pages .actions-row {
  justify-content: flex-start;
}

.monetization-loading .monetization-kpis,
.monetization-loading .monetization-selected-track,
.monetization-loading .monetization-tracked-panel {
  opacity: 0.68;
}

.monetization-report {
  min-width: 0;
  display: grid;
  gap: 20px;
}

.monetization-report-heading {
  min-width: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 4px;
}

.monetization-report-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.monetization-report-heading > .muted {
  max-width: 420px;
  margin: 0;
  text-align: right;
}

.monetization-report-controls {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) minmax(230px, 0.9fr) minmax(250px, 1fr);
  gap: 16px;
  align-items: end;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.admin-monetization-report-controls {
  grid-template-columns: minmax(240px, 1.05fr) minmax(150px, 0.55fr) minmax(230px, 0.9fr) minmax(230px, 0.9fr);
}

.monetization-report-scope-field,
.monetization-report-page-field,
.admin-monetization-user-picker {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.monetization-report-scope-field > .field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.monetization-report-page-field select,
.monetization-report-page-field input,
.admin-monetization-user-picker input {
  min-height: 42px;
}

.monetization-report-segmented {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.monetization-report-segmented .ghost {
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  overflow-wrap: anywhere;
}

.monetization-report-segmented .ghost.is-selected,
.monetization-report-segmented .ghost[aria-checked="true"] {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(23, 32, 38, 0.08);
}

.monetization-report-notices {
  min-height: 22px;
}

.monetization-report-notice {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.monetization-report-notice[data-monetization-report-state="partial"],
.monetization-report-notice[data-monetization-report-state="stale"] {
  color: var(--warn);
}

.monetization-report-notice[data-monetization-report-state="error"] {
  color: var(--bad);
}

[data-monetization-report-results],
[data-admin-monetization-report-results] {
  min-width: 0;
  display: grid;
  gap: 20px;
}

.monetization-report-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.monetization-report-metric {
  min-width: 0;
  min-height: 128px;
}

.monetization-report-metric strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.25;
}

.monetization-report-metric .monetization-currency-line {
  display: block;
  font-size: 16px;
  line-height: 1.45;
}

.monetization-report-chart-head {
  align-items: start;
}

.monetization-report-chart-head h2,
.monetization-report-table-panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.monetization-report-chart-head .muted,
.monetization-report-table-panel .muted {
  margin: 5px 0 0;
}

.monetization-chart-detail {
  max-width: 300px;
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.monetization-daily-chart {
  width: 100%;
  min-width: 0;
  min-height: 260px;
  aspect-ratio: 720 / 260;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  touch-action: pan-y;
}

.monetization-daily-chart > .muted {
  padding: 18px;
  text-align: center;
}

.monetization-daily-chart svg {
  width: 100%;
  height: 100%;
  min-height: 260px;
}

.monetization-chart-grid line {
  stroke: rgba(100, 113, 125, 0.3);
  stroke-width: 1;
}

.monetization-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.monetization-chart-point {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 3;
  cursor: pointer;
}

.monetization-chart-point:hover,
.monetization-chart-point:focus-visible {
  fill: var(--accent-2);
  stroke: var(--accent-2);
  outline: none;
}

.monetization-chart-labels text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.monetization-daily-table {
  width: 100%;
  table-layout: fixed;
}

.monetization-daily-table th:nth-child(1) {
  width: 17%;
}

.monetization-daily-table th:nth-child(2) {
  width: 18%;
}

.monetization-daily-table th:nth-child(3),
.monetization-daily-table th:nth-child(4) {
  width: 32.5%;
}

.monetization-daily-table td {
  vertical-align: top;
  overflow-wrap: anywhere;
}

.monetization-daily-table .monetization-currency-line + .monetization-currency-line {
  margin-top: 5px;
}

.admin-monetization-report {
  min-width: 0;
}

.read-only-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(23, 111, 93, 0.35);
  border-radius: 7px;
  background: rgba(23, 111, 93, 0.09);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.admin-monetization-user-picker {
  position: relative;
}

.admin-monetization-user-results {
  position: absolute;
  z-index: 12;
  top: calc(100% - 3px);
  right: 0;
  left: 0;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-monetization-user-option {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  display: grid;
  gap: 2px;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.admin-monetization-user-option + .admin-monetization-user-option {
  border-top: 1px solid var(--line);
}

.admin-monetization-user-option:hover,
.admin-monetization-user-option.active,
.admin-monetization-user-option[aria-selected="true"] {
  background: var(--surface-2);
}

.admin-monetization-user-option span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.admin-monetization-user-picker > .muted {
  margin: 0;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .sidebar {
    position: static;
    inset: auto;
    width: auto;
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 18px;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .brand {
    margin-right: auto;
  }

  .sidebar .full {
    width: auto;
  }

  .nav {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .shell {
    margin-left: 0;
    padding: 24px;
  }

  .analytics-filter-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-filter-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1000px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .split,
  .login-panel {
    grid-template-columns: 1fr;
  }

  .schedule-row {
    grid-template-columns: 1fr;
  }

  .time-slot-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .affiliate-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .affiliate-form-grid {
    grid-template-columns: 1fr;
  }

  .affiliate-preview-wrap {
    padding-top: 16px;
    padding-left: 0;
    border-top: 3px solid var(--accent);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 15;
    padding: 10px 14px;
  }

  .shell {
    margin-left: 0;
    padding: 18px;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar .nav {
    display: none;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar.nav-open .nav {
    display: grid;
  }

  .sidebar:not(.nav-open) > .full {
    display: none;
  }

  .sidebar.nav-open > .full {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-header,
  .panel-head,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .schedule-export-grid,
  .time-slot-list {
    grid-template-columns: 1fr;
  }

  .saved-pages-toolbar,
  .affiliate-preview-head,
  .affiliate-link-status-tools,
  .collection-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .youtube-content-filter-heading,
  .youtube-content-filter-cell {
    min-width: 176px;
  }

  .affiliate-summary {
    grid-template-columns: 1fr;
  }

  .affiliate-editor button {
    min-height: 44px;
  }

  .affiliate-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .affiliate-actions > * {
    max-width: 100%;
  }

  .affiliate-actions > button {
    width: 100%;
  }

  .affiliate-source-textarea {
    min-height: 132px;
  }

  .affiliate-url-textarea {
    min-height: 112px;
  }

  .affiliate-link-status-item {
    grid-template-columns: 1fr;
  }

  .affiliate-url-disclosure,
  .affiliate-link-status-url {
    max-width: 100%;
  }

  .affiliate-link-status-error {
    grid-column: auto;
  }

  .table-wrap td.actions {
    position: sticky;
    right: 0;
    z-index: 2;
    min-width: 132px;
    background: var(--surface);
    box-shadow: -8px 0 12px rgba(23, 32, 38, 0.08);
  }

  .sensitive-control {
    grid-template-columns: minmax(0, 1fr);
  }

  .sensitive-toggle {
    width: 100%;
  }

  .manual-upload-outcome-list li {
    grid-template-columns: minmax(0, 1fr);
  }

  .manual-upload-outcome-list li > span:last-child {
    grid-column: auto;
  }

  .comment-message {
    width: min(300px, 75vw);
  }

  .analytics-filter-layout,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-account-picker {
    width: 100%;
  }

  .analytics-filter-actions,
  .analytics-filter-actions .primary {
    width: 100%;
  }

  .analytics-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-trend-panel {
    min-height: 0;
  }

  .analytics-trend-head {
    align-items: stretch;
    flex-direction: column;
  }

  .analytics-trend-select {
    width: 100%;
  }

  .analytics-trend-chart,
  .analytics-trend-chart svg {
    min-height: 236px;
    height: 236px;
  }

  .analytics-weekday-counts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .analytics-weekday-counts li + li {
    border-left: 0;
  }

  .analytics-weekday-counts li:nth-child(n + 2) {
    border-left: 1px solid var(--line);
  }

  .analytics-weekday-counts li:nth-child(5) {
    border-left: 0;
  }

  .analytics-ranked-posts,
  .analytics-ranked-posts tbody {
    display: grid;
    width: 100%;
  }

  .analytics-ranked-posts thead {
    display: none;
  }

  .analytics-ranked-posts tr {
    display: grid;
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
  }

  .analytics-ranked-posts td {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(104px, 0.72fr) minmax(0, 1.28fr);
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .analytics-ranked-posts td:last-child {
    border-bottom: 0;
  }

  .analytics-ranked-posts td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .analytics-ranked-posts .analytics-empty-row {
    display: table-row;
    margin: 0;
    border: 0;
    background: transparent;
  }

  .analytics-ranked-posts .analytics-empty-row td {
    display: table-cell;
    border-bottom: 0;
  }

  .analytics-ranked-posts .analytics-empty-row td::before {
    content: none;
  }

  .monetization-heading,
  .monetization-picker-head {
    align-items: stretch;
    flex-direction: column;
  }

  .monetization-picker-layout,
  .monetization-kpis,
  .monetization-selected-track,
  .monetization-detail-grid {
    grid-template-columns: 1fr;
  }

  .monetization-page-options {
    position: static;
    margin-top: 8px;
    max-height: 240px;
  }

  .monetization-track-controls,
  .monetization-tracked-pages .actions-row {
    align-items: stretch;
    flex-direction: column;
  }

  .monetization-track-controls > *,
  .monetization-tracked-pages .actions-row > * {
    width: 100%;
  }

  .monetization-track-controls button {
    min-height: 44px;
  }

  .monetization-row-toggle {
    min-height: 44px;
    justify-content: flex-start;
  }

  .monetization-tracked-pages,
  .monetization-tracked-pages tbody {
    display: grid;
    width: 100%;
  }

  .monetization-tracked-pages thead {
    display: none;
  }

  .monetization-tracked-pages tr {
    display: grid;
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
  }

  .monetization-tracked-pages td {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(104px, 0.72fr) minmax(0, 1.28fr);
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .monetization-tracked-pages td:last-child {
    border-bottom: 0;
  }

  .monetization-tracked-pages td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .monetization-tracked-pages td:not([data-label]) {
    display: block;
    text-align: center;
  }

  .monetization-tracked-pages td:not([data-label])::before {
    content: none;
  }

  .monetization-tracked-pages td.actions {
    position: static;
    right: auto;
    z-index: auto;
    width: auto;
    min-width: 0;
    background: transparent;
    box-shadow: none;
  }

  .monetization-report-heading,
  .monetization-report-chart-head {
    align-items: stretch;
    flex-direction: column;
  }

  .monetization-report-heading > .muted,
  .monetization-chart-detail {
    max-width: none;
    text-align: left;
  }

  .monetization-report-controls {
    grid-template-columns: 1fr;
  }

  .admin-monetization-report-controls {
    grid-template-columns: 1fr;
  }

  .monetization-report-page-field,
  .admin-monetization-user-picker {
    width: 100%;
  }

  .monetization-daily-chart,
  .monetization-daily-chart svg {
    min-height: 236px;
    height: 236px;
  }

  .admin-monetization-user-results {
    position: static;
    margin-top: 8px;
    max-height: 240px;
  }

  .monetization-daily-table,
  .monetization-daily-table tbody {
    display: grid;
    width: 100%;
  }

  .monetization-daily-table thead {
    display: none;
  }

  .monetization-daily-table tr {
    display: grid;
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
  }

  .monetization-daily-table td {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(104px, 0.72fr) minmax(0, 1.28fr);
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .monetization-daily-table td:last-child {
    border-bottom: 0;
  }

  .monetization-daily-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .monetization-daily-table .monetization-daily-empty-row {
    display: table-row;
    margin: 0;
    border: 0;
    background: transparent;
  }

  .monetization-daily-table .monetization-daily-empty-row td {
    display: table-cell;
    border-bottom: 0;
  }

  .monetization-daily-table .monetization-daily-empty-row td::before {
    content: none;
  }

  .admin-monetization-report .read-only-badge {
    align-self: flex-start;
  }
}

@media (max-width: 460px) {
  .metric-grid,
  .nav {
    grid-template-columns: 1fr;
  }

  .login-copy h1 {
    font-size: 38px;
  }

  .analytics-kpis,
  .analytics-date-range,
  .analytics-cadence-facts,
  .monetization-report-kpis {
    grid-template-columns: 1fr;
  }

  .analytics-weekday-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-weekday-counts li:nth-child(n) {
    border-left: 0;
  }

  .analytics-weekday-counts li:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .analytics-kpi strong {
    font-size: 22px;
  }

  .analytics-ranked-posts td {
    grid-template-columns: minmax(92px, 0.7fr) minmax(0, 1.3fr);
  }

  .analytics-money,
  .analytics-revenue-kpi strong {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}


/* ============================================================
   CHẾ ĐỘ TỐI — chỉnh lại phần body dùng gradient cứng
   (Dark mode — neutralise the hard-coded body gradient)
   ============================================================ */
[data-theme="dark"] body {
  background: var(--bg);
}
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}
[data-theme="dark"] img,
[data-theme="dark"] video {
  filter: brightness(0.92);
}


/* ============================================================
   BO THANH PHAN GIAO DIEN MOI (New UI components)
   Dung chung cho moi tab. Khong dung toi class cu.
   ============================================================ */

/* --- Sidebar co nhom (Grouped sidebar) --- */
.nav-group { margin-bottom: 12px; }
.nav-group-label {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 8px 5px;
}
.nav a.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13.5px;
  position: relative;
  margin-bottom: 1px;
}
.nav a.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav a.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 650;
}
.nav a.nav-link.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.nav a.nav-link svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav a.nav-link .nav-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Huy hieu so dem (Count badge) --- */
.count-badge {
  flex: none;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.5;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.count-badge.red { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.count-badge.orange { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.count-badge.grey { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.count-badge.hidden { display: none; }

/* --- Cong tac bat tat (Toggle switch) --- */
.switch { position: relative; display: inline-flex; flex: none; vertical-align: middle; }
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch .switch-track {
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--line-2);
  display: block;
  position: relative;
  transition: background 0.16s;
}
.switch .switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform 0.16s;
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(15px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }

/* --- Menu ba cham (Overflow dropdown menu) --- */
.row-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.overflow { position: relative; display: inline-block; }
.overflow-trigger {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
  min-height: 0;
}
.overflow-trigger:hover { background: var(--surface-3); border-color: var(--line-2); color: var(--ink); }
.overflow-trigger[aria-expanded="true"] { background: var(--surface-3); border-color: var(--line-2); }
.overflow-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  min-width: 208px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-3);
  padding: 5px;
  z-index: 90;
}
.overflow-menu[hidden] { display: none; }
.overflow-menu button,
.overflow-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  background: none;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  min-height: 0;
}
.overflow-menu button:hover,
.overflow-menu a:hover { background: var(--surface-3); color: var(--ink); }
.overflow-menu .menu-sep {
  height: 1px;
  background: var(--line);
  margin: 5px 3px;
}
.overflow-menu button.destructive { color: var(--danger); }
.overflow-menu button.destructive:hover { background: var(--danger-soft); }

/* --- Chip loc (Filter chips) --- */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  min-height: 0;
}
.filter-chip:hover { background: var(--surface-3); border-color: var(--line-2); color: var(--ink); }
.filter-chip[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-ink);
}
.filter-chip .chip-count {
  font-size: 11px;
  font-weight: 750;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.filter-chip[aria-pressed="true"] .chip-count { background: var(--surface); color: var(--brand-ink); }

/* --- Thanh thao tac hang loat (Bulk action bar) --- */
.bulk-bar {
  position: sticky;
  bottom: 14px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--brand);
  box-shadow: var(--sh-3);
}
.bulk-bar[hidden] { display: none; }
.bulk-bar .bulk-count { font-weight: 680; font-size: 13.5px; }
.bulk-bar .bulk-spacer { flex: 1 1 auto; }
.bulk-bar button { min-height: 32px; padding: 6px 12px; font-size: 13px; }

/* --- The muc do nghiem trong (Severity cards) --- */
.severity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
  gap: 12px;
}
.severity {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: var(--surface);
  box-shadow: var(--sh-1);
}
.severity.high { border-color: var(--danger-line); border-left-color: var(--danger); background: var(--danger-soft); }
.severity.medium { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-soft); }
.severity.ok { border-color: var(--good-line); border-left-color: var(--good); background: var(--good-soft); }
.severity-body { min-width: 0; flex: 1 1 auto; }
.severity-value {
  font-size: 26px;
  font-weight: 780;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.severity.high .severity-value { color: var(--danger); }
.severity.medium .severity-value { color: var(--warn); }
.severity.ok .severity-value { color: var(--good); }
.severity-label { font-size: 13.5px; font-weight: 680; margin-top: 1px; }
.severity-note { font-size: 12.5px; color: var(--ink-2); margin: 4px 0 10px; line-height: 1.45; }

/* --- O thong bao (Callout) --- */
.callout {
  display: flex;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  align-items: flex-start;
}
.callout.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.callout.danger { background: var(--danger-soft); border-color: var(--danger-line); }
.callout.info { background: var(--info-soft); border-color: var(--info-line); }
.callout.good { background: var(--good-soft); border-color: var(--good-line); }
.callout-icon { flex: none; margin-top: 1px; }
.callout-body { min-width: 0; flex: 1 1 auto; }
.callout-body strong { display: block; font-size: 13.5px; margin-bottom: 3px; }
.callout-body p { margin: 0 0 9px; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.callout-body p:last-child { margin-bottom: 0; }
.callout-actions { display: flex; flex-wrap: wrap; gap: 7px; }

/* --- Bang loi dien giai bang tieng Viet (Human-readable error panel) --- */
.error-panel {
  margin: 10px 0 4px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--danger-line);
  background: var(--danger-soft);
}
.error-panel-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 5px;
}
.error-panel-why { font-size: 13px; color: var(--ink-2); line-height: 1.5; margin: 0 0 10px; }
.error-panel-fix {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}
.error-panel-fix strong {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.error-panel-fix p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.error-panel details { margin-top: 10px; }
.error-panel summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  padding: 3px 0;
}
.error-panel summary:hover { color: var(--ink-2); }
.error-panel details pre {
  margin: 7px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* --- Nhan nguon token: tu tai khoan hay mo coi
       (Token source: account-linked vs orphan) --- */
.token-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.4;
}
.token-source svg { flex: none; opacity: 0.85; }
.token-source.linked { color: var(--ink-2); }
.token-source.orphan { color: var(--warn); font-weight: 600; }

/* --- Trang thai rong (Empty state) --- */
.empty-state {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state svg { opacity: 0.55; margin-bottom: 10px; }
.empty-state strong { display: block; font-size: 14px; color: var(--ink); margin-bottom: 4px; }
.empty-state p { margin: 0 0 14px; font-size: 13px; }

/* --- Dong bang co canh bao (Row-level state tint) --- */
tbody tr.row-danger { background: var(--danger-soft); }
tbody tr.row-warn { background: var(--warn-soft); }
tbody tr.row-selected { background: var(--brand-soft); }

/* --- O chon trong bang (Table checkbox cell) --- */
th.col-check,
td.col-check { width: 34px; padding-right: 0; }
th.col-check input,
td.col-check input { width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--brand); }

/* --- O ma ky thuat ngan (Inline monospace id) --- */
.mono-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .severity-grid { grid-template-columns: 1fr; }
  .bulk-bar { flex-wrap: wrap; }
}


/* --- Chan sidebar: day xuong duoi cung
       (Sidebar footer: pin to the bottom) --- */
.sidebar .nav { flex: 1 1 auto; align-content: start; overflow-y: auto; }
.side-foot {
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
[data-theme="dark"] .sidebar { background: var(--surface); backdrop-filter: none; }


/* ============================================================
   DONG BO VOI BAN DEMO (Align live UI with the approved demo)
   Ghi de cac quy tac cu de khop dung ti le, mau va do bong.
   ============================================================ */

/* Chu nen 14px, font he thong, so dung chu so deu chieu ngang
   (14px base, system font stack, tabular figures) */
body {
  background: var(--bg);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* Sidebar: 248px, nen dac, khong con padding ngoai vi nav tu lo
   (248px sidebar, solid surface) */
.sidebar {
  width: 248px;
  padding: 0;
  gap: 0;
  background: var(--surface);
  backdrop-filter: none;
}
.sidebar .brand {
  padding: 15px 15px 13px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.sidebar .brand-mark {
  border-radius: 9px;
  background: linear-gradient(160deg, var(--brand), var(--brand-ink));
  color: #fff;
  box-shadow: var(--sh-1);
}
.sidebar .nav { padding: 10px 8px 4px; gap: 0; }
.sidebar .side-foot { padding: 10px; border-top: 1px solid var(--line); }
.shell { margin-left: 248px; padding: 20px 22px 60px; }

/* Thanh tieu de dinh tren dau trang, thay cho page-header cu qua to
   (Sticky topbar replacing the oversized page header) */
.page-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 0;
  margin: -20px -22px 18px;
  padding: 11px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--sh-1);
}
.page-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.page-header .eyebrow {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--muted);
  margin-bottom: 1px;
}

/* The noi dung: nen dac, vien nhat, bong nhe hon
   (Cards: solid surface, softer border, lighter shadow) */
.panel {
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--sh-1);
}
.panel h2 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; }
.panel-head { gap: 10px; }
.panel-head .muted { font-size: 12.5px; }

/* Bang: tieu de nho, chu so deu, dong hover sang len
   (Tables: smaller header, tabular numbers, hover tint) */
table { border-collapse: collapse; width: 100%; }
thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr.row-danger:hover { background: var(--danger-soft); }
tbody tr.row-selected:hover { background: var(--brand-soft); }
tbody tr:last-child td { border-bottom: 0; }

/* Nut bam: cao 34px, bo goc 8px, dong bo voi demo
   (Buttons: 34px tall, 8px radius) */
button { min-height: 34px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  box-shadow: var(--sh-1);
  padding: 7px 13px;
}
.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.ghost {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 7px 13px;
}
.ghost:hover { background: var(--surface-3); border-color: var(--line-2); color: var(--ink); }
.danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
  padding: 7px 13px;
}
[data-theme="dark"] .primary,
[data-theme="dark"] .danger { color: #06231f; }

/* O nhap: bo goc 8px, vien sang khi focus
   (Inputs: 8px radius, brand focus ring) */
input, select, textarea {
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 8px 11px;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  background: var(--surface);
}
label { font-size: 12.5px; font-weight: 600; color: var(--muted); gap: 6px; }

/* Nhan trang thai: vien mau nhat thay vi nen dac
   (Status badges: soft tint with matching border) */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--muted);
}
.badge.good { background: var(--good-soft); color: var(--good); border-color: var(--good-line); }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }

/* The so lieu tren trang Tong quan
   (Metric cards on the dashboard) */
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  padding: 12px 14px;
}
.metric span { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.metric strong {
  font-size: 22px;
  font-weight: 780;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--muted); }
.table-wrap { overflow-x: auto; }


/* Khop chinh xac ti le tieu de voi ban demo (Match the demo heading scale) */
.page-header h1 { font-size: 16.5px; font-weight: 650; }


/* Anh dai dien chu cai + o thong tin nguoi dung
   (Initials avatar and user cell) */
.ecc-user-cell { display: flex; align-items: center; gap: 10px; }
.ecc-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--brand), var(--brand-ink));
  color: #fff;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: 0.02em;
}
[data-theme="dark"] .ecc-avatar { color: #06231f; }
.ecc-user-date { display: block; font-size: 11.5px; }


/* Xep chong nhieu o canh bao va nhieu hang chip
   (Stacked callouts and chip rows) */
.ecc-callout-stack { display: grid; gap: 10px; margin-bottom: 16px; }
.ecc-chip-stack { display: grid; gap: 8px; }
.ecc-source-chips .filter-chip { font-size: 12px; padding: 5px 10px; }

/* Lien ket dang chu trong o bang (Inline text link inside a table cell) */
.ecc-inline-link {
  display: inline;
  min-height: 0;
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.ecc-inline-link:hover { color: var(--brand-ink); }

/* Nut dang the link (Anchor styled as a button) */
.button-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.button-link:hover { background: var(--surface-3); border-color: var(--line-2); color: var(--ink); }


/* Chu giai thich duoi o nhap (Helper text under a field) */
.ecc-hint {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 2px;
}

/* Thanh dung luong dia (Disk usage readout) */
.ecc-disk {
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.ecc-disk-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.ecc-disk-head strong { font-size: 13.5px; }
.ecc-disk-head .muted { font-size: 12px; margin-left: auto; }
.ecc-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.ecc-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}
.ecc-bar.warn span { background: var(--warn); }
.ecc-bar.danger span { background: var(--danger); }


/* Do manh mat khau (Password strength meter) */
.ecc-meter { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.ecc-meter span {
  height: 4px;
  flex: 1 1 0;
  border-radius: 999px;
  background: var(--surface-3);
}
.ecc-meter span.on.lv1 { background: var(--danger); }
.ecc-meter span.on.lv2 { background: var(--warn); }
.ecc-meter span.on.lv3 { background: var(--good); }
.ecc-meter em {
  flex: none;
  font-style: normal;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  min-width: 84px;
}


/* Nhan phan doan trong trang (Section label) */
.ecc-section-label {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 10px;
}
.ecc-attention { margin-bottom: 20px; }
.ecc-attention .ecc-section-label { margin-top: 0; }

/* Bieu tuong trong the muc do (Icon inside a severity card) */
.severity-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
}
.severity.high .severity-icon { color: var(--danger); border-color: var(--danger-line); }
.severity.medium .severity-icon { color: var(--warn); border-color: var(--warn-line); }
.severity.ok .severity-icon { color: var(--good); border-color: var(--good-line); }

/* Danh sach nguyen nhan that bai kem thanh ti le
   (Failure-cause list with proportional bars) */
.ecc-reason-list { display: grid; gap: 12px; }
.ecc-reason-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 13px;
}
.ecc-reason-top span { flex: 1 1 auto; min-width: 0; }
.ecc-reason-top strong {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}
.ecc-reason .ecc-bar span { background: var(--danger); }


/* Tab noi bo trong mot the, thay cho nhieu form xep chong
   (In-card tabs replacing stacked forms) */
.ecc-tabs-card { padding: 0; gap: 0; }
.ecc-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 4px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r) var(--r) 0 0;
}
.ecc-tab {
  flex: 1 1 auto;
  min-height: 38px;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.ecc-tab:hover { color: var(--ink); background: var(--surface-3); }
.ecc-tab[aria-selected="true"] {
  color: var(--brand-ink);
  background: var(--surface);
  border-bottom-color: var(--brand);
}
.ecc-tab-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}
.ecc-tab-panel[hidden] { display: none; }

/* Anh thu nho ve bang CSS, khong tai anh ngoai
   (CSS-drawn thumbnail, no external image) */
.ecc-thumb {
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
  border-radius: 4px;
  background: linear-gradient(160deg, #1e293b, #0f172a);
  overflow: hidden;
}
.ecc-thumb::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-40%, -50%);
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent rgba(255, 255, 255, 0.82);
}
.ecc-video-cell { display: flex; align-items: flex-start; gap: 10px; }
.ecc-video-cell > div { min-width: 0; }
.ecc-video-title {
  display: block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* Bang xem truoc lich (Schedule preview) */
.ecc-preview {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.ecc-preview-head { display: grid; gap: 2px; }
.ecc-preview-head strong { font-size: 13.5px; }
.ecc-preview-head .muted { font-size: 12.5px; }
.ecc-preview table { background: var(--surface); border-radius: var(--r-sm); }
.ecc-preview .callout { margin: 0; }


/* Chip khoang thoi gian nhanh (Quick range chips) */
.ecc-range-chips { margin-bottom: 10px; }


/* Bo chon Page de loc video (Page picker for filtering videos) */
.ecc-page-picker { display: grid; gap: 8px; }
.ecc-page-picker[hidden] { display: none; }
.ecc-page-search { position: relative; max-width: 340px; }
.ecc-page-search input { padding-right: 30px; }
.ecc-page-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.ecc-page-clear:hover { background: var(--line-2); color: var(--ink); }
.ecc-page-clear[hidden] { display: none; }

/* Chip Page: kem so video va dau hieu token het han
   (Page chips with video counts and an expired-token marker) */
.ecc-page-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 132px;
  overflow-y: auto;
  padding: 2px;
}
.ecc-page-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 290px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  min-height: 0;
  cursor: pointer;
}
.ecc-page-chip:hover { background: var(--surface-3); border-color: var(--line-2); color: var(--ink); }
.ecc-page-chip[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-ink);
}
.ecc-page-chip .ecc-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ecc-page-chip .chip-count {
  flex: none;
  font-size: 11px;
  font-weight: 750;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ecc-page-chip[aria-pressed="true"] .chip-count { background: var(--surface); color: var(--brand-ink); }
.ecc-page-chip.is-expired { border-color: var(--danger-line); }
.ecc-page-chip.is-expired .ecc-dot { background: var(--danger); }
.ecc-page-chip.is-off { opacity: 0.62; }
.ecc-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
}
.ecc-page-more {
  font-size: 12px;
  color: var(--muted);
  align-self: center;
  padding-left: 4px;
}
/* Ghi đè responsive phải nằm sau nhóm căn chỉnh desktop.
   (Responsive overrides must follow the desktop alignment rules.) */
@media (max-width: 1100px) {
  .sidebar {
    position: static;
    inset: auto;
    width: 100%;
    min-width: 0;
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 18px;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .brand { margin-right: auto; }

  .sidebar .nav {
    width: 100%;
    flex: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar .side-foot {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
    padding: 0;
    border-top: 0;
  }

  .sidebar .side-foot .full { width: auto; }

  .shell {
    width: 100%;
    min-width: 0;
    margin-left: 0;
    padding: 24px;
  }

  .page-header {
    margin: -24px -24px 18px;
    padding: 11px 24px;
  }
}

@media (max-width: 820px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 15;
    padding: 10px 14px;
  }

  .sidebar .brand {
    min-width: 0;
    padding: 10px 0;
    border-bottom: 0;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar .nav,
  .sidebar .side-foot { display: none; }

  .sidebar.nav-open .nav {
    display: grid;
    width: 100%;
    flex: none;
    grid-template-columns: minmax(0, 1fr);
    padding: 8px 0 0;
    gap: 0;
  }

  .sidebar.nav-open .side-foot {
    display: grid;
    width: 100%;
    flex: none;
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
  }

  .sidebar.nav-open .side-foot .full { width: 100%; }

  .shell { padding: 16px; }

  .page-header {
    position: static;
    margin: -16px -16px 16px;
    padding: 11px 16px;
  }

  .page-stack,
  .monetization-dashboard,
  .monetization-report,
  [data-monetization-report-results],
  [data-admin-monetization-report-results] { min-width: 0; }

  .monetization-report-controls,
  .admin-monetization-report-controls { grid-template-columns: minmax(0, 1fr); }

  .monetization-report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .monetization-daily-chart,
  .monetization-daily-chart svg,
  .monetization-daily-table,
  .monetization-daily-table tbody { min-width: 0; }

  .form-grid.two-cols { grid-template-columns: minmax(0, 1fr); }
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 760px) {
  .form-grid.two-cols { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 460px) {
  .sidebar { padding: 8px 12px; }

  .sidebar .brand { gap: 9px; }

  .shell { padding: 12px; }

  .page-header {
    margin: -12px -12px 14px;
    padding: 10px 12px;
  }

  .monetization-report-kpis { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   REDESIGN OVERLAY v1 (2026-09-14) — Modern SaaS light/dark.
   Append-only: ghi đè bằng cascade, xoá block này để rollback.
   Giữ nguyên class/ID -> không phá chức năng JS.
   ============================================================ */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --line: #e5e9f0;
  --line-2: #d3dae4;
  --brand: #0d9488;
  --brand-ink: #0f766e;
  --brand-soft: #ecfdf8;
  --r: 14px;
  --r-sm: 9px;
  --sh-1: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --sh-2: 0 4px 14px rgba(16,24,40,.08);
  --sh-3: 0 18px 40px rgba(16,24,40,.14);
  --grad-brand: linear-gradient(135deg,#0d9488 0%,#0ea5a0 55%,#10b981 100%);
}
[data-theme="dark"] {
  --bg: #0a0f16;
  --surface: #131b26;
  --surface-2: #18212e;
  --surface-3: #1e2836;
  --line: #253040;
  --line-2: #33414f;
  --brand: #2dd4bf;
  --brand-ink: #5eead4;
  --brand-soft: #0e2f2b;
  --grad-brand: linear-gradient(135deg,#0d9488 0%,#14b8a6 60%,#2dd4bf 100%);
}
html, body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { background: var(--bg); color: var(--ink); }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--sh-1);
}
.brand-mark {
  background: var(--grad-brand) !important;
  color: #fff !important;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(13,148,136,.35);
  font-weight: 800;
}
.brand strong { font-weight: 700; letter-spacing: -.2px; }
.nav-group-label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .6px;
  color: var(--muted);
  font-weight: 600;
  margin: 14px 0 6px;
}
.nav-link {
  border-radius: 10px;
  padding: 9px 12px;
  gap: 11px;
  font-weight: 500;
  color: var(--ink-2);
  transition: background .15s, color .15s;
}
.nav-link svg { width: 19px; height: 19px; opacity: .85; }
.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--brand);
}
.nav-link.active svg { opacity: 1; color: var(--brand); }

/* ---- Panels / cards ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  padding: 20px 22px;
  transition: box-shadow .18s, transform .18s;
}
.panel:hover { box-shadow: var(--sh-2); }
.panel-head { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.panel h2 { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }

/* ---- Metric / KPI cards ---- */
.metric-grid { gap: 14px; }
.metric {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  padding: 16px 18px;
  overflow: hidden;
}
.metric::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--grad-brand);
}
.metric span { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.metric strong { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }

/* ---- Buttons ---- */
.primary {
  background: var(--grad-brand);
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 650;
  color: #fff;
  box-shadow: 0 3px 10px rgba(13,148,136,.28);
  transition: filter .15s, transform .05s, box-shadow .15s;
}
.primary:hover { filter: brightness(1.05); box-shadow: 0 5px 16px rgba(13,148,136,.36); }
.primary:active { transform: translateY(1px); }
.ghost {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 9px 15px;
  font-weight: 550;
  color: var(--ink-2);
  transition: background .15s, border-color .15s;
}
.ghost:hover { background: var(--surface-3); border-color: var(--brand); color: var(--ink); }

/* ---- Inputs ---- */
input, textarea, select {
  border-radius: 10px !important;
  border: 1px solid var(--line-2) !important;
  background: var(--surface) !important;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent) !important;
  outline: none !important;
}
label { font-weight: 550; font-size: 13.5px; color: var(--ink-2); }

/* ---- Tables ---- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: auto;
  box-shadow: var(--sh-1);
  background: var(--surface);
}
table { border-collapse: separate; border-spacing: 0; }
th {
  background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); font-weight: 650;
  border-bottom: 1px solid var(--line);
}
td { border-bottom: 1px solid var(--line); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--brand-soft); }
tbody tr:last-child td { border-bottom: none; }

/* ---- Badges / pills ---- */
.badge {
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.good { background: var(--good-soft); color: var(--good); border-color: var(--good-line); }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }

/* ---- Toast ---- */
.toast { border-radius: 12px; box-shadow: var(--sh-3); }

/* ---- Shell spacing ---- */
.shell { gap: 18px; }

/* ============ RESPONSIVE — PC + Mobile đủ mục ============ */
@media (max-width: 820px) {
  .shell { padding: 14px !important; gap: 14px; }
  .panel { padding: 16px !important; border-radius: 12px; }
  .metric strong { font-size: 22px; }
  .nav-toggle { border-radius: 10px; font-weight: 600; }
  /* Bảng cuộn ngang gọn, không tràn trang */
  .table-wrap { border-radius: 12px; -webkit-overflow-scrolling: touch; }
  th, td { white-space: nowrap; }
  /* Nút bấm to hơn cho dễ chạm */
  .primary, .ghost { padding: 11px 16px; font-size: 14px; }
}
@media (max-width: 460px) {
  .shell { padding: 10px !important; }
  .panel { padding: 13px !important; }
  .panel h2 { font-size: 15px; }
  .metric strong { font-size: 20px; }
  .brand small { display: none; }
}
/* ============ END REDESIGN OVERLAY v1 ============ */

/* ============ MOBILE FIX TOÀN BỘ BẢNG (mọi trang) ============ */
@media (max-width: 820px) {
  /* Gỡ cột thao tác bị GHIM ĐÈ lên bảng (sticky) -> cuộn ngang sạch, không chồng lấn */
  .table-wrap td.actions,
  .table-wrap th.actions {
    position: static !important;
    right: auto !important;
    box-shadow: none !important;
    min-width: 0 !important;
    background: transparent !important;
  }
  /* Bảng cuộn ngang mượt: cột giữ chiều rộng tự nhiên, KHÔNG bóp/xuống 3 dòng */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
  .table-wrap table { min-width: max-content; width: auto; }
  .table-wrap th,
  .table-wrap td { white-space: nowrap; }
  .actions-row { flex-wrap: nowrap; }
  /* Form 2 cột -> 1 cột, không tràn trang */
  .split { display: grid !important; grid-template-columns: 1fr !important; gap: 14px; }
  .shell > section,
  .panel { max-width: 100%; }
  /* Không để bất kỳ khối nào đẩy trang trượt ngang */
  html, body { max-width: 100%; overflow-x: hidden; }
  .shell { overflow-x: hidden; }
}
/* ============ END MOBILE FIX ============ */

/* ============ MOBILE PHÒNG THỦ TOÀN BỘ GRID (mọi trang) v2 ============ */
@media (max-width: 640px) {
  /* Mọi layout dạng grid -> 1 cột trên điện thoại, không tràn ngang */
  .metric-grid,
  .analytics-grid,
  .analytics-kpis,
  .analytics-filter-layout,
  .analytics-insight-column,
  .schedule-export-grid,
  .monetization-detail-grid,
  .monetization-kpis,
  .monetization-report-kpis,
  [class*="-grid"],
  [class*="-kpis"] {
    grid-template-columns: 1fr !important;
  }
  /* Không phần tử nào được rộng hơn màn hình */
  .shell, .shell > section, .panel, .panel * {
    min-width: 0 !important;
    max-width: 100%;
  }
  /* Ảnh/thumbnail không tràn */
  img, video, canvas, svg { max-width: 100%; height: auto; }
  /* Filter/segmented xuống dòng gọn */
  .analytics-segmented,
  .analytics-date-range,
  .analytics-filter-actions { flex-wrap: wrap; }
  .analytics-filter-actions .primary,
  .analytics-filter-actions .ghost { width: 100%; }
  /* Dialog/popup vừa màn hình */
  dialog, .facebook-token-editor-dialog { max-width: 94vw; }
}
/* ============ END v2 ============ */

/* ============ MOBILE CARD LAYOUT — dùng chung cho mọi bảng .table-wrap.cards (v5) ============ */
@media (max-width: 820px) {
  .table-wrap.cards { border: none; box-shadow: none; overflow: visible; background: transparent; }
  .table-wrap.cards table,
  .table-wrap.cards tbody,
  .table-wrap.cards tr,
  .table-wrap.cards td { display: block; width: auto; min-width: 0; }
  .table-wrap.cards thead { display: none; }
  .table-wrap.cards tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--sh-1);
    padding: 6px 14px 12px;
    margin-bottom: 12px;
  }
  /* An dong trong / dong phu (empty state, detail bung ra) khoi khung card */
  .table-wrap.cards tbody tr.ecc-log-detail,
  .table-wrap.cards tbody tr.monetization-daily-empty-row { border: none; box-shadow: none; background: transparent; padding: 0; }
  .table-wrap.cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 9px 0 !important;
    border-bottom: 1px solid var(--line) !important;
    white-space: normal !important;
    text-align: right;
  }
  .table-wrap.cards td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 12px; font-weight: 650;
    text-transform: uppercase; letter-spacing: .3px;
    text-align: left; flex: 0 0 auto;
  }
  /* O dau tien = tieu de the (to hon, khong nhan) */
  .table-wrap.cards tbody td:first-child { font-size: 16px; padding-top: 4px !important; }
  .table-wrap.cards tbody td:first-child::before { display: none; }
  .table-wrap.cards tbody td:first-child strong { font-size: 16px; }
  /* O khong co data-label -> khong hien nhan rong */
  .table-wrap.cards td:not([data-label])::before { display: none; }
  /* O thao tac: nut xuong hang, de cham */
  .table-wrap.cards td.actions { display: block; border-bottom: none !important; padding-top: 12px !important; text-align: left; }
  .table-wrap.cards td.actions::before { display: none; }
  .table-wrap.cards td.actions .row-actions,
  .table-wrap.cards td.actions .actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .table-wrap.cards tbody td:last-child { border-bottom: none !important; }
  .table-wrap.cards td .mini-grid { align-items: flex-end; text-align: right; }
  .table-wrap.cards td.actions .mini-grid { align-items: stretch; text-align: left; }
}
/* ============ END v5 (thay v3) ============ */

/* ============ FIX MOBILE LAYOUT FULL-WIDTH (v4) ============ */
@media (max-width: 820px) {
  html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
  /* Sidebar: thanh trên cùng full-width (reset width/inset của desktop) */
  .sidebar {
    position: sticky !important;
    top: 0 !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--line);
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px !important;
    padding: 10px 14px !important;
  }
  .sidebar .brand { flex: 1 1 auto; }
  .sidebar .nav-toggle { flex: 0 0 auto; margin-left: auto; }
  /* Nav mở ra chiếm full hàng dưới */
  .sidebar .nav,
  .sidebar.nav-open .nav,
  .sidebar .side-foot { flex-basis: 100%; }
  /* Nội dung: full-width, không còn khoảng trắng phải */
  .shell {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 14px !important;
  }
  .shell > section,
  .shell > * { max-width: 100%; }
}
/* ============ END v4 ============ */
