/* ============================================================
   BusinessOS AI — Premium SaaS Design System (RTL Arabic)
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand */
  --brand: #635bff;
  --brand-600: #5448eb;
  --brand-700: #4738cf;
  --brand-50: #eef0ff;
  --accent: #12b981;
  --accent-50: #e6f9f1;

  /* Semantic */
  --success: #12b981;
  --success-bg: #e6f9f1;
  --success-fg: #0c9460;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-fg: #c0261c;
  --warning: #f59e0b;
  --warning-bg: #fdf0d8;
  --warning-fg: #b45309;
  --info: #3b82f6;
  --info-bg: #e3ecff;

  /* Neutrals */
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* Surfaces */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --glass: rgba(255, 255, 255, 0.72);

  /* Sidebar */
  --side-bg: #0f1324;
  --side-ink: #aeb5ca;
  --side-ink-active: #ffffff;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 10px 30px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, .28);
  --shadow-brand: 0 8px 24px -8px rgba(99, 91, 255, .55);

  /* Radius (8px grid) */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Motion */
  --t-fast: 150ms;
  --t: 250ms;
  --t-slow: 400ms;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* Fonts */
  --font: "Segoe UI", Tahoma, "Helvetica Neue", Arial, sans-serif;

  /* Layout */
  --side-w: 262px;
  --top-h: 72px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0b0f1a;
  --surface: #141927;
  --surface-2: #1a2133;
  --ink: #e6eaf5;
  --ink-2: #c3cbe0;
  --muted: #8b94ad;
  --faint: #5b647d;
  --line: #232b40;
  --line-strong: #334059;
  --glass: rgba(20, 25, 39, .72);
  --success-bg: #123327;
  --success-fg: #4ade80;
  --danger-bg: #3b1f25;
  --danger-fg: #f87171;
  --warning-bg: #372a12;
  --warning-fg: #fbbf24;
  --info-bg: #16263d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4),
    0 10px 30px -12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f1a;
    --surface: #141927;
    --surface-2: #1a2133;
    --ink: #e6eaf5;
    --ink-2: #c3cbe0;
    --muted: #8b94ad;
    --faint: #5b647d;
    --line: #232b40;
    --line-strong: #334059;
    --glass: rgba(20, 25, 39, .72);
    --success-bg: #123327;
    --success-fg: #4ade80;
    --danger-bg: #3b1f25;
    --danger-fg: #f87171;
    --warning-bg: #372a12;
    --warning-fg: #fbbf24;
    --info-bg: #16263d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .4),
      0 10px 30px -12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .6);
  }
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--t) var(--ease)
}

a:hover {
  color: var(--brand-700)
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.3;
  margin: 0;
  font-weight: 700;
  color: var(--ink)
}

p {
  margin: 0
}

ul,
ol {
  margin: 0;
  padding: 0
}

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  color: var(--brand-700)
}

::selection {
  background: var(--brand);
  color: #fff
}

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

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box
}

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

/* ---------- Focus / Accessibility ---------- */
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(99, 91, 255, .45);
  outline-offset: 2px
}

.skip-link {
  position: fixed;
  top: -70px;
  right: 12px;
  background: var(--brand);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  z-index: 9999;
  font-weight: 600;
  transition: top var(--t) var(--ease)
}

.skip-link:focus {
  top: 12px;
  outline: 3px solid #fff
}

/* ---------- Layout ---------- */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
}

.main {
  padding: 68px 14px 24px;
  min-width: 0;
  max-width: 100%;
}

/* ---------- Sidebar (Offcanvas Drawer by Default for Mobile - Strictly Vertical) ---------- */
.side {
  position: fixed !important;
  top: 0 !important;
  bottom: 0 !important;
  right: 0 !important;
  left: auto !important;
  width: min(300px, 85vw) !important;
  height: 100vh !important;
  height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  background: linear-gradient(180deg, #0f1324, #141a31 120%) !important;
  color: var(--side-ink) !important;
  padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom)) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  touch-action: pan-y !important;
  z-index: 9999 !important;
  transform: translateX(100%) !important;
  transition: transform var(--t-slow) var(--ease) !important;
  box-shadow: -8px 0 25px rgba(0, 0, 0, 0.5) !important;
}

[dir="ltr"] .side {
  right: auto !important;
  left: 0 !important;
  transform: translateX(-100%) !important;
}

.side.open {
  transform: translateX(0) !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.2px;
  margin: 0 6px 28px;
  white-space: nowrap;
}

.brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  color: #fff;
  font-size: 19px;
  box-shadow: 0 8px 20px -8px rgba(99, 91, 255, .9);
}

.brand b {
  color: #a5a0ff;
  font-weight: 800
}

.nav {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  width: 100% !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
}

.nav-text {
  display: block !important;
  padding: 8px 12px 6px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: .12em !important;
  color: #5b647d !important;
  text-transform: uppercase !important;
}

.nav a {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100% !important;
  padding: 11px 14px !important;
  border-radius: 11px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  color: var(--side-ink) !important;
  text-decoration: none !important;
  transition: all var(--t) var(--ease) !important;
  position: relative;
}

.nav a .ic {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  opacity: .9
}

.nav a span {
  transition: opacity var(--t) var(--ease)
}

.nav a:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
  transform: translateX(2px)
}

.nav a.active {
  background: linear-gradient(135deg, var(--brand), #7c6bff);
  color: #fff;
  box-shadow: var(--shadow-brand)
}

.nav a.active .ic {
  opacity: 1
}

.nav a .count {
  margin-inline-start: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 99px;
  display: grid;
  place-items: center;
}

.side-foot {
  margin-top: auto;
  padding: 14px 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--side-ink);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 11px;
  color: #dfe3f0;
  background: transparent;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t) var(--ease);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, .15);
  border-color: rgba(239, 68, 68, .5);
  color: #fff
}

