:root {
  color-scheme: light;
  font-family: "Be Vietnam Pro", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #253348;
  background: #f5f8fb;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fbfd;
  --line: #e7eef4;
  --line-strong: #d7e2eb;
  --text: #253348;
  --muted: #76859a;
  --primary: #4f8df7;
  --primary-dark: #3675df;
  --success-bg: #e9f8f1;
  --success-text: #2c7a55;
  --warn-bg: #fff7dd;
  --warn-text: #8a6513;
  --danger-bg: #fff0ee;
  --danger-text: #b4473f;
  --blue-bg: #edf4ff;
  --blue-text: #3a6fb8;
  --shadow: 0 16px 42px rgba(33, 48, 70, 0.055);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-weight: 500;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  background:
    linear-gradient(180deg, rgba(229, 239, 255, 0.86) 0, rgba(245, 248, 251, 0.98) 310px),
    var(--bg);
}

body.auth-pending .shell,
body.login-required .shell,
body.authenticated .login-screen {
  display: none;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: var(--primary-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.secondary,
button.icon-button {
  background: #fff;
  color: #243142;
  border-color: var(--line-strong);
}

button.secondary:hover:not(:disabled),
button.icon-button:hover:not(:disabled) {
  background: #f5faf9;
  color: var(--primary-dark);
}

button.wide {
  width: 100%;
}

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

input,
select {
  height: 36px;
  padding: 0 10px;
}

select[multiple] {
  height: auto;
  min-height: 82px;
  padding: 6px;
}

select[multiple] option {
  padding: 6px 8px;
  border-radius: 6px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

textarea {
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

label {
  display: grid;
  gap: 6px;
  color: #526377;
  font-size: 12px;
  font-weight: 750;
}

.field-block {
  display: grid;
  gap: 6px;
}

.field-label {
  color: #526377;
  font-size: 12px;
  font-weight: 750;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.22;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 28% 18%, rgba(79, 141, 247, 0.18), transparent 34%),
    radial-gradient(circle at 78% 72%, rgba(117, 199, 186, 0.16), transparent 32%),
    linear-gradient(180deg, #f7fbff 0%, #eef4fb 100%);
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid rgba(215, 226, 235, 0.88);
  border-radius: 18px;
  padding: 30px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(33, 48, 70, 0.13);
  backdrop-filter: blur(18px);
}

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

.login-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #dbe8f7;
  border-radius: 16px;
  background: #edf4ff;
}

.login-logo img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.login-card h1 {
  margin-top: 3px;
  color: var(--text);
  font-size: 25px;
  font-weight: 800;
}

.login-subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.login-field {
  gap: 8px;
  color: #526277;
  font-size: 13px;
}

.login-field input {
  height: 44px;
  border-radius: 10px;
  padding: 0 13px;
}

.login-submit {
  min-height: 46px;
  border-radius: 10px;
  font-size: 15px;
}

.login-error {
  min-height: 20px;
  color: var(--danger-text);
  font-size: 13px;
  font-weight: 700;
}

.login-footnote {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.login-footnote span {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--primary);
}

.login-footnote p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px 22px 28px;
}

.topbar {
  min-height: 74px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 32px rgba(20, 34, 45, 0.06);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 40;
}

.brand-block {
  min-width: 0;
}

.mobile-brand {
  display: none;
}

.main-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(199, 213, 221, 0.82);
  border-radius: 11px;
  background: rgba(238, 243, 245, 0.82);
}

.main-tab {
  min-height: 38px;
  border-color: transparent;
  border-radius: 8px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.main-tab:hover:not(:disabled) {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
}

.main-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 4px 14px rgba(20, 34, 45, 0.09);
}

.tab-view[hidden] {
  display: none;
}

.messages-view {
  display: grid;
  gap: 14px;
}

.message-content-view {
  display: grid;
  gap: 22px;
}

.message-content-panel {
  min-height: calc(100vh - 112px);
}

.message-content-panel .panel-head {
  align-items: center;
  margin-bottom: 22px;
}

.message-content-panel .panel-head button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
}

.message-content-grid {
  display: grid;
  justify-content: center;
  gap: 28px;
}

.message-content-grid .zalo-phone-shell {
  max-width: 360px;
  margin: 0 auto;
}

.message-content-grid .zalo-phone-chat {
  min-height: 520px;
}

.message-content-grid .zalo-message-bubble p {
  font-size: 13px;
}

.schedule-calendar-view {
  display: grid;
  gap: 22px;
}

.schedule-calendar-panel {
  min-height: calc(100vh - 112px);
}

.schedule-calendar-head {
  align-items: center;
  margin-bottom: 18px;
}

.schedule-calendar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.schedule-calendar-actions button {
  min-height: 38px;
}

.schedule-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.schedule-day {
  min-height: 520px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #dfe9f4;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(248, 251, 255, 0.96)),
    #fbfdff;
}

.schedule-day.today {
  border-color: rgba(79, 141, 247, 0.55);
  background:
    linear-gradient(180deg, rgba(235, 244, 255, 0.96), rgba(255, 255, 255, 0.98)),
    #fff;
  box-shadow: inset 0 0 0 1px rgba(79, 141, 247, 0.12), 0 14px 32px rgba(79, 141, 247, 0.08);
}

.schedule-day header {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  background:
    linear-gradient(135deg, rgba(79, 141, 247, 0.08), rgba(117, 199, 186, 0.08)),
    #f8fbff;
}

.schedule-day header strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-transform: capitalize;
}

.schedule-day header span,
.schedule-day header em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.schedule-day-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

.schedule-event {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #e3edf6;
  border-radius: 8px;
  padding: 8px 9px;
  background:
    linear-gradient(90deg, var(--schedule-accent, #4f8df7) 0 4px, transparent 4px),
    #fff;
  color: var(--text);
  box-shadow: 0 8px 18px rgba(33, 48, 70, 0.035);
  text-align: left;
  white-space: normal;
  cursor: pointer;
}

.schedule-event:hover {
  border-color: color-mix(in srgb, var(--schedule-accent, #4f8df7) 38%, #dfe8f1);
  background:
    linear-gradient(90deg, var(--schedule-accent, #4f8df7) 0 4px, transparent 4px),
    color-mix(in srgb, var(--schedule-accent, #4f8df7) 8%, #fff);
  transform: translateY(-1px);
}

.schedule-event:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--schedule-accent, #4f8df7) 26%, transparent);
  outline-offset: 2px;
}

.schedule-event-pending {
  --schedule-accent: #4f8df7;
}

.schedule-event-poll {
  --schedule-accent: #7c3aed;
}

.schedule-event-image {
  --schedule-accent: #0891b2;
}

.schedule-event-processing {
  --schedule-accent: #d97706;
}

.schedule-event-sent {
  --schedule-accent: #16a34a;
}

.schedule-event-failed {
  --schedule-accent: #dc2626;
}

.schedule-event time {
  min-width: 38px;
  color: var(--schedule-accent, var(--primary-dark));
  font-size: 12px;
  font-weight: 800;
}

.schedule-event strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-event p {
  display: -webkit-box;
  overflow: hidden;
  color: #536176;
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.schedule-event span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-empty {
  border: 1px dashed #dce6ef;
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.schedule-message-modal[hidden] {
  display: none;
}

.schedule-message-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 18px;
}

.schedule-message-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(5px);
}

.schedule-message-dialog {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #dfe8f1;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
}

.schedule-message-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.schedule-message-detail-head {
  display: grid;
  gap: 7px;
  padding: 22px 56px 18px 22px;
  background:
    linear-gradient(135deg, rgba(79, 141, 247, 0.12), rgba(117, 199, 186, 0.12)),
    #f8fbff;
  border-bottom: 1px solid #e5edf7;
}

.schedule-message-detail-head h3 {
  margin: 0;
  color: #172033;
  font-size: 19px;
  line-height: 1.25;
}

.schedule-message-detail-head p {
  color: #65758b;
  font-size: 13px;
}

.schedule-message-type {
  width: fit-content;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eaf3ff;
  color: #0b72e7;
  font-size: 11px;
  font-weight: 850;
}

.schedule-message-type-sent {
  background: #e9f8f1;
  color: #15803d;
}

.schedule-message-type-failed {
  background: #fff0ee;
  color: #b91c1c;
}

.schedule-message-type-processing {
  background: #fff7dd;
  color: #92400e;
}

.schedule-message-type-poll {
  background: #f3e8ff;
  color: #6d28d9;
}

.schedule-message-type-image {
  background: #e6f7fb;
  color: #0e7490;
}

.schedule-message-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 22px 0;
}

.schedule-message-detail-grid div,
.schedule-message-content {
  border: 1px solid #e6eef7;
  border-radius: 10px;
  background: #fbfdff;
}

.schedule-message-detail-grid div {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
}

.schedule-message-detail-grid span,
.schedule-message-content h4 {
  color: #7a8aa0;
  font-size: 11px;
  font-weight: 850;
}

.schedule-message-detail-grid strong {
  min-width: 0;
  color: #243142;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.schedule-message-content {
  display: grid;
  gap: 10px;
  margin: 16px 22px 22px;
  padding: 14px;
}

.schedule-message-content h4 {
  margin: 0;
}

.schedule-message-content p {
  color: #26364d;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.schedule-message-content ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #334155;
  font-size: 13px;
}

.schedule-message-content a {
  width: fit-content;
  color: #0b72e7;
  font-size: 13px;
  font-weight: 800;
}

.schedule-message-error {
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff1f2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 750;
}

.send-history-view {
  display: grid;
  gap: 22px;
}

.send-history-panel {
  min-height: calc(100vh - 112px);
}

.all-log-list {
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.message-schedule-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 20px 24px;
}

.message-schedule-intro h2 {
  margin: 0;
}

.message-schedule-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 560px;
}

.message-schedule-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.message-schedule-control-group {
  display: grid;
  gap: 8px;
}

.message-schedule-control-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.message-schedule-actions,
.message-job-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-schedule-actions {
  position: relative;
  padding-left: 18px;
}

.message-schedule-actions::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22px;
  width: 1px;
  height: calc(100% - 22px);
  min-height: 34px;
  background: #e2e8f0;
}

.message-schedule-actions.v2-job-main-actions {
  justify-content: flex-end;
  margin: 0;
  padding-left: 0;
  padding-top: 0;
  border-top: 0;
  flex-wrap: nowrap;
}

.message-schedule-actions.v2-job-main-actions::before {
  display: none;
}

.message-schedule-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-schedule-actions label {
  min-width: 180px;
  margin: 0;
}

.message-schedule-actions #toggleMessageScheduler {
  background: #0b72e7;
  color: #fff;
  border-color: #0b72e7;
  box-shadow: 0 4px 12px rgba(11, 114, 231, 0.18);
}

.message-schedule-actions #toggleMessageScheduler:hover {
  background: #095fc2;
  border-color: #095fc2;
}

.message-schedule-actions #toggleMessageScheduler.secondary {
  background: #fff;
  color: #475569;
  border-color: #dfe8f1;
  box-shadow: none;
}

.message-schedule-actions #toggleMessageScheduler.secondary:hover {
  background: #f1f5f9;
  color: #0b72e7;
}

.schedule-mode-tabs {
  display: inline-flex;
  width: fit-content;
  gap: 4px;
  border: 1px solid #dfe8f1;
  border-radius: 10px;
  padding: 4px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.045);
}

.schedule-mode-tab {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: #5e6f86;
  box-shadow: none;
  font-size: 13px;
  font-weight: 850;
}

.schedule-mode-tab:hover:not(:disabled) {
  background: #f4f8fd;
  color: #0b72e7;
}

.schedule-mode-tab.active {
  background: #eaf3ff;
  color: #0b72e7;
}

.schedule-mode-tab .lucide-icon {
  width: 17px;
  height: 17px;
}

.schedule-mode-view {
  display: grid;
  gap: 14px;
}

.message-selected-target {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.message-stats {
  margin: 0;
}

.message-jobs-panel {
  padding: 24px;
}

.message-jobs-head {
  margin-bottom: 16px;
}

.message-job-filters select {
  width: 140px;
}

.message-job-filters input {
  width: min(280px, 38vw);
}

.message-jobs-table {
  min-height: 340px;
  max-height: 510px;
}

.message-jobs-table th:first-child,
.message-jobs-table td:first-child {
  width: auto;
}

.message-job-actions {
  display: flex;
  gap: 6px;
}

.message-job-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.message-job-running-row {
  background: #f8fbff;
}

.message-progress {
  display: grid;
  gap: 7px;
  min-width: 190px;
}

.message-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.message-progress-head strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.message-progress-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eef8;
}

.message-progress-bar span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}

.message-progress-label {
  max-width: 280px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-stop-button {
  border-color: var(--danger-text);
  background: var(--danger-bg);
  color: var(--danger-text);
  box-shadow: none;
}

.message-stop-button:hover:not(:disabled) {
  background: #ffe4e1;
  color: var(--danger-text);
}

.message-run-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.7fr);
  gap: 14px;
}

.message-runs-table {
  min-height: 230px;
  max-height: 330px;
}

.message-run-log {
  min-height: 230px;
  max-height: 330px;
  margin: 0;
  overflow: auto;
  border-radius: 10px;
  padding: 12px;
  background: #12202b;
  color: #d7ecf0;
  white-space: pre-wrap;
  font: 12px/1.5 Consolas, monospace;
}

.group-messages-view {
  display: grid;
  gap: 14px;
}

.group-messages-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.group-messages-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.group-message-controls {
  display: flex;
  align-items: end;
  gap: 8px;
}

.group-message-controls label {
  width: min(420px, 42vw);
  margin: 0;
}

