:root {
  --bg: #0a0b0f;
  --bg-sidebar: #0d0f14;
  --bg-elevated: #14161d;
  --bg-elevated-2: #191c24;
  --bg-input: #101217;
  --border: #23262f;
  --border-light: #333947;
  --border-hover: #454c5c;
  --text: #edeef2;
  --text-muted: #93a0b3;
  --text-faint: #5e6879;
  --accent: #5b8cff;
  --accent-hover: #7aa0ff;
  --accent-active: #4a78e6;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --accent-glow: rgba(91, 140, 255, 0.35);
  --success: #45b871;
  --success-soft: rgba(69, 184, 113, 0.14);
  --danger: #f0564d;
  --danger-soft: rgba(240, 86, 77, 0.14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.36), 0 2px 6px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-focus: 0 0 0 3px var(--accent-soft);
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 15px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --lh-tight: 1.3;
  --lh-normal: 1.5;
  --lh-loose: 1.7;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.app {
  display: flex;
  height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 18px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #8a5bff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tab-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  transition:
    background 0.12s,
    color 0.12s;
}

.tab-button::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.12s;
}

.tab-button:hover {
  background: var(--bg-elevated-2);
  color: var(--text);
}

.tab-button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab-button.active::before {
  opacity: 1;
}

/* ---- Language switcher (public viewer only) ---- */
/* Fixed to the top-right rather than living in the sidebar: on a phone the
   sidebar is a drawer translated off-screen, so a switcher inside it would be
   hidden behind the ☰ — no good on a public listings page read mostly on
   phones by people who need the translation in the first place. */
.lang-switcher {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 860;
}

.lang-button {
  background: var(--bg-elevated-2);
  border-color: var(--border-light);
  color: var(--text);
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
}

.lang-button:hover:not(:disabled) {
  background: var(--bg-elevated-2);
  color: var(--text);
}

.lang-caret {
  margin-left: auto;
  font-size: 10px;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  /* 11 entries do not fit on a short phone in landscape — scroll rather than
     run off the bottom of the screen with the last options unreachable. */
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.lang-item {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  color: var(--text);
  padding: 8px 10px;
  font-size: var(--fs-base);
}

.lang-item:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent);
}

.lang-item.active {
  color: var(--accent);
  font-weight: 600;
}

/* Google mounts a visible widget and a fixed banner iframe that shoves the page
   down with an inline `body { top: 40px }`. We drive the widget ourselves, so
   hide all of it and undo the offset. */
#google_translate_element,
.skiptranslate,
.goog-te-banner-frame,
.goog-te-gadget {
  display: none !important;
}

body {
  top: 0 !important;
}

/* Google wraps translated runs in <font> tags and adds a highlight on hover;
   neither should change the layout or colours of the cards. */
font {
  background: none !important;
  box-shadow: none !important;
  color: inherit !important;
}

/* ---- Icon system ---- */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.icon-lg {
  width: 20px;
  height: 20px;
}

.tab-icon {
  width: 18px;
  justify-content: flex-start;
}

.badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-full);
  padding: 1px 7px;
  line-height: 1.6;
}

/* ---- Main ---- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow: auto;
  padding: 28px 32px;
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h1 {
  margin: 0 0 4px;
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.global-actions {
  flex-shrink: 0;
  padding: 18px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* ---- Buttons ---- */
button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.05s;
}

button:hover:not(:disabled) {
  background: var(--bg-elevated-2);
  border-color: var(--border-hover);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

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

button.btn-loading {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
  cursor: wait;
}

.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-left: 4px;
}

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

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

button.primary:active:not(:disabled) {
  background: var(--accent-active);
  border-color: var(--accent-active);
}

button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

button.danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

button.ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text);
}

button.small {
  padding: 5px 10px;
  font-size: 12px;
}

/* ---- Scheduler ---- */
.scheduler-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.scheduler-label {
  font-size: 13px;
  font-weight: 600;
}

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

.scheduler-status.active {
  color: var(--success);
  font-weight: 500;
}

.scheduler-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scheduler-interval-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 0;
}

.scheduler-interval-label input {
  width: 60px;
  padding: 5px 8px;
  font-size: 12px;
  text-align: center;
}

/* ---- Log panel (persistent bottom bar) ---- */
.log-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #0a0c10;
  border-top: 1px solid var(--border);
  height: 180px;
  transition: height 0.2s ease;
}

