/*
 * APEX x Sufee
 * Complete visual replacement based on the Sufee Admin Dashboard design
 * language. The application DOM and IDs remain stable for Firebase modules.
 */

@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --sidebar: 270px;
  --sidebar-bg: #1d2126;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --content-bg: #15181c;
  --surface: var(--c-surface);
  --surface-soft: var(--c-soft);
  --border: #383e46;
  --border2: #454c55;
  --border-accent: rgba(24, 126, 162, 0.28);
  --t1: #e7eaee;
  --t2: #a7afb8;
  --t3: #7f8994;
  --bg0: #15181c;
  --bg1: var(--c-surface);
  --bg2: var(--c-soft);
  --bg3: var(--c-hover);
  --bg-active: #243844;
  --brand: #20a8d8;
  --brand-dark: #187fa5;
  --brand-hover: #45b7df;
  --brand-muted: rgba(32, 168, 216, 0.14);
  --brand-glow: rgba(32, 168, 216, 0.18);
  --purple: #6f42c1;
  --indigo: #5368d5;
  --blue: #20a8d8;
  --cyan: #63c2de;
  --green: #4dbd74;
  --amber: #ffc107;
  --red: #c0504d;
  --pink: #e83e8c;
  --orange: #f59f00;
  --r-card: 12px;
  --r-sm: 8px;
  --r-xs: 3px;
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(39, 44, 51, 0.12);
  --shadow-glow: 0 4px 18px rgba(24, 126, 162, 0.15);
  --font-sans: "Open Sans", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, monospace;
  --ease-out: ease;
  --dur-sm: 150ms;
  --dur-md: 250ms;

  /* Theme tokens for surfaces/lines/text that used to be hardcoded dark hex.
     These :root values are the dark theme; the light theme overrides them
     below. The sidebar keeps its own fixed dark colours in both themes. */
  --c-sunken: #1b1f24;
  --c-surface: #20252b;
  --c-raised: #252a30;
  --c-header: #272c32;
  --c-soft: #292e35;
  --c-hover: #30363d;
  --c-line: #3b424a;
  --c-line-strong: #464d55;
  --c-line-hover: #59616b;
  --c-text-strong: #f3f5f7;
  --c-text: #cbd1d7;
  --c-text-muted: #aab2ba;
  --c-accent-text: #63c2de;
  --c-link-soft: #7aa7ff;
  --c-danger-text: #f3b4b4;
  --c-today-bg: #292923;
  --c-today-line: #d1a01f;
  --c-today-text: #e2b331;
  --c-holiday-bg: #221c30;
  --c-holiday-line: #4c3b6e;
  --c-holiday-text: #c9b6f5;
  --c-intl-text: #f5d6a8;

  /* Coloured text on plain surfaces. Dark keeps the bright shade; light
     swaps in a deeper one so it stays readable on white. */
  --c-stat-text: #2aa9d6;
  --c-green-text: var(--green);
  --c-amber-text: var(--amber);
  --c-orange-text: var(--orange);
  --c-purple-text: #a78bfa;
  --c-blue-text: #60a5fa;
  --c-brand-text: var(--brand);

  --pf-instagram: #e4405f;
  --pf-facebook: #1877f2;
  --pf-linkedin: #0a66c2;
  --pf-tiktok: #f1f1f1;
  --pf-youtube: #ff0000;
  --pf-instagram-bg: linear-gradient(45deg, #f58529 0%, #dd2a7b 50%, #8134af 100%);
}

html[data-theme="light"] {
  --content-bg: #f1f2f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fa;
  --border: #dee2e6;
  --border2: #ced4da;
  --t1: #212529;
  --t2: #495057;
  --t3: #6c757d;
  --bg0: #f1f2f7;
  --bg1: #ffffff;
  --bg2: #f5f6f8;
  --bg3: #e9ecef;
  --bg-active: #e3f2f9;
  --brand-muted: rgba(32, 168, 216, 0.1);
  --shadow-card: 0 1px 2px rgba(39, 44, 51, 0.06);

  --c-sunken: #f5f6f8;
  --c-surface: #ffffff;
  --c-raised: #f8f9fa;
  --c-header: #f8f9fa;
  --c-soft: #f1f3f5;
  --c-hover: #e9ecef;
  --c-line: #e3e6ea;
  --c-line-strong: #ced4da;
  --c-line-hover: #adb5bd;
  --c-text-strong: #1f2328;
  --c-text: #343a40;
  --c-text-muted: #6c757d;
  --c-accent-text: #187fa5;
  --c-link-soft: #2563eb;
  --c-danger-text: #b42318;
  --c-today-bg: #fff8e1;
  --c-today-line: #e2b331;
  --c-today-text: #a67c00;
  --c-holiday-bg: #f5f0ff;
  --c-holiday-line: #c4b1ec;
  --c-holiday-text: #5b3fa8;
  --c-intl-text: #8a5a00;
  --c-stat-text: #187fa5;
  --c-green-text: #1f8a4c;
  --c-amber-text: #8a6100;
  --c-orange-text: #a35f00;
  --c-purple-text: #5b3fa8;
  --c-blue-text: #2563eb;
  --c-brand-text: #187fa5;
  --pf-tiktok: #000000;
  color-scheme: light;
}

html {
  height: 100%;
  background: var(--content-bg);
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--content-bg);
  color: var(--t1);
  display: flex;
  overflow: hidden;
  font: 15px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--c-brand-text);
}

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

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

::-webkit-scrollbar-thumb {
  background: #c8ced5;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 10px;
}

/* SVG icon system */
.apex-svg-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  vertical-align: -0.14em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.emoji-replaced {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

/* Application shell */
#sidebar {
  position: relative;
  z-index: 1020;
  width: var(--sidebar);
  height: 100vh;
  flex: 0 0 var(--sidebar);
  display: flex;
  flex-direction: column;
  overflow: visible;
  color: #c8c9ce;
  background: var(--sidebar-bg);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.08);
  transition: width 0.3s ease, flex-basis 0.3s ease, transform 0.3s ease;
}

.sb-logo {
  position: relative;
  min-height: 70px;
  padding: 13px 18px;
  display: flex;
  align-items: center;
  background: #20252b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sb-logo .mark {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-monogram {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
}

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

.brand-lockup {
  min-width: 0;
  line-height: 1;
}

.brand-wordmark {
  overflow: hidden;
  color: #fff;
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-tagline {
  margin-top: 5px;
  color: #8e979f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sb-logo .hex {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: none;
}

.sb-logo .name {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.sb-logo .name span {
  color: inherit;
}

.sb-logo .sub {
  margin-top: 1px;
  color: #8e979f;
  font-size: 12px;
  white-space: nowrap;
}

.sb-toggle {
  position: absolute;
  top: 50%;
  right: -14px;
  z-index: 4;
  width: 28px;
  height: 34px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #aeb6be;
  background: #22272d;
  border: 1px solid #454c54;
  border-radius: 0 5px 5px 0;
  box-shadow: 2px 1px 4px rgba(0, 0, 0, 0.28);
  transform: translateY(-50%);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.sb-toggle:hover {
  color: #fff;
  background: #2d343b;
  border-color: #65717c;
}

.sb-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sb-toggle-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}

.sb-domain {
  margin: 15px 16px 5px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  color: #c8c9ce;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
}

.sb-domain .url {
  min-width: 0;
  overflow: hidden;
  color: #b9c0c6;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sidebar nav {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 16px 18px;
}

.nav-label {
  padding: 18px 12px 7px;
  color: #737c85;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  min-height: 42px;
  margin: 2px 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: #c8c9ce;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-item:hover {
  color: #fff;
  background: var(--sidebar-hover);
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-active);
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  color: #8f9aa3;
  font-size: 18px;
}

.nav-item.active .icon,
.nav-item:hover .icon {
  color: var(--cyan);
}

.nav-item .nav-text {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
}

.nav-item .badge,
.nav-item .nbadge,
.kb-hint {
  margin-left: auto;
}

.kb-hint {
  display: none;
}

.sb-bottom {
  padding: 14px 16px 16px;
  background: #20252b;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

body.sidebar-collapsed {
  --sidebar: 72px;
}

body.sidebar-collapsed .sb-logo {
  padding-inline: 17px;
}

body.sidebar-collapsed .sb-logo .brand-lockup,
body.sidebar-collapsed .sb-domain .url,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-item .badge,
body.sidebar-collapsed .nav-item .nbadge,
body.sidebar-collapsed .sb-bottom {
  display: none !important;
}

body.sidebar-collapsed #sidebar nav {
  padding-inline: 12px;
}

body.sidebar-collapsed .sb-domain,
body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 10px;
}

body.sidebar-collapsed .sb-domain {
  margin-inline: 13px;
}

body.sidebar-collapsed .sb-logo .mark {
  justify-content: center;
}

body.sidebar-collapsed .sb-logo .sb-toggle {
  display: grid !important;
}

body.sidebar-collapsed .sb-toggle-icon {
  transform: rotate(180deg);
}

/* Collapsed-sidebar hover tooltip. A single element positioned via JS
   (see setupSidebarTooltips in apex-platform.html) rather than a CSS
   ::after on the nav-item itself, because #sidebar/nav clip overflow for
   the collapse-width transition and scroll list, which would clip an
   ::after popping out to the right. */
.sb-tip {
  position: fixed;
  z-index: 500;
  left: 0;
  top: 0;
  transform: translate(-9999px, -9999px);
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t1);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.sb-tip.visible {
  opacity: 1;
}