.group-message-search {
  width: min(320px, 38vw);
  margin: 0;
}

.group-messages-table-wrap {
  min-height: 460px;
  max-height: calc(100vh - 330px);
}

.group-messages-table th:first-child,
.group-messages-table td:first-child {
  width: 150px;
  text-align: left;
}

.group-message-sender {
  display: grid;
  gap: 3px;
  min-width: 145px;
}

.group-message-sender small,
.group-message-content small {
  color: var(--muted);
  display: block;
  margin-top: 5px;
}

.group-message-content {
  min-width: 260px;
  max-width: 620px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.group-message-row-actions {
  display: flex;
  gap: 6px;
  min-width: 190px;
}

.group-message-row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.group-message-row-actions .kick-member {
  border-color: #e8b5af;
  background: #fff;
  color: var(--danger-text);
}

.group-messages-footer {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.top-actions,
.table-actions,
.zalo-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.profile-wrap {
  position: relative;
}

.profile-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid rgba(199, 213, 221, 0.82);
  border-radius: 12px;
  padding: 7px 10px 7px 7px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(20, 34, 45, 0.06);
}

.profile-card:hover:not(:disabled) {
  border-color: var(--primary);
  background: #fff;
}

.profile-card[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.profile-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e8eef4;
  color: #425166;
  font-size: 13px;
  font-weight: 850;
}

.profile-initial.large {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.profile-initial img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  object-fit: cover;
}

.profile-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.profile-name {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-status {
  color: var(--warn-text);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.profile-status.success {
  color: var(--success-text);
}

.profile-status.danger {
  color: var(--danger-text);
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  width: 286px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 18px 54px rgba(20, 34, 45, 0.16);
}

.profile-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f5;
}

.profile-menu-head strong {
  display: block;
  font-size: 14px;
}

.profile-menu-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.profile-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f4f6;
  color: var(--muted);
  font-size: 12px;
}

.profile-detail-row strong {
  color: var(--text);
  font-size: 12px;
  text-align: right;
}

.profile-password-section {
  display: grid;
  gap: 8px;
  border-top: 1px solid #edf2f5;
  padding-top: 10px;
}

.profile-password-section label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.profile-password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.profile-password-row input {
  min-width: 0;
}

.profile-password-row button {
  min-height: 36px;
  padding: 0 12px;
}

.profile-account-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #edf2f5;
}

.profile-account-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.profile-account-title button {
  min-height: 28px;
  padding: 0 10px;
  border-color: var(--line-strong);
  background: #fff;
  color: var(--primary-dark);
  font-size: 12px;
}

.profile-account-list {
  display: grid;
  gap: 7px;
  max-height: 210px;
  overflow: auto;
}

.profile-account-item {
  display: grid;
  gap: 7px;
  border: 1px solid #e2eaef;
  border-radius: 9px;
  padding: 9px;
  background: #fbfcfd;
}

.profile-account-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.profile-account-main strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.profile-account-main span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.profile-account-active {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 11px;
  font-weight: 850;
}

.profile-account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.profile-account-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.profile-account-actions .danger-action {
  border-color: var(--danger-bg);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.profile-menu-secondary,
.profile-menu-logout {
  width: 100%;
  margin-top: 10px;
}

.profile-menu-secondary {
  border-color: var(--line-strong);
  background: #fff;
  color: #243142;
}

.profile-menu-secondary:hover:not(:disabled) {
  background: #f5faf9;
  color: var(--primary-dark);
}

.profile-menu-logout {
  border-color: var(--danger-bg);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.profile-menu-logout:hover:not(:disabled) {
  border-color: var(--danger-text);
  background: #ffd8d3;
  color: var(--danger-text);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.neutral {
  background: #e8eef4;
  color: #425166;
}

.badge.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.workspace,
.control-rail {
  display: grid;
  gap: 14px;
}

.control-rail {
  position: sticky;
  top: 14px;
}

.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.compact-head {
  align-items: flex-start;
}

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

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 7px;
}

.metric strong {
  display: block;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(145px, 0.7fr) minmax(130px, 0.7fr) minmax(120px, 0.55fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  border: 1px solid #e5edf1;
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-soft);
}

.filter-bar select,
.filter-bar .multi-select summary,
.filter-bar .multi-select summary span {
  font-weight: 500;
}

.search-block {
  min-width: 0;
}

.multi-select {
  position: relative;
  min-width: 0;
}

.multi-select summary {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  outline: none;
}

.multi-select summary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select summary::-webkit-details-marker {
  display: none;
}

.multi-select summary::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid #7b8998;
  border-bottom: 2px solid #7b8998;
  transform: rotate(45deg) translateY(-2px);
}

.multi-select[open] summary {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.multi-select[open] summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 25;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 16px 44px rgba(20, 34, 45, 0.16);
}

.multi-select-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.multi-select-option:hover {
  background: #f5faf9;
}

.multi-select-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
}

.table-wrap {
  max-height: calc(100vh - 300px);
  min-height: 410px;
  overflow: auto;
  border: 1px solid #e2eaef;
  border-radius: 10px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #edf2f5;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfb;
  color: #526377;
  font-size: 12px;
  font-weight: 850;
}

tbody tr:hover {
  background: #f5fbfa;
}

td:first-child,
th:first-child {
  width: 42px;
  text-align: center;
}

.group-name {
  display: grid;
  gap: 3px;
}

.group-name strong {
  max-width: 390px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.status-select {
  min-width: 164px;
}

.role-pill,
.chat-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.role-owner {
  background: #fce8d5;
  color: #8a4600;
}

.role-admin {
  background: var(--blue-bg);
  color: var(--blue-text);
}

.role-member {
  background: #eef2f4;
  color: #536274;
}

.chat-open {
  background: var(--success-bg);
  color: var(--success-text);
}

.chat-admin_only {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.zalo-panel,
.action-panel,
.message-panel {
  display: grid;
  gap: 10px;
}

.selected-group-title {
  border-top: 1px solid #edf2f5;
  padding-top: 10px;
  color: #526377;
  font-size: 12px;
  font-weight: 850;
}

.selected-group-list {
  display: grid;
  gap: 7px;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #e2eaef;
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-soft);
}

.selected-group-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #dce6eb;
  border-radius: 8px;
  padding: 8px 8px 8px 10px;
  background: #fff;
}

.selected-group-item strong,
.selected-group-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-group-item strong {
  color: var(--text);
  font-size: 13px;
}

.selected-group-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.selected-group-remove {
  width: 30px;
  min-height: 30px;
  border-color: #f4c7c1;
  border-radius: 999px;
  padding: 0;
  background: #fff;
  color: var(--danger-text);
  font-size: 20px;
  line-height: 1;
}

.selected-group-remove:hover:not(:disabled) {
  border-color: var(--danger-text);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.chat-action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pin-message-toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.pin-message-toggle input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
}

.composer-preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 14px;
  align-items: start;
}

.composer-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.zalo-phone-preview {
  min-width: 0;
}

.zalo-phone-shell {
  overflow: hidden;
  border: 1px solid #d8e2eb;
  border-radius: 22px;
  padding: 8px;
  background: #1f2937;
  box-shadow: 0 16px 36px rgba(33, 48, 70, 0.13);
}

.zalo-phone-bar {
  height: 42px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  border-radius: 16px 16px 0 0;
  padding: 0 10px;
  background: #f7fbff;
}

.zalo-phone-bar span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #64a1ff;
  box-shadow: 8px 0 0 #b7d2ff;
}

.zalo-phone-bar strong {
  color: #253348;
  font-size: 12px;
  font-weight: 800;
}

.zalo-phone-bar em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

.zalo-phone-chat {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 9px;
  border-radius: 0 0 16px 16px;
  padding: 12px 10px;
  background:
    linear-gradient(180deg, rgba(237, 244, 255, 0.78), rgba(248, 251, 253, 0.96)),
    #f8fbfd;
}

.zalo-pin-preview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 8px;
  background: #fff7dd;
  color: #8a6513;
  font-size: 10px;
  font-weight: 700;
}

.zalo-pin-preview .lucide-icon {
  width: 12px;
  height: 12px;
}

.zalo-message-bubble {
  display: grid;
  gap: 8px;
  max-width: 100%;
  justify-self: end;
  border-radius: 16px 16px 4px 16px;
  padding: 9px;
  background: #dff0ff;
  color: #1f3148;
  box-shadow: 0 8px 18px rgba(79, 141, 247, 0.12);
}

.zalo-message-bubble p {
  min-height: 18px;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.zalo-message-bubble time {
  justify-self: end;
  color: #66758b;
  font-size: 10px;
}

.zalo-message-image {
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
}

.zalo-message-image img {
  display: block;
  width: 100%;
  max-height: 170px;
  object-fit: cover;
}

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

.message-image-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.message-image-button {
  min-height: 42px;
  border: 2px dashed #0071ff;
  background: #f0f7ff;
  color: #0071ff;
  font-weight: 800;
}

.message-image-button:hover {
  background: #e6f0ff;
}

.message-image-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-image-remove {
  flex: 0 0 auto;
  border: 0;
  padding: 4px;
  background: transparent;
  color: #b42318;
}

.message-image-preview {
  overflow: hidden;
  max-height: 220px;
  border: 1px solid #dce6eb;
  border-radius: 10px;
  background: #f7fafb;
}

.message-image-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
}