.log-panel.collapsed {
  height: 36px;
}

.log-panel.collapsed #log {
  display: none;
}

.log-panel.expanded {
  height: 50vh;
}

.log-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.log-panel-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.log-title {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.run-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  margin-right: 8px;
}

.run-dot.active {
  background: var(--success);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 109, 0.55);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(76, 175, 109, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 109, 0);
  }
}

#log {
  flex: 1;
  margin: 0;
  padding: 10px 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #c3ccd4;
}

/* ---- Status text ---- */
.status-text {
  font-size: 12px;
  color: var(--text-muted);
}

.status-ok {
  color: var(--success);
  font-size: 12px;
  font-weight: 500;
}

.status-err {
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
}

/* ---- Inbox ---- */
#posts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state .empty-icon {
  display: inline-flex;
}

.empty-state .empty-icon .icon {
  width: 36px;
  height: 36px;
  color: var(--text-faint);
}

.post-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.post-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.post-card h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.post-images img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  transition:
    transform 0.15s,
    border-color 0.15s;
  background: #000;
}

.post-images img:hover {
  transform: scale(1.03);
  border-color: var(--accent);
}

.post-card textarea,
.search-result-card textarea {
  width: 100%;
  min-height: 120px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  resize: vertical;
}

.post-card .actions,
.search-result-card .actions {
  margin-top: 10px;
  margin-bottom: 0;
}

/* ---- Overview ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}

.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 650;
  line-height: var(--lh-tight);
}

.stat-value.stat-value-active {
  color: var(--success);
}

.stat-label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Active posting panel (overview) ---- */
.active-posting-card {
  margin-bottom: var(--space-5);
}

.active-posting-count {
  font-size: var(--fs-sm);
  color: var(--accent);
  font-weight: 600;
  margin-left: 6px;
}