/* Dashboard identity and weather */
.dashboard-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 310px);
  gap: 16px;
  align-items: stretch;
}

.brand-profile-card {
  order: 1;
  min-height: 232px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--t1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

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

.brand-profile-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--c-line);
  border-radius: 4px;
}

.brand-profile-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-profile-identity {
  min-width: 0;
}

.brand-profile-name {
  overflow: hidden;
  color: var(--c-text-strong);
  font-size: 16px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-profile-handle {
  margin-top: 3px;
  color: var(--t3);
  font-size: 13px;
}

.brand-profile-stats {
  margin: 16px -18px -18px;
  padding: 8px 12px;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  background: var(--c-sunken);
  border-top: 1px solid var(--border);
}

.brand-profile-stats > div {
  min-width: 0;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand-profile-stats > div:nth-child(even) {
  border-left: 1px solid var(--c-line);
}

.brand-profile-stats > div:nth-child(n + 3) {
  border-top: 1px solid var(--c-line);
}

.brand-profile-stats strong,
.brand-profile-stats span {
  display: block;
}

.brand-profile-stats strong {
  color: var(--c-stat-text);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-profile-stats strong small {
  display: inline;
  font-size: 13px;
  font-weight: 700;
}

.brand-profile-stats .growth strong,
.brand-profile-stats .engagement strong {
  color: var(--c-green-text);
}

.brand-profile-stats .growth.negative strong {
  color: #d65b65;
}

.brand-profile-stats span {
  margin-top: 6px;
  color: var(--t3);
  font-size: 13px;
  line-height: 1.25;
}

.dashboard-weather-slot,
.dashboard-weather-slot #global-weather-strip,
.dashboard-weather-slot #global-weather-strip > .card {
  height: 100%;
}

.dashboard-weather-slot {
  order: 2;
}

.dashboard-weather-slot #global-weather-strip > .card {
  margin-bottom: 0 !important;
  display: flex;
  flex-direction: column;
  background: var(--surface) !important;
  border-color: var(--border) !important;
  border-radius: var(--r-card) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22) !important;
}

.dashboard-weather-slot #global-weather-strip > .card > div:last-child {
  flex: 1;
}

.dashboard-weather-slot #global-weather-strip > .card > div:last-child > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Weather is a supporting panel, not a headline — keep its controls compact
   so the narrow column does not grow taller than the social card beside it. */
.dashboard-weather-slot #global-weather-strip .btn-sm {
  padding: 3px 8px;
  font-size: 13px;
}

#main {
  min-width: 0;
  height: 100vh;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--content-bg);
}

.topbar {
  position: relative;
  z-index: 900;
  min-height: 70px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  background: #fff;
  border-bottom: 1px solid #e6e8eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.hamburger {
  width: 42px;
  height: 42px;
  margin-left: -7px;
  display: none;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: #e74c3c;
  border-radius: 50%;
  font-size: 0;
}

.hamburger::after {
  content: "";
  width: 18px;
  height: 18px;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6h16M4 12h16M4 18h16'/%3E%3C/svg%3E");
}

.page-title-wrap {
  min-width: 190px;
}

.page-title {
  color: #272c33;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.breadcrumb {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--t3);
  font-size: 13px;
}

.bc-sep {
  color: var(--t3);
  opacity: 0.7;
}

.topbar-right {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.search-btn,
.topbar-pill,
.tb-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  color: #697079;
  background: #fff;
  border: 1px solid #dfe3e7;
  border-radius: 4px;
  transition: 0.15s ease;
}

.search-btn:hover,
.topbar-pill:hover,
.tb-btn:hover {
  color: var(--brand);
  border-color: #b9c9d1;
  background: #f9fafb;
}

.search-btn {
  min-width: 150px;
  padding: 7px 10px;
  justify-content: flex-start;
  font-size: 13px;
}

.s-kbd2 {
  margin-left: auto;
  padding: 1px 5px;
  color: #9ba2a9;
  background: #f1f2f4;
  border: 1px solid #e0e3e6;
  border-radius: 3px;
  font-size: 12px;
}

.topbar-pill {
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.topbar-pill .score {
  color: var(--c-text-strong);
  font-weight: 700;
}

.topbar-pill .label {
  color: var(--c-text-muted);
}

/* Buttons and avatar keep their size; only the context selects give way. */
.topbar-right > * { flex-shrink: 0; }
#brand-context-bar { flex: 0 1 auto; min-width: 0; }
#brand-context-bar > div { flex-wrap: nowrap !important; }
#brand-context-bar select {
  min-width: 0 !important;
  max-width: 230px;
  flex: 0 1 auto;
}
#bb-ctx-badge { flex-shrink: 0; }

.tb-btn {
  width: 36px;
  padding: 0;
  font-size: 16px;
}

#topbar-avatar {
  background: var(--brand) !important;
  color: #fff !important;
  box-shadow: none !important;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  background: var(--content-bg);
}

.section {
  display: none;
  max-width: 1680px;
  margin: 0 auto;
}

.section.active {
  display: block;
  animation: sufeeFade 0.2s ease;
}

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