@media (max-width: 520px) {
  .composer-preview-grid {
    grid-template-columns: 1fr;
  }

  .zalo-phone-shell {
    max-width: 260px;
    margin: 0 auto;
  }

  .message-image-row {
    grid-template-columns: 1fr auto;
  }

  .message-image-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

.qr-box {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px dashed #b9cbd4;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(37, 99, 235, 0.04)),
    #fbfdfd;
}

.qr-box img {
  width: 172px;
  height: 172px;
  image-rendering: crisp-edges;
  border: 10px solid #fff;
  border-radius: 9px;
  box-shadow: 0 12px 34px rgba(20, 34, 45, 0.14);
}

.qr-placeholder {
  width: 172px;
  min-height: 172px;
  display: grid;
  place-items: center;
  border: 1px solid #dce6eb;
  border-radius: 9px;
  padding: 16px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.zalo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.zalo-actions.connected {
  grid-template-columns: 1fr;
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.log-item {
  border: 1px solid #e2eaef;
  border-radius: 9px;
  background: #fbfcfd;
  overflow: hidden;
}

.log-item summary {
  display: grid;
  gap: 4px;
  padding: 10px;
  cursor: pointer;
  list-style: none;
}

.log-item summary::-webkit-details-marker {
  display: none;
}

.log-item summary strong {
  display: block;
  font-size: 13px;
}

.log-item summary span,
.log-item summary em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.log-message-detail {
  display: grid;
  gap: 8px;
  border-top: 1px solid #e2eaef;
  padding: 10px;
  background: #fff;
}

.log-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.log-detail-row span {
  color: var(--muted);
}

.log-message-content {
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #e2eaef;
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfd;
  font-size: 12px;
  line-height: 1.45;
}

.empty {
  padding: 38px 16px;
  text-align: center;
  color: var(--muted);
}

.compact-empty {
  padding: 12px;
  border: 1px dashed #d7e3e9;
  border-radius: 8px;
  background: #fbfcfd;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: none;
  max-width: 420px;
  border-radius: 9px;
  padding: 12px 14px;
  background: #17202b;
  color: #fff;
  box-shadow: 0 16px 44px rgba(24, 33, 47, 0.24);
  font-size: 13px;
}

.toast.show {
  display: block;
}

.toast.error {
  background: var(--danger-text);
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(238, 243, 245, 0.72);
  backdrop-filter: blur(3px);
}

.loading.active {
  display: flex;
}

.loading-card {
  min-width: 300px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(31, 42, 55, 0.18);
}

.loading-card p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d5e2df;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .control-rail {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .log-panel {
    grid-column: 1 / -1;
  }

  .table-wrap {
    max-height: none;
  }

  .message-run-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .filter-bar,
  .stats-grid,
  .control-rail {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head,
  .top-actions,
  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .main-tabs {
    width: 100%;
  }

  .main-tab {
    flex: 1;
  }

  .message-schedule-toolbar,
  .message-jobs-head,
  .message-schedule-controls,
  .message-schedule-actions,
  .message-job-filters,
  .group-messages-toolbar,
  .group-message-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .message-schedule-controls {
    flex-wrap: nowrap;
  }

  .message-schedule-control-group {
    width: 100%;
  }

  .message-schedule-actions {
    padding-left: 0;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
  }

  .message-schedule-actions::before {
    display: none;
  }

  .message-schedule-action-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .message-schedule-actions label,
  .message-schedule-controls,
  .message-job-filters select,
  .message-job-filters input {
    width: 100%;
  }

  .group-message-controls label,
  .group-message-search {
    width: 100%;
  }

  .profile-card {
    width: 100%;
  }

  .profile-menu {
    left: 0;
    right: auto;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 12px;
  }

  .login-card,
  .panel {
    padding: 14px;
  }

  .stats-grid {
    gap: 8px;
  }

  .zalo-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    background:
      linear-gradient(180deg, rgba(210, 239, 234, 0.92) 0, rgba(238, 243, 245, 0.98) 220px),
      var(--bg);
  }

  .shell {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .topbar {
    min-height: 0;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    padding: 12px;
  }

  .app-layout {
    gap: 10px;
  }

  .main-tabs {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .main-tabs::-webkit-scrollbar {
    display: none;
  }

  .main-tab {
    min-width: max-content;
    min-height: 42px;
    padding: 0 12px;
    font-size: 13px;
  }

  .notification-button {
    display: none;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
  }

  .top-actions .icon-button {
    width: 42px;
    min-height: 44px;
    padding: 0 10px;
  }

  .profile-wrap {
    min-width: 0;
  }

  .profile-card {
    width: 100%;
    min-height: 44px;
    gap: 8px;
    padding: 6px 8px;
  }

  .profile-copy {
    min-width: 0;
  }

  .profile-name {
    max-width: 100%;
  }

  .profile-status {
    white-space: normal;
    line-height: 1.2;
  }

  .profile-menu {
    position: fixed;
    top: 78px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(100vh - 90px);
    overflow: auto;
  }

  .profile-account-actions {
    grid-template-columns: 1fr 1fr;
  }

  .profile-detail-row {
    align-items: flex-start;
  }

  .profile-detail-row strong {
    min-width: 0;
    word-break: break-word;
  }

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

  .metric {
    min-height: 86px;
    padding: 12px;
  }

  .metric span {
    min-height: 30px;
    margin-bottom: 6px;
    line-height: 1.25;
  }

  .metric strong {
    font-size: 23px;
  }

  .workspace,
  .control-rail {
    gap: 10px;
  }

  .panel {
    border-radius: 10px;
    padding: 12px;
  }

  .panel-head {
    gap: 8px;
    margin-bottom: 10px;
  }

  .filter-bar {
    gap: 9px;
    margin-bottom: 10px;
    border-radius: 9px;
    padding: 10px;
  }

  .multi-select-menu {
    z-index: 70;
  }

  button {
    min-height: 42px;
  }

  input,
  select {
    height: 42px;
  }

  .multi-select summary {
    height: 42px;
  }

  input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  .table-wrap {
    min-height: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    font-size: 13px;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    border: 1px solid #e2eaef;
    border-radius: 12px;
    padding: 10px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(20, 34, 45, 0.06);
  }

  .message-jobs-data tbody tr,
  .message-runs-data tbody tr,
  .group-messages-data tbody tr {
    padding: 10px 12px;
  }

  tbody tr:hover {
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #edf2f5;
    padding: 9px 0;
    overflow-wrap: anywhere;
  }

  td:last-child {
    border-bottom: 0;
  }

  td:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 0 6px;
    border-bottom: 0;
    text-align: right;
  }

  td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
  }

  td > * {
    min-width: 0;
  }

  td:first-child::before {
    content: "Chọn nhóm";
  }

  td[colspan] {
    display: block;
    padding: 0;
    border-bottom: 0;
    text-align: center;
  }

  td:nth-child(2)::before {
    content: "Nhóm";
  }

  td:nth-child(3)::before {
    content: "Thành viên";
  }

  td:nth-child(4)::before {
    content: "Vai trò";
  }

  td:nth-child(5)::before {
    content: "Trạng thái";
  }

  td:nth-child(6)::before {
    content: "Cập nhật";
  }

  .group-name strong {
    max-width: none;
    white-space: normal;
  }

  .status-select {
    width: 100%;
    min-width: 0;
  }

  .message-schedule-actions button,
  .group-message-controls button,
  .message-job-actions button {
    width: 100%;
  }

  .message-selected-target {
    justify-content: center;
    min-height: 34px;
    border: 1px solid #e2eaef;
    border-radius: 7px;
    background: #fff;
  }

  .message-job-actions,
  .group-message-row-actions {
    display: grid;
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .group-message-sender,
  .group-message-content {
    min-width: 0;
    max-width: none;
  }

  .message-run-log {
    min-height: 180px;
    max-height: 300px;
    font-size: 12px;
  }

  .groups-table td:first-child::before {
    content: "Chọn nhóm";
  }

  .groups-table td:nth-child(2) {
    display: none;
  }

  .groups-table td:nth-child(3)::before {
    content: "Nhóm";
  }

  .groups-table td:nth-child(3) .group-name {
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  .groups-table .group-avatar {
    width: 36px;
    height: 36px;
  }

  .groups-table .group-copy strong {
    white-space: normal;
  }

  .groups-table td:nth-child(4)::before {
    content: "Thành viên";
  }

  .groups-table td:nth-child(5)::before {
    content: "Vai trò";
  }

  .groups-table td:nth-child(6)::before {
    content: "Chat";
  }

  .groups-table .chat-toggle {
    width: auto;
    min-height: 36px;
  }

  .groups-table td:nth-child(7) {
    display: none;
  }

  .message-jobs-data td:first-child::before {
    content: "Row";
  }

  .message-jobs-data td:nth-child(2)::before {
    content: "Tài khoản";
  }

  .message-jobs-data td:nth-child(3)::before {
    content: "Lịch gửi";
  }

  .message-jobs-data td:nth-child(4)::before {
    content: "Type";
  }

  .message-jobs-data td:nth-child(5)::before {
    content: "Nội dung";
  }

  .message-jobs-data td:nth-child(6)::before {
    content: "Poll";
  }

  .message-jobs-data td:nth-child(7)::before {
    content: "Trạng thái";
  }

  .message-jobs-data td:nth-child(8)::before {
    content: "Thao tác";
  }

  .message-runs-data td:first-child::before {
    content: "ID";
  }

  .message-runs-data td:nth-child(2)::before {
    content: "Trạng thái";
  }

  .message-runs-data td:nth-child(3)::before {
    content: "Tài khoản";
  }

  .message-runs-data td:nth-child(4)::before {
    content: "Row";
  }

  .message-runs-data td:nth-child(5)::before {
    content: "Bắt đầu";
  }

  .group-messages-data td:first-child::before {
    content: "Thời gian";
  }

  .group-messages-data td:nth-child(2)::before {
    content: "Người gửi";
  }

  .group-messages-data td:nth-child(3)::before {
    content: "Loại";
  }

  .group-messages-data td:nth-child(4)::before {
    content: "Nội dung";
  }

  .group-messages-data td:nth-child(5)::before {
    content: "Thao tác";
  }

  .qr-box {
    min-height: 170px;
  }

  .qr-placeholder,
  .qr-box img {
    width: min(172px, 100%);
  }

  .action-panel textarea,
  .message-panel textarea {
    min-height: 128px;
  }

  .log-list {
    max-height: none;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
    max-width: none;
  }

  .loading-card {
    width: calc(100% - 24px);
    min-width: 0;
  }
}

@media (max-width: 380px) {
  .top-actions {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .profile-menu {
    top: 126px;
  }

  .profile-account-actions {
    grid-template-columns: 1fr;
  }

  td {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

/* Dashboard overview refresh */
body {
  background:
    radial-gradient(circle at 78% 18%, rgba(15, 118, 110, 0.07), transparent 32%),
    linear-gradient(180deg, #fbfcff 0%, #f5f8fb 100%);
}

.shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 0;
  margin: 0;
  padding: 0;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  padding: 30px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid #edf2f5;
  box-shadow: 16px 0 48px rgba(20, 34, 45, 0.04);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #0071ff;
  font-size: 18px;
  font-weight: 900;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #eef5ff;
  color: #0071ff;
  font-size: 20px;
  overflow: hidden;
}

.brand-mark img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.sidebar-nav {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.sidebar-nav .main-tab {
  width: 100%;
  justify-content: flex-start;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 0;
  border-radius: 9px;
  padding: 0 14px;
  color: #58677b;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
}

.sidebar-nav .main-tab i,
.sidebar-nav .main-tab span {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  text-align: center;
  color: #53647a;
}

.lucide-icon {
  width: 19px;
  height: 19px;
  display: block;
  stroke-width: 2;
}

.sidebar-nav .main-tab.active {
  background: linear-gradient(90deg, #e6f0ff, #eef5ff);
  color: #005bb5;
  box-shadow: none;
}

.sidebar-nav .main-tab.active i,
.sidebar-nav .main-tab.active span {
  color: #0071ff;
}

.sidebar-nav .ghost-tab {
  opacity: 1;
  background: transparent;
  cursor: default;
}

.upgrade-card {
  display: grid;
  gap: 10px;
  border-radius: 14px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(228, 248, 241, 0.95), rgba(247, 252, 250, 0.95)),
    #eef5ff;
  color: #17202b;
}

.upgrade-illustration {
  width: min(136px, 100%);
  height: auto;
  justify-self: center;
  margin: -6px 0 2px;
  object-fit: contain;
}

.upgrade-card strong {
  font-size: 14px;
}

.upgrade-card p {
  color: #66768b;
  font-size: 12px;
  line-height: 1.5;
}

.upgrade-card button {
  margin-top: 6px;
  background: #0071ff;
  border-color: #0071ff;
}

.app-main {
  min-width: 0;
  padding: 10px 15px 34px;
}

.topbar {
  min-height: 58px;
  margin: 0 0 24px;
  padding: 15px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  z-index: 80;
}

.brand-block h1 {
  color: #151b2d;
  font-size: 24px;
  font-weight: 900;
}

.brand-block p {
  margin-top: 8px;
  color: #64748b;
  font-size: 14px;
}

.top-actions {
  gap: 12px;
}

.refresh-button,
.notification-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #142033;
  font-size: 18px;
}

.refresh-button i,
.notification-button i {
  display: inline-grid;
  place-items: center;
}

.refresh-button .lucide-icon,
.notification-button .lucide-icon {
  width: 18px;
  height: 18px;
}

.notification-button:disabled {
  opacity: 1;
}

.profile-card {
  min-height: 44px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.profile-initial {
  background: #eef1f5;
  color: #111827;
}

.profile-status {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border-radius: 999px;
  padding: 1px 7px;
  background: #e6f0ff;
  color: #005bb5;
  font-size: 10px;
}

.app-layout {
  grid-template-columns: minmax(0, 1fr) 356px;
  gap: 24px;
  align-items: start;
}

.workspace,
.control-rail {
  gap: 22px;
}

.control-rail {
  top: 28px;
}

.panel,
.metric {
  border: 1px solid #edf2f5;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 52px rgba(17, 24, 39, 0.06);
}

.panel {
  padding: 22px;
}

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

.metric {
  position: relative;
  min-height: 118px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-areas:
    "icon label"
    "icon value"
    "icon unit";
  align-content: center;
  column-gap: 18px;
  padding: 18px 20px;
}

.metric::before {
  content: "●";
  grid-area: icon;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 999px;
  background: #e6f0ff;
  color: #0071ff;
  font-size: 24px;
}

.metric-open::before,
.metric-selected::before {
  background: #e6f0ff;
  color: #0071ff;
}

.metric-closed::before {
  background: #fff1f2;
  color: #dc2626;
}

.metric-total::before {
  content: none;
}

.metric-total i[data-lucide],
.metric-total .lucide-icon {
  grid-area: icon;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 999px;
  background: #e6f0ff;
  color: #0071ff;
}

.metric-total .lucide-icon {
  width: 26px;
  height: 26px;
}

.metric span {
  grid-area: label;
  margin: 0;
  color: #63718a;
  font-size: 13px;
  font-weight: 750;
}

.metric strong {
  grid-area: value;
  margin-top: 3px;
  color: #101827;
  font-size: 25px;
  font-weight: 900;
}

.metric em {
  grid-area: unit;
  color: #64748b;
  font-size: 12px;
  font-style: normal;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head h2 {
  color: #121827;
  font-size: 18px;
  font-weight: 900;
}

.panel-head p {
  color: #68778f;
}

.filter-bar {
  grid-template-columns: minmax(260px, 1fr) minmax(170px, 0.32fr) minmax(170px, 0.32fr) 120px;
  gap: 12px;
  margin-bottom: 14px;
  border: 0;
  padding: 0;
  background: transparent;
}

input,
select,
textarea,
.multi-select summary {
  border-color: #dfe7ee;
  border-radius: 8px;
}

input,
select,
.multi-select summary {
  height: 40px;
}

.table-wrap {
  min-height: 0;
  max-height: none;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
}

table {
  font-size: 13px;
}

th {
  position: static;
  height: 44px;
  background: #f9fbfd;
  color: #65748a;
  font-size: 12px;
}

td {
  height: 64px;
  color: #243145;
}

tbody tr:hover {
  background: #fbfefd;
}

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

.group-avatar {
  width: 34px;
  height: 34px;
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(145deg, #e6f0ff, #eef5ff);
  color: #005bb5;
  border: 1px solid #e3edf2;
  font-size: 13px;
  font-weight: 900;
}

.group-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.group-avatar-letter {
  display: none;
}

.group-avatar.avatar-error .group-avatar-letter {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
}

.group-avatar-fallback {
  background: linear-gradient(145deg, #0f9f7a, #2563eb);
  color: #fff;
}

.group-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.group-name strong {
  max-width: 360px;
  color: #1f2937;
  font-size: 13px;
  font-weight: 900;
}

.role-pill {
  height: 26px;
  border-radius: 8px;
}

.role-owner,
.role-admin {
  background: #e6f0ff;
  color: #005bb5;
}

.role-member {
  background: #eef5ff;
  color: #2563eb;
}

.status-select {
  min-width: 116px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  color: #005bb5;
  background: #e6f0ff;
  font-size: 12px;
  font-weight: 850;
}

.status-select.status-admin_only {
  color: #dc2626;
  background: #fff1f2;
}

.chat-pill {
  height: 24px;
  border-radius: 8px;
}

.action-panel {
  gap: 18px;
  padding: 24px;
}

.selected-group-title {
  display: block;
  border-top: 1px solid #eef2f6;
  padding-top: 12px;
  color: #17202b;
  font-size: 13px;
  font-weight: 900;
}

.selected-group-list {
  display: grid;
  max-height: 168px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-action-buttons {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chat-action-buttons button {
  min-height: 46px;
  border-radius: 8px;
}

#closeBulkChat {
  border-color: #fecaca;
  background: #fff1f2;
  color: #dc2626;
}

#openBulkChat {
  border-color: #d7f3e5;
  background: #e6f0ff;
  color: #0071ff;
}

.pin-message-toggle {
  border: 0;
  min-height: 28px;
  padding: 0;
  background: transparent;
}

.composer-section-title {
  padding-top: 12px;
  border-top: 1px solid #eef2f6;
  color: #17202b;
  font-size: 13px;
  font-weight: 900;
}

.action-panel textarea {
  min-height: 132px;
  resize: vertical;
}

.message-image-row {
  grid-template-columns: 1fr;
  border: 1px dashed #cfdbe6;
  border-radius: 10px;
  padding: 14px;
  background: #fbfdff;
  text-align: center;
}

.message-image-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #0071ff;
}

.message-image-name {
  text-align: center;
}

.muted-toggle {
  color: #314256;
  font-size: 12px;
}

#sendBulkMessage {
  min-height: 50px;
  border-radius: 8px;
  background: #0071ff;
  border-color: #0071ff;
  font-size: 15px;
}

.zalo-panel {
  order: 2;
}

.log-panel {
  box-shadow: 0 14px 42px rgba(17, 24, 39, 0.04);
}

.log-list {
  max-height: none;
}

.log-item {
  border: 0;
  border-top: 1px solid #eef2f6;
  border-radius: 0;
  background: transparent;
}

.log-item:first-child {
  border-top: 0;
}

.log-item summary {
  grid-template-columns: 180px minmax(0, 1fr) auto;
  align-items: center;
  padding: 12px 0;
}

.log-item summary strong {
  font-size: 13px;
}

.log-item summary span,
.log-item summary em {
  font-size: 12px;
}

@media (max-width: 1280px) {
  .shell {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .app-sidebar {
    padding: 24px 18px;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 900px) {
  .shell {
    display: block;
  }

  .app-sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto;
    gap: 14px;
    padding: 14px;
  }

  .sidebar-brand {
    justify-content: center;
  }

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

  .upgrade-card {
    display: none;
  }

  .app-main {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    gap: 14px;
  }

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

  .filter-bar {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .app-main {
    padding: 12px;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .top-actions {
    grid-template-columns: 44px 44px minmax(0, 1fr);
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 96px;
  }

  .chat-action-buttons {
    grid-template-columns: 1fr;
  }
}

/* Zalo Auto Sender reference polish */
.shell {
  grid-template-columns: 292px minmax(0, 1fr);
  background: #fbfcfe;
}

.app-sidebar {
  padding: 30px 32px;
  background: rgba(255, 255, 255, 0.96);
}

.sidebar-brand {
  margin-bottom: 18px;
}

.app-main {
  padding: 32px 34px 34px;
}

.topbar {
  margin-bottom: 28px;
}

.app-layout {
  grid-template-columns: minmax(0, 1fr) 384px;
  gap: 28px;
}

.workspace,
.control-rail {
  gap: 24px;
}

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

.metric {
  min-height: 116px;
  border: 0;
  border-radius: 8px;
  padding: 18px 22px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.055);
}

.metric:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 24px;
  right: -8px;
  width: 1px;
  height: 68px;
  background: #eef2f6;
}

.metric::before {
  content: none;
}

.metric-icon {
  grid-area: icon;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 999px;
  background: #eef4ff;
  color: #2563eb;
}

.metric-icon .lucide-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  stroke-width: 3;
}

.metric-open .metric-icon,
.metric-selected .metric-icon {
  background: #e6f0ff;
  color: #0071ff;
}

.metric-closed .metric-icon {
  background: #fff1f2;
  color: #dc2626;
}

.metric span {
  color: #667085;
  font-size: 13px;
}

.metric strong {
  font-size: 25px;
}

.panel {
  border: 0;
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.055);
}

.group-panel {
  padding: 22px 22px 14px;
}

.panel-head {
  margin-bottom: 0;
}

.last-updated {
  margin-top: 4px;
  color: #68778f;
  font-size: 12px;
}

.add-group-button {
  width: 128px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 8px;
  background: #0071ff;
  box-shadow: 0 10px 22px rgba(5, 150, 105, 0.2);
}

.filter-bar {
  grid-template-columns: minmax(270px, 1fr) 210px 210px 46px;
  align-items: center;
  margin: 18px 0 12px;
}

.member-filter-field {
  display: none;
}

.filter-tools-button {
  width: 46px;
  min-height: 40px;
  border: 1px solid #dfe7ee;
  border-radius: 8px;
  background: #fff;
  color: #344054;
}

.search-block {
  position: relative;
}

.search-block::before {
  content: "⌕";
  position: absolute;
  left: 13px;
  top: 50%;
  z-index: 1;
  color: #7b8796;
  transform: translateY(-50%);
}

.search-block input {
  padding-left: 36px;
}

.table-wrap {
  border-radius: 8px;
  max-height: calc(100vh - 365px);
  overflow: auto;
}

.groups-table th,
.groups-table td {
  padding: 11px 13px;
}

.groups-table th:first-child,
.groups-table td:first-child {
  width: 44px;
}

.groups-table th:nth-child(2),
.groups-table td:nth-child(2) {
  width: 44px;
  color: #667085;
}

.groups-table th:nth-child(3),
.groups-table td:nth-child(3) {
  width: 32%;
}

.row-index {
  font-weight: 750;
}

.chat-toggle {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #0071ff;
  font-size: 12px;
  font-weight: 850;
  box-shadow: none;
}

.chat-toggle:hover:not(:disabled) {
  background: transparent;
  color: #005bb5;
}

.chat-toggle-admin_only {
  color: #dc2626;
}

.chat-toggle-admin_only:hover:not(:disabled) {
  color: #b91c1c;
}

.chat-toggle-knob {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #0071ff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.chat-toggle-knob::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fff;
}

.chat-toggle-admin_only .chat-toggle-knob {
  background: #cbd5e1;
}

.chat-toggle-admin_only .chat-toggle-knob::after {
  right: auto;
  left: 3px;
}

.action-panel {
  gap: 20px;
}

.chat-action-buttons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pin-message-toggle {
  border-bottom: 0;
  padding-bottom: 0;
}

.action-panel textarea {
  min-height: 138px;
}

.message-image-row {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-style: dashed;
  text-align: left;
}

.message-image-row.drag-over {
  border-color: #0071ff;
  background: #f0fdf4;
}

.message-image-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0;
  white-space: nowrap;
}

.message-image-button .lucide-icon {
  width: 17px;
  height: 17px;
  color: #101828;
}

.message-image-name {
  text-align: right;
}

.message-image-remove {
  min-height: 28px;
  padding: 0 8px;
}

#sendBulkMessage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#sendBulkMessage .lucide-icon {
  width: 17px;
  height: 17px;
}

.log-panel {
  padding: 22px 24px 14px;
}

.view-all-logs {
  min-height: 40px;
  border: 1px solid #dfe7ee;
  border-radius: 8px;
  padding: 0 17px;
  background: #fff;
  color: #111827;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
  font-size: 13px;
}

.view-all-logs:disabled {
  opacity: 1;
  cursor: default;
}

.log-list {
  gap: 0;
  max-height: none;
  overflow: visible;
}

.log-entry {
  border-top: 1px solid #eef2f6;
}

.log-entry:first-child {
  border-top: 0;
}

.log-item {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 34px 185px minmax(0, 1fr) 140px;
  align-items: center;
  gap: 18px;
  border: 0;
  border-radius: 0;
  padding: 10px 0;
  background: transparent;
  color: inherit;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}

.log-item:hover:not(:disabled),
.log-item[aria-expanded="true"] {
  background: #fbfefd;
}

.log-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 12px;
  font-weight: 900;
}

.log-failed .log-icon {
  background: #ffe4e6;
  color: #dc2626;
}

.log-item time {
  color: #64748b;
  font-size: 13px;
  font-weight: 850;
}

.log-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.log-copy strong {
  overflow: hidden;
  color: #334155;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-copy span,
.log-item em {
  color: #94a3b8;
  font-size: 12px;
  font-style: normal;
}

.log-item em {
  justify-self: start;
  font-weight: 800;
}

.log-inline-detail {
  display: grid;
  gap: 9px;
  margin: 0 0 12px 52px;
  border: 1px solid #e5edf3;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdff;
}

.log-inline-detail div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.log-inline-detail span {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 800;
}

.log-inline-detail strong {
  min-width: 0;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.settings-view {
  display: grid;
  gap: 22px;
}

.settings-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.settings-hero h2,
.settings-card h2 {
  color: #121827;
  font-size: 18px;
  font-weight: 900;
}

.settings-hero p,
.settings-card p,
.settings-status-row span:last-child {
  margin-top: 4px;
  color: #68778f;
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 22px;
}

.settings-card {
  display: grid;
  gap: 18px;
}

.settings-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.settings-card-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e6f0ff;
  color: #0071ff;
}

.settings-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #eef2f6;
  border-bottom: 1px solid #eef2f6;
  padding: 14px 0;
}

.settings-detail-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.settings-detail-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f4f7;
}

.settings-detail-list div:last-child {
  border-bottom: 0;
}

.settings-detail-list dt {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 850;
}

.settings-detail-list dd {
  min-width: 0;
  margin: 0;
  color: #334155;
  font-size: 13px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.settings-error {
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff1f2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

@media (max-width: 1440px) {
  .shell {
    grid-template-columns: 258px minmax(0, 1fr);
  }

  .app-main {
    padding: 28px 26px 30px;
  }

  .app-layout {
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 22px;
  }

  .filter-bar {
    grid-template-columns: minmax(230px, 1fr) 180px 180px 44px;
  }

  .table-wrap {
    max-height: calc(100vh - 350px);
  }
}

@media (max-width: 1180px) {
  .metric:not(:last-child)::after {
    display: none;
  }
}

@media (max-width: 900px) {
  .shell {
    background: #fbfcfe;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .filter-tools-button {
    width: 100%;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  .log-item {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 6px 12px;
    align-items: start;
    padding: 12px 0;
  }

  .log-item time,
  .log-copy,
  .log-item em {
    grid-column: 2;
  }

  .log-item time {
    grid-row: 1;
  }

  .log-copy {
    grid-row: 2;
  }

  .log-item em {
    grid-row: 3;
  }

  .log-inline-detail {
    margin-left: 42px;
  }

  .log-inline-detail div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .message-image-name {
    text-align: left;
  }

  .settings-hero,
  .settings-status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-detail-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (max-width: 680px) {
  .groups-table td:nth-child(2)::before {
    content: "#";
  }

  .groups-table td:nth-child(3)::before {
    content: "Nhóm";
  }

  .groups-table td:nth-child(4)::before {
    content: "Thành viên";
  }

  .groups-table td:nth-child(5)::before {
    content: "Vai trò";
  }

  .groups-table td:nth-child(6)::before {
    content: "Trạng thái";
  }

  .groups-table td:nth-child(7)::before {
    content: "Cập nhật";
  }

}

/* Soft premium refresh */
body {
  color: var(--text);
}

button {
  font-weight: 700;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(79, 141, 247, 0.14);
}

button:hover:not(:disabled) {
  background: var(--primary-dark);
}

button.secondary,
button.icon-button,
.view-all-logs,
.filter-tools-button {
  color: #3a4658;
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--line-strong);
  box-shadow: 0 8px 20px rgba(33, 48, 70, 0.035);
}

input,
select,
textarea,
.multi-select summary {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.94);
}

input:focus,
select:focus,
textarea:focus,
.multi-select[open] summary {
  border-color: rgba(79, 141, 247, 0.72);
  box-shadow: 0 0 0 3px rgba(79, 141, 247, 0.12);
}

label,
.field-label,
.muted,
.last-updated,
.panel-head p,
.settings-hero p,
.settings-card p,
.settings-status-row span:last-child,
.log-copy span,
.log-item em {
  color: var(--muted);
}

h1,
h2,
.panel-head h2,
.settings-hero h2,
.settings-card h2,
.brand-block h1,
.selected-group-title,
.composer-section-title {
  color: #253348;
  font-weight: 800;
}

.shell,
.shell.app-shell {
  background: #f7f9fc;
}

.app-sidebar {
  background: rgba(255, 255, 255, 0.9);
}

.sidebar-brand strong,
.profile-name,
.group-name strong,
.metric strong,
.settings-detail-list dd,
.log-copy strong {
  color: #263447;
}

.main-tab {
  color: #738198;
  font-weight: 700;
}

.main-tab.active,
.chat-toggle,
.message-image-button,
.profile-account-title button {
  color: var(--primary-dark);
}

.main-tab.active {
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(33, 48, 70, 0.055);
}

.topbar,
.panel,
.metric,
.login-card,
.profile-card {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  box-shadow: 0 16px 40px rgba(33, 48, 70, 0.045);
}

.metric-icon,
.metric-open .metric-icon,
.metric-selected .metric-icon,
.settings-card-icon,
.profile-status,
.role-owner,
.role-admin,
.status-select,
#openBulkChat,
.badge.neutral,
.group-avatar {
  background: var(--blue-bg);
  color: var(--blue-text);
}

.metric-closed .metric-icon,
.status-select.status-admin_only,
#closeBulkChat,
.log-failed .log-icon {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.add-group-button,
#sendBulkMessage,
.chat-toggle-knob {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 10px 22px rgba(79, 141, 247, 0.18);
}

.chat-toggle:hover:not(:disabled) {
  color: var(--primary-dark);
}

.group-avatar-fallback {
  background: linear-gradient(145deg, #75c7ba, #6d9df4);
}

.table-wrap,
th {
  background: #fbfdff;
}

td,
.log-item time {
  color: #536176;
}

tbody tr:hover,
.log-item:hover:not(:disabled),
.log-item[aria-expanded="true"] {
  background: #f8fbff;
}

.log-icon {
  background: var(--success-bg);
  color: var(--success-text);
}

.sidebar-brand strong,
.metric strong,
.group-name strong,
.profile-name,
.settings-detail-list dd,
.log-copy strong {
  font-weight: 700;
}

.badge,
.role-pill,
.chat-pill,
.status-select,
.row-index,
.log-item time,
.selected-group-title,
.composer-section-title {
  font-weight: 700;
}

.log-icon,
.log-failed .log-icon {
  background: var(--blue-bg);
  color: var(--blue-text);
}

.log-icon .lucide-icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}

/* Composer phone preview final layout */
.composer-preview-grid {
  grid-template-columns: minmax(0, 1fr) 190px;
}

.message-content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px);
  justify-content: center;
}

.composer-fields .message-image-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  text-align: left;
}

.composer-fields .message-image-button {
  grid-column: 1 / -1;
  width: 100%;
}

.composer-fields .message-image-name {
  text-align: left;
}

.zalo-message-bubble p.muted {
  color: #7a8798;
}

@media (max-width: 1280px) {
  .composer-preview-grid {
    grid-template-columns: minmax(0, 1fr) 210px;
  }

  .message-content-grid {
    grid-template-columns: minmax(260px, 320px);
  }
}

@media (max-width: 520px) {
  .composer-preview-grid {
    grid-template-columns: 1fr;
  }

  .message-content-grid {
    grid-template-columns: 1fr;
  }
}

/* Fixed sidebar, scrollable content */
body.authenticated {
  height: 100vh;
  overflow: hidden;
}

body.authenticated .shell {
  height: 100vh;
  overflow: hidden;
}

body.authenticated .app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

body.authenticated .app-main {
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

@media (max-width: 900px) {
  body.authenticated {
    height: auto;
    overflow: auto;
  }

  body.authenticated .shell,
  body.authenticated .app-main {
    height: auto;
    overflow: visible;
  }

  body.authenticated .app-sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }
}

/* Activity log dashboard */
.send-history-view {
  gap: 18px;
}

.send-history-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.send-history-hero h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

.send-history-hero p {
  margin: 5px 0 0;
  color: #73819a;
  font-size: 13px;
  font-weight: 600;
}

.send-history-hero .secondary {
  min-height: 38px;
  border-color: #d7e5f4;
  background: rgba(255, 255, 255, 0.9);
  color: #40516a;
  box-shadow: 0 10px 24px rgba(24, 90, 156, 0.06);
}

.log-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.log-stat-card {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  border: 1px solid #e4edf7;
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(41, 76, 112, 0.05);
}

.log-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eaf3ff;
  color: #0b7cff;
}

.log-stat-icon.success {
  background: #eafaf0;
  color: #16a34a;
}

.log-stat-icon.danger {
  background: #fff3e6;
  color: #f97316;
}

.log-stat-icon.warn {
  background: #f2e8ff;
  color: #8b5cf6;
}

.log-stat-card strong {
  display: block;
  color: #182538;
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
}

.log-stat-card p,
.log-stat-card em {
  margin: 0;
  color: #75849a;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.log-stat-card em {
  display: block;
  margin-top: 4px;
  color: #5b7ea6;
  font-size: 11px;
}

.send-history-panel {
  min-height: 0;
  padding: 10px;
}

.log-filter-bar {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(180px, 1fr) minmax(180px, 1fr) minmax(260px, 1.4fr);
  gap: 10px;
  margin-bottom: 10px;
}

.log-filter-bar input,
.log-filter-bar select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #dce8f5;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #34445a;
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}

.log-search {
  position: relative;
  display: block;
  margin: 0;
}

.log-search input {
  padding-right: 36px;
}

.log-search .lucide-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 16px;
  height: 16px;
  color: #6f84a0;
  transform: translateY(-50%);
}

.all-logs-table-wrap {
  max-height: calc(100vh - 320px);
  min-height: 360px;
  overflow: auto;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: #fff;
}

.all-logs-table {
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

.all-logs-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid #e8eff7;
  background: #f7faff;
  color: #58708f;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.all-logs-table th,
.all-logs-table td {
  padding: 13px 14px;
  vertical-align: middle;
}

.all-logs-table td {
  border-bottom: 1px solid #edf2f7;
  color: #314058;
  font-size: 12px;
}

.all-log-row:hover td {
  background: #f9fcff;
}

.all-logs-table time {
  display: block;
  min-width: 78px;
  color: #426187;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  white-space: pre-line;
}

.log-type {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
}

.log-type strong {
  display: -webkit-box;
  overflow: hidden;
  color: #243247;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.all-logs-table .log-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  background: #eaf3ff;
  color: #0b7cff;
}

.log-table-content {
  display: grid;
  gap: 4px;
  min-width: 240px;
  max-width: 420px;
}

.log-table-content strong {
  display: -webkit-box;
  overflow: hidden;
  color: #26364d;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.log-table-content span,
.log-actor span {
  overflow: hidden;
  color: #74849a;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-actor {
  display: grid;
  gap: 3px;
  min-width: 120px;
}

.log-actor strong {
  color: #35455d;
  font-size: 12px;
  font-weight: 850;
}

.log-row-menu {
  width: 30px;
  height: 30px;
  border-color: transparent;
  background: transparent;
  color: #5f7795;
  box-shadow: none;
}

.log-row-menu:hover,
.log-row-menu[aria-expanded="true"] {
  background: #eaf3ff;
  color: #0b72e7;
}

.all-log-detail-row td {
  padding: 0 14px 14px;
  background: #fbfdff;
}

.all-log-detail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid #e1ebf6;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.all-log-detail div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.all-log-detail span {
  color: #71819a;
  font-size: 11px;
  font-weight: 800;
}

.all-log-detail strong {
  overflow: hidden;
  color: #26364d;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1200px) {
  .log-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 720px) {
  .send-history-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .log-stats-grid,
  .log-filter-bar,
  .all-log-detail {
    grid-template-columns: 1fr;
  }
}

/* Settings dashboard */
.settings-view {
  gap: 18px;
}

.settings-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  overflow: hidden;
}

.settings-hero-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.settings-kicker,
.settings-section-label {
  color: #0b72e7;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.settings-hero h2 {
  max-width: 820px;
  font-size: 22px;
  line-height: 1.2;
}

.settings-hero p {
  max-width: 760px;
  margin: 0;
  line-height: 1.5;
}

.settings-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.settings-hero-actions .badge {
  min-height: 38px;
  align-items: center;
  white-space: nowrap;
}

.settings-hero-actions button,
.settings-user-create button,
.settings-password-row button,
#saveZaloPermissions {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  border-radius: 8px;
  line-height: 1;
  white-space: nowrap;
}

.settings-hero-actions button .lucide-icon,
.settings-user-create button .lucide-icon,
.settings-password-row button .lucide-icon,
#saveZaloPermissions .lucide-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  align-items: start;
  gap: 18px;
}

