/* IntegrationXPro Social Hub — design system
   Compact, dense, native-feeling. Every colour is a token so light/dark
   switch by redefining tokens only. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --bg: #f6f6f8;
  --bg-elev: #ffffff;
  --bg-sunken: #efeff3;
  --bg-hover: #f1f1f5;
  --bg-active: #e6ecf7;
  --sidebar: #fbfbfc;
  --border: #e4e4ea;
  --border-strong: #d3d3dc;
  --text: #17171c;
  --text-2: #4c4c57;
  --text-3: #80808c;
  --text-inv: #ffffff;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #e8f0fe;
  --accent-text: #1d4ed8;
  --ok: #148a4b;
  --ok-soft: #e6f6ed;
  --warn: #a76100;
  --warn-soft: #fff3de;
  --danger: #cf2d3b;
  --danger-soft: #fdecee;
  --info: #1f6fd6;
  --info-soft: #e7f0fd;
  --neutral-soft: #efeff3;
  --brand-grad: linear-gradient(135deg, #1d4ed8 0%, #0ea5e9 100%);
  --shadow-1: 0 1px 2px rgba(20, 20, 40, .06);
  --shadow-2: 0 4px 16px rgba(20, 20, 40, .08), 0 1px 3px rgba(20, 20, 40, .06);
  --shadow-3: 0 18px 48px rgba(20, 20, 40, .18), 0 2px 8px rgba(20, 20, 40, .08);
  --ring: 0 0 0 3px rgba(37, 99, 235, .22);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --sidebar-w: 236px;
  --topbar-h: 52px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e0e11;
  --bg-elev: #17171b;
  --bg-sunken: #121215;
  --bg-hover: #1f1f25;
  --bg-active: #1e2638;
  --sidebar: #121215;
  --border: #26262d;
  --border-strong: #34343d;
  --text: #ececf1;
  --text-2: #b4b4bf;
  --text-3: #7c7c88;
  --accent: #4f8cff;
  --accent-2: #6ea0ff;
  --accent-soft: #14254a;
  --accent-text: #93b8ff;
  --ok: #3ccf7c;
  --ok-soft: #102a1c;
  --warn: #f0b24a;
  --warn-soft: #2e2210;
  --danger: #ff6b76;
  --danger-soft: #34151a;
  --info: #62a4ff;
  --info-soft: #11223b;
  --neutral-soft: #222228;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px rgba(79, 140, 255, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.ig {
  margin: 0; font-family: var(--font); font-size: 13.5px; line-height: 1.45; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.ig a { color: inherit; text-decoration: none; }
.ig a.link { color: var(--accent-text); }
.ig a.link:hover { text-decoration: underline; }
.ig h1, .ig h2, .ig h3, .ig h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.ig p { margin: 0; }
:where(.ig) :where(button, input, select, textarea) { font: inherit; color: inherit; }
.ig :focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
.ig ::selection { background: var(--accent-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 14px; height: 14px; }
.i-lg { width: 20px; height: 20px; }
[x-cloak] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }
.shell.collapsed { --sidebar-w: 64px; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-width: 0; overflow: hidden; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--brand-grad); display: grid; place-items: center; color: #fff; flex: none; }
.brand-mark .i { width: 16px; height: 16px; stroke: #fff; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 8px 10px 12px; scrollbar-width: thin; }
.nav-group { margin-top: 12px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 600; padding: 0 10px 4px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 8px; color: var(--text-2);
  font-weight: 500; white-space: nowrap; position: relative; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); font-weight: 600; }
.nav-item.active .i { color: var(--accent); }
.nav-item .badge { margin-left: auto; }
.shell.collapsed .nav-label, .shell.collapsed .nav-text, .shell.collapsed .brand-text, .shell.collapsed .nav-item .badge, .shell.collapsed .sw-text { display: none; }
.shell.collapsed .nav-item { justify-content: center; padding: 0; }
.shell.collapsed .nav-item .badge-dot { position: absolute; top: 5px; right: 9px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 8px 10px; }

.main-col { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 18px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); position: relative; z-index: 20;
}
.topbar .crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; font-size: 14px; }
.topbar .crumbs .sep { color: var(--text-3); }
.topbar .crumbs .muted { color: var(--text-3); font-weight: 500; }
.topbar .spacer { flex: 1; }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: var(--accent); opacity: 0; transition: width .25s ease, opacity .3s; }
.htmx-request .progress, .progress.on { opacity: 1; width: 70%; transition: width 2.5s cubic-bezier(.1,.7,.2,1); }
.page { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; }
.page-inner { padding: 18px 22px 40px; max-width: 1680px; margin: 0 auto; }
#ig-main { transition: opacity .12s ease; }
#ig-main.htmx-swapping { opacity: .6; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.page-head .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.mobile-toggle, .btn.mobile-toggle { display: none; }
.scrim { display: none; }

/* ---------- Account switcher ---------- */
.switcher { margin: 10px 10px 0; position: relative; }
.sw-btn {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg-elev); cursor: pointer; text-align: left; box-shadow: var(--shadow-1);
}
.sw-btn:hover { border-color: var(--border-strong); }
.sw-text { min-width: 0; flex: 1; }
.sw-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-meta { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell.collapsed .sw-btn { justify-content: center; padding: 6px; }
.menu {
  position: absolute; z-index: 60; min-width: 240px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-3); padding: 6px; max-height: 70vh; overflow-y: auto;
}
.menu-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; cursor: pointer; width: 100%; background: none; border: 0; text-align: left; }
.menu-item:hover, .menu-item.focus { background: var(--bg-hover); }
.menu-item.active { background: var(--accent-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.menu-title { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px 4px; font-weight: 600; }

/* ---------- Avatars ---------- */
.av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--bg-sunken); display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text-2); overflow: hidden; }
.av-xs { width: 20px; height: 20px; font-size: 9px; }
.av-sm { width: 24px; height: 24px; }
.av-md { width: 36px; height: 36px; font-size: 13px; }
.av-lg { width: 56px; height: 56px; font-size: 18px; }
.av-xl { width: 88px; height: 88px; font-size: 26px; }
.av-ring { padding: 2px; background: var(--brand-grad); border-radius: 50%; display: inline-flex; flex: none; }
.av-ring > .av { border: 2px solid var(--bg-elev); }
.av-stack { display: inline-flex; }
.av-stack .av { border: 2px solid var(--bg-elev); margin-left: -7px; }
.av-stack .av:first-child { margin-left: 0; }
.av-wrap { position: relative; display: inline-flex; flex: none; }
.av-wrap .dot { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--bg-elev); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .06s; box-shadow: var(--shadow-1);
  user-select: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(80, 50, 220, .3), inset 0 1px 0 rgba(255,255,255,.14); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: transparent; }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }
.btn-xs { height: 23px; padding: 0 7px; font-size: 12px; border-radius: 6px; gap: 4px; }
.btn-icon { width: 32px; padding: 0; }
.btn-icon.btn-sm { width: 27px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.htmx-request.btn, .btn.htmx-request { opacity: .7; pointer-events: none; }

/* ---------- Segmented / tabs ---------- */
.seg { display: inline-flex; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; }
.seg a, .seg button { height: 26px; padding: 0 10px; border-radius: 7px; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 550; border: 0; background: none; cursor: pointer; white-space: nowrap; font-size: 12.5px; }
.seg a:hover, .seg button:hover { color: var(--text); }
.seg .on { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-1); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px; color: var(--text-3); font-weight: 550; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs .on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Badges & pills ---------- */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 10.5px; font-weight: 700; background: var(--neutral-soft); color: var(--text-2); font-variant-numeric: tabular-nums; }
.badge-accent { background: var(--accent); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; background: var(--neutral-soft); color: var(--text-2); white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-accent { background: var(--accent-soft); color: var(--accent-text); }
.tone-neutral { background: var(--neutral-soft); color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.danger { background: var(--danger); } .dot.info { background: var(--info); } .dot.accent { background: var(--accent); }
.dot.pulse { box-shadow: 0 0 0 0 currentColor; animation: pulse 1.6s infinite; color: color-mix(in srgb, var(--accent) 60%, transparent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);} 100% { box-shadow: 0 0 0 7px transparent; } }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 550; background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--text-3); display: inline-flex; }
.kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; color: var(--text-3); background: var(--bg-elev); }