/* ---------- Upgraded Modern Navbar / Header ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 0 24px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--t) var(--ease);
  flex-wrap: wrap;
}

.navbar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--t) var(--ease);
  user-select: none;
}

.navbar-toggle-btn:hover {
  background: var(--brand-50);
  border-color: var(--brand);
  color: var(--brand);
  transform: scale(1.05);
}

.navbar-toggle-btn:active {
  transform: scale(0.95);
}

.topbar h1 {
  font-size: 26px;
  letter-spacing: -.02em;
  margin: 0
}

.topbar .subtitle {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px
}

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

.topbar-user .who {
  text-align: right;
  line-height: 1.2
}

.topbar-user .name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink)
}

.topbar-user .role {
  font-size: 11.5px;
  color: var(--muted)
}

/* ---------- Avatar ---------- */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  position: relative;
  background: linear-gradient(135deg, #635bff, #8b5cf6, #ec4899);
  box-shadow: var(--shadow-brand);
}

.avatar .patient {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  bottom: 1px;
  left: 1px
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--t) var(--ease);
  user-select: none;
  white-space: nowrap;
}

.btn .ic {
  font-size: 1em
}

.btn {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-brand)
}

.btn:hover {
  background: var(--brand-600);
  color: #fff;
  box-shadow: 0 12px 30px -10px rgba(99, 91, 255, .7);
  transform: translateY(-1px)
}

.btn:active {
  transform: scale(.98)
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none
}

.btn.orange {
  background: linear-gradient(135deg, #f97316, #fb923c);
  box-shadow: 0 8px 24px -8px rgba(249, 115, 22, .6)
}

.btn.orange:hover {
  background: linear-gradient(135deg, #ea580c, #f97316)
}

.btn.soft {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line);
  box-shadow: var(--shadow-sm)
}

.btn.soft:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
  transform: none
}

.btn.danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: transparent;
  box-shadow: none
}

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

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line)
}

.btn.ghost:hover {
  border-color: var(--line-strong);
  background: var(--surface-2)
}

.btn.outline {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand)
}

.btn.outline:hover {
  background: var(--brand-50);
  color: var(--brand-700)
}

.btn.sm {
  padding: 7px 13px;
  font-size: 12.5px;
  border-radius: 9px
}

.btn.lg {
  padding: 13px 26px;
  font-size: 15px;
  border-radius: 12px
}

.btn.block {
  width: 100%
}

/* ---------- Cards & Panels ---------- */
.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}

.card {
  padding: 20px
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg)
}

.panel {
  padding: 26px;
  margin-bottom: 20px
}

.panel h2 {
  font-size: 18.5px;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 10px
}

.panel h2::before {
  content: "";
  width: 4px;
  height: 20px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--brand), #8b5cf6)
}

.card h3 {
  font-size: 16px;
  margin: 12px 0 6px
}

.card p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65
}

/* Section title */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 30px 0 16px;
  flex-wrap: wrap
}

.section-title h2 {
  font-size: 18px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px
}

.section-title h2 .ic {
  font-size: 20px
}

.section-title a {
  color: var(--brand);
  font-weight: 700;
  font-size: 13.5px
}

/* Grids */
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px
}

.stat {
  text-align: center;
  padding: 22px 14px;
  position: relative;
  overflow: hidden
}

.stat b {
  display: block;
  font-size: 30px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.03em
}

.stat span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600
}

.stat .ic {
  font-size: 30px;
  line-height: 1
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: right;
  padding: 18px
}

.stat-top .num {
  font-size: 30px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.03em;
  line-height: 1;
  margin-bottom: 4px
}

.stat-top .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 21px;
  color: #fff;
  flex-shrink: 0
}

/* ---------- Hero & Score ---------- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 30px 32px;
  border-radius: var(--r-xl);
  margin-bottom: 4px;
  background: linear-gradient(120deg, var(--surface), var(--brand-50));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(99, 91, 255, .16), transparent 70%);
  top: -90px;
  inset-inline-start: -60px;
  pointer-events: none
}

.hero h2 {
  font-size: 26px;
  margin: 10px 0 8px;
  letter-spacing: -.02em
}

.hero p {
  color: var(--muted);
  margin: 0;
  line-height: 1.85;
  max-width: 560px
}

.score {
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 26px;
  text-align: center;
  min-width: 150px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.score b {
  display: block;
  font-size: 34px;
  font-weight: 800;
  color: var(--brand-600)
}

.score span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px
}

.field {
  margin-bottom: 0
}

.field.full {
  grid-column: 1/-1
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2)
}

.field .hint {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
  font-weight: 400
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  width: 100%;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}

input::-moz-placeholder,
textarea::-moz-placeholder {
  color: var(--faint)
}

input::placeholder,
textarea::placeholder {
  color: var(--faint)
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong)
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(99, 91, 255, .15);
  background: var(--surface)
}

select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 38px
}

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

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer
}

input[type="datetime-local"],
input[type="time"] {
  direction: ltr
}

input[dir="ltr"] {
  direction: ltr;
  text-align: left
}

/* Checkbox chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  transition: all var(--t) var(--ease);
  user-select: none
}

.chip:hover {
  border-color: var(--line-strong)
}

.chip:has(input:checked) {
  background: var(--brand-50);
  border-color: var(--brand);
  color: var(--brand-700)
}

/* ---------- Alerts / Notices ---------- */
.notice {
  padding: 14px 18px;
  border-radius: var(--r);
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent
}

.notice::before {
  content: "✓";
  font-weight: 800;
  line-height: 1.4
}

.notice {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: rgba(18, 185, 129, .25)
}

.notice.danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: rgba(239, 68, 68, .25)
}

.notice.danger::before {
  content: "✕"
}