.settings-main-column,
.settings-side-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.settings-card {
  min-width: 0;
  gap: 16px;
}

.settings-card-head {
  align-items: center;
}

.settings-card-head > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.settings-card h2 {
  font-size: 17px;
  line-height: 1.25;
}

.settings-card p {
  margin: 0;
  line-height: 1.45;
}

.settings-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #eef6ff;
}

.settings-integration-card .settings-detail-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-integration-card .settings-detail-list div {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 8px;
  min-height: 96px;
  border: 1px solid #e7eef7;
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.settings-detail-list.compact div {
  grid-template-columns: minmax(112px, 0.45fr) minmax(0, 1fr);
}

.settings-link {
  display: block;
  padding: 2px 0;
}

.settings-account-list {
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.settings-account-item {
  border-color: #e2ebf5;
  background: #fbfdff;
}

.settings-account-item.not-allowed {
  background: #f8fafc;
  opacity: 0.76;
}

.settings-account-item.not-allowed strong,
.settings-account-item.not-allowed span,
.settings-account-item.not-allowed small {
  color: #64748b;
}

.settings-permissions-card {
  gap: 18px;
}

.settings-password-card {
  gap: 18px;
}

.settings-password-form {
  display: grid;
  gap: 8px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.settings-password-form label {
  margin: 0;
  color: #6b7d93;
  font-size: 12px;
  font-weight: 800;
}

.settings-password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.settings-password-row input {
  min-width: 0;
}

.settings-user-create {
  grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 0.8fr) auto;
  align-items: center;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.settings-user-card {
  border-radius: 8px;
  background: #fff;
}

.settings-permission-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-error {
  margin: 0;
}

.settings-grid-main {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  align-items: start;
}

.settings-card-wide {
  grid-column: 1 / -1;
}

.settings-link-list dd {
  min-width: 0;
}

.settings-link,
.settings-empty {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  overflow: hidden;
  color: #0b72e7;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-link:hover {
  color: #075bb9;
  text-decoration: underline;
}

.settings-empty {
  color: #8a98aa;
}

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

.settings-account-empty {
  border: 1px dashed #d8e4f1;
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
  color: #73819a;
  font-size: 13px;
  font-weight: 700;
}

.settings-account-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.settings-account-avatar {
  display: inline-flex;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 999px;
  background: #eaf3ff;
}

.settings-account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-account-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.settings-account-item strong,
.settings-account-item span,
.settings-account-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-account-item strong {
  color: #26364d;
  font-size: 13px;
  font-weight: 850;
}

.settings-account-item span,
.settings-account-item small {
  color: #728198;
  font-size: 11px;
  font-weight: 700;
}

.settings-account-item .badge {
  white-space: nowrap;
}

.settings-user-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(126px, auto);
  gap: 10px;
}

.settings-user-list {
  display: grid;
  gap: 12px;
}

.settings-user-card {
  display: grid;
  gap: 12px;
  border: 1px solid #e4edf5;
  border-radius: 10px;
  padding: 12px;
  background: #f8fbff;
}

.settings-user-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.settings-user-head div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.settings-user-head strong {
  color: #172033;
  font-size: 14px;
}

.settings-user-head span {
  color: #6b7d93;
  font-size: 12px;
}

.settings-user-fields {
  display: grid;
  grid-template-columns: minmax(140px, 0.45fr) minmax(0, 1fr);
  gap: 10px;
}

.settings-permission-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.settings-permission-option {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #dfe8f1;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: #243142;
  font-size: 12px;
  font-weight: 750;
}

.settings-permission-option input {
  flex: 0 0 auto;
}

.settings-permission-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-layout .settings-account-item {
  border-color: #e2ebf5;
  background: #fbfdff;
}

.settings-layout .settings-card-head {
  align-items: center;
}

.settings-layout .settings-card-head > div {
  min-width: 0;
}

.settings-layout .settings-detail-list.compact div {
  grid-template-columns: minmax(112px, 0.45fr) minmax(0, 1fr);
}

@media (max-width: 1180px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-grid-main {
    grid-template-columns: 1fr;
  }

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

  .settings-side-column .settings-card:first-child {
    grid-column: 1 / -1;
  }

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

@media (max-width: 760px) {
  .settings-hero,
  .settings-hero-actions,
  .settings-side-column,
  .settings-integration-card .settings-detail-list,
  .settings-password-row,
  .settings-user-create,
  .settings-user-fields,
  .settings-permission-list {
    grid-template-columns: 1fr;
  }

  .settings-hero-actions {
    display: grid;
    justify-content: stretch;
  }

  .settings-hero-actions .badge,
  .settings-hero-actions button {
    width: 100%;
    justify-content: center;
  }

  .settings-password-row button,
  .settings-user-create button,
  #saveZaloPermissions {
    width: 100%;
  }

  .settings-hero h2 {
    font-size: 18px;
  }

  .settings-detail-list.compact div,
  .settings-detail-list div {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .settings-account-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .settings-account-item .badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

}

/* Compact overview metrics */
.stats-grid {
  gap: 12px;
}

.stats-grid .metric {
  min-height: 104px;
  gap: 12px;
  padding: 18px 24px;
}

.stats-grid .metric-icon {
  width: 56px;
  height: 56px;
  font-size: 22px;
}

.stats-grid .metric-icon .lucide-icon {
  width: 30px;
  height: 30px;
}

.stats-grid .metric span {
  font-size: 14px;
  line-height: 1.15;
}

.stats-grid .metric strong {
  margin-top: 2px;
  font-size: 29px;
  line-height: 0.95;
}

.stats-grid .metric em {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.1;
}

/* Mobile final polish */
@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  body.authenticated {
    height: auto;
    min-height: 100vh;
    overflow: auto;
    background: #f6f8fb;
  }

  body.authenticated .shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    background: #f6f8fb;
  }

  body.authenticated .app-sidebar {
    position: sticky;
    top: 0;
    z-index: 80;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid #e7edf5;
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
    overflow: hidden;
  }

  .sidebar-brand {
    justify-content: flex-start;
    gap: 9px;
    margin: 0;
    font-size: 15px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-mark img {
    width: 21px;
    height: 21px;
  }

  .sidebar-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-nav .main-tab {
    width: auto;
    min-width: 112px;
    min-height: 38px;
    flex: 0 0 auto;
    justify-content: center;
    gap: 7px;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 12px;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .sidebar-nav .main-tab .lucide-icon,
  .sidebar-nav .main-tab i {
    width: 17px;
    height: 17px;
  }

  .upgrade-card {
    display: none;
  }

  body.authenticated .app-main {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 12px 10px calc(18px + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    border-radius: 8px;
    padding: 12px;
  }

  .brand-block {
    flex: 0 1 auto;
    min-width: 0;
  }

  .top-actions {
    flex: 0 0 auto;
    max-width: 60vw;
    min-width: 0;
  }

  .notification-button {
    display: none;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
  }

  .top-actions .icon-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .profile-card {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border-radius: 8px;
    padding: 5px 8px 5px 5px;
  }

  .profile-menu {
    position: fixed;
    top: 104px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100vh - 118px);
    overflow: auto;
  }

  .app-layout,
  .workspace,
  .control-rail,
  .messages-view,
  .message-run-grid,
  .settings-view,
  .send-history-view,
  .message-content-view,
  .schedule-calendar-view {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .stats-grid .metric {
    min-height: 82px;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px 10px;
    padding: 12px;
  }

  .stats-grid .metric::after {
    display: none;
  }

  .stats-grid .metric-icon {
    width: 42px;
    height: 42px;
  }

  .stats-grid .metric-icon .lucide-icon {
    width: 23px;
    height: 23px;
  }

  .stats-grid .metric span {
    font-size: 12px;
  }

  .stats-grid .metric strong {
    font-size: 24px;
  }

  .stats-grid .metric em {
    font-size: 11px;
  }

  .panel,
  .group-panel,
  .message-content-panel,
  .send-history-panel {
    border-radius: 8px;
    padding: 14px;
  }

  .panel-head,
  .message-schedule-toolbar,
  .message-jobs-head,
  .settings-hero,
  .send-history-hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }

  .panel-head h2,
  .message-schedule-toolbar h2,
  .settings-hero h2,
  .send-history-hero h2 {
    font-size: 17px;
  }

  .panel-head p,
  .message-schedule-toolbar p,
  .settings-hero p,
  .send-history-hero p {
    font-size: 12px;
    line-height: 1.45;
  }

  .filter-bar,
  .message-job-filters,
  .message-schedule-actions,
  .message-schedule-control-group,
  .log-filter-bar,
  .settings-grid-main,
  .message-run-grid,
  .message-run-grid > .panel,
  .message-content-grid,
  .composer-preview-grid,
  .composer-fields .message-image-row,
  .chat-action-buttons,
  .zalo-actions {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    margin: 12px 0;
    padding: 10px;
  }

  button,
  input,
  select,
  textarea,
  .multi-select summary {
    max-width: 100%;
  }

  .add-group-button,
  .view-all-logs,
  .message-schedule-actions button,
  .message-schedule-action-buttons,
  .message-job-filters select,
  .message-job-filters input,
  .send-history-hero button,
  .settings-hero button {
    width: 100%;
  }

  .table-wrap,
  .message-jobs-table,
  .message-runs-table,
  .all-logs-table-wrap,
  .group-messages-table-wrap {
    width: 100%;
    min-height: 0;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  table,
  .groups-table,
  .message-jobs-data,
  .message-runs-data,
  .all-logs-table {
    min-width: 760px;
  }

  .selected-group-list,
  .message-run-log,
  .log-list {
    max-height: 260px;
  }

  .composer-preview-grid {
    justify-items: center;
  }

  .message-content-grid {
    grid-template-columns: 1fr;
  }

  .message-content-grid .zalo-phone-shell {
    width: min(280px, 100%);
  }

  .message-content-grid .zalo-phone-chat {
    min-height: 420px;
  }

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

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

  .log-stat-card {
    padding: 12px;
  }

  .all-log-detail {
    grid-template-columns: 1fr;
  }

  .settings-account-item {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .settings-account-item .badge {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 420px) {
  .sidebar-nav .main-tab {
    min-width: 102px;
    padding: 0 10px;
  }

  .stats-grid,
  .log-stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid .metric {
    min-height: 76px;
  }

  .top-actions {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .profile-menu {
    top: 98px;
  }
}

/* Native-app mobile shell */
@media (max-width: 760px) {
  body.authenticated {
    background: #f5f7fb;
  }

  body.authenticated .shell {
    padding: 0;
  }

  body.authenticated .app-sidebar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    top: auto;
    z-index: 120;
    display: block;
    height: calc(70px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid rgba(214, 226, 239, 0.9);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -12px 34px rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(18px);
  }

  body.authenticated .sidebar-brand,
  body.authenticated .upgrade-card {
    display: none;
  }

  body.authenticated .sidebar-nav {
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    overflow: visible;
    padding: 0;
  }

  body.authenticated .sidebar-nav .main-tab {
    min-width: 0;
    width: 100%;
    height: 58px;
    min-height: 58px;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    align-content: center;
    gap: 4px;
    border-radius: 10px;
    padding: 4px 2px;
    color: #718096;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.05;
    text-align: center;
    white-space: normal;
  }

  body.authenticated .sidebar-nav .main-tab .lucide-icon,
  body.authenticated .sidebar-nav .main-tab i {
    width: 21px;
    height: 21px;
    margin: 0;
    stroke-width: 2.3;
  }

  body.authenticated .sidebar-nav .main-tab.active {
    background: #eaf3ff;
    color: #0b72e7;
    box-shadow: none;
  }

  body.authenticated .app-main {
    padding: 10px 10px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 70;
    margin: -10px -10px 12px;
    border: 0;
    border-bottom: 1px solid rgba(226, 234, 244, 0.9);
    border-radius: 0 0 14px 14px;
    padding: max(12px, env(safe-area-inset-top)) 12px 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(16px);
  }

  .brand-block h1 {
    display: none;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1f2d3d;
    font-size: 17px;
    font-weight: 900;
  }

  .mobile-brand .brand-mark {
    width: 34px;
    height: 34px;
  }

  .mobile-brand .brand-mark img {
    width: 22px;
    height: 22px;
  }

  .profile-menu {
    top: calc(56px + env(safe-area-inset-top));
    z-index: 130;
  }

  .panel,
  .metric,
  .log-stat-card,
  .settings-account-item,
  .schedule-day {
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.055);
  }

  .panel,
  .group-panel,
  .message-content-panel,
  .send-history-panel {
    border: 1px solid rgba(226, 234, 244, 0.86);
    background: #fff;
  }

  .filter-bar,
  .log-filter-bar {
    border: 0;
    background: transparent;
    padding: 0;
  }

  .filter-bar input,
  .filter-bar select,
  .log-filter-bar input,
  .log-filter-bar select,
  .message-job-filters input,
  .message-job-filters select {
    border-radius: 10px;
    background: #f8fbff;
  }

  .table-wrap,
  .all-logs-table-wrap,
  .message-jobs-table,
  .message-runs-table {
    border-radius: 10px;
  }

  .toast {
    right: 10px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    left: 10px;
    max-width: none;
    z-index: 140;
  }
}

@media (max-width: 380px) {
  body.authenticated .sidebar-nav .main-tab {
    font-size: 9px;
  }

  body.authenticated .sidebar-nav .main-tab .lucide-icon,
  body.authenticated .sidebar-nav .main-tab i {
    width: 19px;
    height: 19px;
  }
}

/* Mobile app layout audit pass */
@media (max-width: 760px) {
  body.authenticated .app-main {
    padding: 10px 10px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: -8px -8px 10px;
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  }

  .brand-block {
    flex: 0 1 auto;
    min-width: 0;
  }

  .top-actions {
    flex: 0 0 auto;
    width: auto;
    max-width: 60vw;
    min-width: 0;
  }

  .top-actions {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 8px;
  }

  .top-actions .icon-button,
  .profile-card {
    min-height: 40px;
    height: 40px;
  }

  .profile-initial {
    width: 28px;
    height: 28px;
  }

  .profile-name {
    font-size: 12px;
  }

  .profile-status {
    font-size: 10px;
  }

  .app-layout,
  .workspace,
  .control-rail,
  .messages-view,
  .message-run-grid,
  .settings-view,
  .send-history-view,
  .message-content-view,
  .schedule-calendar-view {
    gap: 10px;
  }

  .stats-grid,
  .message-stats,
  .log-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats-grid .metric,
  .message-stats .metric {
    min-height: 72px;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 4px 9px;
    border-radius: 12px;
    padding: 10px;
  }

  .stats-grid .metric {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .message-stats .metric {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .stats-grid .metric-icon {
    width: 36px;
    height: 36px;
  }

  .stats-grid .metric-icon .lucide-icon {
    width: 20px;
    height: 20px;
  }

  .stats-grid .metric span,
  .message-stats .metric span {
    min-height: 0;
    margin: 0;
    font-size: 11px;
    line-height: 1.2;
  }

  .stats-grid .metric strong,
  .message-stats .metric strong {
    font-size: 22px;
    line-height: 1;
  }

  .stats-grid .metric em {
    font-size: 10px;
  }

  .panel,
  .group-panel,
  .message-content-panel,
  .send-history-panel,
  .schedule-calendar-panel {
    border-radius: 12px;
    padding: 12px;
  }

  .panel-head,
  .compact-head,
  .message-schedule-toolbar,
  .message-jobs-head,
  .settings-hero,
  .send-history-hero,
  .schedule-calendar-head {
    gap: 8px;
  }

  .panel-head h2,
  .compact-head h2,
  .message-schedule-toolbar h2,
  .settings-hero h2,
  .send-history-hero h2,
  .schedule-calendar-head h2 {
    font-size: 16px;
  }

  .panel-head p,
  .compact-head p,
  .message-schedule-toolbar p,
  .settings-hero p,
  .send-history-hero p,
  .schedule-calendar-head p {
    font-size: 11px;
  }

  button,
  input,
  select,
  textarea,
  .multi-select summary {
    min-height: 40px;
    border-radius: 10px;
    font-size: 12px;
    touch-action: manipulation;
  }

  textarea {
    min-height: 108px;
  }

  .filter-bar,
  .message-job-filters,
  .message-schedule-actions,
  .schedule-calendar-actions,
  .log-filter-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

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

  .schedule-mode-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .message-schedule-controls {
    justify-content: flex-start;
  }

  .schedule-mode-tab {
    justify-content: center;
    padding: 0 10px;
  }

  .table-wrap,
  .message-jobs-table,
  .message-runs-table,
  .all-logs-table-wrap,
  .group-messages-table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
  }

  table,
  .groups-table,
  .message-jobs-data,
  .message-runs-data,
  .all-logs-table {
    min-width: 0;
    width: 100%;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    border: 1px solid #e3ebf5;
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.055);
  }

  td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border: 0;
    border-bottom: 1px solid #edf2f7;
    padding: 9px 0;
    color: #26364d;
    font-size: 12px;
    text-align: left;
    overflow-wrap: anywhere;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    color: #7a8aa0;
    font-size: 11px;
    font-weight: 850;
  }

  td[colspan] {
    display: block;
    padding: 0;
  }

  .groups-table td:first-child {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 4px 0 8px;
    border-bottom: 1px solid #edf2f7;
  }

  .groups-table td:first-child::before {
    content: "Chọn nhóm";
    flex: 1;
    text-align: left;
  }

  .groups-table td:first-child input[type="checkbox"] {
    flex: 0 0 auto;
  }

  .groups-table td:nth-child(2) {
    display: none;
  }

  .groups-table td:nth-child(3)::before {
    content: "Nhóm";
  }

  .groups-table td:nth-child(3) .group-name {
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  .groups-table .group-avatar {
    width: 36px;
    height: 36px;
  }

  .groups-table .group-copy strong {
    white-space: normal;
  }

  .groups-table td:nth-child(4)::before {
    content: "Thành viên";
  }

  .groups-table td:nth-child(5)::before {
    content: "Vai trò";
  }

  .groups-table td:nth-child(6)::before {
    content: "Chat";
  }

  .groups-table .chat-toggle {
    width: auto;
    min-height: 36px;
  }

  .groups-table td:nth-child(7) {
    display: none;
  }

  .message-jobs-data td:first-child::before {
    content: "Row";
  }

  .message-jobs-data td:nth-child(2)::before {
    content: "Tài khoản";
  }

  .message-jobs-data td:nth-child(3)::before {
    content: "Lịch";
  }

  .message-jobs-data td:nth-child(4)::before {
    content: "Type";
  }

  .message-jobs-data td:nth-child(5)::before {
    content: "Nội dung";
  }

  .message-jobs-data td:nth-child(6)::before {
    content: "Poll";
  }

  .message-jobs-data td:nth-child(7)::before {
    content: "Trạng thái";
  }

  .message-jobs-data td:nth-child(8)::before {
    content: "Thao tác";
  }

  .message-runs-data td:first-child::before {
    content: "ID";
  }

  .message-runs-data td:nth-child(2)::before {
    content: "Trạng thái";
  }

  .message-runs-data td:nth-child(3)::before {
    content: "Tài khoản";
  }

  .message-runs-data td:nth-child(4)::before {
    content: "Row";
  }

  .message-runs-data td:nth-child(5)::before {
    content: "Bắt đầu";
  }

  .all-logs-table td:first-child::before {
    content: "Thời gian";
  }

  .all-logs-table td:nth-child(2)::before {
    content: "Hoạt động";
  }

  .all-logs-table td:nth-child(3)::before {
    content: "Nội dung";
  }

  .all-logs-table td:nth-child(4)::before {
    content: "Nhóm";
  }

  .all-logs-table td:nth-child(5)::before {
    content: "Trạng thái";
  }

  .all-logs-table td:nth-child(6)::before {
    content: "Người làm";
  }

  .all-logs-table td:nth-child(7)::before {
    content: "Chi tiết";
  }

  .all-log-detail-row {
    margin-top: -10px;
  }

  .all-log-detail-row td {
    display: block;
    padding: 0;
    background: transparent;
  }

  .all-log-detail-row td::before {
    content: none;
  }

  .all-log-detail {
    grid-template-columns: 1fr;
    border-radius: 12px;
  }

  .group-name {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .group-avatar {
    width: 34px;
    height: 34px;
  }

  .chat-toggle,
  .message-job-actions button,
  .group-message-row-actions button {
    width: 100%;
    min-height: 40px;
  }

  .message-image-button,
  .message-image-remove {
    min-height: 40px;
  }

  .selected-group-list {
    max-height: 180px;
  }

  .qr-box {
    min-height: 170px;
  }

  .log-list,
  .message-run-log {
    max-height: 240px;
  }

  .schedule-calendar-grid {
    gap: 10px;
  }

  .schedule-day {
    border-radius: 12px;
  }

  .zalo-phone-shell {
    max-width: 292px;
    width: 100%;
  }

  .zalo-phone-chat {
    min-height: 390px;
  }

  .settings-detail-list div {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (max-width: 390px) {
  body.authenticated .sidebar-nav .main-tab {
    height: 54px;
    min-height: 54px;
    font-size: 10px;
  }

  body.authenticated .app-sidebar {
    height: calc(66px + env(safe-area-inset-bottom));
  }

  body.authenticated .app-main {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  td {
    grid-template-columns: 88px minmax(0, 1fr);
  }
}

@media (max-width: 360px) {
  body.authenticated .sidebar-nav .main-tab {
    font-size: 0;
    gap: 0;
    padding: 4px;
  }

  body.authenticated .sidebar-nav .main-tab .lucide-icon,
  body.authenticated .sidebar-nav .main-tab i {
    width: 24px;
    height: 24px;
  }

  body.authenticated .app-sidebar {
    height: calc(60px + env(safe-area-inset-bottom));
  }

  body.authenticated .app-main {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

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

  .stats-grid .metric,
  .message-stats .metric {
    min-height: 68px;
    padding: 8px;
    gap: 4px 8px;
  }

  .stats-grid .metric-icon {
    width: 32px;
    height: 32px;
  }

  .stats-grid .metric-icon .lucide-icon {
    width: 18px;
    height: 18px;
  }

  .stats-grid .metric strong,
  .message-stats .metric strong {
    font-size: 20px;
  }
}

/* Sidebar guide page */
.upgrade-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 7px;
  font-weight: 900;
}

.upgrade-card button.active,
.upgrade-card button:hover:not(:disabled) {
  background: #005bd8;
  border-color: #005bd8;
  color: #fff;
  transform: translateY(-1px);
}

.guide-view {
  display: grid;
  gap: 18px;
}

.guide-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  align-items: center;
  gap: 22px;
  min-height: 300px;
  padding: 26px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 82% 18%, rgba(0, 113, 255, 0.16), transparent 30%),
    linear-gradient(135deg, #eef8f5 0%, #f8fbff 52%, #eef4ff 100%);
  box-shadow: 0 18px 45px rgba(22, 35, 59, 0.08);
  overflow: hidden;
}

.guide-kicker {
  color: #0071ff;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.guide-hero h2,
.guide-section-head h2 {
  margin: 8px 0 0;
  color: #142033;
  font-size: 30px;
  font-weight: 900;
}

.guide-hero p,
.guide-section-head p,
.guide-feature-card p,
.guide-step-card p {
  color: #607087;
  line-height: 1.65;
}

.guide-hero-copy {
  display: grid;
  gap: 14px;
}

.guide-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.guide-hero-actions button {
  min-height: 42px;
  padding: 0 18px;
}

.guide-hero-illustration {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.guide-plane-card {
  position: relative;
  display: grid;
  place-items: center;
  width: min(250px, 100%);
  aspect-ratio: 1 / 0.78;
  border-radius: 17px;
  background: linear-gradient(150deg, #e0f6ef, #f8fcff);
  box-shadow: inset 0 0 0 1px rgba(0, 113, 255, 0.08), 0 16px 36px rgba(0, 70, 160, 0.12);
}

.guide-plane-card .lucide-icon {
  position: relative;
  z-index: 2;
  width: 70px;
  height: 70px;
  color: #0071ff;
  fill: rgba(0, 113, 255, 0.14);
  transform: translate(16px, -12px) rotate(-12deg);
}

.guide-plane-shadow {
  position: absolute;
  width: 86px;
  height: 20px;
  border-radius: 999px;
  background: rgba(0, 82, 190, 0.13);
  filter: blur(8px);
  transform: translate(22px, 18px);
}

.guide-envelope {
  position: absolute;
  bottom: 42px;
  width: 58px;
  height: 36px;
  border: 2px solid #0071ff;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.78);
}

.guide-envelope::before,
.guide-envelope::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 32px;
  height: 2px;
  background: #0071ff;
}

.guide-envelope::before {
  left: 2px;
  transform: rotate(34deg);
  transform-origin: left center;
}

.guide-envelope::after {
  right: 2px;
  transform: rotate(-34deg);
  transform-origin: right center;
}

.guide-flight-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(330px, 100%);
}

.guide-flight-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(20, 32, 51, 0.08);
}

.guide-flight-row .lucide-icon {
  width: 15px;
  height: 15px;
  color: #0071ff;
}

.guide-section {
  display: grid;
  gap: 14px;
}

.guide-section-head {
  display: grid;
  gap: 4px;
}

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

.guide-step-card,
.guide-feature-card {
  border: 1px solid #e2eaf3;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(22, 35, 59, 0.06);
}

.guide-step-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(160px, 0.72fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.guide-step-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #0071ff;
  color: #fff;
  font-weight: 900;
}

.guide-step-card h3,
.guide-feature-card h3 {
  margin: 0 0 6px;
  color: #17202b;
  font-size: 16px;
  font-weight: 900;
}

.guide-step-card p,
.guide-feature-card p {
  margin: 0;
  font-size: 13px;
}

.guide-mini-screen {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 14px;
  border-radius: 13px;
  background: linear-gradient(180deg, #f8fbff, #eef5ff);
  box-shadow: inset 0 0 0 1px #dbe8f7;
}

.guide-mini-top,
.guide-mini-line,
.guide-row,
.guide-log,
.guide-message-bubble {
  border-radius: 999px;
  background: #c7d9ee;
}

.guide-mini-top {
  width: 68%;
  height: 9px;
}

.guide-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0071ff, #16a34a);
}

.guide-mini-line {
  width: 54%;
  height: 9px;
}

.guide-mini-line.wide {
  width: 82%;
}

.guide-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  font-size: 11px;
  font-weight: 900;
}

.guide-search-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  color: #0071ff;
}

.guide-search-line span {
  display: block;
  width: 68%;
  height: 8px;
  border-radius: 999px;
  background: #d8e4f2;
}

.guide-row {
  height: 18px;
  background: #d8e4f2;
}

.guide-row.checked {
  background: linear-gradient(90deg, #0071ff 0 18%, #dbeafe 18%);
}

.guide-row.short {
  width: 72%;
}

.guide-send-screen {
  align-content: center;
}

.guide-message-bubble {
  width: 82%;
  height: 24px;
  border-radius: 14px 14px 14px 4px;
  background: #dbeafe;
}

.guide-message-bubble.small {
  width: 56%;
  background: #dcfce7;
}

.guide-send-button {
  display: grid;
  place-items: center;
  justify-self: end;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #0071ff;
  color: #fff;
}

.guide-send-button .lucide-icon {
  width: 17px;
  height: 17px;
}

.guide-log {
  height: 22px;
}

.guide-log.success {
  background: linear-gradient(90deg, #16a34a 0 16%, #dcfce7 16%);
}

.guide-log.pending {
  background: linear-gradient(90deg, #d97706 0 16%, #fef3c7 16%);
}

.guide-log.failed {
  background: linear-gradient(90deg, #dc2626 0 16%, #fee2e2 16%);
}

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

.guide-feature-card {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.guide-feature-card-strong {
  border-color: rgba(0, 113, 255, 0.28);
  background: linear-gradient(180deg, #ffffff, #f4f9ff);
}

.guide-feature-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #eef5ff;
  color: #0071ff;
}

.guide-feature-icon .lucide-icon {
  width: 21px;
  height: 21px;
}

.guide-feature-card ul {
  display: grid;
  gap: 7px;
  margin: 2px 0 0;
  padding-left: 18px;
  color: #44546a;
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .guide-hero,
  .guide-steps,
  .guide-feature-grid {
    grid-template-columns: 1fr;
  }

  .guide-step-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .guide-mini-screen {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .guide-hero {
    min-height: 0;
    padding: 18px;
    border-radius: 14px;
  }

  .guide-hero h2,
  .guide-section-head h2 {
    font-size: 23px;
  }

  .guide-plane-card {
    width: min(220px, 100%);
  }

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

  .guide-step-card,
  .guide-feature-card {
    border-radius: 12px;
  }
}

/* Saved group segments */
.group-segment-box {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #e1eaf5;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.group-segment-dock {
  grid-template-columns: minmax(130px, 0.7fr) minmax(220px, 1fr) minmax(260px, 1.35fr);
  align-items: start;
  margin: 8px 0;
  padding: 10px;
  border-radius: 10px;
}

.segment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.segment-head div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.segment-head strong {
  color: #17202b;
  font-size: 13px;
  font-weight: 900;
}

.segment-head span {
  color: #66768b;
  font-size: 12px;
  line-height: 1.4;
}

.segment-save-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.segment-save-row input {
  min-width: 0;
  min-height: 38px;
}

.segment-save-row button {
  min-height: 38px;
  white-space: nowrap;
}

.segment-list {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
}

.group-segment-dock .segment-list {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  max-height: 104px;
}

.segment-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid #e4edf7;
  border-radius: 10px;
  background: #fff;
}

.segment-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.segment-copy strong,
.segment-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-copy strong {
  color: #17202b;
  font-size: 13px;
}

.segment-copy span {
  color: #66768b;
  font-size: 12px;
}

.segment-actions {
  display: flex;
  gap: 6px;
}

.segment-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.v2-segment-picker {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.v2-segment-picker label {
  color: #44546a;
  font-size: 12px;
  font-weight: 900;
}

.v2-segment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.v2-segment-row select,
.v2-segment-row button {
  min-height: 38px;
}

@media (max-width: 980px) {
  .group-segment-dock {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .segment-save-row,
  .segment-item,
  .v2-segment-row {
    grid-template-columns: 1fr;
  }

  .segment-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* Group control mobile fit pass */
@media (max-width: 760px) {
  body.authenticated .shell,
  body.authenticated .app-main,
  #tabViews,
  .tab-view,
  .workspace,
  .control-rail,
  .panel,
  .metric {
    min-width: 0;
  }

  body.authenticated .app-main {
    width: 100%;
    padding-right: 8px;
    padding-left: 8px;
  }

  .topbar {
    margin-right: -8px;
    margin-left: -8px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .mobile-brand {
    min-width: 0;
    font-size: 15px;
  }

  .mobile-brand strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    max-width: 54vw;
    grid-template-columns: 40px minmax(0, 132px);
  }

  .profile-card {
    overflow: hidden;
  }

  .profile-copy,
  .profile-name,
  .profile-status {
    min-width: 0;
  }

  .profile-name,
  .profile-status {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #groupModeView {
    width: 100%;
  }

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

  #groupModeView .metric {
    align-items: center;
    overflow: hidden;
  }

  #groupModeView .metric span,
  #groupModeView .metric em {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #groupModeView .panel-head,
  #groupModeView .compact-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  #groupModeView .panel-head > *,
  #groupModeView .compact-head > * {
    min-width: 0;
  }

  #groupModeView .add-group-button,
  #groupModeView .view-all-logs {
    width: 100%;
  }

  #groupModeView .filter-bar {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 12px 0 10px;
  }

  #groupModeView .multi-select-menu {
    position: static;
    margin-top: 6px;
    box-shadow: none;
  }

  #groupModeView .table-wrap {
    min-height: 0;
    overflow: visible;
  }

  #groupModeView .groups-table,
  #groupModeView .groups-table tbody,
  #groupModeView .groups-table tr,
  #groupModeView .groups-table td {
    width: 100%;
  }

  #groupModeView .groups-table tr {
    overflow: hidden;
  }

  #groupModeView .groups-table td {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
  }

  #groupModeView .groups-table td:first-child {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
  }

  #groupModeView .groups-table td:first-child::before {
    content: "Ch\1ECD n";
  }

  #groupModeView .groups-table td:nth-child(3)::before {
    content: "Nh\00F3 m";
  }

  #groupModeView .groups-table td:nth-child(4)::before {
    content: "Th\00E0 nh vi\00EA n";
  }

  #groupModeView .groups-table td:nth-child(5)::before {
    content: "Vai tr\00F2";
  }

  #groupModeView .groups-table td:nth-child(6)::before {
    content: "Chat";
  }

  #groupModeView .groups-table .group-name,
  #groupModeView .groups-table td:nth-child(3) .group-name {
    grid-template-columns: 34px minmax(0, 1fr);
    max-width: 100%;
  }

  #groupModeView .groups-table .group-copy,
  #groupModeView .groups-table .group-copy strong,
  #groupModeView .groups-table .group-copy .muted {
    min-width: 0;
    max-width: 100%;
  }

  #groupModeView .groups-table .group-copy strong,
  #groupModeView .groups-table .group-copy .muted {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #groupModeView .groups-table .role-pill {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #groupModeView .groups-table .chat-toggle {
    justify-content: space-between;
    gap: 10px;
    padding: 0 10px;
    border: 1px solid #d9e5f0;
    border-radius: 999px;
    background: #f8fbff;
  }

  #groupModeView .control-rail {
    position: static;
  }

  #groupModeView .zalo-actions,
  #groupModeView .chat-action-buttons,
  #groupModeView .message-image-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #groupModeView .selected-group-item {
    grid-template-columns: minmax(0, 1fr) 34px;
  }

  #groupModeView .selected-group-remove {
    width: 34px;
    min-height: 34px;
  }

  #groupModeView .log-list {
    max-height: none;
  }
}