/* ---------- Surfaces ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--border); min-height: 44px; }
.card-head h3 { font-size: 13.5px; font-weight: 650; }
.card-head .sub { color: var(--text-3); font-size: 12px; }
.card-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px; }
.card-body.tight { padding: 8px; }
.card-foot { padding: 9px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.strong { font-weight: 650; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.trunc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-top { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.ml-auto { margin-left: auto; }
.hr { height: 1px; background: var(--border); margin: 12px 0; }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.right-align { text-align: right; }
.hidden { display: none !important; }

.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main-side { grid-template-columns: minmax(0, 1fr) 360px; }
.g-side-main { grid-template-columns: 300px minmax(0, 1fr); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.kpi { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px 10px; box-shadow: var(--shadow-1); display: block; transition: border-color .12s, transform .12s, box-shadow .12s; position: relative; min-width: 0; }
a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.kpi-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-foot { font-size: 11.5px; color: var(--text-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.delta { font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); } .delta.flat { color: var(--text-3); }
.spark { position: absolute; right: 12px; top: 12px; width: 76px; height: 28px; opacity: .9; pointer-events: none; }
.spark canvas { width: 100% !important; height: 100% !important; }
.kpi:has(.spark) .kpi-label { padding-right: 84px; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); max-height: calc(100vh - 220px); }
.tbl-wrap.free { max-height: none; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th { position: sticky; top: 0; z-index: 2; background: var(--bg-elev); text-align: left; font-weight: 600; font-size: 11.5px; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.tbl th a { display: inline-flex; align-items: center; gap: 3px; }
.tbl th a:hover { color: var(--text); }
.tbl th.sorted { color: var(--text); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background .08s; }
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl tbody tr.selected { background: var(--accent-soft); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl .filter-row th { top: 34px; padding: 4px 6px 6px; background: var(--bg-elev); }
.tbl .filter-row input, .tbl .filter-row select { height: 26px; font-size: 12px; width: 100%; min-width: 70px; }
.tbl-clickable tbody tr { cursor: pointer; }
.pager { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.pager .ml-auto { display: flex; gap: 4px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field + .field { margin-top: 12px; }
.label { font-size: 12px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.label .count { margin-left: auto; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.label .count.over { color: var(--danger); font-weight: 700; }
.help { font-size: 11.5px; color: var(--text-3); }
.error { font-size: 11.5px; color: var(--danger); font-weight: 550; }
.input, .select, .textarea {
  width: 100%; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text); transition: border-color .12s, box-shadow .12s; min-width: 0;
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 72px; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.invalid, .textarea.invalid { border-color: var(--danger); }
.input-sm { height: 27px; font-size: 12.5px; }
.search { position: relative; }
.search .i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 30px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.switch { position: relative; width: 32px; height: 19px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 10px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(13px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.toolbar .search { width: 240px; max-width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .field + .field { margin-top: 0; }
.form-grid .full { grid-column: 1 / -1; }
.fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.fieldset + .fieldset { margin-top: 12px; }
.fieldset-title { font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

/* ---------- Empty / skeleton / notices ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--text-3); }
.empty .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--bg-sunken); display: inline-grid; place-items: center; color: var(--text-3); margin-bottom: 10px; border: 1px solid var(--border); }
.empty h3 { color: var(--text); font-size: 14px; margin-bottom: 4px; }
.empty p { max-width: 380px; margin: 0 auto 12px; font-size: 12.5px; }
.empty.compact { padding: 22px 12px; }
.skel { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 37%, var(--bg-sunken) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; border-radius: 6px; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skel-line { height: 11px; margin: 7px 0; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-sunken); font-size: 12.5px; }
.notice .i { margin-top: 1px; }
.notice.tone-warn { border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.notice.tone-danger { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.notice.tone-info { border-color: color-mix(in srgb, var(--info) 30%, var(--border)); }
.notice.tone-accent { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); min-width: 0; transition: background .08s; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, .list-item.hover:hover { background: var(--bg-hover); }
.list-item .meta { margin-left: auto; text-align: right; flex: none; font-size: 11.5px; color: var(--text-3); }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--bg-sunken); flex: none; border: 1px solid var(--border); }
.thumb-lg { width: 56px; height: 56px; }
.thumb-ph { display: grid; place-items: center; color: var(--text-3); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast { pointer-events: auto; min-width: 260px; max-width: 380px; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--text); color: var(--bg-elev); box-shadow: var(--shadow-3); font-size: 13px; animation: toastIn .22s cubic-bezier(.2,.9,.3,1.2); }
:root[data-theme="dark"] .toast { background: #2a2a31; color: #f2f2f6; border: 1px solid #3a3a44; }
.toast .i { margin-top: 1px; }
.toast.ok .i { color: #34d27b; } .toast.danger .i { color: #ff6b76; } .toast.warn .i { color: #f0b24a; }
.toast.out { animation: toastOut .18s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Dialog / drawer ---------- */
dialog.modal { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-3); width: min(460px, calc(100vw - 32px)); }
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 10, 20, .42); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modalIn .18s cubic-bezier(.2,.9,.3,1.1); }
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(.985); } }
.modal-head { padding: 14px 16px 6px; display: flex; align-items: center; gap: 8px; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 6px 16px 14px; color: var(--text-2); }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg-sunken); border-radius: 0 0 16px 16px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--bg-elev); border-left: 1px solid var(--border); box-shadow: var(--shadow-3); z-index: 90; display: flex; flex-direction: column; animation: drawerIn .2s cubic-bezier(.2,.9,.3,1); }
@keyframes drawerIn { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(10,10,20,.3); z-index: 89; }