.section-header {
  margin: 0 0 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h2 {
  margin: 0;
  color: #272c33;
  font-size: 21px;
  font-weight: 600;
}

.section-header p,
.section-header .sub {
  margin: 4px 0 0;
  color: var(--t2);
  font-size: 13px;
}

/* Sufee cards and grids */
.grid2,
.grid3,
.grid4 {
  display: grid;
  gap: 20px;
}

.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid2 > *,
.grid3 > *,
.grid4 > * { min-width: 0; }

.card,
.platform-card,
.ai-feat-card,
.ai-rec,
.chart-box,
.setting-row {
  color: var(--t1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.card,
.platform-card,
.ai-feat-card {
  padding: 20px;
}

.card-sm {
  padding: 15px;
}

.card:hover,
.platform-card:hover,
.ai-feat-card:hover {
  border-color: #d7dce1;
  box-shadow: 0 3px 10px rgba(39, 44, 51, 0.07);
}

.card h3 {
  margin: -20px -20px 18px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #343a40;
  background: #fbfbfc;
  border-bottom: 1px solid var(--border);
  border-radius: calc(var(--r-card) - 1px) calc(var(--r-card) - 1px) 0 0;
  font-size: 15px;
  font-weight: 600;
}

.card-sm h3 {
  margin: -15px -15px 14px;
  padding: 12px 15px;
}

.ch-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  color: var(--brand);
  background: var(--brand-muted);
  border-radius: 50%;
}

.kpi {
  position: relative;
  min-height: 145px;
  padding: 20px;
  overflow: hidden;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: var(--r-card);
  box-shadow: 0 2px 5px rgba(39, 44, 51, 0.12);
}

.kpi::after {
  display: none;
}

.kpi.purple { background: #5368d5; color: #fff; }
.kpi.green { background: #20c997; color: #fff; }
.kpi.amber { background: #ffc107; color: #29323a; }
.kpi.blue { background: #20a8d8; color: #fff; }
.kpi.pink { background: #f05b72; color: #fff; }
.kpi.red { background: #f86c6b; color: #fff; }
.kpi.cyan { background: #63c2de; color: #24313a; }

.kpi-icon {
  position: absolute;
  top: 19px;
  right: 18px;
  z-index: 1;
  color: currentColor;
  opacity: 0.9;
  font-size: 22px;
}

.kpi-label {
  position: relative;
  z-index: 1;
  color: inherit;
  opacity: 0.88;
  font-size: 13px;
  font-weight: 600;
}

.kpi-value {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  color: inherit;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.2;
}

.kpi-value.sm { font-size: 22px; }

.kpi-change {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  color: inherit;
  opacity: 0.84;
  font-size: 13px;
}

.kpi .neutral,
.kpi .green,
.kpi .red,
.kpi .amber {
  color: inherit !important;
}

/* Controls */
.btn {
  min-height: 36px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  color: #495057;
  background: #fff;
  border: 1px solid #c8ced4;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: 0.15s ease;
}

.btn:hover {
  color: #212529;
  background: #f1f3f5;
  border-color: #adb5bd;
}

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

.btn-primary:hover {
  color: #fff;
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-secondary {
  color: #545b62;
  background: #fff;
  border-color: #c8ced4;
}

.btn-green {
  color: #fff;
  background: #3da862;
  border-color: #3da862;
}

.btn-amber {
  color: #2f3337;
  background: var(--amber);
  border-color: var(--amber);
}

.btn-ai {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 13px;
}

.input,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
  min-height: 38px;
  padding: 8px 11px;
  color: #495057;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { min-height: 96px; resize: vertical; }

/* Form fields fill their column; text fields may shrink beside a button
   (selects keep their natural width so the chosen option isn't cut off). */
.input { width: 100%; }
input.input,
textarea.input { min-width: 0; }

.input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: #69abc1;
  box-shadow: 0 0 0 3px rgba(24, 126, 162, 0.13);
}

.input::placeholder,
input::placeholder,
textarea::placeholder {
  color: #adb5bd;
}

label,
.setting-label {
  color: #454b51;
  font-weight: 600;
}

.toggle {
  position: relative;
  width: 42px;
  height: 22px;
  flex: 0 0 auto;
  cursor: pointer;
  background: #ccd1d6;
  border-radius: 50rem;
  transition: 0.2s ease;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: 0.2s ease;
}

.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(20px); }

/* Tabs, tables and data */
.tabs {
  margin-bottom: 20px;
  padding: 0;
  display: flex;
  gap: 0;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.tab {
  min-height: 42px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  cursor: pointer;
  color: #6c757d;
  background: transparent;
  border: 0;
  border-right: 1px solid #eceff2;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s ease;
}

.tab:hover { color: var(--brand); background: #fafbfc; }
.tab.active { color: var(--brand); background: #fff; border-bottom-color: var(--brand); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}

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

thead { background: #f8f9fa; }

th {
  padding: 11px 13px;
  color: #596169;
  border-bottom: 2px solid #dee2e6;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 11px 13px;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
.td-main { color: #343a40; font-weight: 600; }

.badge,
.nbadge,
.platform-chip,
.score-chip,
.engage-pill,
.today-badge {
  padding: 3px 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #596169;
  background: #e9ecef;
  border: 1px solid transparent;
  border-radius: 50rem;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.badge.green, .score-high { color: #24723f; background: #daf2e2; }
.nbadge { color: #d7dce1; background: rgba(255, 255, 255, 0.1); }
.badge.red { color: #8d3230; background: #f5dedd; }
.badge.amber { color: #735b00; background: #fff2bf; }
.badge.blue, .badge.cyan { color: #17667f; background: #d8f0f7; }
.badge.purple { color: #563398; background: #e9def8; }

.prog-wrap {
  height: 6px;
  overflow: hidden;
  background: #e9ecef;
  border-radius: 50rem;
}

.prog-bar { height: 100%; background: var(--brand); border-radius: inherit; }
.prog-green { background: var(--green); }
.prog-amber { background: var(--amber); }
.prog-blue { background: var(--blue); }
.prog-purple { background: var(--purple); }

/* Feature components */
.ai-ticker {
  display: none !important;
}

.ai-ticker > .label {
  color: #fff;
  background: #359758;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ai-ticker-msgs { min-width: 0; overflow: hidden; font-size: 13px; }
.ai-ticker-msgs .msg { white-space: nowrap; }

.platform-card { position: relative; }
.pc-header { display: flex; align-items: center; gap: 12px; }
.pc-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border-radius: 4px;
  font-size: 20px;
}
.pc-name { color: #343a40; font-weight: 700; }
.pc-status { margin-left: auto; }
.pc-stat-row { margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); }
.pc-stat { padding-top: 14px; text-align: center; }
.pc-stat + .pc-stat { border-left: 1px solid var(--border); }
.pc-stat-val { color: #343a40; font-size: 17px; font-weight: 700; }
.pc-stat-label { color: var(--t2); font-size: 12px; }

/* Social channel cards */
.social-platform-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.social-platform-card {
  --social-card-color: #fff;
  min-width: 0;
  min-height: 270px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  color: var(--social-card-color);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--r-card);
  box-shadow: 0 2px 5px rgba(39, 44, 51, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.social-platform-card:hover {
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 4px 8px rgba(39, 44, 51, 0.15);
  transform: none;
}

.social-facebook { background: #1877f2; }
.social-instagram { background: var(--pf-instagram-bg); }
.social-linkedin { background: #0a66c2; }
.social-tiktok { background: #000000; }
.social-youtube {
  --social-logo-cutout: #ff0000;
  background: #ff0000;
}
.social-twitter { background: #202020; }

.social-card-icon {
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
  border-radius: 50%;
}

.social-card-icon svg {
  width: 30px;
  height: 30px;
  color: inherit;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.social-card-name {
  margin-bottom: 1px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

.kpi-help {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-left: 2px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  opacity: 0.6;
  cursor: help;
}

/* ── Dashboard: social media analytics panel ── */

.dash-social-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.dash-social-head h3 {
  margin: 0;
}

.dash-social-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.dash-social-stats div {
  padding: 12px 14px;
  background: var(--bg2);
  border-radius: var(--r-sm);
}

.dash-social-stats strong {
  display: block;
  color: var(--t1);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.dash-social-stats span {
  color: var(--t3);
  font-size: 13px;
}

.dash-social-recent h4 {
  margin: 0 0 10px;
  color: var(--t2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dash-social-post {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.dash-social-post-body {
  flex: 1;
  min-width: 0;
}

.dash-social-post-text {
  color: var(--t1);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-social-post-meta {
  margin-top: 2px;
  color: var(--t3);
  font-size: 13px;
}

.dash-social-post-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  color: var(--t3);
  font-size: 13px;
  text-align: right;
}

.dash-social-post-stats strong {
  display: block;
  color: var(--t1);
  font-size: 15px;
}

.dash-social-empty {
  margin: 0;
  padding: 14px 0;
  color: var(--t3);
  font-size: 14px;
}

@media (max-width: 640px) {
  .dash-social-post-stats {
    display: none;
  }
}

/* ── Media library (Calendar sidebar) ── */

.media-lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.media-lib-head h3 {
  margin: 0;
}

.media-lib-hint {
  margin: 0 0 10px;
  color: var(--t3);
  font-size: 13px;
}

.media-lib-tabs {
  margin-bottom: 10px;
}

.media-lib-status {
  min-height: 14px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--t3);
}

.media-lib-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.media-lib-grid-full {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  max-height: none;
}

.media-lib-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 16px 0;
  color: var(--t3);
  font-size: 13px;
  text-align: center;
}

.media-lib-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--border);
  cursor: grab;
}

.media-lib-item:active {
  cursor: grabbing;
}

.media-lib-item img,
.media-lib-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.media-lib-item .media-lib-video-badge {
  position: absolute;
  bottom: 3px;
  left: 3px;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  pointer-events: none;
}

.media-lib-item .media-lib-used-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  padding: 1px 5px;
  background: rgba(16, 185, 129, 0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  pointer-events: none;
}

.media-lib-item .media-lib-delete {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.media-lib-item:hover .media-lib-delete {
  display: flex;
}

#compose-media-field.is-dragover {
  outline: 2px dashed var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.recent-posts-footer {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

/* ── Platform brand badge: real logo on the brand colour ── */
.pf-badge {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: #6c757d;
  border-radius: 5px;
  vertical-align: middle;
  font-style: normal;
  line-height: 1;
}

.pf-badge svg {
  width: 62%;
  height: 62%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.pf-badge .icon-fill {
  fill: currentColor;
  stroke: none;
}

.pf-badge.pf-instagram { background: var(--pf-instagram-bg); }
.pf-badge.pf-facebook { background: #1877f2; }
.pf-badge.pf-linkedin { background: #0a66c2; }
.pf-badge.pf-tiktok { background: #000; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); }
.pf-badge.pf-youtube { background: #ff0000; --platform-bg: #ff0000; }

.pf-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 3px;
  color: var(--t1);
  background: color-mix(in srgb, var(--chip-colour) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip-colour) 45%, transparent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.pf-chip .pf-badge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.q-thumb.q-thumb-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: var(--c-soft);
}

.q-thumb.q-thumb-brand .pf-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.cal-chip .pf-badge {
  width: 13px;
  height: 13px;
  border-radius: 3px;
}

.cal-detail-platform .pf-badge,
.compose-time-platform .pf-badge {
  width: 18px;
  height: 18px;
}

.cal-legend-item .pf-badge {
  width: 15px;
  height: 15px;
  border-radius: 4px;
}

.cal-today-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

/* Post History: on-demand stats sync result line */
.post-stats-sync-status {
  margin: -4px 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  color: var(--t3);
  font-size: 13px;
}

.post-stats-sync-status:empty {
  display: none;
}

.post-stats-sync-ok,
.post-stats-sync-error {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.post-stats-sync-ok .pf-badge,
.post-stats-sync-error .pf-badge {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.post-stats-sync-error {
  color: var(--c-danger-text);
}

/* ── Calendar views: Preview · Week · Month · List ── */
/* `hidden` must win over the display values set on these elements below. */
.cal-view[hidden],
.cal-legend[hidden],
.cal-nav-btn[hidden] {
  display: none !important;
}

.cal-nav {
  flex-wrap: wrap;
}

.cal-nav-left {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
}

.cal-nav-left h4 {
  flex: 0 1 auto;
  margin-left: 6px;
  text-align: left;
  white-space: nowrap;
}

.cal-view-switch {
  display: inline-flex;
  border: 1px solid var(--c-line-strong);
  border-radius: 6px;
  overflow: hidden;
}

.cal-view-switch button {
  padding: 6px 14px;
  cursor: pointer;
  color: var(--t2);
  background: var(--c-surface);
  border: 0;
  border-left: 1px solid var(--c-line-strong);
  font-size: 13px;
  font-weight: 700;
}

.cal-view-switch button:first-child {
  border-left: 0;
}

.cal-view-switch button:hover {
  color: var(--t1);
  background: var(--c-hover);
}

.cal-view-switch button.is-active {
  color: var(--c-brand-text);
  background: var(--brand-muted);
}

.cal-view-error,
.cal-view-empty {
  grid-column: 1 / -1;
  padding: 28px 16px;
  color: var(--t3);
  font-size: 14px;
  text-align: center;
}

.cal-more {
  color: var(--c-brand-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cal-more:hover {
  text-decoration: underline;
}

/* Week */
.cal-week {
  border: 1px solid var(--c-line);
  border-radius: 6px;
  overflow: hidden;
}

.cal-week-grid {
  display: grid;
  grid-template-columns: 58px repeat(7, minmax(0, 1fr));
}

.cal-week-head {
  background: var(--c-header);
  border-bottom: 1px solid var(--c-line);
}

.cal-week-hd {
  padding: 8px 4px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 6px;
  color: var(--t3);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.cal-week-hd strong {
  color: var(--t1);
  font-size: 16px;
}

.cal-week-hd.is-today strong {
  min-width: 26px;
  padding: 1px 6px;
  color: #fff;
  background: var(--brand);
  border-radius: 999px;
  text-align: center;
}

.cal-week-stories {
  border-bottom: 1px solid var(--c-line);
}

.cal-week-note {
  padding: 4px;
  color: var(--t3);
  background: var(--c-sunken);
  border-bottom: 1px solid var(--c-line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.cal-week-scroll {
  max-height: 620px;
  overflow-y: auto;
}

.cal-week-time {
  padding: 4px 8px 0 0;
  color: var(--t3);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.cal-week-stories .cal-week-time {
  padding-top: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.cal-week-cell {
  position: relative;
  min-width: 0;
  min-height: 46px;
  padding: 3px;
  cursor: pointer;
  border-left: 1px solid var(--c-line);
  border-bottom: 1px dashed var(--c-line);
}

.cal-week-story {
  min-height: 40px;
}

.cal-week-cell:hover {
  background: var(--c-hover);
}

.cal-week-cell.is-today {
  background: color-mix(in srgb, var(--brand) 6%, transparent);
}

.cal-week-cell.is-past {
  background: var(--c-sunken);
}

.cal-week-cell .cal-chip {
  margin-bottom: 3px;
}

/* List */
.cal-list-filters {
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.cal-list-filters label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--t3);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.cal-list-filters label.cal-list-range {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.cal-list-filters .compose-control {
  width: auto;
  min-height: 34px;
  padding: 4px 8px;
  font-size: 13px;
  text-transform: none;
}

.cal-list-count {
  margin-left: auto;
  color: var(--t3);
  font-size: 13px;
}

.cal-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cal-list-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-card);
  overflow: hidden;
}

.cal-list-card.cal-list-draft {
  border-style: dashed;
}

.cal-list-head {
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--c-line);
}

.cal-list-avatar .pf-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.cal-list-who {
  min-width: 0;
  display: flex;
  flex-direction: column;
  color: var(--t3);
  font-size: 13px;
}

.cal-list-who strong {
  color: var(--t1);
  font-size: 14px;
}

.cal-list-when {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--t2);
  font-size: 13px;
}

.cal-list-actions {
  display: flex;
  gap: 6px;
}

.cal-icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--t2);
  background: var(--c-soft);
  border: 1px solid var(--c-line-strong);
  border-radius: 50%;
  font-size: 15px;
}

.cal-icon-btn:hover {
  color: var(--t1);
  border-color: var(--brand);
}

.cal-icon-btn.cal-icon-danger:hover {
  color: var(--red);
  border-color: var(--red);
}

.cal-list-body {
  padding: 12px;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 14px;
}

.cal-list-media {
  position: relative;
  align-self: start;
  aspect-ratio: 4 / 5;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}

.cal-list-media img,
.cal-list-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cal-list-nomedia {
  height: 100%;
  display: grid;
  place-items: center;
  color: #8b949e;
  font-size: 13px;
}

.cal-list-expand {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 0;
  border-radius: 4px;
  font-size: 15px;
}

.cal-list-text .compose-label {
  margin-bottom: 4px;
}

.cal-list-stats {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  color: var(--t2);
  font-size: 13px;
}

.cal-list-error {
  margin-top: 8px;
  color: var(--c-danger-text);
  font-size: 13px;
}

@media (max-width: 700px) {
  .cal-list-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .cal-list-media {
    max-width: 240px;
  }
}

/* Preview (Instagram feed) */
.cal-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 16px;
  align-items: start;
}

.cal-preview-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.cal-preview-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--t3);
  font-size: 13px;
  text-align: center;
}

.ig-toggle {
  padding: 4px 11px;
  cursor: pointer;
  color: var(--t2);
  background: var(--c-soft);
  border: 1px solid var(--c-line-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.ig-toggle.is-on {
  color: var(--c-brand-text);
  background: var(--brand-muted);
  border-color: var(--brand);
}

.ig-phone {
  width: 100%;
  max-width: 330px;
  padding: 12px 8px 18px;
  background: #fff;
  border: 1px solid #d7dce1;
  border-radius: 34px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  color: #111;
}

.ig-phone-head {
  padding: 8px 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ig-phone-head div {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}

.ig-phone-head strong {
  font-size: 15px;
}

.ig-phone-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #111;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #dd2a7b;
  font-weight: 800;
}

.ig-phone-tabs {
  margin-bottom: 2px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #e5e7eb;
}

.ig-phone-tabs button {
  padding: 8px;
  cursor: pointer;
  color: #9ca3af;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 16px;
}

.ig-phone-tabs button.is-active {
  color: #111;
  border-bottom-color: #111;
}

.ig-grid {
  max-height: 560px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  overflow-y: auto;
}

.ig-tile {
  position: relative;
  aspect-ratio: 3 / 4;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: #111;
  border: 0;
}

.ig-grid-reels .ig-tile {
  aspect-ratio: 9 / 16;
}

.ig-tile-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.ig-tile-text {
  height: 100%;
  padding: 8px;
  display: grid;
  place-items: center;
  color: #e5e7eb;
  font-size: 12px;
}

.ig-tile-draft {
  outline: 2px dashed #dd2a7b;
  outline-offset: -2px;
}

.ig-tile-video {
  position: absolute;
  top: 5px;
  right: 6px;
  color: #fff;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.ig-tile-flag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 5px;
  color: #fff;
  background: rgba(221, 42, 123, 0.9);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.ig-tile-flag-soon {
  background: rgba(17, 17, 17, 0.75);
}

.ig-tile:hover {
  filter: brightness(1.1);
}

.ig-grid-empty {
  grid-column: 1 / -1;
  padding: 30px 12px;
  color: #6b7280;
  font-size: 13px;
  text-align: center;
}

.cal-preview-side {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 8px;
  overflow: hidden;
}

.cal-preview-side h4 {
  margin: 0;
  padding: 12px;
  color: var(--t1);
  border-bottom: 1px solid var(--c-line);
  font-size: 14px;
}

.cal-preview-row {
  width: 100%;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--t2);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--c-line);
  font-size: 13px;
  text-align: left;
}

.cal-preview-row:hover {
  background: var(--c-hover);
}

.cal-preview-thumb {
  width: 30px;
  height: 38px;
  flex: 0 0 30px;
  background: #111;
  border-radius: 2px;
  overflow: hidden;
}

.cal-preview-draft {
  padding: 2px 6px;
  border: 1px dashed var(--c-line-strong);
  border-radius: 4px;
}

.cal-preview-sched {
  padding: 2px 6px;
  color: var(--c-green-text);
  font-weight: 700;
}

.cal-preview-date {
  margin-left: auto;
  white-space: nowrap;
}

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

/* Small screens: seven day columns can't fit, so the month and week grids
   keep a readable minimum width and scroll sideways instead of clipping. */
@media (max-width: 760px) {
  #cal-view-month,
  #cal-view-week {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #cal-view-month .cal-header,
  #cal-view-month .cal-grid {
    min-width: 640px;
  }
  #cal-view-month .cal-day {
    min-height: 88px;
  }
  #cal-view-week .cal-week {
    min-width: 720px;
  }
  .cal-list-filters label.cal-list-range {
    flex-wrap: wrap;
  }
  .cal-list-filters label.cal-list-range .compose-control {
    flex: 1 1 130px;
    min-width: 0;
  }
  .cal-list-when {
    margin-left: 0;
    flex-wrap: wrap;
  }
}

/* ── Calendar tab layout: media library left, calendar right ── */
.cal-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  grid-template-areas:
    "media main"
    "media side";
  gap: 16px;
  align-items: start;
}

.cal-media-col {
  grid-area: media;
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 110px);
}

.cal-media-col .cal-create-btn {
  min-height: 42px;
  font-size: 15px;
  font-weight: 700;
}

.cal-media-col .media-lib-hint {
  margin: 2px 0 0;
}

.cal-media-col .media-lib-tabs,
.cal-media-col .media-lib-status {
  margin-bottom: 0;
}

.cal-media-grid {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  gap: 4px;
  overflow-y: auto;
  /* Keep tiles square instead of letting the fixed-height column squash rows. */
  grid-auto-rows: max-content;
  align-content: start;
}

.cal-media-grid .media-lib-item {
  flex-shrink: 0;
}

.cal-media-grid .media-lib-item {
  border-radius: 3px;
}

.cal-main {
  grid-area: main;
  min-width: 0;
}

.cal-side-row {
  grid-area: side;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

@media (max-width: 1100px) {
  .cal-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "media" "main" "side";
  }
  .cal-media-col {
    position: static;
    max-height: none;
  }
  .cal-media-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    max-height: 260px;
  }
  .cal-side-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Drag-to-schedule feedback */
body.is-dragging-media .cal-day[data-day] {
  outline: 1px dashed var(--c-line-strong);
  outline-offset: -3px;
}

.cal-day.is-drop-target {
  background: var(--brand-muted) !important;
  border-color: var(--brand) !important;
  outline: 2px dashed var(--brand) !important;
  outline-offset: -3px;
}

.cal-day.is-uploading {
  opacity: 0.55;
  cursor: progress;
}

.cal-day.is-drop-target::after,
.cal-day.is-uploading::after {
  content: "Drop to schedule";
  position: absolute;
  inset: auto 6px 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.cal-day.is-uploading::after {
  content: "Uploading…";
}

.cal-chip-body {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  line-height: 1.25;
}

.cal-chip-line {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.cal-chip-line strong {
  font-weight: 700;
}

.cal-chip-body .cal-chip-text {
  display: block;
  white-space: nowrap;
}

.cal-chip-thumb {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 2px;
  background: #000;
  pointer-events: none;
}

.compose-media-preview video {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-top: 8px;
  border: 1px solid var(--c-line-strong);
  border-radius: 4px;
  background: #000;
}

/* ── Best times to post ── */

.best-times-title {
  margin: 0 0 2px;
  color: var(--t1);
  font-size: 16px;
  font-weight: 700;
}

.best-times-sub {
  margin: 0 0 12px;
  color: var(--t3);
  font-size: 13px;
}

.best-times-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.best-times-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  background: var(--bg2);
  border-radius: 8px;
}

.best-times-platform {
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.best-times-when {
  color: var(--t1);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.best-times-platform.social-all {
  background: var(--brand);
}

.best-times-detail {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.best-times-meta,
.best-times-pending {
  color: var(--t3);
  font-size: 12px;
}

.best-times-list li.best-times-empty {
  justify-content: center;
  color: var(--t3);
  font-size: 13px;
}

/* ── Recent posts table: platform badge + filter tabs ── */

.social-post-platform {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
}

.social-post-platform svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.recent-posts-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recent-posts-tab {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--t2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.recent-posts-tab:hover {
  color: var(--t1);
  border-color: var(--t3);
}

.recent-posts-tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #14181f;
}

.social-card-label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

.social-follower-line {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.social-follower-value {
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.social-growth {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #7fd69a;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.social-growth svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.social-growth.down { color: #e9a4a0; }
.social-growth.down svg { transform: rotate(180deg); }
.social-growth.is-empty { color: rgba(255, 255, 255, 0.62); }

.social-card-divider {
  height: 1px;
  margin: 8px 0 10px;
  background: rgba(255, 255, 255, 0.34);
}

.social-card-latest {
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.social-card-metric {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 13px;
}

.social-card-metric strong {
  color: #fff;
  font-size: 13px;
}

/* Social overview follower trend */
#organic-growth {
  margin-bottom: 20px;
}

.social-growth-panel {
  padding: 18px;
  color: var(--t1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.social-growth-header {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.social-growth-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--c-text-strong);
  font-size: 16px;
  font-weight: 700;
}

.social-growth-title svg {
  width: 20px;
  height: 20px;
  color: var(--brand);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.social-growth-header p {
  margin: 4px 0 0 29px;
  color: var(--t3);
  font-size: 13px;
}

.social-growth-summary {
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--c-sunken);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
}

.social-growth-summary > div {
  min-width: 0;
  padding: 12px 14px;
}

.social-growth-summary > div + div {
  border-left: 1px solid var(--c-line);
}

.social-growth-summary strong,
.social-growth-summary span {
  display: block;
}

.social-growth-summary strong {
  color: var(--c-stat-text);
  font-size: 20px;
  font-weight: 750;
  line-height: 1.1;
}

.social-growth-summary .positive strong { color: var(--c-green-text); }
.social-growth-summary .negative strong { color: #d65b65; }
.social-growth-summary .neutral strong { color: var(--t2); }

.social-growth-summary span {
  margin-top: 5px;
  color: var(--t3);
  font-size: 12px;
}

.social-growth-chart {
  padding: 10px 12px 8px;
  background: var(--c-sunken);
  border: 1px solid var(--c-hover);
  border-radius: var(--r-sm);
}

.social-growth-chart svg {
  display: block;
  width: 100%;
  height: 205px;
  overflow: visible;
}

.growth-grid-line,
.growth-line {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.growth-grid-line {
  stroke: var(--c-hover);
  stroke-width: 1;
}

.growth-line {
  stroke: #2aa9d6;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.growth-point {
  fill: var(--c-sunken);
  stroke: #63c2de;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.social-growth-dates {
  padding-inline: 2px;
  display: flex;
  justify-content: space-between;
  color: var(--t3);
  font-size: 12px;
}

.chart-box {
  position: relative;
  min-height: 260px;
  padding: 16px;
}
.chart-box.tall { min-height: 340px; }
.chart-box.sm { min-height: 190px; }
.chart-box canvas { max-width: 100%; }

.activity-item,
.queue-item,
.inv-row,
.sr-item {
  padding: 12px 0;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border-bottom: 1px solid #edf0f2;
}

.activity-item:last-child,
.queue-item:last-child,
.inv-row:last-child { border-bottom: 0; }

.act-icon,
.afc-icon,
.sr-ico {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--brand);
  background: var(--brand-muted);
  border-radius: 50%;
}

.act-text { color: #4e555b; font-size: 13px; }
.act-time, .q-time, .p-meta, .sr-desc { color: #9299a0; font-size: 12px; }
.act-green { color: #2f9e57; background: #e1f3e7; }
.act-amber { color: #826700; background: #fff4ca; }
.act-blue { color: #147694; background: #def2f7; }
.act-purple { color: #6941b4; background: #ece4f8; }

.ai-rec { margin-bottom: 12px; overflow: hidden; }
.ai-rec-header { padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: #f8f9fa; border-bottom: 1px solid var(--border); }
.ai-rec-icon { width: 32px; height: 32px; display: grid; place-items: center; color: var(--purple); background: #ece4f8; border-radius: 50%; }
.ai-rec-title { color: #373757; font-weight: 700; }
.ai-rec-conf { margin-left: auto; color: #6c757d; font-size: 12px; }
.ai-rec-body { padding: 16px; color: var(--c-text); font-size: 13px; }
.ai-rec-actions { margin-top: 13px; display: flex; flex-wrap: wrap; gap: 8px; }

.setting-row {
  padding: 15px 17px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: 0;
  border-width: 0 0 1px;
  box-shadow: none;
}

#global-weather-strip > .card {
  background: #fff !important;
  border-color: var(--border) !important;
  border-radius: var(--r-card) !important;
  box-shadow: var(--shadow-card) !important;
}

.ai-rec-icon {
  color: var(--brand);
  background: var(--brand-muted);
}
.setting-info { flex: 1; }
.setting-desc { margin-top: 2px; color: var(--t2); font-size: 13px; font-weight: 400; }

.empty-state,
.empty {
  padding: 36px 20px;
  color: #8b9299;
  background: #fbfcfd;
  border: 1px dashed #cfd5da;
  border-radius: 4px;
  text-align: center;
}

.divider { height: 1px; margin: 18px 0; background: #e8ebee; }

/* Calendar and specialty panels */
.cal-day-hd { padding: 9px; color: #70777d; background: #f8f9fa; border: 1px solid #e5e8eb; font-size: 12px; font-weight: 700; text-align: center; }
.cal-day { min-height: 100px; padding: 8px; background: #fff; border: 1px solid #e7eaed; }
.cal-day-num { color: #5d646a; font-size: 13px; font-weight: 600; }
.cal-nav-btn, .cal-add-btn { cursor: pointer; color: #5f676e; background: #fff; border: 1px solid #ced4da; border-radius: 4px; }

.funnel { padding: 6px 0; }
.funnel-stage { margin-bottom: 12px; }
.funnel-label { margin-bottom: 5px; display: flex; justify-content: space-between; color: var(--c-text); font-size: 13px; }
.funnel-bar-wrap { height: 26px; overflow: hidden; background: #edf0f2; border-radius: 3px; }
.funnel-bar { height: 100%; display: flex; align-items: center; padding: 0 9px; color: #fff; background: var(--brand); font-size: 12px; }
.funnel-val { margin-left: auto; font-weight: 700; }

/* Search and overlays */
.search-overlay,
.modal-overlay,
[class*="modal-overlay"] {
  position: fixed;
  inset: 0;
  z-index: 3000;
  padding: 8vh 20px 30px;
  display: none;
  justify-content: center;
  align-items: flex-start;
  background: rgba(22, 27, 31, 0.62);
  backdrop-filter: blur(2px);
}

.search-overlay.open,
.modal-overlay.open,
[class*="modal-overlay"].open { display: flex; }

.search-box,
.modal,
[class$="-modal"] {
  width: min(680px, 100%);
  max-height: 84vh;
  overflow: auto;
  color: var(--t1);
  background: #fff;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
}

.search-input-wrap { padding: 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.search-input-wrap input { flex: 1; border: 0; box-shadow: none; font-size: 16px; }
.search-results { max-height: 52vh; overflow: auto; padding: 8px; }
.search-footer { padding: 10px 16px; color: #8b9299; background: #f8f9fa; border-top: 1px solid var(--border); font-size: 12px; }

/* Utilities retained by application modules */
.flex { display: flex !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.flex-wrap { flex-wrap: wrap !important; }
.ml-auto { margin-left: auto !important; }
.w-full { width: 100% !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 20px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.text-xs { font-size: 12px !important; }
.text-sm { font-size: 13px !important; }
.green { color: var(--c-green-text); }
.red { color: var(--red); }
.amber { color: var(--c-amber-text); }
.blue { color: var(--c-brand-text); }
.purple { color: var(--c-purple-text); }
.cyan { color: #16829f; }
.orange { color: var(--c-orange-text); }
.neutral { color: var(--t2); }

.sidebar-overlay { display: none; }
/* Sits above the APEX Brain chat launcher, which owns the bottom-right corner. */
.back-top { position: fixed; right: 26px; bottom: 92px; z-index: 500; }

/* APEX Brain floating chatbot (backend/chatbot-ui.js) */
.apx-bot-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 950;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #000;
  /* Hairline ring keeps the black button visible against the dark theme. */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 6px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.apx-bot-launcher:hover { background: #23272c; transform: translateY(-2px); }
.apx-bot-launcher:focus-visible { outline: 3px solid var(--brand-glow); outline-offset: 3px; }
.apx-bot-launcher.is-open { background: #23272c; }

.apx-bot-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  z-index: 950;
  width: 380px;
  height: min(580px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.apx-bot-panel[hidden] { display: none; }

/* The AI Brain page has its own full chat, so the floating one steps aside there. */
body:has(#sec-aibrain.active) .apx-bot-launcher,
body:has(#sec-aibrain.active) .apx-bot-panel { display: none; }

.apx-bot-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.apx-bot-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.apx-bot-avatar svg { width: 18px; height: 18px; }
.apx-bot-logo-c {
  font-family: 'Anton', sans-serif;
  line-height: 1;
  color: #fff;
  user-select: none;
}
.apx-bot-launcher .apx-bot-logo-c { font-size: 26px; }
.apx-bot-avatar .apx-bot-logo-c { font-size: 18px; }
.apx-bot-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.apx-bot-title strong { color: var(--t1); font-size: 14px; }
.apx-bot-title span { color: var(--t3); font-size: 12px; }
.apx-bot-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t2);
  background: transparent;
  cursor: pointer;
}
.apx-bot-icon-btn:hover { color: var(--t1); background: var(--brand-muted); }

.apx-bot-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.apx-bot-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.apx-bot-msg.is-user {
  align-self: flex-end;
  white-space: pre-wrap;
  color: #fff;
  background: var(--brand-dark);
  border-bottom-right-radius: 4px;
}
.apx-bot-msg.is-bot {
  align-self: flex-start;
  color: var(--t1);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.apx-bot-msg.is-error { color: var(--red); }
.apx-bot-msg p { margin: 0 0 6px; }
.apx-bot-msg p:last-child { margin-bottom: 0; }
.apx-bot-msg .apx-bot-h { font-weight: 700; margin-top: 4px; }
.apx-bot-msg ul,
.apx-bot-msg ol { margin: 0 0 6px; padding-left: 20px; }
.apx-bot-msg li { margin: 2px 0; }
.apx-bot-msg code {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--brand-muted);
}
.apx-bot-cite {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--t3);
  font-size: 11px;
}
.apx-bot-cite span {
  display: inline-block;
  margin: 3px 4px 0 0;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--brand-muted);
  color: var(--t2);
}
.apx-bot-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }

.apx-bot-typing { display: flex; gap: 4px; padding: 12px 14px; }
.apx-bot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--t3);
  animation: apx-bot-dot 1.2s infinite ease-in-out;
}
.apx-bot-typing span:nth-child(2) { animation-delay: 0.15s; }
.apx-bot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes apx-bot-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.apx-bot-empty { margin: auto 0; text-align: center; color: var(--t3); font-size: 13px; }
.apx-bot-empty p { margin: 0 0 4px; }
.apx-bot-empty-title { color: var(--t1); font-size: 16px; font-weight: 600; }
.apx-bot-chips { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.apx-bot-chip {
  padding: 7px 14px;
  border: 1px solid var(--border-accent);
  border-radius: 18px;
  color: var(--c-brand-text);
  background: var(--brand-muted);
  font-size: 12px;
  cursor: pointer;
}
.apx-bot-chip:hover { border-color: var(--brand); }

.apx-bot-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.apx-bot-form textarea {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  padding: 9px 12px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  color: var(--t1);
  background: var(--bg2);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
}
.apx-bot-form textarea:focus { border-color: var(--brand); }
.apx-bot-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
}
.apx-bot-send:disabled { opacity: 0.5; cursor: default; }

/* Attachments: paperclip, upload tray above the input, media in bubbles */
.apx-bot-attach {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.apx-bot-attach:hover { color: var(--brand); border-color: var(--brand); }
.apx-bot-attach:disabled { opacity: 0.5; cursor: default; }

.apx-bot-tray {
  max-height: 150px;
  padding: 8px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.apx-bot-tray[hidden] { display: none; }
.apx-bot-tray-item {
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.apx-bot-tray-item.is-error { border-color: var(--red); }
.apx-bot-tray-item img,
.apx-bot-tray-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 6px;
}
.apx-bot-tray-icon {
  display: grid;
  place-items: center;
  color: var(--t2);
  background: var(--brand-muted);
  font-size: 10px;
  font-weight: 600;
}
.apx-bot-tray-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.apx-bot-tray-name {
  overflow: hidden;
  color: var(--t1);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.apx-bot-tray-state { color: var(--t3); font-size: 11px; }
.apx-bot-tray-state.is-done { color: var(--c-green-text); }
.apx-bot-tray-state.is-error { color: var(--red); }
.apx-bot-tray-remove {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--t3);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.apx-bot-tray-remove:hover { color: var(--t1); background: var(--brand-muted); }
.apx-bot-tray-remove:disabled { opacity: 0.4; cursor: default; }

.apx-bot-media { display: flex; flex-wrap: wrap; gap: 4px; }
.apx-bot-media + div { margin-top: 6px; }
.apx-bot-media-item {
  position: relative;
  width: 110px;
  height: 110px;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}
.apx-bot-media-item img,
.apx-bot-media-item video { width: 100%; height: 100%; display: block; object-fit: cover; }
.apx-bot-media-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 6px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  font-size: 10px;
}

.apx-bot-panel.is-dragover { outline: 2px dashed var(--brand); outline-offset: -6px; }

@media (max-width: 640px) {
  .apx-bot-launcher { right: 16px; bottom: 16px; }
  .back-top { right: 20px; bottom: 84px; }
  .apx-bot-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    border-radius: 14px 14px 0 0;
  }
  body:has(.apx-bot-panel:not([hidden])) .apx-bot-launcher { display: none; }
}

/* Sufee dark theme */
body,
#main,
.content {
  color: var(--t1);
  background: var(--content-bg);
}

#sidebar {
  background: var(--sidebar-bg);
  box-shadow: 1px 0 0 var(--c-hover);
}

.sb-logo,
.sb-bottom {
  background: #181b1f;
}

.sb-domain {
  color: #c8c9ce;
  background: #252a30;
  border-color: #393f46;
}

.topbar {
  background: var(--surface);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.32);
}

.page-title,
.section-header h2,
.card h3,
.pc-name,
.pc-stat-val,
.ai-rec-title,
.setting-label,
label,
.td-main {
  color: var(--t1);
}

.search-btn,
.topbar-pill,
.tb-btn,
.btn,
.btn-secondary,
.cal-nav-btn,
.cal-add-btn {
  color: var(--c-text);
  background: var(--c-soft);
  border-color: var(--c-line-strong);
}

.search-btn:hover,
.topbar-pill:hover,
.tb-btn:hover,
.btn:hover,
.btn-secondary:hover {
  color: var(--c-text-strong);
  background: var(--c-hover);
  border-color: var(--c-line-hover);
}

.btn-primary,
.btn-ai {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover,
.btn-ai:hover {
  color: #fff;
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.s-kbd2 {
  color: var(--c-text-muted);
  background: var(--c-hover);
  border-color: var(--c-line-strong);
}

.card,
.platform-card:not(.social-platform-card),
.ai-feat-card,
.ai-rec,
.chart-box,
.setting-row,
.table-wrap,
.tabs {
  color: var(--t1);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.card:hover,
.platform-card:not(.social-platform-card):hover,
.ai-feat-card:hover {
  border-color: var(--c-line-strong);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.card h3,
.ai-rec-header,
thead,
.search-footer,
.cal-day-hd {
  background: var(--c-header);
  border-color: var(--border);
}

.input,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
  color: var(--c-text-strong);
  background: var(--c-sunken);
  border-color: var(--c-line-strong);
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(32, 168, 216, 0.18);
}

.tabs {
  border-color: var(--border);
}

.tab {
  color: var(--c-text-muted);
  border-right-color: var(--border);
  background: transparent;
}

.tab:hover {
  color: var(--c-text-strong);
  background: var(--c-soft);
}

.tab.active {
  color: var(--c-accent-text);
  background: var(--c-raised);
  border-bottom-color: var(--brand);
}

table {
  color: var(--c-text);
}

th {
  color: var(--c-text);
  border-bottom-color: var(--c-line-strong);
}

td {
  border-bottom-color: var(--c-line);
}

tbody tr:hover {
  background: var(--c-soft);
}

.badge,
.platform-chip,
.score-chip,
.engage-pill,
.today-badge {
  color: var(--c-text);
  background: var(--c-hover);
}

.prog-wrap {
  background: var(--c-hover);
}

.activity-item,
.queue-item,
.inv-row,
.sr-item,
.pc-stat-row,
.divider {
  border-color: var(--border);
}

.empty-state,
.empty {
  color: var(--c-text-muted);
  background: var(--c-sunken);
  border-color: var(--c-line-strong);
}

.cal-day {
  background: var(--surface);
  border-color: var(--border);
}

/* Social calendar: month grid */
#social-calendar > .grid2 {
  grid-template-columns: minmax(0, 1fr) 280px !important;
  gap: 16px;
  align-items: start;
}

.cal-outer {
  min-width: 0;
  padding: 18px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

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

/* Month names vary in width, so let the label absorb the slack instead of
   letting it push the arrows to different spots each month. */
.cal-nav h4 {
  flex: 1;
  margin: 0;
  color: var(--t1);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.cal-nav-btn {
  width: 34px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 15px;
}

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

.cal-header {
  margin-bottom: 4px;
}

.cal-day-hd {
  padding: 7px 4px;
  color: var(--t3);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
  text-transform: uppercase;
}

.cal-day {
  position: relative;
  min-width: 0;
  min-height: 100px;
  padding: 7px;
  overflow: hidden;
  cursor: pointer;
  background: var(--c-surface);
  border: 1px solid var(--c-hover);
  border-radius: 4px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cal-day:hover {
  background: var(--c-raised);
  border-color: var(--c-line-hover);
}

.cal-day.today {
  background: var(--c-today-bg);
  border-color: var(--c-today-line);
}

.cal-day.past {
  opacity: 0.68;
}

.cal-day.empty {
  min-height: 100px;
  padding: 0;
  cursor: default;
  background: var(--c-sunken);
  border: 1px solid var(--c-header);
  opacity: 0.55;
}

.cal-day.empty:hover {
  background: var(--c-sunken);
  border-color: var(--c-header);
}

.cal-day-num {
  min-width: 0;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  color: var(--t3);
  font-size: 13px;
  font-weight: 700;
}

.cal-day.today .cal-day-num {
  color: var(--c-today-text);
}

.cal-day-num .today-badge {
  margin-left: auto;
  padding: 2px 5px;
  color: #15181c;
  background: #e2b331;
  font-size: 10px;
}

.cal-add-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 18px;
  color: var(--c-text);
  background: var(--c-hover);
  border: 1px solid var(--c-line-strong);
  border-radius: 3px;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
}

.cal-day:hover .cal-add-btn,
.cal-day:focus-within .cal-add-btn {
  opacity: 1;
}

.cal-chip {
  min-width: 0;
  margin-bottom: 3px;
  padding: 3px 5px;
  overflow: hidden;
  color: var(--c-text);
  background: var(--c-soft);
  border-radius: 2px;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-chip.chip-done {
  opacity: 0.62;
  text-decoration: line-through;
}

/* Status is carried by the border: solid = scheduled, dashed = draft.
   --chip-colour is the post's platform colour. */
.cal-chip[data-post-id] {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--c-text-strong);
  background: color-mix(in srgb, var(--chip-colour) 22%, transparent);
  border: 1px solid var(--chip-colour);
  border-left-width: 3px;
}

.cal-chip.cal-chip-draft {
  color: var(--c-text-muted);
  background: transparent;
  border-style: dashed;
  font-style: italic;
}

.cal-chip.cal-chip-published {
  opacity: 0.7;
}

.cal-chip.cal-chip-failed {
  border-color: var(--red, #ef4444);
  border-style: dashed;
}

.cal-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-legend {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  color: var(--t3);
  font-size: 13px;
}

.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cal-legend-sep {
  width: 1px;
  height: 14px;
  background: var(--c-line);
}

.cal-legend-status b {
  width: 18px;
  height: 10px;
  border: 1.5px solid var(--c-text-muted);
  border-radius: 2px;
}

.cal-legend-status b.cal-legend-dashed {
  border-style: dashed;
}

/* Scheduled / draft totals above the month and week grids. */
.cal-counts {
  margin: -4px 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.cal-counts[hidden] {
  display: none;
}

.cal-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  color: var(--t2);
  background: var(--c-soft);
  border: 1px solid var(--c-line-strong);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.cal-count:hover {
  color: var(--c-text-strong);
  border-color: var(--brand);
}

.cal-count strong {
  color: var(--c-text-strong);
}

.cal-count b {
  width: 16px;
  height: 9px;
  border: 1.5px solid var(--c-text-muted);
  border-radius: 2px;
}

.cal-count b.cal-legend-dashed {
  border-style: dashed;
}

.cal-count-period {
  color: var(--t3);
}

.cal-count-undated {
  margin-left: auto;
  border-style: dashed;
}

/* Per-day totals in a month cell: solid = scheduled, dashed = draft. */
.cal-day-counts {
  margin-bottom: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cal-day-count {
  padding: 0 5px;
  color: var(--c-text-strong);
  border: 1px solid var(--c-text-muted);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}

.cal-day-count.is-draft {
  color: var(--c-text-muted);
  border-style: dashed;
}

/* Calendar post detail (reuses the composer's overlay/dialog shell) */
.cal-detail-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.cal-detail-platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  color: var(--c-text-strong);
  background: color-mix(in srgb, var(--chip-colour) 25%, transparent);
  border: 1px solid var(--chip-colour);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}

.cal-detail-media {
  display: grid;
  place-items: center;
  background: var(--c-sunken);
  border: 1px solid var(--c-line);
  border-radius: 6px;
  overflow: hidden;
}

.cal-detail-media img,
.cal-detail-media video {
  display: block;
  max-width: 100%;
  max-height: 420px;
}

.cal-detail-empty {
  padding: 28px;
  color: var(--t3);
  font-size: 13px;
}

.cal-detail-caption {
  color: var(--t1);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.cal-detail-hashtags {
  margin-top: 8px;
  color: var(--c-link-soft);
  font-size: 13px;
}

.cal-detail-meta {
  margin-top: 14px;
  padding-top: 12px;
  color: var(--t2, var(--c-text-muted));
  border-top: 1px solid var(--c-line);
  font-size: 13px;
}

.cal-detail-status {
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
}

.cal-detail-status-scheduled { color: #0f1a12; background: #4ade80; }
.cal-detail-status-draft { color: var(--c-text); border: 1px dashed #8b949e; }
.cal-detail-status-published { color: #fff; background: #3b82f6; }
.cal-detail-status-failed { color: #fff; background: #ef4444; }
.cal-detail-status-publishing { color: #15181c; background: #e2b331; }

.cal-day.cal-day-holiday {
  background: var(--c-holiday-bg);
  border-color: var(--c-holiday-line);
}

.cal-holiday-badge,
.cal-intl-badge {
  min-width: 0;
  margin-bottom: 3px;
  padding: 2px 5px;
  overflow: hidden;
  border-radius: 2px;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.cal-holiday-badge {
  color: var(--c-holiday-text);
  background: rgba(139, 92, 246, 0.18);
}

.cal-intl-badge {
  color: var(--c-intl-text);
  background: rgba(232, 178, 55, 0.15);
}

.funnel-bar-wrap {
  background: var(--c-hover);
}

.search-box,
.modal,
[class$="-modal"] {
  color: var(--t1);
  background: var(--surface);
}

.search-input-wrap,
.search-footer {
  border-color: var(--border);
}

#global-weather-strip > .card {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

#global-weather-strip [style*="background:var(--bg2)"] {
  background: var(--bg2) !important;
}

canvas {
  filter: brightness(1.15) contrast(0.95);
}

/* Calendar post composer */
.compose-modal-overlay {
  --platform-instagram: var(--pf-instagram-bg);
  --platform-facebook: #1877f2;
  --platform-linkedin: #0a66c2;
  --platform-tiktok: #000000;
  --platform-youtube: #ff0000;
  position: fixed;
  inset: 0;
  z-index: 9999;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 9, 0.78);
  backdrop-filter: blur(3px);
}

.compose-dialog {
  width: min(720px, 100%);
  max-height: min(900px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: var(--t1);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: 6px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.42);
}

.compose-header {
  padding: 20px 22px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: var(--c-raised);
  border-bottom: 1px solid var(--c-line);
}

.compose-header h3 {
  margin: 0;
  color: var(--c-text-strong);
  font-size: 18px;
  font-weight: 700;
}

.compose-header p {
  margin: 5px 0 0;
  color: var(--t3);
  font-size: 13px;
}

.compose-close {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  cursor: pointer;
  color: var(--c-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
}

.compose-close:hover {
  color: var(--c-text-strong);
  background: var(--c-hover);
  border-color: var(--c-line-strong);
}

.compose-close svg,
.compose-publish svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compose-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.compose-section,
.compose-field {
  margin-bottom: 18px;
}

.compose-label-row {
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.compose-label-row .compose-label {
  margin-bottom: 0;
}

.compose-label-row > span {
  color: var(--t3);
  font-size: 12px;
}

.compose-label {
  margin-bottom: 8px;
  display: block;
  color: var(--c-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compose-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compose-platform-btn {
  position: relative;
  cursor: pointer;
}

.compose-platform-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.compose-platform-content {
  min-height: 34px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  background: var(--platform-bg);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  opacity: 0.62;
  filter: saturate(0.78);
  transition: opacity 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.compose-platform-content > svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.compose-platform-content .icon-fill {
  fill: currentColor;
  stroke: none;
}

.compose-platform-btn:hover .compose-platform-content,
.compose-platform-btn input:checked + .compose-platform-content {
  opacity: 1;
  filter: saturate(0.95);
}

.compose-platform-btn input:checked + .compose-platform-content {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.48);
}

.compose-platform-btn input:focus-visible + .compose-platform-content {
  outline: 2px solid #63c2de;
  outline-offset: 2px;
}

.compose-platform-check {
  width: 15px;
  height: 15px;
  display: none;
  place-items: center;
  color: var(--platform-bg);
  background: #fff;
  border-radius: 50%;
}

.compose-platform-check svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compose-platform-btn input:checked + .compose-platform-content .compose-platform-check {
  display: grid;
}

.compose-control {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--c-text-strong);
  background: var(--c-sunken);
  border: 1px solid var(--c-line-strong);
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
  outline: 0;
}

.compose-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(32, 168, 216, 0.16);
}

.compose-caption {
  min-height: 126px;
  resize: vertical;
  line-height: 1.55;
}

.compose-file {
  padding: 6px;
  color: var(--t2);
}

.compose-file::file-selector-button {
  margin-right: 10px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--c-text-strong);
  background: var(--c-hover);
  border: 1px solid var(--c-line-strong);
  border-radius: 3px;
  font: inherit;
  font-size: 13px;
}

.compose-media-status {
  min-height: 16px;
  margin-top: 6px;
  color: var(--t3);
  font-size: 13px;
}

.compose-media-preview:empty {
  display: none;
}

/* ── Composer guidance: per-platform specs, best times, counters ── */
.compose-specs {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compose-spec-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 5px 8px;
  background: var(--c-surface);
  border: 1px solid var(--c-hover);
  border-radius: 4px;
  color: var(--t2);
  font-size: 12px;
}

.compose-spec-row.is-over {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--c-danger-text);
}

.compose-spec-name {
  min-width: 70px;
  color: var(--t1);
  font-weight: 700;
}

.compose-spec-empty {
  color: var(--t3);
  font-size: 12px;
}

.compose-counter {
  color: var(--t3);
  font-size: 12px;
}

.compose-counter.is-over {
  color: var(--red);
  font-weight: 700;
}

.compose-best-times {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compose-time-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 8px 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-hover);
  border-radius: 6px;
}

.compose-time-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.compose-time-platform {
  color: var(--t1);
  font-size: 13px;
  font-weight: 700;
}

.compose-time-window {
  color: var(--t3);
  font-size: 12px;
}

.compose-time-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compose-time-pill {
  padding: 5px 11px;
  cursor: pointer;
  color: var(--t1);
  background: var(--c-soft);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.compose-time-pill:hover {
  background: var(--c-hover);
  border-color: var(--brand);
}

.compose-time-pill.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

/* Per-channel schedule picker */
.compose-time-platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.compose-time-count {
  color: var(--c-green-text);
  font-size: 12px;
  font-weight: 700;
}

.compose-time-count.is-empty {
  color: var(--c-danger-text);
}

.compose-time-custom {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.compose-time-custom .compose-control {
  width: auto;
  flex: 0 1 230px;
  min-height: 32px;
  padding: 4px 8px;
  font-size: 13px;
}

.compose-schedule-summary {
  margin-top: 8px;
  color: var(--t2);
  font-size: 13px;
}

.compose-schedule-summary:empty {
  display: none;
}

.compose-schedule-summary strong {
  color: var(--t1);
}

.compose-schedule-warn {
  color: var(--c-danger-text);
}

.compose-hashtag-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.compose-hashtag-select {
  width: auto;
  min-width: 170px;
  flex: 0 1 auto;
  font-size: 13px;
}

/* ── Saved hashtag sets ── */
.hashtag-set {
  margin-bottom: 8px;
  padding: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

.hashtag-set-name {
  color: var(--t1);
  font-size: 14px;
  font-weight: 700;
}

.hashtag-set-count {
  color: var(--t3);
  font-size: 13px;
}

.hashtag-set-tags {
  margin: 6px 0 8px;
  color: #a78bfa;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.hashtag-set-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Post History per-post stats ── */
.q-stats {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
}

.q-stat {
  color: var(--t2);
}

.q-stat-total {
  color: var(--c-brand-text);
  font-weight: 700;
}

.q-stat-pending {
  color: var(--t3);
  font-style: italic;
}

.compose-media-preview img {
  display: block;
  max-width: 100%;
  max-height: 150px;
  margin-top: 8px;
  object-fit: cover;
  border: 1px solid var(--c-line-strong);
  border-radius: 4px;
}

.compose-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.compose-two-col .compose-field {
  margin-bottom: 0;
}

.compose-error {
  display: none;
  margin-top: 18px;
  padding: 10px 12px;
  color: var(--c-danger-text);
  background: rgba(214, 91, 101, 0.1);
  border: 1px solid rgba(214, 91, 101, 0.35);
  border-radius: 4px;
  font-size: 13px;
}

.compose-footer {
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--c-raised);
  border-top: 1px solid var(--c-line);
}

.compose-footer .btn {
  min-height: 38px;
}

.compose-publish {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.compose-schedule {
  min-width: 128px;
  justify-content: center;
}

/* Responsive shell */
/* Topbar: make room for the context selects before they get cramped. */
@media (max-width: 1600px) {
  #brand-context-bar > div > span:first-child { display: none; }
  .search-btn { min-width: 38px; width: 38px; justify-content: center; font-size: 0; }
  .search-btn > span:first-child { font-size: 15px; }
  .search-btn .s-kbd2 { display: none; }
}

@media (max-width: 1440px) {
  #bb-ctx-badge,
  #global-weather-pill .label { display: none; }
}

@media (max-width: 1280px) {
  .dashboard-hero-grid { grid-template-columns: minmax(0, 1fr) minmax(250px, 285px); }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .social-platform-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { padding-inline: 20px; }
  #brand-context-bar { display: none; }
}

@media (max-width: 1100px) {
  #social-calendar > .grid2 {
    grid-template-columns: 1fr !important;
  }

  #social-calendar > .grid2 > div:last-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .sb-toggle { display: none !important; }
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    flex-basis: 270px;
    transform: translateX(-100%);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.22);
  }
  body.mobile-sidebar-open #sidebar { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1010;
    background: rgba(22, 27, 31, 0.5);
  }
  body.mobile-sidebar-open .sidebar-overlay { display: block; }
  .hamburger { display: grid; }
  .topbar { min-height: 64px; }
  .content { padding: 20px; }
  .dashboard-hero-grid { grid-template-columns: 1fr; }
  .brand-profile-card { min-height: 0; }
  .grid3 { grid-template-columns: 1fr; }
  .social-platform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .social-growth-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .social-growth-summary > div:nth-child(3) { border-left: 0; }
  .social-growth-summary > div:nth-child(n + 3) { border-top: 1px solid var(--c-line); }
  .topbar-right .topbar-pill,
  .topbar-right .date-sel { display: none; }
  /* Main + fixed-width sidebar layouts ("1fr 320px") stack on tablets. */
  .grid2[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (max-width: 620px) {
  .compose-modal-overlay { padding: 0; align-items: stretch; }
  .compose-dialog { max-height: 100vh; border: 0; border-radius: 0; }
  .compose-header, .compose-body, .compose-footer { padding-inline: 15px; }
  .compose-two-col { grid-template-columns: 1fr; }
  .compose-two-col .compose-field { margin-bottom: 16px; }
  .compose-footer { flex-wrap: wrap; }
  .compose-footer .btn { flex: 1 1 auto; justify-content: center; }
  .topbar { padding-inline: 14px; gap: 11px; }
  .page-title { font-size: 17px; }
  .breadcrumb { display: none; }
  .topbar-right { gap: 6px; }
  .topbar-right .search-btn,
  .topbar-right #global-weather-pill,
  .topbar-right .date-sel { display: none; }
  .content { padding: 14px; }
  .dashboard-hero-grid { gap: 14px; }
  .brand-profile-card { padding: 15px; }
  .brand-profile-stats { margin-inline: -15px; padding-inline: 15px; }
  /* !important beats inline desktop columns such as "1fr 340px";
     minmax(0, …) stops a wide table from stretching the column. */
  .grid2,
  .grid3,
  .grid4 { grid-template-columns: minmax(0, 1fr) !important; gap: 14px; }
  .stat-quad { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .bridge-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px !important; }
  .bridge-grid .bridge-arrow { display: inline-block; transform: rotate(90deg); }
  .verdict-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .verdict-grid > * { grid-column: auto !important; }
  .queue-layout { flex-direction: column; align-items: stretch !important; }
  .queue-layout > .queue-preview { position: static !important; }
  #social-calendar > .grid2 > div:last-child {
    grid-template-columns: 1fr;
  }
  .cal-outer {
    padding: 14px;
    overflow-x: auto;
  }
  .cal-header,
  .cal-grid {
    min-width: 630px;
  }
  .cal-day,
  .cal-day.empty {
    min-height: 88px;
  }
  .social-platform-grid { grid-template-columns: 1fr; }
  .social-growth-panel { padding: 14px; }
  .social-growth-summary > div { padding: 11px; }
  .social-growth-summary strong { font-size: 17px; }
  .social-growth-chart { overflow-x: auto; }
  .social-growth-chart svg { min-width: 560px; height: 180px; }
  .social-growth-dates { min-width: 560px; }
  .social-platform-card { min-height: 250px; }
  .section-header { align-items: flex-start; flex-direction: column; }
  .card, .platform-card, .ai-feat-card { padding: 15px; }
  .card h3 { margin: -15px -15px 14px; padding: 12px 15px; }
  .tabs { border-radius: 0; }
  .tab { padding-inline: 12px; }
  .kpi { min-height: 125px; }
  .search-overlay, .modal-overlay, [class*="modal-overlay"] { padding: 0; align-items: stretch; }
  .search-box, .modal, [class$="-modal"] { max-height: 100vh; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