@media (max-width: 390px) {
  .top-actions {
    max-width: 50vw;
    grid-template-columns: 38px minmax(0, 112px);
  }

  #groupModeView .groups-table td {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  #groupModeView .stats-grid .metric,
  #groupModeView .message-stats .metric {
    grid-template-columns: 32px minmax(0, 1fr);
  }
}

/* Mobile group list cards */
@media (max-width: 760px) {
  #groupModeView .groups-table tbody {
    gap: 10px;
  }

  #groupModeView .groups-table tr {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 10px;
    padding: 12px;
    border: 1px solid #e3ebf5;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.055);
  }

  #groupModeView .groups-table td {
    width: auto;
    min-width: 0;
    border-bottom: 0;
    padding: 0;
  }

  #groupModeView .groups-table td:first-child {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: block;
    width: auto;
    padding: 0;
  }

  #groupModeView .groups-table td:first-child::before,
  #groupModeView .groups-table td:nth-child(3)::before {
    content: none;
  }

  #groupModeView .groups-table td:first-child input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 0;
  }

  #groupModeView .groups-table td:nth-child(2),
  #groupModeView .groups-table td:nth-child(7) {
    display: none;
  }

  #groupModeView .groups-table td:nth-child(3) {
    grid-column: 1 / -1;
    padding: 2px 38px 12px 0;
    border-bottom: 1px solid #edf2f7;
  }

  #groupModeView .groups-table .group-name,
  #groupModeView .groups-table td:nth-child(3) .group-name {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }

  #groupModeView .groups-table .group-avatar {
    width: 42px;
    height: 42px;
  }

  #groupModeView .groups-table .group-copy strong {
    color: #0f2745;
    font-size: 13px;
    line-height: 1.25;
  }

  #groupModeView .groups-table .group-copy .muted {
    margin-top: 3px;
    color: #6b7d93;
    font-size: 11px;
  }

  #groupModeView .groups-table td:nth-child(4),
  #groupModeView .groups-table td:nth-child(5) {
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 5px;
    padding: 12px 0;
    border-bottom: 1px solid #edf2f7;
  }

  #groupModeView .groups-table td:nth-child(4)::before,
  #groupModeView .groups-table td:nth-child(5)::before,
  #groupModeView .groups-table td:nth-child(6)::before {
    color: #7b8aa0;
    font-size: 11px;
    font-weight: 850;
    line-height: 1.1;
  }

  #groupModeView .groups-table td:nth-child(4) {
    color: #0f2745;
    font-weight: 850;
  }

  #groupModeView .groups-table td:nth-child(4) .muted {
    display: inline;
    margin-left: 3px;
    color: #7b8aa0;
    font-weight: 700;
  }

  #groupModeView .groups-table .role-pill {
    width: fit-content;
    max-width: 100%;
    height: 28px;
    border-radius: 8px;
    padding: 0 12px;
  }

  #groupModeView .groups-table td:nth-child(6) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(126px, auto);
    align-items: center;
    gap: 10px;
    padding-top: 12px;
  }

  #groupModeView .groups-table .chat-toggle {
    width: 100%;
    min-height: 36px;
    justify-content: space-between;
    padding: 0 11px;
  }
}