.notice.warning {
  background: var(--warning-bg);
  color: var(--warning-fg);
  border-color: rgba(245, 158, 11, .3)
}

.notice.warning::before {
  content: "!"
}

/* ---------- Badges / Status / Tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap
}

.badge.on {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: rgba(22, 185, 106, .25)
}

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

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

.badge.brand {
  background: var(--brand-50);
  color: var(--brand-700)
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line)
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint)
}

.status.on {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: transparent
}

.status.on::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 185, 106, .2)
}

.status.off::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .16)
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm)
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 640px
}

th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: right;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line)
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle
}

tr:last-child td {
  border-bottom: none
}

tbody tr {
  transition: background var(--t) var(--ease)
}

tbody tr:hover {
  background: var(--brand-50)
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0
}

.tabs a {
  padding: 11px 20px;
  border-radius: 10px 10px 0 0;
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  border-bottom: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--t) var(--ease);
  margin-bottom: -1px;
}

.tabs a:hover {
  color: var(--ink-2)
}

.tabs a.active {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--line);
  box-shadow: 0 -3px 10px -6px rgba(15, 23, 42, .1)
}

/* ---------- Inbox / Chat ---------- */
.inbox {
  display: grid;
  grid-template-columns: 320px 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  min-height: 560px;
  box-shadow: var(--shadow)
}

.thread-list {
  border-inline-end: 1px solid var(--line);
  overflow-y: auto;
  max-height: 640px;
  background: var(--surface-2)
}

.thread {
  display: block;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink-2);
  transition: all var(--t) var(--ease);
  position: relative
}

.thread.active,
.thread:hover {
  background: var(--surface)
}

.thread.active {
  border-inline-start: 3px solid var(--brand)
}

.thread b {
  color: var(--ink);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px
}

.thread .meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px
}

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface)
}

.chat-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px
}

.msgs {
  flex: 1;
  padding: 24px;
  overflow: auto;
  max-height: 520px;
  background: var(--bg)
}

.bubble {
  width: fit-content;
  max-width: 76%;
  padding: 11px 15px;
  border-radius: 15px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.6;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-sm)
}

.bubble.in {
  background: var(--brand-50);
  border-color: rgba(99, 91, 255, .2)
}

.bubble small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  font-size: 11px
}

.compose {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface)
}

.compose input {
  flex: 1;
  border-radius: var(--r-pill);
  padding: 12px 18px
}

.compose .btn {
  border-radius: var(--r-pill)
}

.msg-row {
  display: flex;
  margin-bottom: 8px
}

.msg-row.in {
  justify-content: flex-start
}

.msg-row.out {
  justify-content: flex-end
}

.msg-row.out .bubble {
  background: linear-gradient(135deg, var(--brand), #7c6bff);
  color: #fff;
  border: none;
  border-bottom-right-radius: 4px
}

/* ---------- Upload ---------- */
.upload-zone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-lg);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t) var(--ease);
  position: relative;
  background: var(--surface-2);
}

.upload-zone:hover,
.upload-zone.drag {
  border-color: var(--brand);
  background: var(--brand-50)
}

.upload-zone .up-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: var(--brand);
  background: var(--brand-50)
}

.upload-zone p {
  color: var(--ink-2);
  margin: 8px 0 4px;
  font-weight: 600
}

.upload-zone small {
  color: var(--muted)
}

.file-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  margin-top: 16px
}

.file-item {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  position: relative
}

.file-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: var(--shadow-sm)
}

.file-item .thumb-placeholder {
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 22px;
  color: var(--brand)
}

/* ---------- Posts grid ---------- */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px
}

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

.post-media {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 0
}

.post-media-empty {
  width: 100%;
  aspect-ratio: 4/3;
  display: grid;
  place-items: center;
  font-size: 38px;
  color: var(--brand);
  background: var(--brand-50)
}

.post-body {
  padding: 16px
}

/* ---------- Connection cards ---------- */
.channel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap
}

.channel-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 23px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm)
}

.channel-icon.ig {
  background: linear-gradient(135deg, #f9cef3, #f8819e);
  color: #c2185b
}

.channel-icon.fb {
  background: linear-gradient(135deg, #8ab6ff, #3b82f6);
  color: #fff
}

.channel-icon.wa {
  background: linear-gradient(135deg, #7deab0, #12b981);
  color: #075e42
}

.channel-meta {
  margin: 14px 0
}

.channel-meta h2 {
  font-size: 18px;
  margin: 0
}

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

.webhook-box {
  margin-top: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  direction: ltr;
  text-align: left;
  overflow: hidden
}

.webhook-box small {
  color: var(--muted)
}

.webhook-box code {
  display: block;
  margin-top: 4px;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 12.5px
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  background: var(--ink);
  color: #fff;
  padding: 14px 24px;
  border-radius: var(--r);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90%;
  animation: toastIn var(--t) var(--ease), toastOut var(--t) var(--ease) 2.6s forwards;
}

.toast.success {
  background: var(--accent)
}

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

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px)
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(16px)
  }
}

/* ---------- Loading / Spinner ---------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 26, .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t) var(--ease), visibility var(--t) var(--ease)
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible
}

.loading-box {
  background: var(--surface);
  padding: 32px 44px;
  border-radius: 20px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px
}

.loading-box .spinner {
  width: 38px;
  height: 38px;
  border-width: 4px
}

.loading-box p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite
}

@keyframes shimmer {
  to {
    background-position: -200% 0
  }
}

/* ---------- Empty / Error states ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted)
}

.empty .empty-ic {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: var(--surface-2);
  border: 1px solid var(--line)
}

.empty b {
  display: block;
  color: var(--ink-2);
  font-size: 16px;
  margin-bottom: 6px
}

.empty p {
  font-size: 13.5px;
  max-width: 380px;
  margin: 0 auto
}

.empty .btn {
  margin-top: 16px
}

/* ---------- Actions / row actions ---------- */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center
}