/* ---------- Command palette ---------- */
.cmdk { width: min(620px, calc(100vw - 32px)); }
.cmdk input { border: 0; border-bottom: 1px solid var(--border); border-radius: 16px 16px 0 0; height: 48px; font-size: 15px; padding: 0 16px; background: transparent; width: 100%; }
.cmdk input:focus { outline: none; box-shadow: none; }
.cmdk .results { max-height: 380px; overflow-y: auto; padding: 6px; }

/* ---------- Instagram previews ---------- */
.ig-phone { width: 100%; max-width: 360px; margin: 0 auto; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-2); }
.ig-post-head { display: flex; align-items: center; gap: 9px; padding: 9px 11px; }
.ig-post-head .name { font-weight: 650; font-size: 13px; }
.ig-post-head .loc { font-size: 11px; color: var(--text-2); }
.ig-media { position: relative; aspect-ratio: 1 / 1; background: var(--bg-sunken); overflow: hidden; }
.ig-media.portrait { aspect-ratio: 4 / 5; }
.ig-media.reel, .ig-media.story { aspect-ratio: 9 / 16; }
.ig-media img, .ig-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-media .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); text-align: center; font-size: 12px; }
.ig-dots { display: flex; justify-content: center; gap: 4px; padding: 8px 0 0; }
.ig-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); display: block; }
.ig-dots i.on { background: var(--accent); }
.ig-actions { display: flex; gap: 14px; padding: 8px 12px 2px; }
.ig-actions .i { width: 22px; height: 22px; stroke-width: 1.7; }
.ig-caption { padding: 4px 12px 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.ig-caption b { font-weight: 650; }
.ig-caption .tag { color: #3b64c9; }
:root[data-theme="dark"] .ig-caption .tag { color: #8fb0ff; }
.ig-first-comment { padding: 0 12px 12px; font-size: 12.5px; color: var(--text-2); }
.story-bar { position: absolute; top: 8px; left: 8px; right: 8px; height: 2px; background: rgba(255,255,255,.45); border-radius: 2px; }
.story-bar::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 35%; background: #fff; border-radius: 2px; }
.story-head { position: absolute; top: 18px; left: 10px; display: flex; gap: 7px; align-items: center; color: #fff; font-weight: 650; font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.reel-side { position: absolute; right: 10px; bottom: 60px; display: flex; flex-direction: column; gap: 16px; color: #fff; }
.reel-side .i { width: 24px; height: 24px; stroke: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.reel-cap { position: absolute; left: 10px; right: 50px; bottom: 14px; color: #fff; font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,.5); }

/* Profile preview */
.igp { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px; padding: 16px; max-width: 420px; }
.igp-top { display: flex; align-items: center; gap: 18px; }
.igp-stats { display: flex; gap: 18px; text-align: center; flex: 1; justify-content: space-around; }
.igp-stats b { display: block; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.igp-stats span { font-size: 12px; color: var(--text-2); }
.igp-name { font-weight: 650; margin-top: 10px; font-size: 13.5px; }
.igp-cat { color: var(--text-3); font-size: 12.5px; }
.igp-bio { white-space: pre-wrap; font-size: 13px; margin-top: 2px; word-break: break-word; }
.igp-link { color: #3b64c9; font-weight: 600; font-size: 13px; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
:root[data-theme="dark"] .igp-link { color: #8fb0ff; }
.igp-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.igp-btns span { background: var(--bg-sunken); border-radius: 8px; text-align: center; padding: 6px; font-weight: 650; font-size: 12.5px; }
.igp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 14px -16px -16px; border-top: 1px solid var(--border); padding-top: 2px; }
.igp-grid div { aspect-ratio: 1; background: var(--bg-sunken); }
.igp-grid img { width: 100%; height: 100%; object-fit: cover; }
.diff-add { background: var(--ok-soft); color: var(--ok); border-radius: 3px; }
.diff-del { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; border-radius: 3px; }
.changed { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- Inbox three-pane ---------- */
.inbox { display: grid; grid-template-columns: 220px 340px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); background: var(--bg-elev); }
.inbox > section { border-right: 1px solid var(--border); min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.inbox > section:last-child { border-right: 0; }
.pane-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; min-height: 48px; }
.pane-scroll { flex: 1; overflow-y: auto; }
.acct-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; margin: 2px 6px; border-radius: 8px; cursor: pointer; }
.acct-row:hover { background: var(--bg-hover); }
.acct-row.on { background: var(--bg-active); }
.conv { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.conv:hover { background: var(--bg-hover); }
.conv.on { background: var(--accent-soft); }
.conv.unread .conv-name { font-weight: 750; }
.conv.unread::before { content: ""; position: absolute; left: 4px; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); transform: translateY(-50%); }
.conv-name { font-weight: 600; font-size: 13px; }
.conv-prev { color: var(--text-3); font-size: 12.5px; }
.conv.unread .conv-prev { color: var(--text-2); }
.thread { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.bubble { max-width: min(72%, 560px); padding: 8px 12px; border-radius: 18px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.bubble.in { background: var(--bg-elev); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.out { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble.failed { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.bubble img, .bubble video { max-width: 240px; border-radius: 12px; display: block; margin-top: 4px; }
.bubble-meta { font-size: 10.5px; color: var(--text-3); margin: 0 6px 6px; }
.bubble-meta.out { align-self: flex-end; }
.day-sep { align-self: center; font-size: 11px; color: var(--text-3); padding: 8px 0 4px; font-weight: 600; }
.composer { border-top: 1px solid var(--border); padding: 10px 12px; background: var(--bg-elev); }
.composer textarea { min-height: 44px; max-height: 180px; }
.note { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; }
.ctx-pane { width: 280px; border-left: 1px solid var(--border); overflow-y: auto; padding: 12px; background: var(--bg-elev); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-dow { padding: 6px 8px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-elev); position: sticky; top: 0; z-index: 1; }
.cal-day { min-height: 118px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 5px; background: var(--bg-elev); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { background: var(--bg-sunken); }
.cal-day.other .cal-num { color: var(--text-3); }
.cal-day.today .cal-num { background: var(--accent); color: #fff; }
.cal-day.drop { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -3px; }
.cal-num { font-size: 12px; font-weight: 650; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal-item { display: flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 3px 5px; border-radius: 6px; background: var(--bg-sunken); border-left: 3px solid var(--text-3); cursor: pointer; min-width: 0; }
.cal-item:hover { filter: brightness(.97); }
.cal-item[draggable="true"] { cursor: grab; }
.cal-item.st-draft { border-left-color: var(--text-3); }
.cal-item.st-pending { border-left-color: var(--warn); background: var(--warn-soft); }
.cal-item.st-scheduled { border-left-color: var(--info); background: var(--info-soft); }
.cal-item.st-publishing { border-left-color: var(--accent); background: var(--accent-soft); }
.cal-item.st-published { border-left-color: var(--ok); background: var(--ok-soft); }
.cal-item.st-failed { border-left-color: var(--danger); background: var(--danger-soft); }
.cal-item img { width: 16px; height: 16px; border-radius: 4px; object-fit: cover; flex: none; }
.cal-more { font-size: 11px; color: var(--text-3); padding: 0 4px; }
.week { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.week .hour { height: 44px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); font-size: 10.5px; color: var(--text-3); padding: 2px 6px; position: relative; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Media grid ---------- */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; }
.mcard { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-elev); position: relative; cursor: pointer; transition: box-shadow .12s, border-color .12s; }
.mcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.mcard.sel { border-color: var(--accent); box-shadow: var(--ring); }
.mcard .mthumb { aspect-ratio: 1; background: var(--bg-sunken); position: relative; }
.mcard .mthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mcard .mbadge { position: absolute; left: 6px; top: 6px; }
.mcard .mcheck { position: absolute; right: 6px; top: 6px; }
.mcard .minfo { padding: 7px 8px; }
.mcard .mname { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcard .msub { font-size: 11px; color: var(--text-3); }
.dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 10.5px; padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 18px; text-align: center; color: var(--text-3); transition: .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Content grid (IG profile-like) ---------- */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.ccard { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-elev); display: flex; flex-direction: column; transition: border-color .12s, box-shadow .12s; }
.ccard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.ccard .cthumb { position: relative; aspect-ratio: 4/5; background: var(--bg-sunken); }
.ccard .cthumb.sq { aspect-ratio: 1; }
.ccard .cthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ccard .cbody { padding: 8px 9px; display: flex; flex-direction: column; gap: 5px; }
.ccard .cstatus { position: absolute; left: 7px; top: 7px; }
.ccard .cfmt { position: absolute; right: 7px; top: 7px; background: rgba(0,0,0,.55); color: #fff; border-radius: 6px; padding: 2px 5px; display: inline-flex; }
.ccard .cfmt .i { stroke: #fff; width: 14px; height: 14px; }
.stats-inline { display: flex; gap: 10px; font-size: 11.5px; color: var(--text-3); }
.stats-inline span { display: inline-flex; gap: 3px; align-items: center; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.sm { height: 160px; }
.chart-box.lg { height: 300px; }
.bar-list .bar { height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.bar-list .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- Permissions matrix ---------- */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.tick { color: var(--ok); } .cross { color: var(--text-3); opacity: .5; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main-side { grid-template-columns: minmax(0, 1fr) 320px; }
  .inbox { grid-template-columns: 64px 300px minmax(0, 1fr); }
  .inbox .acct-row .trunc, .inbox .acct-row .badge, .inbox .accounts-title { display: none; }
  .inbox .acct-row { justify-content: center; padding: 7px 0; }
  .ctx-pane { display: none; }
}
@media (max-width: 1024px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main-side, .g-side-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-3); }
  .shell.mobile-open .sidebar { transform: none; }
  .shell.mobile-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,10,20,.35); z-index: 25; }
  .shell.collapsed { --sidebar-w: 264px; }
  .shell.collapsed .nav-label, .shell.collapsed .nav-text, .shell.collapsed .brand-text, .shell.collapsed .nav-item .badge, .shell.collapsed .sw-text { display: revert; }
  .mobile-toggle, .btn.mobile-toggle { display: inline-flex; }
  .collapse-toggle { display: none !important; }
  .page-inner { padding: 14px 14px 32px; }
  .g-2, .g-3, .g-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox > section.accounts-pane { display: none; }
  .inbox.has-active > section.list-pane { display: none; }
  .inbox:not(.has-active) > section.thread-pane { display: none; }
  .topbar .hide-sm { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spark { display: none; }
  .kpi:has(.spark) .kpi-label { padding-right: 0; }
  .cal-day { min-height: 76px; }
  .cal-item span.trunc { display: none; }
  .toolbar .search { width: 100%; }
  .tbl .hide-sm { display: none; }
  .page-head h1 { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Account setup stepper ---------- */
.setup-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.setup-steps li { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--text-3); }
.setup-steps .bar { height: 4px; width: 100%; border-radius: 2px; background: var(--border); }
.setup-steps .st-done { color: var(--text); font-weight: 600; } .setup-steps .st-done .bar { background: var(--ok); }
.setup-steps .st-active { color: var(--text); font-weight: 600; } .setup-steps .st-active .bar { background: var(--accent); }
.setup-steps .st-fail { color: var(--danger); font-weight: 600; } .setup-steps .st-fail .bar { background: var(--danger); }
.setup-steps .dot { width: 6px; height: 6px; }
.cap-yes { color: var(--ok); display: inline-flex; } .cap-no { color: var(--text-3); display: inline-flex; }
.cap-why { max-width: 60%; text-align: right; }
@media (max-width: 860px) { .setup-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cap-why { max-width: 50%; } }