@media (max-width: 390px) {
  #groupModeView .groups-table tr {
    padding: 11px;
  }

  #groupModeView .groups-table td:nth-child(6) {
    grid-template-columns: 64px minmax(0, 1fr);
  }
}

/* Schedule calendar final polish */
.schedule-calendar-grid .schedule-event,
.schedule-calendar-grid .schedule-event:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--schedule-accent, #4f8df7) 24%, #dfe8f1);
  background:
    linear-gradient(90deg, var(--schedule-accent, #4f8df7) 0 4px, transparent 4px),
    color-mix(in srgb, var(--schedule-accent, #4f8df7) 7%, #fff);
  color: var(--text);
  box-shadow: 0 8px 18px rgba(33, 48, 70, 0.045);
}

.schedule-calendar-grid .schedule-event:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--schedule-accent, #4f8df7) 42%, #dfe8f1);
  background:
    linear-gradient(90deg, var(--schedule-accent, #4f8df7) 0 4px, transparent 4px),
    color-mix(in srgb, var(--schedule-accent, #4f8df7) 13%, #fff);
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .schedule-message-modal {
    align-items: end;
    padding: 12px;
  }

  .schedule-message-dialog {
    max-height: calc(100vh - 24px);
    border-radius: 14px;
  }

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

/* ===== Schedule V2 ===== */
.v2-form {
  display: grid;
  gap: 12px;
}
.v2-form .v2-field {
  display: grid;
  gap: 6px;
}
.v2-form .v2-field > span {
  color: #526377;
  font-size: 12px;
  font-weight: 600;
}
.v2-fieldset {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.v2-fieldset legend {
  padding: 0 6px;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.v2-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.v2-poll-options-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: center;
}
.v2-db-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  border-color: #f2c15f;
  background: #fff8e6;
  color: #7a4b00;
}
.v2-db-notice strong {
  flex: 0 0 auto;
}
.v2-db-notice span {
  min-width: 0;
  font-size: 13px;
}
.v2-target-tabs {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 4px;
}
.v2-target-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  min-height: 32px;
  box-shadow: none;
}
.v2-target-tab.active {
  background: var(--primary);
  color: #fff;
}
.v2-filter-row {
  margin-bottom: 8px;
}
.v2-group-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 2px;
  padding: 6px;
}
.v2-group-list.compact {
  max-height: 160px;
}
.v2-group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.v2-group-item:hover {
  background: #f5faf9;
}
.v2-group-item input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
}
.v2-group-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v2-group-item-id {
  color: var(--muted);
  font-size: 11px;
}
.v2-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.v2-job-dialog {
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  overflow: auto;
}
.v2-job-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.v2-job-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.v2-bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  border: 1px solid #dce7f2;
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fbff;
}

.v2-bulk-toolbar strong {
  color: #243142;
  font-size: 13px;
  white-space: nowrap;
}

.v2-bulk-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.v2-bulk-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.v2-select-col {
  width: 44px;
  min-width: 44px;
  text-align: center;
}

.v2-select-col input[type="checkbox"] {
  margin: 0 auto;
}

.v2-jobs-data tbody tr:has([data-v2-select-job]:checked) {
  background: #f2f7ff;
}

.v2-jobs-data tbody tr:has([data-v2-select-job]:checked) td {
  border-color: #d7e7fb;
}

/* Schedule V2 job modal comfort pass */
.v2-job-dialog {
  --v2-modal-pad: 22px;
  width: min(940px, calc(100vw - 32px));
  max-width: none;
  max-height: min(820px, calc(100vh - 28px));
  border-radius: 16px;
  border-color: rgba(215, 226, 235, 0.92);
  overflow: auto;
  overflow-x: hidden;
  background: #f8fbff;
}

.v2-job-dialog .panel-head {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 66px;
  padding: 18px 70px 14px var(--v2-modal-pad);
  border-bottom: 1px solid #e5edf7;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.96)),
    #fff;
  box-shadow: 0 12px 26px rgba(33, 48, 70, 0.06);
}

.v2-job-dialog .panel-head h2 {
  color: #172033;
  font-size: 22px;
  line-height: 1.2;
}

.v2-job-dialog .schedule-message-close {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 5;
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(79, 141, 247, 0.22);
}

.v2-job-dialog .v2-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: var(--v2-modal-pad);
  min-width: 0;
  overflow-x: hidden;
}

.v2-job-dialog .v2-form > *,
.v2-job-dialog .v2-target-panel,
.v2-job-dialog .v2-filter-row,
.v2-job-dialog .v2-group-tools {
  min-width: 0;
}

.v2-job-dialog .v2-form > .v2-field:has(textarea),
.v2-job-dialog .v2-form > .v2-fieldset,
.v2-job-dialog .v2-form > .v2-form-actions {
  grid-column: 1 / -1;
}

.v2-job-dialog .v2-field > span,
.v2-job-dialog .v2-fieldset legend {
  color: #45566d;
  font-size: 12px;
  font-weight: 850;
}

.v2-job-dialog input,
.v2-job-dialog select,
.v2-job-dialog textarea {
  border-radius: 9px;
  border-color: #ccd9e7;
  background: #fff;
}

.v2-job-dialog input,
.v2-job-dialog select {
  height: 44px;
  padding-inline: 12px;
}

.v2-job-dialog textarea {
  min-height: 96px;
  padding: 12px;
}

.v2-job-dialog input:hover,
.v2-job-dialog select:hover,
.v2-job-dialog textarea:hover {
  border-color: #aebed0;
}

.v2-job-dialog .v2-fieldset {
  border-radius: 12px;
  border-color: #dce7f2;
  padding: 16px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(33, 48, 70, 0.045);
}

.v2-job-dialog .v2-target-tabs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border-radius: 11px;
  border-color: #d7e2eb;
  padding: 5px;
  background: #f3f7fb;
}

.v2-job-dialog .v2-target-tab {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 850;
}

.v2-job-dialog .v2-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.v2-group-tools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.v2-group-tools button {
  min-height: 36px;
  padding-inline: 11px;
  font-size: 12px;
  min-width: 0;
}

.v2-job-dialog .v2-group-list {
  max-height: clamp(220px, 34vh, 340px);
  border-radius: 10px;
  border-color: #dbe7f2;
  padding: 8px;
  background: #fbfdff;
}

.v2-job-dialog .v2-group-list.compact {
  max-height: 220px;
}

.v2-job-dialog .v2-group-item {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  color: #334155;
}

.v2-job-dialog .v2-group-item:hover {
  border-color: #d7e7fb;
  background: #f2f7ff;
}

.v2-job-dialog .v2-group-item:has(input:checked) {
  border-color: rgba(79, 141, 247, 0.38);
  background: #edf4ff;
  color: #203a66;
  font-weight: 800;
}

.v2-job-dialog .v2-group-item-name {
  flex: 1 1 auto;
}

.v2-job-dialog .v2-group-item-id {
  flex: 0 0 auto;
}

.v2-job-dialog #v2ManualCount {
  margin-top: -2px;
  color: #5b6f88;
  font-size: 12px;
  font-weight: 800;
}