/* ---------- Utilities ---------- */
.mt-1 {
  margin-top: 8px
}

.mt-2 {
  margin-top: 16px
}

.mt-3 {
  margin-top: 24px
}

.mt-4 {
  margin-top: 32px
}

.mb-1 {
  margin-bottom: 8px
}

.mb-2 {
  margin-bottom: 16px
}

.mb-3 {
  margin-bottom: 24px
}

.d-none {
  display: none !important
}

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

.flex-sb {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap
}

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

.fw-7 {
  font-weight: 700
}

.nowrap {
  white-space: nowrap
}

.grid-1 {
  gap: 18px
}

.overflow-auto {
  overflow: auto
}

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

/* Steps / cron box */
.info-box {
  background: var(--info-bg);
  border: 1px solid rgba(59, 130, 246, .25);
  border-radius: var(--r);
  padding: 14px 18px;
  color: var(--warning-fg)
}

/* ============================================================
   RESPONSIVE DESIGN SYSTEM — Mobile-First
   Breakpoints:
   - Base:    0 – 479px   (Small phones: 320–430px)
   - SM:      480px+      (Large phones)
   - MD:      768px+      (Tablet/iPad)
   - LG:      1024px+     (iPad Pro / small laptop)
   - XL:      1280px+     (Laptop)
   - 2XL:     1440px+     (Desktop)
   - 3XL:     1920px+     (Full HD)
   - 4XL:     2560px+     (Ultra-wide)
   ============================================================ */

/* ---------- Hamburger Menu Button ---------- */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 10px;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t) var(--ease);
  -webkit-tap-highlight-color: transparent;
  z-index: 60;
  padding: 0;
  line-height: 1;
}

.hamburger:hover {
  background: rgba(255, 255, 255, .1)
}

.hamburger:active {
  transform: scale(.92)
}

/* ---------- Mobile Sidebar Overlay ---------- */
.side-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 49;
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
}

.side-overlay.active {
  opacity: 1;
}

/* ---------- Responsive Typography ---------- */
h1 {
  font-size: clamp(1.25rem, 2vw + 0.5rem, 1.625rem)
}

h2 {
  font-size: clamp(1.05rem, 1.5vw + 0.4rem, 1.15rem)
}

h3 {
  font-size: clamp(0.95rem, 1.2vw + 0.3rem, 1rem)
}

/* ---------- Touch Friendly Base ---------- */
@media (pointer: coarse) {

  .btn,
  button,
  .nav a,
  .tabs a,
  .thread,
  .dropdown-item,
  .cmd-item {
    min-height: 44px;
  }

  .btn.sm {
    min-height: 40px
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px
  }

  select {
    padding-left: 42px
  }
}

/* ========== BASE: 0 – 479px (Small phones 320–430px) ========== */
.hamburger {
  display: flex
}

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

.side {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-end: auto;
  inset-inline-start: 0;
  width: min(300px, 85vw);
  height: 100vh;
  z-index: 51;
  flex-direction: column;
  align-items: stretch;
  padding: 22px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(-110%);
  transition: transform var(--t-slow) var(--ease);
  border-bottom: none;
  border-inline-end: 1px solid var(--line-strong);
}

[dir="rtl"] .side {
  transform: translateX(110%);
}

.side.open {
  transform: translateX(0) !important
}

.side.open~.side-overlay {
  display: block;
  opacity: 1
}

/* Mobile top bar */
.mobile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 48;
  background: linear-gradient(180deg, #0f1324, #141a31);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-strong);
}

.mobile-topbar .brand {
  margin: 0;
  font-size: 16px;
}

.mobile-topbar .brand .logo {
  width: 32px;
  height: 32px;
  font-size: 15px;
}

/* Sidebar Drawer Header & Close Button */
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.side-head .brand {
  margin: 0;
}

.side-close-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.side-close-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

.side-actions-mobile {
  display: block;
}

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

.nav-text {
  display: block
}

.nav a {
  padding: 10px 12px;
  font-size: 13.5px;
  border-radius: 9px;
}

.nav a span {
  display: inline
}

.nav a .ic {
  display: inline
}

.side-foot {
  display: block
}

.logout-btn {
  display: flex
}

.main {
  padding: 68px 12px 20px;
  min-width: 0;
  max-width: 100%;
}