.active-posting-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.active-post-row {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.active-post-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.active-post-name {
  font-weight: 600;
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-post-elapsed {
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.active-post-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 8px;
}

.active-post-bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.active-post-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.active-post-bar.indeterminate .active-post-bar-fill {
  width: 35%;
  animation: activePostIndeterminate 1.2s ease-in-out infinite;
}

@keyframes activePostIndeterminate {
  0% {
    margin-left: -35%;
  }
  100% {
    margin-left: 100%;
  }
}

.active-post-current {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Resume posting card ---- */
.resume-posting-card {
  margin-bottom: var(--space-5);
}

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

.resume-posting-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 12px;
}

.resume-continue-btn {
  flex: none;
}

.resume-head-actions,
.resume-row-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

/* ---- Failed posts card ---- */
.failures-card {
  margin-bottom: var(--space-5);
}

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

.failures-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.failure-group {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.failure-group + .failure-group {
  margin-top: 0;
}

.failure-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}

.failure-group-head::-webkit-details-marker {
  display: none;
}

.failure-group-head::before {
  content: "▸";
  color: var(--text-muted);
  margin-right: 6px;
  flex: none;
  transition: transform 0.18s ease;
}

.failure-group[open] .failure-group-head::before {
  transform: rotate(90deg);
}

.failure-group-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.failure-row {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.failure-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.failure-page {
  font-weight: 600;
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.failure-time {
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.failure-cause {
  margin-top: 4px;
  font-size: 13px;
  color: var(--danger);
}

.failure-caption {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.failure-error {
  margin-top: 6px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.5em;
  overflow: auto;
}

/* ---- Settings ---- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
  max-width: 760px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
}

.card h2 .icon {
  color: var(--accent);
}

.settings-card {
  padding: 0;
  overflow: hidden;
}

.settings-card h2 {
  margin: 0;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.card-header-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.card-header-icon.fb-icon {
  background: linear-gradient(135deg, #1877f2, #0d65d9);
}

.card-header-icon.zalo-icon {
  background: linear-gradient(135deg, #0068ff, #0052cc);
}

.card-header-icon.scheduler-icon {
  background: linear-gradient(135deg, var(--success), #2e8b4a);
  font-size: 18px;
}

.card-header p.card-header-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 3px 0 0;
  line-height: 1;
}

.settings-section {
  padding: 18px 22px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.settings-section p.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.5;
  opacity: 0.75;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ---- Collapsible settings section ---- */
.settings-collapse {
  border-top: 1px solid var(--border);
}

.settings-collapse-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.settings-collapse-header::-webkit-details-marker {
  display: none;
}

.settings-collapse-header .settings-section-title {
  margin-bottom: 0;
}

.settings-collapse-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  line-height: 1.6;
}

.settings-collapse-arrow {
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-muted);
  transition: transform 0.2s;
}

.settings-collapse[open] > .settings-collapse-header .settings-collapse-arrow {
  transform: rotate(180deg);
}

.settings-collapse-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.settings-collapse-body {
  padding-top: 0;
  border-top: 1px solid var(--border);
}

.settings-actions {
  padding: 14px 22px;
  margin-bottom: 0;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

/* ---- Toggle switches ---- */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.toggle-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  cursor: pointer;
  margin-bottom: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.toggle-label:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.toggle-label:first-child {
  padding-top: 0;
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toggle-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.toggle-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 22px;
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Form labels (enhanced) ---- */
.form-label-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.form-label-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  opacity: 0.75;
}

.actions-spacer {
  flex: 1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.field-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

label.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 16px;
}

.form-grid-spaced {
  margin-top: 14px;
}

.inline-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-controls select {
  flex: 1;
}

.inline-controls input {
  flex: 1;
}

/* ---- Inputs ---- */
input,
select,
textarea {
  font-family: inherit;
}

input,
select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

/* iOS Safari ignores background/color on a native <select> and paints its own
   system control, so the dark theme's white-ish text landed on a white system
   background — the district/type filters were effectively invisible on iPhone.
   Opting out of the native appearance is what makes the theme apply; the arrow
   then has to be drawn back in (inline SVG, allowed by the page CSP's
   `img-src … data:`). */
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%2393a0b3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 11px;
  padding-right: 28px;
}

input::placeholder {
  color: #5b6473;
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--border-hover);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

/* ---- Guide ---- */
.guide-steps {
  margin: 0;
  padding-left: 22px;
  font-size: 13px;
  line-height: 1.7;
}

.guide-steps li {
  margin-bottom: 6px;
}

.guide-list {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.guide-list dt {
  font-weight: 600;
  margin-top: 12px;
}

.guide-list dt:first-child {
  margin-top: 0;
}

.guide-list dd {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.card p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.card p:last-child {
  margin-bottom: 0;
}

.card code {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 12px;
}

/* ---- Search Rooms By AI ---- */
.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-bar input {
  flex: 1;
  min-width: 0;
}

.search-cache-info {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.search-result-count {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar select,
.filter-bar input[type="number"],
.filter-bar input[type="search"] {
  /* background-COLOR, not the shorthand: the shorthand would reset the custom
     dropdown arrow that the base `select` rule paints as a background-image. */
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  height: 34px;
}

.filter-bar select {
  padding-right: 28px;
}

.filter-bar select:focus,
.filter-bar input[type="number"]:focus,
.filter-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-bar input[type="number"] {
  width: 130px;
}

.filter-bar input[type="search"].rooms-search-input {
  width: 240px;
  flex: 1 1 200px;
  max-width: 320px;
}

.price-range {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.search-result-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.search-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.search-result-text {
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* Toggle between the original Zalo caption and the SEO caption on read-only
   room cards. */
.text-type-toggle {
  align-self: flex-start;
  margin-bottom: 8px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border-color: var(--border);
}

/* ---- Groups table ---- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
}

#groups-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

#groups-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: var(--bg-input);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

#groups-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

#groups-table tr:last-child td {
  border-bottom: none;
}

#groups-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.012);
}

#groups-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

#groups-table input[type="text"] {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
}

#groups-table input[type="text"]:hover,
#groups-table input[type="text"]:focus {
  border-color: var(--border-light);
  background: var(--bg-input);
}

#groups-table td:last-child {
  width: 60px;
  text-align: center;
}

/* ---- Page URLs table ---- */
#pageurls-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

#pageurls-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: var(--bg-input);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

#pageurls-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

#pageurls-table tr:last-child td {
  border-bottom: none;
}

#pageurls-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

#pageurls-table td:last-child {
  width: 90px;
  text-align: right;
  white-space: nowrap;
}

/* ---- Page URLs drag-to-reorder ---- */
#pageurls-table .pageurl-drag-col {
  width: 34px;
  padding-left: 8px;
  padding-right: 0;
}

.pageurl-drag {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: grab;
}

.pageurl-drag:hover,
.pageurl-drag:focus-visible {
  color: var(--text);
  background: var(--bg-input);
}

#pageurls-table tr.dragging {
  opacity: 0.45;
}

#pageurls-table tr.dragging .pageurl-drag {
  cursor: grabbing;
}

/* Insertion target while dragging. */
#pageurls-table tr.drag-over td {
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

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

.pageurl-name {
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pageurl-url {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-all;
}

.pageurl-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  margin: 0 6px 4px 0;
}

.pageurl-badge-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---- Open Facebook / Open Zalo page picker dropdown ---- */
.caret {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 2px;
}

.pageurl-menu {
  position: fixed;
  z-index: 1100;
  min-width: 220px;
  max-width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: fadeIn 0.1s ease;
}

.pageurl-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.pageurl-menu-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.pageurl-menu-item.active {
  color: var(--accent);
  font-weight: 600;
}

.pageurl-menu-item.active::after {
  content: " ✓";
}

.pageurl-menu-empty {
  padding: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Post-to-multiple menu ---- */
.post-menu-all {
  font-weight: 600;
  color: var(--accent);
}

.post-menu-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

.post-menu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
}

.post-menu-row input[type="checkbox"] {
  flex: none;
  cursor: pointer;
}

.post-menu-name {
  flex: 1;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-menu-name:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.post-menu-name.active {
  color: var(--accent);
  font-weight: 600;
}

.post-menu-selected {
  margin-top: 6px;
  border-top: 1px solid var(--border-light);
  font-weight: 600;
  color: var(--accent);
}

.post-menu-reset {
  margin-top: 6px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Caption raw/seo ---- */
.caption-raw-toggle {
  margin-bottom: 8px;
}

.caption-raw-toggle summary {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  margin-bottom: 4px;
}

.caption-raw-text {
  margin: 6px 0 0;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.caption-seo-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 10px;
  margin-bottom: 6px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 28px 20px;
  min-width: 360px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

/* ---- Progress card (bulk delete) ---- */
/* Sits in the corner alongside the toasts rather than over the page: the rows
   are already gone from the list before this work starts, so there is nothing
   to shield the user from and no reason to freeze the dashboard for it. */
.progress-toast {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 40px));
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.25s ease;
  /* Inherits the container's `pointer-events: none` — there is nothing to click
     on it, so it must not swallow clicks on whatever it happens to cover. */
}

.progress-toast.toast-exit {
  animation: slideOutRight 0.2s ease forwards;
}

.progress-toast-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.progress-toast-body {
  margin-top: 3px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.progress-toast .progress-bar {
  margin-top: 10px;
}

.progress-toast .progress-count {
  margin-top: 6px;
  font-size: var(--fs-xs);
}

.progress-bar {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 18px;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  border-radius: var(--radius-full);
  background: var(--danger);
  transition: width 0.2s ease;
}

.progress-count {
  margin-top: 10px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* A single room being deleted — dim its card while the request is in flight. */
.card-deleting {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.modal-body {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.modal-input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 12px;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-input-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  cursor: pointer;
}

.modal-checkbox {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 9px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  transition:
    background 0.15s,
    border-color 0.15s;
}

.modal-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.modal-btn.primary:hover {
  background: var(--accent-hover);
}

.modal-btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.modal-btn.danger:hover {
  background: var(--danger);
  color: #fff;
}

.modal-btn.ghost {
  border-color: transparent;
  color: var(--text-muted);
}

.modal-btn.ghost:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

/* ---- Structured form modal (Add / Edit Page URL) ---- */
.modal.form-modal {
  padding: 0;
  width: 460px;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.form-modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.form-modal-header .modal-title {
  margin: 0;
}

.form-modal-header .modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0;
  line-height: 1.5;
}

.form-modal-body {
  padding: 8px 24px 4px;
  overflow-y: auto;
}

.form-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: rgba(255, 255, 255, 0.015);
}

.modal-field {
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.modal-field:last-child {
  border-bottom: none;
}

.modal-field > .modal-input {
  margin-bottom: 0;
}

.modal-field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 7px;
}

.modal-field-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  opacity: 0.75;
  margin-top: 7px;
}

.modal-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 8px 0 -2px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Toggle rows reuse .toggle-label/.toggle-info/.toggle-switch from settings */
.modal-toggle-group {
  padding: 4px 0;
}

/* Segmented (2+ option) control */
.segmented {
  display: inline-flex;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.segmented button {
  flex: 1;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-light);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.25s ease;
  pointer-events: auto;
}

.toast.toast-success {
  border-color: var(--success);
}
.toast.toast-error {
  border-color: var(--danger);
}
.toast.toast-info {
  border-color: var(--accent);
}

.toast-icon {
  display: inline-flex;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  color: var(--success);
}
.toast-error .toast-icon {
  color: var(--danger);
}
.toast-info .toast-icon {
  color: var(--accent);
}

.toast.toast-exit {
  animation: slideOutRight 0.2s ease forwards;
}

/* ---- Button group divider ---- */
.btn-divider {
  width: 1px;
  height: 24px;
  background: var(--border-light);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ---- Responsive sidebar ---- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 900;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 18px;
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  cursor: pointer;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 800;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 850;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-backdrop.visible {
    display: block;
  }

  .main-content {
    padding: 20px 16px;
  }

  .global-actions {
    padding: 14px 16px;
    padding-left: 56px;
  }

  .global-actions {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  /* iOS zooms the whole page in when a focused field's text is under 16px, and
     never zooms back out — tapping the search box left the layout stranded.
     The filter-bar selectors are listed explicitly because their own rules are
     more specific than a bare `input`/`select`. */
  input,
  select,
  textarea,
  .filter-bar select,
  .filter-bar input[type="number"],
  .filter-bar input[type="search"] {
    font-size: 16px;
  }

  .filter-bar select,
  .filter-bar input[type="number"],
  .filter-bar input[type="search"] {
    height: auto;
  }
}

/* ---- Metadata chips ---- */
.meta-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

/* Per-room delete button, pushed to the far right of the chips row. */
.room-delete {
  margin-left: auto;
  flex: none;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(91, 140, 255, 0.2);
}

.meta-chip.chip-price {
  background: rgba(76, 175, 109, 0.12);
  color: var(--success);
  border-color: rgba(76, 175, 109, 0.2);
}

.meta-chip.chip-district {
  background: rgba(168, 130, 255, 0.12);
  color: #a882ff;
  border-color: rgba(168, 130, 255, 0.2);
}

.meta-chip.chip-bedroom {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(245, 165, 36, 0.2);
}

.meta-chip.chip-time {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

/* Where a listing stands with the active Facebook page. */
.meta-chip.chip-topost {
  background: rgba(76, 175, 109, 0.16);
  color: var(--success);
  border-color: rgba(76, 175, 109, 0.35);
  font-weight: 600;
}

.meta-chip.chip-posted {
  background: transparent;
  color: var(--text-faint);
  border-color: var(--border);
}

.meta-chip.chip-nophotos {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(245, 165, 36, 0.2);
}

/* ---- Log coloring ---- */
.log-error {
  color: var(--danger);
}
.log-warn {
  color: var(--warn);
}
.log-success {
  color: var(--success);
}
.log-info {
  color: var(--accent);
}
.log-muted {
  color: var(--text-muted);
}

/* ---- Tab transitions ---- */
.tab-panel {
  display: none;
  flex-direction: column;
  min-height: 100%;
}

.tab-panel.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

/* ---- Lightbox ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  cursor: zoom-out;
  animation: fadeIn 0.15s ease;
}

.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  animation: scaleIn 0.2s ease;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-prev {
  left: 16px;
}
.lightbox-next {
  right: 16px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.lightbox-copy {
  position: absolute;
  top: 16px;
  right: 68px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.lightbox-copy:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-copy.copied {
  background: var(--success);
  color: #fff;
}

/* ---- Copy to clipboard ---- */
/* Sits over a thumbnail; revealed on hover or keyboard focus. */
.post-image-cell {
  position: relative;
}

.post-image-cell img {
  display: block;
}

.copy-icon-btn.image-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.15s,
    background 0.15s;
}

.post-image-cell:hover .image-copy-btn,
.image-copy-btn:focus-visible {
  opacity: 1;
}

.image-copy-btn:hover {
  background: var(--accent);
}

/* Touch devices have no hover, so keep it visible there. */
@media (hover: none) {
  .copy-icon-btn.image-copy-btn {
    opacity: 1;
  }
}

.room-copy-caption,
.room-copy-photos,
.room-share-photos {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.room-copy-caption.copied,
.room-copy-photos.copied,
.room-share-photos.copied {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(69, 184, 113, 0.4);
}

.image-copy-btn.copied {
  background: var(--success);
  color: #fff;
  opacity: 1;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---- Server unreachable banner ---- */
.server-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  text-align: center;
  line-height: 1.5;
}

.server-banner code {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: Consolas, monospace;
}

.server-banner small {
  opacity: 0.8;
}

/* ---- Post card hover ---- */
.post-images img {
  cursor: zoom-in;
}

/* ---- All Rooms single thumbnail ---- */
.room-thumb-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 8px;
  cursor: zoom-in;
}

.room-thumb {
  display: block;
  width: 150px;
  height: 110px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition:
    border-color 0.15s,
    transform 0.15s;
}

.room-thumb:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

.room-thumb-count {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

/* ---- Search result card hover ---- */
.search-result-card {
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.search-result-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

/* ---- Infinite scroll sentinel ---- */
#rooms-sentinel {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rooms-loading-more {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- Vercel read-only mode ---- */
/* Hide everything except All Rooms tab + filter bar */
html.vercel-mode .global-actions {
  display: none;
}
html.vercel-mode #log-panel {
  display: none;
}
html.vercel-mode .tab-button:not([data-tab="rooms"]):not([data-tab="contact"]) {
  display: none;
}
html.vercel-mode #overview {
  display: none;
}
html.vercel-mode #inbox {
  display: none;
}
html.vercel-mode #search {
  display: none;
}
html.vercel-mode #settings {
  display: none;
}
html.vercel-mode #guide {
  display: none;
}
/* Read-only viewer: hide every mutating control (cloud upload+clear /
   bulk + per-room delete). */
html.vercel-mode #btn-sync-cloud,
html.vercel-mode #btn-clear-images,
html.vercel-mode #btn-delete-rooms-by,
html.vercel-mode #btn-clear-rooms,
html.vercel-mode .room-delete,
html.vercel-mode .room-copy-photos,
/* A static deploy has no posting state, so status means nothing there. */
html.vercel-mode #rooms-filter-status {
  display: none;
}
/* Force All Rooms tab to appear selected from first paint */
html.vercel-mode .tab-button[data-tab="rooms"] {
  background: var(--accent-soft);
  color: var(--accent);
  cursor: default;
}
/* Remove sidebar toggle since there's nothing to navigate */
html.vercel-mode .sidebar-toggle {
  display: none;
}

/* ---- SEO block (public viewer only) ----
   `.seo-only` is IN the HTML source on both sides and only hidden by CSS on the
   dashboard, which is the point: the markup a crawler parses must contain the
   copy and the internal links to /apartments-for-rent-da-nang/, regardless of
   which mode the page later decides it is in. It is not cloaking — the public
   deploy shows every word of it to a human visitor too. */
html:not(.vercel-mode) .seo-only {
  display: none;
}
html.vercel-mode .dash-only {
  display: none;
}
.seo-intro {
  max-width: 68ch;
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  line-height: 1.65;
}
.seo-intro strong {
  color: var(--text);
  font-weight: 600;
}
.seo-intro a {
  color: var(--accent);
}
.seo-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0.75rem 0;
}
.seo-links a {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 0.85rem;
  text-decoration: none;
}
.seo-contact {
  margin-bottom: 0;
}

/* ---- Contact tab ---- */
.contact-card {
  max-width: 480px;
}
.contact-section-title {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.contact-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.contact-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  transition:
    filter 0.15s,
    transform 0.1s;
  color: #fff;
}
.contact-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.contact-btn:active {
  transform: translateY(0);
}
.contact-btn-zalo {
  background: #0068ff;
}
.contact-btn-whatsapp {
  background: #25d366;
}
.contact-btn-facebook {
  background: #1877f2;
}
.contact-btn-zalo-group {
  background: #0068ff;
}
.contact-btn-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  fill: currentColor;
}
.contact-btn-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.contact-btn-title {
  font-size: 1rem;
}
.contact-btn-sub {
  font-size: 0.8rem;
  opacity: 0.88;
  font-weight: 400;
}
