/* ============================================================
   SEOBlug design system
   Tokens → base → layout → components → utilities
   Light mode is default; dark mode is a deliberate palette,
   not an inversion. RTL is handled with logical properties.
   ============================================================ */

:root {
  /* Brand */
  --green: #22C55E;
  --green-600: #16A34A;
  --green-700: #15803D;
  --green-soft: #DCFCE7;
  --lime: #84F13D;
  --navy: #081220;

  /* Semantic accents (never use green for everything) */
  --blue: #2563EB;   --blue-soft: #DBEAFE;
  --orange: #F59E0B; --orange-soft: #FEF3C7;
  --red: #DC2626;    --red-soft: #FEE2E2;
  --purple: #7C3AED; --purple-soft: #EDE9FE;

  /* Light surfaces */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --elevated: #FFFFFF;
  --sidebar-bg: #FFFFFF;
  --sidebar-text: #334155;
  --sidebar-active-bg: #DCFCE7;
  --sidebar-active-text: #15803D;
  --text: #081220;
  --text-2: #64748B;
  --text-3: #94A3B8;
  --border: #E5E7EB;
  --border-strong: #CBD5E1;
  --ring: rgba(34, 197, 94, .35);
  --shadow-sm: 0 1px 2px rgba(8, 18, 32, .06);
  --shadow: 0 4px 16px -4px rgba(8, 18, 32, .10);
  --shadow-lg: 0 20px 40px -12px rgba(8, 18, 32, .18);
  --overlay: rgba(8, 18, 32, .5);
  --chart-grid: #EEF2F7;

  --font-latin: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-arabic: 'Tajawal', 'Inter', system-ui, sans-serif;
  --font: var(--font-latin);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --sidebar-w: 264px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;
  --content-max: 1440px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 140ms;
  --t: 220ms;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #07101A;
  --surface: #0E1926;
  --surface-2: #0B1522;
  --elevated: #142131;
  --sidebar-bg: #081220;
  --sidebar-text: #B6C2D2;
  --sidebar-active-bg: rgba(34, 197, 94, .14);
  --sidebar-active-text: #4ADE80;
  --text: #F8FAFC;
  --text-2: #94A3B8;
  --text-3: #64748B;
  --border: #1E293B;
  --border-strong: #334155;
  --green-soft: rgba(34, 197, 94, .16);
  --blue-soft: rgba(37, 99, 235, .18);
  --orange-soft: rgba(245, 158, 11, .18);
  --red-soft: rgba(220, 38, 38, .18);
  --purple-soft: rgba(124, 58, 237, .20);
  --ring: rgba(132, 241, 61, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 6px 20px -6px rgba(0, 0, 0, .55);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
  --overlay: rgba(2, 6, 12, .7);
  --chart-grid: #152233;
  color-scheme: dark;
}

[dir="rtl"] { --font: var(--font-arabic); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
}
[dir="rtl"] body { font-size: 15px; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; } h4 { font-size: .875rem; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--blue); }
a.link:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--surface-2); padding: .1em .4em; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 6px; }
.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; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -48px; background: var(--navy); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 200; }
.skip-link:focus { top: 8px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon.sm { width: 14px; height: 14px; } .icon.lg { width: 24px; height: 24px; }
.muted { color: var(--text-2); } .subtle { color: var(--text-3); }
.text-sm { font-size: .8125rem; } .text-xs { font-size: .75rem; } .text-lg { font-size: 1.05rem; }
.font-medium { font-weight: 550; } .font-semibold { font-weight: 650; } .tnum { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Logo mark ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.15rem; letter-spacing: -.02em; color: var(--text); }
.brand .mark { width: 34px; height: 34px; }
.brand .word span { color: var(--green); }
.brand.compact .word { display: none; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar-bg); color: var(--sidebar-text);
  border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; scrollbar-width: thin;
}
[data-theme="dark"] .sidebar { border-inline-end-color: #0F1A2A; }
.sidebar .brand { padding: 4px 8px 16px; }
.sidebar .tenant-switch {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2); margin-bottom: 14px; width: 100%; text-align: start; cursor: pointer; color: inherit;
}
[data-theme="dark"] .sidebar .tenant-switch { background: rgba(255,255,255,.04); border-color: #16233A; }
.tenant-switch .avatar { width: 32px; height: 32px; }
.tenant-switch .meta { min-width: 0; flex: 1; }
.tenant-switch .meta strong { display: block; font-size: .85rem; color: var(--text); }
.tenant-switch .meta span { font-size: .72rem; color: var(--text-3); }
.nav-group { margin-bottom: 8px; }
.nav-group > .nav-label {
  display: flex; align-items: center; justify-content: space-between; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); padding: 12px 10px 6px; font-weight: 650; cursor: pointer; user-select: none; width: 100%; background: none; border: 0;
}
.nav-group > .nav-label .chev { transition: transform var(--t) var(--ease); }
.nav-group.collapsed > .nav-label .chev { transform: rotate(-90deg); }
[dir="rtl"] .nav-group.collapsed > .nav-label .chev { transform: rotate(90deg); }
.nav-group.collapsed > ul { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--sidebar-text); font-weight: 500; font-size: .875rem;
  transition: background var(--t-fast), color var(--t-fast); position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .nav-item:hover { background: rgba(255,255,255,.05); }