.topbar {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.topbar h1 {
  font-size: clamp(1.15rem, 4vw, 1.35rem)
}

.topbar-actions {
  width: 100%;
  flex-wrap: wrap;
  gap: 6px;
}

.topbar-actions .btn {
  flex: 1;
  min-width: 0
}

.topbar-actions .kbd-badge {
  display: none
}

.topbar-actions .sr-mobile-hide {
  display: none
}

.topbar-user .who {
  display: none
}

.topbar-user {
  gap: 8px
}

.breadcrumb {
  display: none
}

.hero {
  flex-direction: column;
  text-align: center;
  padding: 20px 16px;
  gap: 14px;
}

.hero h2 {
  font-size: clamp(1.1rem, 4vw, 1.3rem)
}

.hero p {
  font-size: 13px;
  line-height: 1.7
}

.score {
  min-width: auto;
  padding: 14px 20px
}

.score b {
  font-size: 28px
}

.grid3 {
  grid-template-columns: 1fr;
  gap: 12px
}

.grid2 {
  grid-template-columns: 1fr;
  gap: 12px
}

.grid-auto {
  grid-template-columns: 1fr;
  gap: 12px
}

.grid4 {
  grid-template-columns: 1fr;
  gap: 12px
}

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

.stat-top {
  padding: 14px;
  gap: 10px
}

.stat-top .num {
  font-size: 24px
}

.stat-top .label {
  font-size: 11.5px
}

.stat-icon {
  width: 38px;
  height: 38px;
  font-size: 18px
}

.card {
  padding: 16px
}

.panel {
  padding: 18px;
  margin-bottom: 14px
}

.panel h2 {
  font-size: 16px;
  margin-bottom: 12px
}

.section-title {
  margin: 20px 0 10px
}

.section-title h2 {
  font-size: 15px
}

.form-grid {
  grid-template-columns: 1fr;
  gap: 12px
}

.inbox {
  grid-template-columns: 1fr;
  min-height: auto
}

.thread-list {
  max-height: 200px;
  border-inline-end: none;
  border-bottom: 1px solid var(--line)
}

.msgs {
  max-height: 350px;
  padding: 14px
}

.bubble {
  max-width: 90%;
  font-size: 13.5px;
  padding: 10px 13px
}

.compose {
  padding: 10px;
  gap: 8px
}

.compose input {
  padding: 10px 14px
}

.chat-head {
  padding: 12px 14px;
  flex-wrap: wrap;
  gap: 8px
}

.tabs {
  gap: 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0
}

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

.tabs a {
  padding: 10px 14px;
  font-size: 12.5px;
  white-space: nowrap;
  flex-shrink: 0
}

.btn {
  font-size: 13.5px;
  padding: 10px 16px
}

.btn.sm {
  padding: 8px 12px;
  font-size: 12px
}

.actions {
  gap: 6px
}

.table-wrap {
  border-radius: var(--r);
  margin-inline: -2px
}

table {
  min-width: 580px
}

.channel-head {
  gap: 8px
}

.channel-icon {
  width: 44px;
  height: 44px;
  font-size: 20px;
  border-radius: 12px
}

.channel-meta h2 {
  font-size: 15px
}

.empty {
  padding: 30px 16px
}

.upload-zone {
  padding: 24px 14px
}

.notice {
  font-size: 13px;
  padding: 12px 14px
}

.modal-backdrop {
  padding: 12px
}

.modal-box {
  padding: 20px;
  border-radius: var(--r-lg)
}

.ai-drawer {
  width: min(340px, 92vw)
}

.cmd-box {
  width: min(540px, 94vw)
}

.kpi .kpi-value {
  font-size: 26px
}

.dropdown-menu {
  width: min-content;
  min-width: 180px
}

.info-box {
  font-size: 13px;
  padding: 12px 14px
}

.webhook-box code {
  font-size: 11.5px
}

/* Facebook mobile  */
.fb-page-grid,
.fb-post-grid,
.fb-detail-layout {
  grid-template-columns: 1fr
}

.fb-subnav {
  width: 100%;
  overflow-x: auto
}

.fb-subnav a {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  font-size: 12px
}

.fb-hero-side {
  flex-direction: column;
  align-items: flex-start
}

.fb-hero-side .actions,
.fb-hero-side .actions form,
.fb-hero-side .actions .btn {
  width: 100%
}

.fb-toolbar,
.fb-active-band,
.social-account-row {
  align-items: flex-start;
  flex-wrap: wrap
}

.fb-active-band>div:nth-child(2),
.social-account-main {
  flex: 1
}

.fb-toolbar .actions,
.fb-active-band .actions,
.social-account-row .actions {
  width: 100%;
  flex-wrap: wrap
}

.fb-facts {
  grid-template-columns: 1fr
}

.fb-page-item {
  padding: 14px
}

.fb-page-item .actions form,
.fb-page-item .actions .btn,
.fb-toolbar .actions form,
.fb-toolbar .actions .btn {
  width: 100%
}

.fb-page-item .actions button,
.fb-toolbar .actions button {
  width: 100%
}

.fb-post-meta {
  align-items: flex-start;
  flex-direction: column
}

.fb-publish-context {
  align-items: flex-start;
  flex-direction: column
}

.fb-publish-context>div {
  align-items: flex-start;
  flex-direction: column;
  gap: 2px
}

/* YouTube mobile */
.yt-account-summary {
  align-items: flex-start;
  flex-wrap: wrap
}

.yt-account-main {
  min-width: 0
}

.yt-token-facts {
  display: grid;
  gap: 6px
}

.yt-account-summary>.actions,
.yt-account-summary>.actions form,
.yt-account-summary>.actions .btn,
.yt-account-summary>.actions button {
  width: 100%
}

/* ========== SM: 480px+ (Large phones) ========== */
@media (min-width: 480px) {
  .main {
    padding: 68px 16px 24px
  }

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

  .grid-auto {
    grid-template-columns: repeat(2, 1fr)
  }

  .fb-facts {
    grid-template-columns: 1fr 1fr
  }

  .btn.sm {
    font-size: 12.5px
  }

  .hero {
    padding: 22px 20px
  }
}

/* ========== MD: 768px+ (Tablet / iPad) ========== */
@media (min-width: 768px) {
  .main {
    padding: 72px 24px 28px
  }

  .grid3 {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px
  }

  .grid2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px
  }

  .grid4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px
  }

  .grid-auto {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px
  }

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

  .stat-top .num {
    font-size: 26px
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 16px
  }

  .topbar-actions {
    width: auto;
    flex-wrap: nowrap
  }

  .topbar-actions .btn {
    flex: none
  }

  .topbar-user .who {
    display: block
  }

  .breadcrumb {
    display: flex
  }

  .hero {
    flex-direction: row;
    text-align: start;
    padding: 26px 28px
  }

  .hero h2 {
    font-size: 22px
  }

  .card {
    padding: 20px
  }

  .panel {
    padding: 24px
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px
  }

  .inbox {
    min-height: 480px
  }

  .thread-list {
    max-height: 480px;
    border-inline-end: 1px solid var(--line);
    border-bottom: none
  }

  .msgs {
    max-height: 440px;
    padding: 20px
  }

  .tabs a {
    padding: 11px 18px;
    font-size: 13.5px
  }

  .channel-icon {
    width: 48px;
    height: 48px;
    font-size: 22px
  }

  .fb-page-grid,
  .fb-post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }

  .fb-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }

  .fb-hero-side {
    flex-direction: row;
    align-items: center
  }

  .ai-drawer {
    width: 360px
  }
}