.v2-job-dialog .v2-poll-options-row {
  grid-template-columns: minmax(160px, 0.8fr) repeat(4, minmax(150px, 1fr));
  align-items: end;
}

.v2-job-dialog .v2-checkbox {
  min-height: 42px;
  border: 1px solid #dce7f2;
  border-radius: 9px;
  padding: 9px 10px;
  background: #fbfdff;
  color: #334155;
  font-weight: 750;
}

.v2-job-dialog .v2-checkbox:has(input:checked) {
  border-color: rgba(79, 141, 247, 0.4);
  background: #edf4ff;
}

.v2-job-dialog .v2-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 6px calc(var(--v2-modal-pad) * -1) calc(var(--v2-modal-pad) * -1);
  padding: 14px var(--v2-modal-pad);
  border-top: 1px solid #e5edf7;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -12px 24px rgba(33, 48, 70, 0.06);
}

.v2-job-dialog .v2-form-actions button {
  min-width: 118px;
  min-height: 40px;
  border-radius: 9px;
}

@media (max-width: 760px) {
  .v2-job-dialog {
    --v2-modal-pad: 16px;
    width: 100%;
    max-height: calc(100vh - 18px);
    border-radius: 16px 16px 0 0;
  }

  .v2-job-dialog .panel-head h2 {
    font-size: 19px;
  }

  .v2-job-dialog .v2-form,
  .v2-job-dialog .v2-filter-row,
  .v2-job-dialog .v2-poll-options-row {
    grid-template-columns: 1fr;
  }

  .v2-group-tools,
  .v2-job-dialog .v2-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .v2-job-dialog .v2-form-actions button,
  .v2-group-tools button {
    width: 100%;
    white-space: normal;
  }
}