.nav-item.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.nav-item.is-active::before { content: ''; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--green); }
.nav-item .badge { margin-inline-start: auto; }
.nav-item .icon { color: var(--text-3); }
.nav-item.is-active .icon { color: currentColor; }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
[data-theme="dark"] .sidebar-footer { border-color: #16233A; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.user-chip .meta strong { display: block; font-size: .85rem; color: var(--text); }
.user-chip .meta span { font-size: .72rem; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { padding-inline-start: 38px; height: 40px; border-radius: 12px; }
.topbar .search .icon { position: absolute; inset-inline-start: 12px; top: 11px; color: var(--text-3); }
.topbar .spacer { flex: 1; }
.content { padding: 24px; max-width: var(--content-max); width: 100%; margin: 0 auto; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.45rem; }
.page-head .sub { color: var(--text-2); margin-top: 4px; max-width: 64ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-footer { padding: 18px 24px; color: var(--text-3); font-size: .75rem; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.app-footer a { color: var(--text-2); font-weight: 550; }
.app-footer a:hover { color: var(--green-600); }

.impersonation-bar { background: var(--orange); color: #1F1300; padding: 8px 24px; font-size: .8125rem; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.impersonation-bar .btn { background: #1F1300; color: #fff; border-color: transparent; }

/* Mobile */
.menu-btn { display: none; }
.bottom-nav { display: none; }
.sidebar-overlay { display: none; }
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 60; width: min(88vw, 320px); transform: translateX(-100%); transition: transform var(--t) var(--ease); box-shadow: none; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .app.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.sidebar-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px calc(var(--bottomnav-h) + 24px); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; height: var(--bottomnav-h); z-index: 50;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .68rem; color: var(--text-2); background: none; border: 0; font-weight: 550; }
  .bottom-nav a.is-active { color: var(--green-600); }
  .bottom-nav .create { position: relative; }
  .bottom-nav .create span.fab { width: 48px; height: 48px; border-radius: 16px; background: linear-gradient(135deg, var(--green), var(--green-600)); color: #fff; display: grid; place-items: center; margin-top: -22px; box-shadow: 0 8px 20px -6px rgba(34,197,94,.6); }
  .bottom-nav .create span.fab .icon { width: 24px; height: 24px; }
  .hide-mobile { display: none !important; }
  .app-footer { padding-bottom: calc(var(--bottomnav-h) + 12px); }
}
@media (min-width: 1025px) { .hide-desktop, .menu-btn { display: none !important; } }

/* Create sheet (mobile) */
.sheet { position: fixed; inset: 0; z-index: 90; display: none; }
.sheet.open { display: block; }
.sheet .backdrop { position: absolute; inset: 0; background: var(--overlay); }
.sheet .panel { position: absolute; bottom: 0; inset-inline: 0; background: var(--surface); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: sheetUp var(--t) var(--ease); }
.sheet .grabber { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0 auto 14px; }
.sheet .panel a { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 12px; font-weight: 550; }
.sheet .panel a:hover { background: var(--surface-2); }
.sheet .panel a .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Cards & surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: .95rem; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1200px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } .grid.main-side { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mb-2 { margin-bottom: 16px; } .mb-1 { margin-bottom: 8px; }

/* Metric tiles */
.metric { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; }
.metric .label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: .8125rem; font-weight: 550; }
.metric .label .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.metric .value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric .value.na { font-size: .95rem; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.metric .delta { font-size: .78rem; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.metric .delta.up { color: var(--green-600); } .metric .delta.down { color: var(--red); } .metric .delta.flat { color: var(--text-3); }
.metric .hint { font-size: .75rem; color: var(--text-3); }
.metric .spark { position: absolute; inset-inline-end: 0; bottom: 0; width: 45%; height: 48px; opacity: .8; }
.ic.green { background: var(--green-soft); color: var(--green-700); } .ic.blue { background: var(--blue-soft); color: var(--blue); }
.ic.orange { background: var(--orange-soft); color: #B45309; } .ic.red { background: var(--red-soft); color: var(--red); } .ic.purple { background: var(--purple-soft); color: var(--purple); }
.ic.gray { background: var(--surface-2); color: var(--text-2); }
[data-theme="dark"] .ic.green { color: #4ADE80; } [data-theme="dark"] .ic.blue { color: #60A5FA; } [data-theme="dark"] .ic.orange { color: #FBBF24; } [data-theme="dark"] .ic.red { color: #F87171; } [data-theme="dark"] .ic.purple { color: #A78BFA; }

/* Score ring */
.score-ring { --p: 0; --c: var(--green); width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; }
.score-ring::before { content: ''; position: absolute; inset: 6px; background: var(--surface); border-radius: 50%; }
.score-ring span { position: relative; font-weight: 700; font-size: .95rem; }
.score-ring.lg { width: 96px; height: 96px; } .score-ring.lg span { font-size: 1.4rem; }

/* Progress */
.progress { height: 8px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 8px; background: var(--green); transition: width .6s var(--ease); }
.progress.warn > span { background: var(--orange); } .progress.danger > span { background: var(--red); } .progress.blue > span { background: var(--blue); }
.usage-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.usage-row:last-child { border-bottom: 0; }
.usage-row .progress { grid-column: 1 / -1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #052E16; }
.btn-primary:hover { background: var(--green-600); border-color: var(--green-600); color: #fff; }
[data-theme="dark"] .btn-primary { color: #04150A; }
.btn-dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-dark:hover { background: #0F1F35; }
[data-theme="dark"] .btn-dark { background: #F8FAFC; color: var(--navy); border-color: #F8FAFC; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ai { background: var(--purple-soft); border-color: transparent; color: var(--purple); }
.btn-ai:hover { background: var(--purple); color: #fff; }
.btn-sm { height: 32px; padding: 0 10px; font-size: .8rem; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: .95rem; border-radius: 12px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: .8125rem; font-weight: 600; color: var(--text); }
.field .help { font-size: .75rem; color: var(--text-3); }
.field .error { font-size: .75rem; color: var(--red); font-weight: 550; }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-inline-end: 34px; 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' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
[dir="rtl"] select { background-position: left 12px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .85rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--green-600); flex-shrink: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip-check span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .8125rem; font-weight: 550; transition: all var(--t-fast); }
.chip-check input:checked + span { background: var(--green-soft); border-color: var(--green); color: var(--green-700); }
[data-theme="dark"] .chip-check input:checked + span { color: #4ADE80; }
.chip-check input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; gap: 2px; }
.segmented a, .segmented button { padding: 6px 12px; border-radius: 8px; font-size: .8rem; font-weight: 600; color: var(--text-2); border: 0; background: none; cursor: pointer; }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 22px; transition: background var(--t-fast); }
.toggle span::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; inset-inline-start: 2px; transition: transform var(--t-fast); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(18px); }
[dir="rtl"] .toggle input:checked + span::after { transform: translateX(-18px); }

/* ---------- Badges & status ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 650; line-height: 1.6; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.no-dot::before { display: none; }
.badge.green { background: var(--green-soft); color: var(--green-700); } .badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.orange { background: var(--orange-soft); color: #B45309; } .badge.red { background: var(--red-soft); color: var(--red); } .badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.navy { background: var(--navy); color: #fff; }
[data-theme="dark"] .badge.green { color: #4ADE80; } [data-theme="dark"] .badge.blue { color: #60A5FA; } [data-theme="dark"] .badge.orange { color: #FBBF24; } [data-theme="dark"] .badge.red { color: #F87171; } [data-theme="dark"] .badge.purple { color: #A78BFA; }
[data-theme="dark"] .badge.navy { background: #F8FAFC; color: var(--navy); }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--navy); color: #fff; flex-shrink: 0; overflow: hidden; }
.avatar.round { border-radius: 50%; } .avatar.sm { width: 28px; height: 28px; font-size: .7rem; } .avatar img { width: 100%; height: 100%; object-fit: cover; }
[data-theme="dark"] .avatar { background: #F8FAFC; color: var(--navy); }
.avatar.green { background: var(--green); color: #052E16; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); } .dot.red { background: var(--red); } .dot.orange { background: var(--orange); } .dot.gray { background: var(--text-3); } .dot.blue { background: var(--blue); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: .85rem; }
.alert .icon { margin-top: 1px; }
.alert.info { background: var(--blue-soft); border-color: transparent; color: #1E3A8A; } .alert.success { background: var(--green-soft); border-color: transparent; color: #14532D; }
.alert.warning { background: var(--orange-soft); border-color: transparent; color: #78350F; } .alert.error { background: var(--red-soft); border-color: transparent; color: #7F1D1D; }
[data-theme="dark"] .alert.info { color: #BFDBFE; } [data-theme="dark"] .alert.success { color: #BBF7D0; } [data-theme="dark"] .alert.warning { color: #FDE68A; } [data-theme="dark"] .alert.error { color: #FECACA; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th { text-align: start; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .actions-cell { text-align: end; white-space: nowrap; }
.table td .row-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity var(--t-fast); }
.table tr:hover .row-actions, .table tr:focus-within .row-actions { opacity: 1; }
@media (max-width: 768px) {
  table.table.responsive thead { display: none; }
  table.table.responsive tr { display: block; border: 1px solid var(--border); border-radius: 12px; margin: 10px 0; padding: 6px 12px; background: var(--surface); }
  table.table.responsive td { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); text-align: end; }
  table.table.responsive td:last-child { border-bottom: 0; }
  table.table.responsive td::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; text-align: start; }
  table.table.responsive td.actions-cell { justify-content: flex-end; }
  table.table.responsive td .row-actions { opacity: 1; }
  table.table.responsive tbody tr:hover td { background: transparent; }
}
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; font-size: .8rem; color: var(--text-2); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages a, .pagination .pages span { min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; font-weight: 600; }
.pagination .pages a:hover { background: var(--surface-2); }
.pagination .pages .is-active { background: var(--navy); color: #fff; }
[data-theme="dark"] .pagination .pages .is-active { background: #F8FAFC; color: var(--navy); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters select, .filters input { height: 36px; width: auto; min-width: 140px; }
.filters .search { flex: 1; min-width: 200px; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); margin-bottom: 4px; }
.empty .ic .icon { width: 26px; height: 26px; }
.empty h3 { font-size: 1rem; } .empty p { color: var(--text-2); max-width: 44ch; }
.no-data { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: .8rem; }

/* ---------- Dropdowns, modals, toasts, tooltips ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 220px; background: var(--elevated); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 70; display: none; animation: pop var(--t-fast) var(--ease); }
.dropdown-menu.start { inset-inline-end: auto; inset-inline-start: 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: .85rem; border: 0; background: none; cursor: pointer; text-align: start; color: var(--text); }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-menu .head { padding: 8px 10px 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal .backdrop { position: absolute; inset: 0; background: var(--overlay); }
.modal .dialog { position: relative; background: var(--elevated); border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop var(--t) var(--ease); }
.modal .dialog.wide { width: min(820px, 100%); }
.modal .dialog header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal .dialog .body { padding: 20px; }
.modal .dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

.toasts { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--elevated); border: 1px solid var(--border); border-inline-start: 4px solid var(--green); border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .85rem; animation: toastIn var(--t) var(--ease); }
.toast.error { border-inline-start-color: var(--red); } .toast.warning { border-inline-start-color: var(--orange); } .toast.info { border-inline-start-color: var(--blue); }
.toast .icon { margin-top: 1px; } .toast.success .icon { color: var(--green-600); } .toast.error .icon { color: var(--red); } .toast.warning .icon { color: var(--orange); } .toast.info .icon { color: var(--blue); }
.toast button { margin-inline-start: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); inset-inline-start: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 5px 8px; border-radius: 6px; font-size: .72rem; white-space: nowrap; z-index: 80; pointer-events: none; }
[dir="rtl"] [data-tip]:hover::after { transform: translateX(50%); }

/* ---------- Skeletons ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Tabs / subnav ---------- */
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.subnav a { padding: 10px 14px; font-weight: 600; font-size: .85rem; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subnav a.is-active { color: var(--text); border-bottom-color: var(--green); }
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-weight: 550; font-size: .85rem; }
.settings-nav a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } .settings-nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px; } .settings-nav a { white-space: nowrap; } }

/* ---------- Auth / onboarding layouts ---------- */
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--navy); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(34,197,94,.35), transparent 60%); bottom: -200px; inset-inline-end: -160px; }
.auth-side .brand { color: #fff; }
.auth-side h2 { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; max-width: 16ch; }
.auth-side p { color: #94A3B8; max-width: 44ch; margin-top: 12px; font-size: .95rem; }
.auth-side .flow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.auth-side .flow span { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); padding: 6px 12px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.auth-side .flow span.hi { background: var(--green); color: #052E16; border-color: transparent; }
.auth-side small { color: #64748B; font-size: .75rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-box { width: min(420px, 100%); }
.auth-box h1 { font-size: 1.6rem; margin-bottom: 4px; }
.auth-box .lead { color: var(--text-2); margin-bottom: 24px; }
.auth-box form { display: flex; flex-direction: column; gap: 16px; }
.auth-box .foot { margin-top: 24px; text-align: center; color: var(--text-2); font-size: .85rem; }
.auth-box .foot a { color: var(--green-700); font-weight: 600; }
[data-theme="dark"] .auth-box .foot a { color: #4ADE80; }
@media (max-width: 900px) { .auth-layout { grid-template-columns: 1fr; } .auth-side { display: none; } }
.wizard { max-width: 860px; margin: 0 auto; }
.wizard-progress { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin: 12px 0 24px; }
.wizard-progress span { height: 6px; border-radius: 6px; background: var(--border); }
.wizard-progress span.done { background: var(--green); } .wizard-progress span.current { background: var(--navy); }
[data-theme="dark"] .wizard-progress span.current { background: #F8FAFC; }
.wizard .step-intro { color: var(--text-2); margin-bottom: 20px; max-width: 64ch; }
.wizard .card-body form { display: flex; flex-direction: column; gap: 16px; }
.service-rows .service-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 8px; align-items: start; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 12px; }
.service-rows .service-row textarea { grid-column: 1 / -1; min-height: 60px; }
@media (max-width: 720px) { .service-rows .service-row { grid-template-columns: 1fr; } }

/* ---------- Workflow strip (marketing + dashboard) ---------- */
.flow-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flow-strip .node { padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .85rem; display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow-sm); }
.flow-strip .node .icon { color: var(--text-3); }
.flow-strip .node.hi { border-color: var(--green); background: var(--green-soft); color: var(--green-700); }
[data-theme="dark"] .flow-strip .node.hi { color: #4ADE80; }
.flow-strip .arrow { color: var(--text-3); }
[dir="rtl"] .flow-strip .arrow { transform: scaleX(-1); }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 10px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--text-2); }
.chart-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; background: var(--c, var(--green)); vertical-align: -1px; }

/* ---------- Marketing ---------- */
.mk { --mk-max: 1180px; }
.mk-nav { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.mk-nav .in { max-width: var(--mk-max); margin: 0 auto; padding: 0 24px; height: 68px; display: flex; align-items: center; gap: 24px; }
.mk-nav .links { display: flex; gap: 22px; margin-inline-start: 12px; }
.mk-nav .links a { font-weight: 550; color: var(--text-2); font-size: .9rem; }
.mk-nav .links a:hover { color: var(--text); }
.mk-nav .cta { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.mk-section { max-width: var(--mk-max); margin: 0 auto; padding: 72px 24px; }
.mk-section.tight { padding: 40px 24px; }
.mk-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--green-700); margin-bottom: 14px; }
[data-theme="dark"] .mk-eyebrow { color: #4ADE80; }
.mk h2.title { font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 750; letter-spacing: -.025em; max-width: 24ch; }
.mk .lead { color: var(--text-2); font-size: 1.05rem; max-width: 56ch; margin-top: 12px; }
.hero { padding: 96px 24px 64px; text-align: center; position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(800px 400px at 50% -10%, rgba(34,197,94,.14), transparent 70%); pointer-events: none; }
.hero .in { position: relative; max-width: 880px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.9rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; }
.hero h1 span { color: var(--green); }
.hero .lead { margin: 20px auto 0; text-align: center; }
.hero .ctas { display: flex; gap: 10px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }
.hero .flow-strip { justify-content: center; margin-top: 44px; }
.mk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 36px; }
.mk-grid.two { grid-template-columns: repeat(2, 1fr); } .mk-grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .mk-grid, .mk-grid.four { grid-template-columns: repeat(2, 1fr); } .mk-nav .links { display: none; } }
@media (max-width: 600px) { .mk-grid, .mk-grid.two, .mk-grid.four { grid-template-columns: 1fr; } .hero { padding-top: 56px; } }
.feature { padding: 24px; }
.feature .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; }
.feature h3 { font-size: 1rem; margin-bottom: 6px; } .feature p { color: var(--text-2); font-size: .9rem; }
.step-card { padding: 24px; position: relative; }
.step-card .n { width: 32px; height: 32px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 700; display: grid; place-items: center; margin-bottom: 14px; font-size: .85rem; }
[data-theme="dark"] .step-card .n { background: var(--green); color: #052E16; }
.price-card { padding: 28px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.price-card.hi { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), var(--shadow); }
.price-card .price { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; }
.price-card .price small { font-size: .9rem; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.price-card ul { display: flex; flex-direction: column; gap: 8px; font-size: .875rem; }
.price-card li { display: flex; gap: 8px; align-items: flex-start; }
.price-card li .icon { color: var(--green-600); width: 16px; height: 16px; margin-top: 2px; }
.price-card .ribbon { position: absolute; top: -12px; inset-inline-start: 24px; }
.faq details { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 0 18px; }
.faq details + details { margin-top: 8px; }
.faq summary { cursor: pointer; padding: 16px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--text-3); font-size: 1.2rem; }
.faq details[open] summary::after { content: '–'; }
.faq details p { padding: 0 0 16px; color: var(--text-2); }
.final-cta { background: var(--navy); color: #fff; border-radius: var(--radius-xl); padding: 56px 32px; text-align: center; position: relative; overflow: hidden; }
.final-cta::after { content: ''; position: absolute; width: 400px; height: 400px; border-radius: 50%; background: radial-gradient(circle, rgba(132,241,61,.35), transparent 60%); top: -150px; inset-inline-end: -100px; }
.final-cta h2 { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; position: relative; } .final-cta p { color: #94A3B8; margin: 10px 0 24px; position: relative; }
.mk-footer { border-top: 1px solid var(--border); padding: 48px 24px 28px; }
.mk-footer .in { max-width: var(--mk-max); margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.mk-footer h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: 12px; }
.mk-footer ul { display: flex; flex-direction: column; gap: 8px; font-size: .875rem; } .mk-footer ul a { color: var(--text-2); } .mk-footer ul a:hover { color: var(--text); }
.mk-footer .bottom { max-width: var(--mk-max); margin: 32px auto 0; padding-top: 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--text-3); font-size: .78rem; }
.mk-footer .bottom a { color: var(--text-2); font-weight: 600; }
@media (max-width: 800px) { .mk-footer .in { grid-template-columns: 1fr 1fr; } }
.integration-logos { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.integration-logos span { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; color: var(--text-2); font-size: .85rem; display: inline-flex; gap: 8px; align-items: center; }

/* ---------- Error pages ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.error-page .code { font-size: 5rem; font-weight: 800; letter-spacing: -.05em; color: var(--border-strong); line-height: 1; }
.error-page h1 { margin: 8px 0; } .error-page p { color: var(--text-2); max-width: 44ch; }
.error-page pre { text-align: start; background: var(--surface); border: 1px solid var(--border); padding: 16px; border-radius: 12px; overflow: auto; max-width: 900px; font-size: .75rem; }

/* ---------- Motion ---------- */
.fade-up { animation: fadeUp .5s var(--ease) both; }
.stagger > * { animation: fadeUp .5s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: 60ms; } .stagger > *:nth-child(3) { animation-delay: 120ms; } .stagger > *:nth-child(4) { animation-delay: 180ms; } .stagger > *:nth-child(n+5) { animation-delay: 240ms; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print { .sidebar, .topbar, .bottom-nav, .app-footer, .btn { display: none !important; } .app { display: block; } }