.desktop-hamburger {
  display: none !important;
}

/* ========== LG: 1024px+ (iPad Pro / Small laptop) ========== */
@media (min-width: 1024px) {

  .side-close-btn,
  .side-actions-mobile,
  .mobile-topbar {
    display: none !important;
  }

  .desktop-hamburger {
    display: inline-flex !important;
    width: 38px;
    height: 38px;
    font-size: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--ink);
  }

  .side-overlay {
    display: none !important;
  }

  .side-head {
    border-bottom: none;
    margin-bottom: 28px;
    padding-bottom: 0;
  }

  .shell {
    display: block !important;
    min-height: 100vh !important;
  }

  .side {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: var(--side-w) !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: none !important;
    z-index: 60 !important;
    box-shadow: none !important;
    border-inline-end: 1px solid var(--line-strong) !important;
    overflow: hidden !important;
  }

  [dir="rtl"] .side {
    transform: none !important;
  }

  .nav-text {
    display: block
  }

  .main {
    margin-inline-start: var(--side-w);
    min-height: 100vh;
    max-width: none;
    padding: 28px 32px
  }

  .grid3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px
  }

  .grid4 {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px
  }

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

  .stat-top .num {
    font-size: 28px
  }

  .inbox {
    grid-template-columns: 300px 1fr;
    min-height: 520px
  }

  .thread-list {
    max-height: 600px
  }

  .msgs {
    max-height: 500px
  }

  .topbar h1 {
    font-size: 24px
  }

  .hero h2 {
    font-size: 24px
  }

  .fb-detail-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }
}

/* ========== XL: 1280px+ (Laptop) ========== */
@media (min-width: 1280px) {
  .main {
    padding: 28px 36px
  }

  .grid4 {
    grid-template-columns: repeat(4, 1fr)
  }

  .inbox {
    grid-template-columns: 320px 1fr;
    min-height: 560px
  }

  .thread-list {
    max-height: 640px
  }

  .msgs {
    max-height: 520px
  }

  .topbar h1 {
    font-size: 26px
  }

  .hero h2 {
    font-size: 26px
  }

  .hero {
    padding: 30px 32px
  }
}

/* ========== 2XL: 1440px+ (Desktop) ========== */
@media (min-width: 1440px) {
  .main {
    padding: 28px 40px;
    max-width: none;
  }

  .stats {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr))
  }

  .stat-top .num {
    font-size: 30px
  }
}

/* ========== 3XL: 1920px+ (Full HD) ========== */
@media (min-width: 1920px) {
  .main {
    max-width: none;
    padding: 32px 48px;
  }

  .hero {
    max-width: 1400px
  }
}

/* ========== 4XL: 2560px+ (Ultra-wide) ========== */
@media (min-width: 2560px) {
  .main {
    max-width: none;
    padding: 36px 56px;
  }

  body {
    font-size: 16px
  }

  .nav a {
    font-size: 15px;
    padding: 12px 16px
  }

  .btn {
    font-size: 15px
  }

  .topbar h1 {
    font-size: 28px
  }

  .card {
    padding: 24px
  }

  .panel {
    padding: 30px
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion:reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important
  }
}

/* ---------- Print ---------- */
@media print {

  .side,
  .topbar,
  .btn,
  .toast,
  .loading-overlay,
  .sticky,
  .hamburger,
  .mobile-topbar,
  .side-overlay {
    display: none !important
  }

  .shell {
    display: block
  }

  .main {
    padding: 0;
    max-width: 100%
  }

  .card,
  .panel {
    box-shadow: none;
    border: 1px solid #ccc
  }
}

/* ---------- Facebook workspace ---------- */
.fb-subnav {
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow-x: auto
}

.fb-subnav a {
  padding: 8px 15px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap
}

.fb-subnav a:hover {
  color: var(--ink);
  background: var(--surface-2)
}

.fb-subnav a.active {
  color: #fff;
  background: #1877f2
}

.fb-hero {
  min-height: 220px;
  border-inline-start: 4px solid #1877f2
}

.fb-hero h2 {
  margin-top: 10px
}

.fb-hero>div:first-child {
  max-width: 720px
}

.fb-hero-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px
}

.fb-hero-meta b {
  color: var(--ink-2)
}

.fb-hero-side {
  display: flex;
  align-items: center;
  gap: 18px
}

.fb-hero-side .score {
  text-align: center;
  min-width: 130px
}

.fb-hero-side .score b {
  display: block;
  color: #1877f2;
  font-size: 36px;
  line-height: 1
}

.fb-hero-side .score span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 7px
}

.fb-hero-side .actions {
  margin: 0
}

.fb-overview-stats {
  margin-bottom: 26px
}

.fb-blue {
  background: #1877f2 !important;
  color: #fff
}

.fb-green {
  background: #12b981 !important;
  color: #fff
}

.fb-cyan {
  background: #0891b2 !important;
  color: #fff
}

.fb-amber {
  background: #d97706 !important;
  color: #fff
}

.fb-quick-actions {
  margin-bottom: 26px
}

.fb-quick-actions>a {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px;
  text-decoration: none;
  border-radius: 8px
}

.fb-quick-actions h3 {
  margin: 0 0 3px;
  font-size: 14px
}

.fb-quick-actions p {
  margin: 0;
  font-size: 12px
}