@media (max-width: 430px) {
  .v2-job-dialog .v2-target-tabs,
  .v2-group-tools,
  .v2-job-dialog .v2-form-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .v2-bulk-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .v2-bulk-toolbar strong {
    white-space: normal;
  }

  .v2-bulk-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .v2-bulk-actions button {
    width: 100%;
    white-space: normal;
  }

  .v2-jobs-data td:first-child {
    min-height: 34px;
  }

  .v2-jobs-data td:first-child::before {
    content: "Chọn";
  }

  .v2-jobs-data td:nth-child(2)::before {
    content: "Tên job";
  }

  .v2-jobs-data td:nth-child(3)::before {
    content: "Lịch gửi";
  }

  .v2-jobs-data td:nth-child(4)::before {
    content: "Loại";
  }

  .v2-jobs-data td:nth-child(5)::before {
    content: "Nội dung";
  }

  .v2-jobs-data td:nth-child(6)::before {
    content: "Nhóm nhận";
  }

  .v2-jobs-data td:nth-child(7)::before {
    content: "Trạng thái";
  }

  .v2-jobs-data td:nth-child(8)::before {
    content: "Thao tác";
  }
}

@media (max-width: 360px) {
  .v2-bulk-actions {
    grid-template-columns: 1fr;
  }
}