.quick-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 7px;
  font-size: 20px;
  font-weight: 800
}

.fb-toolbar,
.fb-active-band,
.fb-publish-context,
.social-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px
}

.fb-toolbar>div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap
}

.fb-active-band {
  border-inline-start: 4px solid #1877f2
}

.fb-active-band.compact {
  padding: 14px 18px
}

.fb-active-band img,
.fb-active-band .fb-avatar-placeholder,
.fb-identity img,
.fb-identity .fb-avatar-placeholder {
  width: 64px;
  height: 64px;
  flex: 0 0 64px
}

.fb-active-band h2,
.social-account-row h2 {
  font-size: 18px;
  margin: 5px 0 0
}

.fb-active-band p,
.social-account-row p {
  margin: 2px 0;
  color: var(--muted)
}

.fb-page-grid,
.fb-post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px
}

.fb-page-item,
.fb-post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden
}

.fb-page-item {
  padding: 18px
}

.fb-page-item.active {
  border-color: #1877f2;
  box-shadow: inset 0 0 0 1px #1877f2
}

.fb-page-head,
.fb-identity {
  display: flex;
  align-items: center;
  gap: 12px
}

.fb-page-head img,
.fb-page-head .fb-avatar-placeholder {
  width: 52px;
  height: 52px;
  flex: 0 0 52px
}

.fb-page-head img,
.fb-active-band img,
.fb-identity img {
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2)
}

.fb-avatar-placeholder {
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #1877f2;
  color: #fff;
  font-size: 28px;
  font-weight: 800
}

.fb-page-head>div {
  min-width: 0;
  flex: 1
}

.fb-page-head h3,
.fb-identity h3 {
  font-size: 16px;
  margin: 0
}

.fb-page-head p,
.fb-identity p {
  margin: 2px 0;
  color: var(--muted);
  overflow-wrap: anywhere
}

.fb-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0
}

.fb-facts>div {
  background: var(--surface-2);
  padding: 9px;
  border-radius: 6px;
  min-width: 0
}

.fb-facts dt {
  font-size: 11px;
  color: var(--muted)
}

.fb-facts dd {
  margin: 3px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere
}

.fb-facts.vertical {
  grid-template-columns: 1fr
}

.fb-permissions {
  font-size: 12px;
  color: var(--muted);
  min-height: 42px;
  overflow-wrap: anywhere
}

.fb-page-item .actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

.fb-detail-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px
}

.fb-identity {
  margin-bottom: 18px
}

.fb-account-permissions {
  margin-top: 16px
}

.fb-account-permissions>div {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px
}

.fb-post-media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  background: #090b10
}

.fb-post-media-grid.count-1 {
  grid-template-columns: 1fr
}

.fb-post-media-grid img,
.fb-post-media-grid video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 180px;
  aspect-ratio: 16/10;
  object-fit: cover;
  background: #090b10
}

.fb-post-body {
  padding: 16px
}

.fb-post-body>p {
  min-height: 70px;
  white-space: normal;
  overflow-wrap: anywhere
}

.fb-engagement {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 14px 0
}

.fb-engagement span {
  background: var(--surface-2);
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  font-size: 12px
}

.fb-engagement b {
  display: block;
  font-size: 15px
}

.fb-post-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 12px
}

.fb-post-meta>.actions {
  margin: 0
}

.fb-post-details {
  position: relative
}

.fb-post-details summary {
  list-style: none
}

.fb-post-details summary::-webkit-details-marker {
  display: none
}

.fb-post-details[open] dl {
  position: absolute;
  z-index: 10;
  left: 0;
  bottom: 38px;
  width: 260px;
  padding: 12px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-lg)
}

.fb-post-details dl>div {
  margin-bottom: 7px
}

.fb-post-details dt {
  color: var(--muted);
  font-size: 11px
}

.fb-post-details dd {
  margin: 1px 0;
  overflow-wrap: anywhere
}

.fb-post-meta code {
  overflow: hidden;
  text-overflow: ellipsis
}

.fb-load-more {
  text-align: center;
  margin: 22px 0
}

.social-account-grid {
  display: grid;
  gap: 12px
}

.social-account-row {
  margin: 0
}

.provider-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  color: #fff;
  font-size: 22px;
  font-weight: 800
}

.provider-mark.facebook {
  background: #1877f2
}

.provider-mark.instagram {
  background: #c13584
}

.provider-mark.youtube {
  background: #ff0033
}

.provider-mark.twitter,
.provider-mark.threads {
  background: #111
}

.social-account-main {
  flex: 1;
  min-width: 0
}

.social-account-main .flex {
  gap: 9px
}

.social-account-main small {
  color: var(--muted)
}

.fb-publish-context {
  padding: 12px 16px;
  flex-wrap: wrap
}

.fb-publish-context>div {
  display: flex;
  gap: 10px;
  align-items: center
}

.fb-publish-context span {
  color: var(--muted)
}

.fb-page-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap
}

.fb-page-selector label {
  font-size: 12px;
  font-weight: 700
}

.fb-page-selector select {
  width: min(320px, 70vw);
  min-width: 180px
}

/* ---------- YouTube OAuth and studio ---------- */
.yt-account-summary {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 4px solid #ff0033;
  border-radius: 8px
}

.yt-account-summary.requires-auth {
  border-inline-start-color: var(--danger)
}

.yt-account-summary>img,
.yt-avatar {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 8px;
  object-fit: cover
}

.yt-avatar {
  display: grid;
  place-items: center;
  background: #ff0033;
  color: #fff;
  font-size: 24px
}

.yt-account-main {
  flex: 1;
  min-width: 0
}

.yt-account-main h2 {
  font-size: 18px;
  margin: 0
}

.yt-account-main p {
  margin: 4px 0;
  color: var(--muted)
}

.yt-token-facts {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted)
}

.yt-token-facts b {
  color: var(--ink-2)
}

.yt-account-summary>.actions {
  margin: 0;
  flex-wrap: wrap
}

.yt-red {
  background: #ff0033 !important;
  color: #fff
}

.yt-blue {
  background: #2563eb !important;
  color: #fff
}

.yt-green {
  background: #059669 !important;
  color: #fff
}

.yt-amber {
  background: #d97706 !important;
  color: #fff
}

.yt-stats {
  margin-bottom: 18px
}

.yt-video-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px
}

.yt-video-cell img {
  width: 72px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted)
}

.breadcrumb a {
  color: var(--muted);
  font-weight: 600
}

.breadcrumb a:hover {
  color: var(--brand)
}

.breadcrumb .active {
  color: var(--ink-2);
  font-weight: 700
}

/* ---------- Command Palette ---------- */
.cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  place-items: start center;
  padding-top: 18vh
}

.cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px)
}

.cmd-box {
  position: relative;
  width: min(580px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cmdIn .2s var(--ease)
}

@keyframes cmdIn {
  from {
    opacity: 0;
    transform: scale(.96) translateY(-10px)
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0)
  }
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line)
}

.cmd-search-icon {
  font-size: 18px;
  flex-shrink: 0;
  color: var(--muted)
}

.cmd-input-wrap input {
  flex: 1;
  border: none !important;
  box-shadow: none !important;
  padding: 8px 0;
  font-size: 15px;
  background: transparent !important
}

.cmd-badge {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: monospace
}

.cmd-results {
  max-height: 340px;
  overflow-y: auto;
  padding: 8px
}

.cmd-group-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 12px
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r);
  text-decoration: none;
  color: var(--ink-2);
  transition: background var(--t-fast) var(--ease)
}

.cmd-item:hover {
  background: var(--brand-50);
  color: var(--brand-700)
}

.cmd-item .ic {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0
}

.cmd-item-info b {
  display: block;
  font-size: 13.5px
}

.cmd-item-info small {
  color: var(--muted);
  font-size: 11.5px
}

/* ---------- AI Copilot Drawer ---------- */
.ai-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 380px;
  height: 100vh;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--t-slow) var(--ease);
  direction: rtl
}

[dir="rtl"] .ai-drawer {
  left: auto;
  right: 0;
  transform: translateX(100%)
}

.ai-drawer.active {
  transform: translateX(0)
}

.ai-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  gap: 10px
}

.ai-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px
}

.ai-drawer-footer {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2)
}

.ai-drawer-footer input {
  flex: 1;
  border-radius: var(--r-pill);
  padding: 10px 16px
}

/* ---------- Dropdown Menu ---------- */
.dropdown-wrap {
  position: relative
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 99;
  animation: fadeDown .15s var(--ease)
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.dropdown-head {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px
}

.dropdown-item {
  display: block;
  padding: 9px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--t-fast) var(--ease);
  cursor: pointer
}

.dropdown-item:hover {
  background: var(--surface-2);
  color: var(--ink)
}

.dropdown-item.danger {
  color: var(--danger-fg)
}

.dropdown-item small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px
}

/* Notification dot */
.danger-dot {
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  position: absolute;
  top: -4px;
  right: -4px
}

.btn {
  position: relative
}

/* ---------- Modal & Backdrops ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: clamp(20px, 4vw, 32px);
  width: min(540px, 100%);
  max-height: min(88vh, 750px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  margin: auto;
  animation: cmdIn .2s var(--ease);
}

.modal-box h3 {
  font-size: clamp(1.1rem, 3.5vw, 1.25rem);
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--ink);
}

.modal-box p {
  color: var(--muted);
  font-size: clamp(13px, 2.5vw, 14px);
  line-height: 1.6;
}

.modal-box .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.modal-box .modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ---------- Progress Bar ---------- */
.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), #8b5cf6);
  transition: width var(--t-slow) var(--ease);
}

.progress-bar.green {
  background: linear-gradient(90deg, var(--accent), #34d399);
}

.progress-bar.orange {
  background: linear-gradient(90deg, #f97316, #fb923c);
}

.progress-bar.danger {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

/* ---------- KPI Trend Card ---------- */
.kpi {
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.kpi::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 91, 255, .08), transparent 70%);
  top: -40px;
  inset-inline-end: -30px;
  pointer-events: none;
}

.kpi .kpi-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.kpi .kpi-value {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.03em;
  line-height: 1;
}

.kpi .kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-pill);
}

.kpi .kpi-trend.up {
  background: var(--success-bg);
  color: var(--success-fg);
}

.kpi .kpi-trend.down {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

.kpi .kpi-trend.neutral {
  background: var(--surface-2);
  color: var(--muted);
}

/* ---------- kbd badge ---------- */
.kbd-badge {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 10px;
  color: var(--muted);
  font-family: monospace;
  margin-inline-start: 4px;
}

/* Nav separator */
.nav-sep {
  height: 1px;
  background: rgba(255, 255, 255, .08);
  margin: 8px 0;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding: 8px 0;
}

.pagination a,
.pagination span {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--t-fast) var(--ease);
}

.pagination a:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.pagination .active,
.pagination span.current {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ---------- Global overflow protection ---------- */
html {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

.main>* {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

img,
video,
iframe,
embed,
object,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

pre,
code {
  overflow-x: auto;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Topbar Actions ---------- */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions .btn {
  position: relative;
}

/* Timeline */
.timeline {
  position: relative;
  padding-inline-start: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  inset-inline-start: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}

.timeline-item::before {
  content: "";
  position: absolute;
  inset-inline-start: -20px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
}

.timeline-item .timeline-time {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.timeline-item .timeline-action {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 4px;
}

.timeline-item .timeline-detail {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 2px;
}
