:root {
  --cx-bg: #f3efe6;
  --cx-bg-2: #efe8d6;
  --cx-glow: #f6e27a;
  --cx-yellow: #f5c518;
  --cx-yellow-deep: #e6b400;
  --cx-yellow-soft: rgba(245, 197, 24, 0.22);
  --cx-ink: #1a1a1a;
  --cx-ink-2: #2c2c2c;
  --cx-muted: #8a8578;
  --cx-muted-2: #6b665c;
  --cx-card: #ffffff;
  --cx-card-soft: rgba(255, 255, 255, 0.72);
  --cx-border: rgba(26, 26, 26, 0.06);
  --cx-border-2: rgba(26, 26, 26, 0.1);
  --cx-success: #7cb518;
  --cx-danger: #e04f4f;
  --cx-warning: #f5a623;
  --cx-info: #3d8bfd;
  --cx-shadow: 0 4px 18px rgba(40, 30, 10, 0.05);
  --cx-shadow-lg: 0 18px 50px rgba(40, 30, 10, 0.1);
  --cx-radius: 28px;
  --cx-radius-md: 20px;
  --cx-radius-sm: 14px;
  --cx-pill: 999px;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --font-display: "Outfit", "Plus Jakarta Sans", sans-serif;

  /* Legacy aliases so older markup keeps working */
  --bx-accent: var(--cx-yellow);
  --bx-accent-2: var(--cx-ink);
  --bx-accent-soft: var(--cx-yellow-soft);
  --bx-menu: var(--cx-yellow);
  --bx-menu-dark: var(--cx-yellow-deep);
  --bx-sidebar: var(--cx-card);
  --bx-sidebar-text: var(--cx-muted-2);
  --bx-sidebar-active: var(--cx-yellow-soft);
  --bx-bg: var(--cx-bg);
  --bx-card: var(--cx-card);
  --bx-text: var(--cx-ink);
  --bx-muted: var(--cx-muted);
  --bx-muted-2: var(--cx-muted-2);
  --bx-border: var(--cx-border);
  --bx-border-2: var(--cx-border-2);
  --bx-success: var(--cx-success);
  --bx-danger: var(--cx-danger);
  --bx-warning: var(--cx-warning);
  --bx-shadow: var(--cx-shadow);
  --bx-shadow-lg: var(--cx-shadow-lg);
  --bx-radius: var(--cx-radius-md);
  --bx-radius-sm: var(--cx-radius-sm);
  --bx-sidebar-w: 280px;
  --bx-topbar-h: 72px;
  --bx-blue: var(--cx-yellow);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--cx-ink);
  background: var(--cx-bg);
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cx-ink); text-decoration: none; }
a:hover { color: var(--cx-ink-2); }

/* ========== Progress ========== */
.spa-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10000;
  background: transparent; overflow: hidden; pointer-events: none;
}
.spa-progress.is-active { background: rgba(245, 197, 24, 0.18); }
.spa-progress.is-active::after {
  content: ""; display: block; height: 100%; width: 35%;
  background: linear-gradient(90deg, var(--cx-yellow), #ffe56a);
  animation: spa-indeterminate .85s ease-in-out infinite;
}
@keyframes spa-indeterminate {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(320%); }
}

/* ========== Auth (Crextio login) ========== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 18% 12%, rgba(246, 226, 122, 0.85), transparent 55%),
    radial-gradient(ellipse 55% 50% at 88% 78%, rgba(245, 197, 24, 0.35), transparent 50%),
    radial-gradient(ellipse 40% 35% at 70% 18%, rgba(255, 255, 255, 0.7), transparent 45%),
    linear-gradient(160deg, #f7f3e8 0%, #efe6cf 48%, #f4edd9 100%);
}
.auth-page::before,
.auth-page::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(2px);
}
.auth-page::before {
  width: 420px; height: 420px;
  top: -120px; right: -80px;
  background: radial-gradient(circle, rgba(245, 197, 24, 0.45), transparent 68%);
  animation: auth-float 12s ease-in-out infinite;
}
.auth-page::after {
  width: 280px; height: 280px;
  bottom: -60px; left: -40px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent 70%);
  animation: auth-float 14s ease-in-out infinite reverse;
}
@keyframes auth-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(18px) scale(1.04); }
}

.auth-shell {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 0;
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 40px;
  box-shadow: var(--cx-shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(18px);
  overflow: hidden;
  animation: auth-rise .7s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes auth-rise {
  from { opacity: 0; transform: translateY(22px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-visual {
  padding: 36px 32px 32px;
  background:
    linear-gradient(165deg, rgba(255, 248, 220, 0.9), rgba(255, 255, 255, 0.35)),
    radial-gradient(circle at 30% 20%, rgba(245, 197, 24, 0.35), transparent 50%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 560px;
}
.auth-visual-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  border-radius: var(--cx-pill);
  border: 1px solid rgba(26, 26, 26, 0.08);
  background: rgba(255, 255, 255, 0.65);
  width: fit-content;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.02em;
}
.auth-visual-brand .mark {
  width: 32px; height: 32px; border-radius: 12px;
  background: var(--cx-ink); color: var(--cx-yellow);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.auth-visual h2 {
  margin: 48px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1.1;
  color: var(--cx-ink);
  max-width: 11ch;
}
.auth-visual p {
  margin: 0;
  color: var(--cx-muted-2);
  font-size: 15px;
  max-width: 28ch;
  line-height: 1.5;
}
.auth-preview {
  margin-top: 36px;
  display: grid;
  gap: 10px;
}
.auth-preview-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: var(--cx-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.auth-preview-card strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
}
.auth-preview-card span {
  font-size: 12px;
  color: var(--cx-muted);
}
.auth-preview-bar {
  width: 88px; height: 8px; border-radius: var(--cx-pill);
  background: #ebe6da; overflow: hidden;
}
.auth-preview-bar i {
  display: block; height: 100%; width: 68%;
  background: linear-gradient(90deg, var(--cx-yellow), #ffe56a);
  border-radius: inherit;
}
.auth-preview-card.dark {
  background: var(--cx-ink);
  border-color: transparent;
  color: #fff;
}
.auth-preview-card.dark span { color: rgba(255, 255, 255, 0.55); }
.auth-preview-card.dark .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--cx-yellow);
}

.auth-card {
  padding: 40px 36px 36px;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-brand { display: none; }
.auth-card .auth-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cx-muted);
  margin: 0 0 8px;
}
.auth-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.03em;
}
.auth-card .auth-sub {
  margin: 0 0 28px;
  color: var(--cx-muted-2);
  font-size: 14px;
}
.auth-foot {
  margin-top: 22px;
  color: var(--cx-muted-2);
  font-size: 13px;
  text-align: center;
}
.auth-foot a {
  font-weight: 700;
  border-bottom: 2px solid var(--cx-yellow);
  padding-bottom: 1px;
}

/* ========== App canvas / Crextio shell ========== */
.crm-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 60% 45% at 12% 8%, rgba(246, 226, 122, 0.7), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 90%, rgba(245, 197, 24, 0.28), transparent 50%),
    linear-gradient(165deg, #f6f2e8 0%, #efe7d4 55%, #f4edd9 100%);
}
.crm-canvas {
  min-height: 100vh;
  padding: 18px;
  display: flex;
}
.app-frame {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 36px;
  box-shadow: var(--cx-shadow-lg);
  backdrop-filter: blur(12px);
  overflow: hidden;
  position: relative;
}

.app-shell { display: flex; flex: 1; min-height: 0; position: relative; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(20, 16, 8, 0.35);
  z-index: 90; backdrop-filter: blur(2px);
  pointer-events: auto;
}
.sidebar-backdrop.show { display: block; }

/* Desktop: top nav; mobile: drawer sidebar (outside app-frame so it sits above backdrop) */
.sidebar {
  display: none;
  width: var(--bx-sidebar-w);
  background: rgba(255, 255, 255, 0.98);
  border-right: 1px solid var(--cx-border);
  flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; flex-shrink: 0;
  z-index: 100;
  pointer-events: auto;
}
.sidebar-brand {
  height: 72px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--cx-border);
  font-family: var(--font-display);
  font-weight: 700; color: var(--cx-ink); letter-spacing: -.02em;
}
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 12px;
  background: var(--cx-ink); color: var(--cx-yellow);
  display: grid; place-items: center; font-size: 14px; font-weight: 800;
}
.sidebar nav { padding: 14px 12px; overflow: auto; flex: 1; }
.nav-section {
  color: var(--cx-muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 14px 12px 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--cx-pill);
  color: var(--cx-muted-2); font-weight: 600; margin-bottom: 4px;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(26, 26, 26, 0.04); text-decoration: none; color: var(--cx-ink); }
.nav-link.active {
  background: var(--cx-ink); color: #fff; font-weight: 700;
}
.nav-ico {
  width: 28px; height: 28px; border-radius: 10px;
  display: grid; place-items: center;
  background: #f3efe6; color: var(--cx-muted-2); font-size: 13px; flex-shrink: 0;
}
.nav-link.active .nav-ico { background: rgba(245, 197, 24, 0.25); color: var(--cx-yellow); }
.sidebar-user {
  border-top: 1px solid var(--cx-border);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--cx-muted-2);
}
.sidebar-user .name { font-weight: 700; color: var(--cx-ink); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
turbo-frame#spa-main {
  display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0;
}
turbo-frame#spa-main.is-loading { opacity: .85; transition: opacity .15s ease; }

/* Top navigation (Crextio) */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px 8px;
  flex-shrink: 0;
}
.app-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  border-radius: var(--cx-pill);
  border: 1px solid var(--cx-border-2);
  background: rgba(255, 255, 255, 0.7);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.02em;
  color: var(--cx-ink);
  flex-shrink: 0;
}
.app-nav-brand:hover { color: var(--cx-ink); }
.app-nav-brand .logo {
  width: 32px; height: 32px; border-radius: 11px;
  background: var(--cx-ink); color: var(--cx-yellow);
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.app-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  flex: 1;
  min-width: 0;
}
.app-nav-links .nav-link {
  margin: 0;
  padding: 10px 16px;
  font-size: 13.5px;
}
.app-nav-links .nav-link .nav-ico { display: none; }
.app-nav-utils {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.app-nav-utils .btn-setting {
  border-radius: var(--cx-pill);
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--cx-border-2);
  font-weight: 650;
}
.app-nav-utils .icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--cx-border-2);
  background: rgba(255, 255, 255, 0.75);
  display: grid; place-items: center;
  color: var(--cx-ink); cursor: pointer;
  font-size: 15px;
}
.app-nav-utils .user-chip {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(145deg, #ffe56a, var(--cx-yellow));
  color: var(--cx-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.topbar {
  min-height: auto;
  background: transparent;
  border-bottom: 0;
  padding: 8px 22px 4px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  position: relative; z-index: 20;
}
.topbar-left { display: flex; align-items: flex-start; gap: 12px; min-width: 0; flex: 1; }
.topbar-copy { min-width: 0; }
.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.15;
}
.topbar .welcome-sub {
  margin: 6px 0 0;
  color: var(--cx-muted-2);
  font-size: 14px;
}
.menu-toggle {
  display: none; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--cx-border-2); background: rgba(255, 255, 255, 0.85); cursor: pointer;
  align-items: center; justify-content: center; flex-direction: column; gap: 4px;
  flex-shrink: 0;
}
.menu-toggle span {
  display: block; width: 16px; height: 2px; background: var(--cx-ink); border-radius: 2px;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 12px 22px 28px; flex: 1; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--cx-pill);
  padding: 10px 18px; font-size: 13px; font-weight: 700;
  cursor: pointer; text-decoration: none; background: #fff; color: var(--cx-ink);
  line-height: 1.2; transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
  font-family: inherit;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary {
  background: var(--cx-ink); border-color: var(--cx-ink); color: #fff;
  box-shadow: 0 8px 20px rgba(26, 26, 26, 0.18);
}
.btn-primary:hover { background: #000; border-color: #000; color: #fff; }
.btn-primary::after {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cx-yellow);
  margin-left: 2px;
}
.btn-success { background: var(--cx-yellow); border-color: var(--cx-yellow); color: var(--cx-ink); }
.btn-danger { background: #fff; border-color: #ffd0ce; color: var(--cx-danger); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--cx-border-2);
}
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
}
.btn-block.btn-primary::after { display: none; }

/* Button busy / anti double-click loader */
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
.btn-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  flex-shrink: 0;
  animation: btn-spin .65s linear infinite;
  vertical-align: -2px;
}
.btn.is-busy,
button.is-busy,
a.btn.is-busy,
a.nav-link.is-busy,
.btn-setting.is-busy,
.view-switch a.is-busy,
.search-box button.is-busy,
a.app-nav-brand.is-busy {
  pointer-events: none !important;
  cursor: wait !important;
  opacity: 0.78;
  position: relative;
}
.btn.is-busy.btn-primary::after { display: none; }
.btn.is-busy .btn-spinner,
button.is-busy .btn-spinner {
  border-color: currentColor;
  border-right-color: transparent;
}
a.nav-link.is-busy .btn-spinner,
.view-switch a.is-busy .btn-spinner {
  width: 12px; height: 12px; border-width: 2px;
}
.search-box button.is-busy {
  min-width: 72px;
}
form[data-submitting="1"] {
  pointer-events: none;
}
form[data-submitting="1"] .form-control,
form[data-submitting="1"] select,
form[data-submitting="1"] textarea {
  opacity: 0.7;
}

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 7px; color: var(--cx-muted-2);
  font-size: 12px; font-weight: 700;
}
.form-control, select.form-control, textarea.form-control {
  width: 100%; border: 1px solid var(--cx-border-2); border-radius: 16px;
  padding: 12px 14px; font: inherit; background: rgba(255, 255, 255, 0.9); color: var(--cx-ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
  outline: none; border-color: var(--cx-yellow);
  box-shadow: 0 0 0 4px var(--cx-yellow-soft);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cx-muted-2); }
.error { color: var(--cx-danger); font-size: 12px; margin-top: 4px; }

.alert {
  border-radius: 16px; padding: 12px 16px; margin-bottom: 14px; font-size: 13px;
  box-shadow: var(--cx-shadow);
}
.alert-success { background: #f3f9df; color: #4f6b00; border: 1px solid #dceeb0; }
.alert-error { background: #fff0ef; color: #a12824; border: 1px solid #ffcfcb; }

/* ========== Stats / panels ========== */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--cx-card); border: 1px solid var(--cx-border);
  border-radius: var(--cx-radius); padding: 20px 22px;
  box-shadow: var(--cx-shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--cx-shadow-lg); }
.stat-card .label { color: var(--cx-muted-2); font-size: 12px; margin-bottom: 8px; font-weight: 650; }
.stat-card .value {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 700; letter-spacing: -.04em;
}
.stat-card .hint { margin-top: 6px; color: var(--cx-muted); font-size: 12px; }
.stat-card .stat-ico {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--cx-yellow-soft); color: var(--cx-ink);
  font-size: 16px; margin-bottom: 12px;
}

.panel {
  background: var(--cx-card); border: 1px solid var(--cx-border);
  border-radius: var(--cx-radius); margin-bottom: 16px; overflow: hidden;
  box-shadow: var(--cx-shadow);
}
.panel-h {
  padding: 16px 20px; border-bottom: 1px solid var(--cx-border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.panel-h h2 {
  margin: 0; font-size: 15px; font-weight: 700;
  font-family: var(--font-display); letter-spacing: -.02em;
}
.panel-h a { font-weight: 700; font-size: 13px; color: var(--cx-muted-2); }
.panel-h a:hover { color: var(--cx-ink); }
.panel-b { padding: 18px 20px; }
.panel-b.flush { padding: 0; }

/* Toolbar */
.crm-toolbar {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap;
}
.crm-toolbar .search-box {
  display: flex; align-items: center; gap: 0;
  background: rgba(255, 255, 255, 0.9); border: 1px solid var(--cx-border-2);
  border-radius: var(--cx-pill); overflow: hidden; min-width: min(100%, 320px);
  flex: 1; max-width: 420px; box-shadow: var(--cx-shadow);
}
.crm-toolbar .search-box input {
  border: 0; outline: none; padding: 11px 16px; width: 100%; font: inherit; background: transparent;
}
.crm-toolbar .search-box button {
  border: 0; background: transparent; padding: 10px 16px; cursor: pointer;
  color: var(--cx-muted-2); font-weight: 700; border-left: 1px solid var(--cx-border);
}
.view-switch {
  display: inline-flex; background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--cx-border-2);
  border-radius: var(--cx-pill); padding: 4px; gap: 2px; box-shadow: var(--cx-shadow);
}
.view-switch a {
  padding: 8px 14px; border-radius: var(--cx-pill); color: var(--cx-muted-2);
  font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
}
.view-switch a.active {
  background: var(--cx-ink); color: #fff;
}
.hint-line { color: var(--cx-muted-2); font-size: 13px; margin: 0 0 12px; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 720px; }
.table th, .table td {
  padding: 14px 18px; border-bottom: 1px solid var(--cx-border); text-align: left; vertical-align: middle;
}
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--cx-muted); background: #faf8f3; font-weight: 700; white-space: nowrap;
}
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover td { background: #fffbeb; }
.table .entity-title { font-weight: 700; color: var(--cx-ink); }
.table .entity-title:hover { color: var(--cx-ink-2); }
.muted { color: var(--cx-muted-2); }
.mono { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--cx-pill);
  font-size: 11px; font-weight: 700; background: #f3efe6; color: var(--cx-muted-2); white-space: nowrap;
}
.badge-blue { background: #fff3c4; color: #8a6a00; }
.badge-green { background: #eef8d4; color: #4f6b00; }
.badge-red { background: #ffe8e7; color: #a12824; }
.badge-orange { background: #fff4de; color: #8a5b00; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #ffe56a, var(--cx-yellow)); color: var(--cx-ink);
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 800;
  flex-shrink: 0;
}

/* ========== Dashboard (Crextio bento) ========== */
.dash-hero-meters {
  display: flex; flex-wrap: wrap; gap: 10px 18px;
  margin-top: 16px;
  animation: dash-rise .55s cubic-bezier(.2,.8,.2,1) both;
}
.meter {
  display: flex; flex-direction: column; gap: 6px; min-width: 120px; flex: 1;
}
.meter-label {
  font-size: 11px; font-weight: 700; color: var(--cx-muted-2);
  text-transform: uppercase; letter-spacing: .04em;
}
.meter-track {
  height: 8px; border-radius: var(--cx-pill); background: rgba(26, 26, 26, 0.08);
  overflow: hidden; min-width: 110px;
}
.meter-fill {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--cx-yellow), #ffe56a);
  transition: width .6s ease;
}
.meter-fill.striped {
  background: repeating-linear-gradient(
    -45deg,
    var(--cx-yellow),
    var(--cx-yellow) 6px,
    #ffe56a 6px,
    #ffe56a 12px
  );
}
.meter-fill.muted { background: #cfc8b8; }

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

.dash { display: flex; flex-direction: column; gap: 16px; }
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.dash-kpi {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 18px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--cx-border);
  border-radius: 24px;
  box-shadow: var(--cx-shadow);
  animation: dash-rise .55s cubic-bezier(.2,.8,.2,1) both;
}
.dash-kpi:nth-child(2) { animation-delay: .05s; }
.dash-kpi:nth-child(3) { animation-delay: .1s; }
.dash-kpi:nth-child(4) { animation-delay: .15s; }
.dash-kpi.accent {
  background: linear-gradient(145deg, #fff8d6, #ffe56a);
  border-color: rgba(245, 197, 24, .35);
}
.dash-kpi-ico {
  width: 44px; height: 44px; border-radius: 16px;
  display: grid; place-items: center;
  background: #fff; font-size: 18px;
  box-shadow: var(--cx-shadow);
  flex-shrink: 0;
}
.dash-kpi-num {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 800; letter-spacing: -.04em; line-height: 1;
}
.dash-kpi-lbl {
  margin-top: 4px; font-size: 12px; font-weight: 650; color: var(--cx-muted-2);
}

.dash-bento {
  display: grid;
  grid-template-columns: 1fr 1.15fr 0.95fr;
  grid-template-areas:
    "profile chart ring"
    "leads   leads tasks"
    "funnel  deals deals"
    "quick   deals deals";
  gap: 14px;
}
.dash-profile { grid-area: profile; }
.dash-chart { grid-area: chart; }
.dash-ring-card { grid-area: ring; }
.dash-leads { grid-area: leads; }
.dash-tasks { grid-area: tasks; }
.dash-funnel { grid-area: funnel; }
.dash-deals { grid-area: deals; }
.dash-quick { grid-area: quick; }

.dash-card {
  background: rgba(255,255,255,.82);
  border: 1px solid var(--cx-border);
  border-radius: 28px;
  box-shadow: var(--cx-shadow);
  padding: 18px 18px 16px;
  min-width: 0;
  animation: dash-rise .6s cubic-bezier(.2,.8,.2,1) both;
}
.dash-card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.dash-card-h h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px; font-weight: 750; letter-spacing: -.02em;
}
.dash-card-h a {
  font-size: 13px; font-weight: 700; color: var(--cx-muted-2);
}
.dash-card-h a:hover { color: var(--cx-ink); }

.dash-profile {
  padding: 14px;
  background:
    linear-gradient(165deg, rgba(255,248,220,.95), rgba(255,255,255,.9));
}
.dash-profile-art {
  aspect-ratio: 1.2;
  border-radius: 22px;
  background: linear-gradient(145deg, #ffe56a 0%, var(--cx-yellow) 42%, #f4edd9 100%);
  display: grid; place-items: center;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.dash-profile-art::after {
  content: "";
  position: absolute; inset: auto -20% -30% auto;
  width: 70%; height: 70%;
  background: radial-gradient(circle, rgba(255,255,255,.55), transparent 70%);
  pointer-events: none;
}
.dash-profile-art span {
  font-family: var(--font-display);
  font-size: clamp(48px, 8vw, 72px);
  font-weight: 800; letter-spacing: -.05em; color: var(--cx-ink);
  position: relative; z-index: 1;
}
.dash-profile-body h3 {
  margin: 0; font-family: var(--font-display);
  font-size: 20px; font-weight: 750; letter-spacing: -.02em;
}
.dash-profile-body p {
  margin: 4px 0 12px; color: var(--cx-muted-2); font-size: 13px;
}
.dash-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-pill {
  display: inline-flex; padding: 7px 12px; border-radius: var(--cx-pill);
  background: rgba(255,255,255,.75); border: 1px solid var(--cx-border);
  font-size: 12px; font-weight: 750;
}

.dash-bars {
  display: flex; align-items: flex-end; gap: 8px;
  height: 140px; padding-top: 8px;
}
.dash-bar-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  height: 100%;
}
.dash-bar-track {
  flex: 1; width: 100%; max-width: 36px;
  display: flex; align-items: flex-end;
  background: #f3efe6; border-radius: 12px;
  overflow: hidden;
}
.dash-bar-fill {
  width: 100%; border-radius: 12px 12px 4px 4px;
  background: linear-gradient(180deg, #ffe56a, var(--cx-yellow));
  min-height: 8px;
  transition: height .5s ease;
}
.dash-bar-fill.hot {
  background: linear-gradient(180deg, #fff, var(--cx-ink));
}
.dash-bar-col > span {
  font-family: var(--font-display); font-weight: 750; font-size: 13px;
}
.dash-bar-col small {
  font-size: 10px; color: var(--cx-muted); font-weight: 650;
  text-transform: uppercase; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; max-width: 100%;
}

.dash-ring-wrap {
  display: grid; place-items: center;
  position: relative;
  min-height: 150px;
}
.dash-ring {
  width: 140px; height: 140px;
  transform: rotate(-90deg);
}
.dash-ring-bg {
  fill: none; stroke: #f0ebe0; stroke-width: 3.2;
}
.dash-ring-fg {
  fill: none; stroke: var(--cx-yellow); stroke-width: 3.2;
  stroke-linecap: round;
  transition: stroke-dasharray .7s ease;
}
.dash-ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.dash-ring-label strong {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 800; letter-spacing: -.04em;
}
.dash-ring-label span {
  font-size: 11px; color: var(--cx-muted-2); font-weight: 650; margin-top: 2px;
}

.dash-list { display: flex; flex-direction: column; }
.dash-list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--cx-border);
  color: inherit; text-decoration: none;
  border-radius: 12px;
  transition: background .15s ease;
}
.dash-list-row:last-child { border-bottom: 0; }
.dash-list-row:hover { background: #fffbeb; }
.dash-list-main { flex: 1; min-width: 0; }
.dash-list-main strong {
  display: block; font-size: 13.5px; font-weight: 750;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-list-main .muted {
  display: block; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dash-tasks {
  background: var(--cx-ink);
  color: #fff;
  border-color: transparent;
}
.dash-tasks .dash-card-h h2,
.dash-tasks h2 { color: #fff; margin: 0; font-family: var(--font-display); font-size: 16px; }
.dash-task-list { max-height: 280px; overflow: auto; }
.dash-tasks-add {
  margin-top: 12px; width: 100%;
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: #fff !important;
}
.dash-tasks-add:hover { background: rgba(255,255,255,.14) !important; color: #fff !important; }

.funnel-row {
  display: flex; justify-content: space-between; gap: 8px;
  margin-bottom: 6px; font-size: 13px;
}
.funnel-bar {
  height: 8px; background: #f0ebe0; border-radius: var(--cx-pill);
  margin-bottom: 12px; overflow: hidden;
}
.funnel-bar > span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--cx-yellow), #ffe56a);
}

.task-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.task-row:last-child { border-bottom: 0; }
.task-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0; margin-top: 2px;
  display: grid; place-items: center;
}
.task-check.done {
  background: var(--cx-yellow);
  border-color: var(--cx-yellow);
  color: var(--cx-ink);
  font-size: 11px; font-weight: 800;
}
.task-body { flex: 1; min-width: 0; }
.task-body strong { display: block; font-size: 13.5px; font-weight: 650; }
.task-body .muted { color: rgba(255, 255, 255, 0.45); font-size: 12px; }
.task-progress {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.task-progress .frac {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; color: #fff;
}
.seg-bar {
  display: flex; gap: 4px; margin-bottom: 14px;
}
.seg-bar i {
  flex: 1; height: 6px; border-radius: var(--cx-pill);
  background: rgba(255, 255, 255, 0.12);
}
.seg-bar i.on { background: var(--cx-yellow); }

.dash-deal-rail {
  display: flex; flex-direction: column; gap: 8px;
}
.dash-deal-pill {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #faf8f3;
  border: 1px solid var(--cx-border);
  text-decoration: none; color: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
}
.dash-deal-pill:hover {
  transform: translateY(-1px);
  box-shadow: var(--cx-shadow);
}
.dash-deal-title {
  font-weight: 750; font-size: 13.5px;
  grid-column: 1;
}
.dash-deal-pill .badge { grid-column: 2; grid-row: 1; align-self: start; }
.dash-deal-pill .muted {
  grid-column: 1 / -1; font-size: 12px;
}

.dash-quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dash-quick-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 12px;
  border-radius: 16px;
  background: #faf8f3;
  border: 1px solid var(--cx-border);
  font-weight: 750; font-size: 13px;
  color: var(--cx-ink); text-decoration: none;
  transition: background .15s ease, transform .12s ease;
}
.dash-quick-btn:hover {
  background: #fff3c4;
  transform: translateY(-1px);
}
.dash-quick-btn span {
  width: 28px; height: 28px; border-radius: 10px;
  display: grid; place-items: center;
  background: #fff; font-size: 13px;
  box-shadow: var(--cx-shadow);
}

/* legacy aliases kept for other pages */
.bento { display: grid; gap: 16px; }
.bento-card { background: var(--cx-card); border-radius: var(--cx-radius); padding: 20px; }
.lead-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--cx-border); }
.mini-stat { text-align: center; padding: 14px; border-radius: 20px; background: #faf8f3; }

/* ========== Kanban ========== */
.kanban-board {
  display: flex; gap: 12px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden;
  padding: 4px 2px 18px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  min-height: calc(100vh - 220px);
}
.kanban-board.is-dragging-board {
  scroll-snap-type: none;
  cursor: grabbing;
  touch-action: none;
  position: relative;
}
.kanban-board::-webkit-scrollbar { height: 8px; }
.kanban-board::-webkit-scrollbar-thumb {
  background: #d4cbb8; border-radius: 99px;
}
.kanban-col {
  width: min(290px, 82vw);
  min-width: min(290px, 82vw);
  max-width: 290px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 24px;
  border: 1px solid var(--cx-border);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 230px);
  scroll-snap-align: start;
  flex-shrink: 0;
  overflow: hidden;
}
.kanban-col-h {
  padding: 14px 14px 10px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  position: sticky; top: 0; z-index: 2;
  background: inherit;
  border-radius: 24px 24px 0 0;
}
.kanban-col-h .col-title {
  font-weight: 750; font-size: 13px; color: var(--cx-ink);
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--font-display);
}
.kanban-col-h .col-title small {
  font-weight: 600; color: var(--cx-muted-2); font-size: 11px;
  font-family: var(--font);
}
.kanban-col-h .col-count {
  min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; background: #fff; color: var(--cx-muted-2);
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--cx-shadow);
}
.kanban-col[data-tone="blue"] .kanban-col-h { border-top: 3px solid var(--cx-yellow); border-radius: 24px 24px 0 0; }
.kanban-col[data-tone="orange"] .kanban-col-h { border-top: 3px solid #ffa901; border-radius: 24px 24px 0 0; }
.kanban-col[data-tone="green"] .kanban-col-h { border-top: 3px solid #9dcf00; border-radius: 24px 24px 0 0; }
.kanban-col[data-tone="purple"] .kanban-col-h { border-top: 3px solid #c3b2e5; border-radius: 24px 24px 0 0; }
.kanban-col[data-tone="red"] .kanban-col-h { border-top: 3px solid #ff5752; border-radius: 24px 24px 0 0; }
.kanban-col[data-tone="teal"] .kanban-col-h { border-top: 3px solid #55d0e0; border-radius: 24px 24px 0 0; }

.kanban-col-b {
  padding: 0 10px 12px;
  display: flex; flex-direction: column;
  /* no flex gap — Sortable ghost position breaks with gap */
  gap: 0;
  overflow-y: auto; flex: 1;
  min-height: 160px;
  transition: background .15s ease;
}
.kanban-col-b.sortable-ghost-target {
  background: rgba(47, 198, 246, 0.12);
  border-radius: 14px;
  box-shadow: inset 0 0 0 2px rgba(47, 198, 246, 0.35);
}
.kanban-card {
  background: #fff; border-radius: 18px; padding: 14px 14px 12px;
  box-shadow: var(--cx-shadow);
  border: 1px solid var(--cx-border);
  cursor: grab; touch-action: none;
  transition: box-shadow .15s ease, border-color .15s ease;
  position: relative;
  margin-bottom: 8px;
  -webkit-user-select: none;
  user-select: none;
}
.kanban-card:last-child { margin-bottom: 0; }
.kanban-card:active { cursor: grabbing; }
.kanban-card:hover {
  box-shadow: var(--cx-shadow-lg);
  border-color: rgba(245, 197, 24, 0.45);
}
.kanban-card .drag-handle {
  position: absolute; top: 6px; right: 6px;
  width: 32px; height: 32px; border-radius: 10px;
  color: #a8a29a; font-size: 14px; display: grid; place-items: center;
  user-select: none; touch-action: none;
  background: #f7f3ea;
}
.kanban-card .title {
  color: var(--cx-ink); font-weight: 750; text-decoration: none;
  display: block; margin: 0 34px 6px 0; font-size: 13.5px; line-height: 1.3;
}
.kanban-card .title:hover { color: var(--cx-ink-2); }
.kanban-card .meta {
  color: var(--cx-muted-2); font-size: 12px; margin-bottom: 3px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.kanban-card .chip {
  display: inline-flex; align-items: center;
  background: #f3efe6; color: var(--cx-muted-2); border-radius: 8px;
  padding: 2px 7px; font-size: 11px; font-weight: 650;
}
.kanban-card .foot {
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed #efe9dc;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.kanban-empty {
  padding: 22px 10px; text-align: center; color: var(--cx-muted);
  font-size: 12px; border: 1px dashed #d4cbb8; border-radius: 14px;
  background: rgba(255,255,255,.35);
  margin-bottom: 8px;
  pointer-events: none;
}
.kanban-empty.is-hidden { display: none !important; }

/* Placeholder slot that follows drag across columns */
.sortable-ghost {
  opacity: 1 !important;
  background: #d7f2ff !important;
  border: 2px dashed #2fc6f6 !important;
  box-shadow: none !important;
  border-radius: 18px !important;
  min-height: 72px;
}
.sortable-ghost > * {
  visibility: hidden !important;
}
.sortable-chosen {
  box-shadow: var(--cx-shadow-lg);
  opacity: 0.92;
}
/* Floating card under the finger / cursor — kept inside board via JS clamp */
.sortable-fallback,
.sortable-drag {
  opacity: 0.98 !important;
  background: #fff !important;
  border: 1px solid rgba(47, 198, 246, 0.45) !important;
  box-shadow: 0 18px 40px rgba(15, 40, 60, 0.22) !important;
  cursor: grabbing !important;
  z-index: 10050 !important;
  pointer-events: none !important;
  margin: 0 !important;
  max-width: min(280px, 78vw) !important;
  box-sizing: border-box !important;
  will-change: transform, left, top;
}
.sortable-fallback > *,
.sortable-drag > * {
  visibility: visible !important;
}
/* Do NOT position:fixed the in-list ghost — only the floating fallback clone */
body.kanban-dragging {
  cursor: grabbing !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}
body.kanban-dragging a {
  pointer-events: none;
}

.detail-grid { display: grid; grid-template-columns: 1.45fr .85fr; gap: 16px; }
.field-list { display: grid; gap: 12px; }
.field-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; }
.field-row .k { color: var(--cx-muted-2); font-size: 12px; padding-top: 2px; font-weight: 650; }
.field-row .v { font-weight: 500; }

.empty { padding: 28px 16px; text-align: center; color: var(--cx-muted); }
.pagination { display: flex; gap: 6px; padding: 12px 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 10px; border-radius: var(--cx-pill); border: 1px solid var(--cx-border);
  background: #fff; color: var(--cx-ink); font-size: 12px;
}
.pagination .active span {
  background: var(--cx-ink); border-color: var(--cx-ink); color: #fff; font-weight: 700;
}

.toast-host {
  position: fixed; right: 16px; bottom: 16px; z-index: 10001;
  display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px));
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.toast-host .alert { margin: 0; box-shadow: var(--cx-shadow-lg); }

.mobile-list { display: none; gap: 10px; }
.mobile-card {
  background: #fff; border: 1px solid var(--cx-border); border-radius: 20px;
  padding: 14px; box-shadow: var(--cx-shadow);
}
.mobile-card .mc-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px;
}
.mobile-card .mc-title { font-weight: 750; color: var(--cx-ink); font-size: 15px; }
.mobile-card .mc-row {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--cx-muted-2); margin-top: 4px;
}
.mobile-card .mc-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-card .mc-actions .btn { flex: 1; min-width: 0; justify-content: center; }

.desktop-only { display: block; }
.mobile-only { display: none; }

/* ========== Roles / Users / Permissions (responsive) ========== */
.roles-mobile,
.users-mobile { gap: 12px; }

.perm-intro {
  margin: 4px 0 14px;
}
.perm-intro h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: -.02em;
}
.perm-intro p {
  margin: 0;
  color: var(--cx-muted-2);
  font-size: 13px;
  line-height: 1.45;
}

.perm-select { max-width: 220px; }
.perm-table { min-width: 560px; }

.perm-modules {
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}
.perm-module {
  background: var(--cx-card);
  border: 1px solid var(--cx-border);
  border-radius: 22px;
  box-shadow: var(--cx-shadow);
  overflow: hidden;
}
.perm-module-h {
  padding: 14px 16px;
  background: #faf8f3;
  border-bottom: 1px solid var(--cx-border);
}
.perm-module-h h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -.02em;
}
.perm-module-b { padding: 8px 14px 14px; }
.perm-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--cx-border);
}
.perm-row:last-child { border-bottom: 0; padding-bottom: 0; }
.perm-label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--cx-ink);
}
.perm-row .form-control {
  width: 100%;
  max-width: none;
}

.role-form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  position: sticky;
  bottom: 12px;
  z-index: 5;
  padding: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--cx-border);
  border-radius: 18px;
  box-shadow: var(--cx-shadow-lg);
}
.role-form-actions .btn { flex: 1; min-width: 120px; }

.user-role-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.user-role-form .form-control {
  min-width: 160px;
  max-width: 220px;
}
.user-role-form.stacked {
  flex-direction: column;
  align-items: stretch;
  margin-top: 12px;
  gap: 8px;
}
.user-role-form.stacked label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--cx-muted-2);
}
.user-role-form.stacked .form-control {
  min-width: 0;
  max-width: none;
  width: 100%;
}
.user-role-card .mc-top {
  align-items: center;
}

/* ========== Drawer ========== */
.crm-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(20, 16, 8, 0.4);
  z-index: 80; opacity: 0; transition: opacity .2s ease;
}
.crm-drawer-backdrop[hidden] { display: none !important; }
.crm-drawer-backdrop.is-open { opacity: 1; display: block !important; }

.crm-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  background: #fff;
  z-index: 90;
  display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(40, 30, 10, .18);
  transform: translateX(105%);
  transition: transform .24s cubic-bezier(.2,0,0,1);
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-radius: 28px 0 0 28px;
}
.crm-drawer.is-open { transform: translateX(0); }
.crm-drawer-header {
  min-height: 68px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 0 22px;
  border-bottom: 1px solid var(--cx-border);
  background: #fff;
}
.crm-drawer-header h2 {
  margin: 0; font-size: 18px; font-weight: 700;
  font-family: var(--font-display); letter-spacing: -.02em;
}
.crm-drawer-header .btn-icon {
  font-size: 22px; line-height: 1; color: var(--cx-muted-2);
}
.crm-drawer-body {
  flex: 1; overflow: auto; padding: 18px 22px 28px;
  -webkit-overflow-scrolling: touch;
}
.crm-drawer-body .form-grid { grid-template-columns: 1fr; }
.drawer-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; padding-top: 16px;
  border-top: 1px solid var(--cx-border);
  position: sticky; bottom: 0; background: #fff; padding-bottom: 4px;
}
.drawer-loading {
  padding: 40px 12px; text-align: center; color: var(--cx-muted-2);
}
.drawer-errors {
  background: #fff0ef; border: 1px solid #ffcfcb; color: #a12824;
  border-radius: 14px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
}
.drawer-errors ul { margin: 6px 0 0; padding-left: 18px; }
body.drawer-open { overflow: hidden; }

/* ========== Responsive ========== */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-bento {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "profile ring"
      "chart   chart"
      "leads   leads"
      "tasks   funnel"
      "deals   deals"
      "quick   quick";
  }
  .bento {
    grid-template-columns: 1fr 1fr;
  }
  .bento .span-profile { grid-column: 1; grid-row: auto; }
  .bento .span-funnel { grid-column: 2; grid-row: auto; }
  .bento .span-leads { grid-column: 1 / -1; grid-row: auto; }
  .bento .span-tasks { grid-column: 1 / -1; grid-row: auto; }
  .app-nav-links .nav-link { padding: 9px 12px; font-size: 12.5px; }
}

@media (max-width: 900px) {
  .crm-canvas { padding: 10px; }
  .app-frame { border-radius: 24px; }
  .app-nav { display: none; }
  .menu-toggle { display: inline-flex; }

  /* Roles / Users / permission matrix — phone & tablet */
  .roles-mobile.mobile-only,
  .users-mobile.mobile-only,
  .perm-modules.mobile-only {
    display: flex !important;
    flex-direction: column;
  }
  .content > .panel.desktop-only,
  .role-form > .panel.desktop-only {
    display: none !important;
  }

  .role-meta-grid { grid-template-columns: 1fr; }
  .role-form-actions {
    bottom: calc(10px + env(safe-area-inset-bottom, 0));
  }
  .role-form-actions .btn {
    flex: 1 1 100%;
    min-height: 44px;
  }
  .perm-module-h { padding: 12px 14px; }
  .user-role-card .badge {
    flex-shrink: 0;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar {
    display: flex;
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: var(--cx-shadow-lg);
    height: 100dvh;
    padding-top: env(safe-area-inset-top, 0);
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; z-index: 90; }
  .content {
    padding: 12px 14px calc(24px + env(safe-area-inset-bottom, 0));
  }
  .topbar {
    padding: 14px 14px 6px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .topbar h1 { font-size: 22px; }
  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }
  .topbar-actions .view-switch { flex: 1; }
  .topbar-actions .view-switch a { flex: 1; justify-content: center; }
  .topbar-actions .btn { flex: 1; white-space: nowrap; }

  .auth-shell { grid-template-columns: 1fr; max-width: 440px; }
  .auth-visual { display: none; }
  .auth-card { padding: 32px 24px; }

  .kanban-board {
    min-height: calc(100dvh - 200px);
    padding-bottom: 24px;
    gap: 10px;
    margin: 0 -14px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .kanban-col {
    width: min(300px, 78vw);
    min-width: min(300px, 78vw);
    max-width: min(300px, 78vw);
    max-height: calc(100dvh - 210px);
  }
  .crm-toolbar { gap: 8px; }
  .crm-toolbar .search-box {
    max-width: none; min-width: 0; width: 100%; flex: 1 1 100%;
  }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .stat-card .value { font-size: 24px; }
  .form-grid, .field-row { grid-template-columns: 1fr; }
  .bento { grid-template-columns: 1fr; }
  .bento .span-profile,
  .bento .span-funnel,
  .bento .span-leads,
  .bento .span-tasks { grid-column: 1; }
  .bento-stats-row { grid-template-columns: 1fr; }
  .dash-kpis { grid-template-columns: 1fr; gap: 10px; }
  .dash-kpi { padding: 14px 16px; }
  .dash-kpi-num { font-size: 26px; }
  .dash-bento {
    grid-template-columns: 1fr;
    grid-template-areas:
      "profile"
      "ring"
      "chart"
      "leads"
      "tasks"
      "funnel"
      "deals"
      "quick";
  }
  .dash-bars { height: 120px; gap: 6px; }
  .dash-profile-art { aspect-ratio: 1.4; }
  .dash-quick-grid { grid-template-columns: 1fr 1fr; }
  .dash-list-row .badge {
    max-width: 38%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .desktop-only, .table-wrap.desktop-only { display: none !important; }
  .mobile-only { display: block; }
  .mobile-list { display: flex; flex-direction: column; }

  .table { min-width: 0; }
  .btn, .btn-sm { min-height: 40px; }
  .form-control, select.form-control, textarea.form-control { min-height: 42px; font-size: 16px; }

  .kanban-col {
    width: min(86vw, 320px);
    min-width: min(86vw, 320px);
    max-width: min(86vw, 320px);
    max-height: calc(100dvh - 200px);
  }

  .crm-drawer { width: 100vw; border-radius: 0; }
  .crm-drawer-body { padding: 14px 14px 24px; }
  .drawer-actions .btn { flex: 1; min-height: 44px; }

  .toast-host { left: 12px; right: 12px; max-width: none; bottom: calc(12px + env(safe-area-inset-bottom, 0)); }
  .pagination { justify-content: center; }
  .topbar-actions .btn-primary { order: -1; width: 100%; flex: 1 1 100%; }
  .topbar-actions .view-switch { width: 100%; }
  .dash-hero-meters { gap: 10px; }
  .meter { min-width: calc(50% - 8px); flex: 1; }
}

/* ========== Pager ========== */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-top: 1px solid var(--cx-border);
  background: #faf8f3;
}
.pager-info { font-size: 12px; color: var(--cx-muted-2); }
.pager-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: var(--cx-pill); border: 1px solid var(--cx-border-2);
  background: #fff; color: var(--cx-ink); font-size: 12px; font-weight: 650;
  text-decoration: none;
}
.pager-btn:hover { border-color: var(--cx-yellow); color: var(--cx-ink); text-decoration: none; }
.pager-btn.is-active { background: var(--cx-ink); border-color: var(--cx-ink); color: #fff; }
.pager-btn.is-disabled { opacity: .45; pointer-events: none; }
.pager-size label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--cx-muted-2); font-weight: 650; margin: 0;
}
.pager-size select {
  height: 34px; border: 1px solid var(--cx-border-2); border-radius: 12px;
  padding: 0 8px; background: #fff; font: inherit;
}
@media (max-width: 640px) {
  .pager { justify-content: center; }
  .pager-info, .pager-controls, .pager-size { width: 100%; justify-content: center; text-align: center; }
  .pager-size { display: flex; }
}

/* ========== Skeleton ========== */
@keyframes sk-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk {
  display: block;
  background: linear-gradient(90deg, #ebe6da 25%, #f7f3e8 37%, #ebe6da 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.15s ease-in-out infinite;
  border-radius: 8px;
}
.sk-page { padding: 0 0 24px; pointer-events: none; user-select: none; }
.sk-topbar {
  min-height: 72px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px;
}
.sk-topbar .sk-title { width: 200px; height: 28px; }
.sk-topbar .sk-btn { width: 110px; height: 36px; border-radius: 999px; }
.sk-body { padding: 16px 22px; }
.sk-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.sk-toolbar .sk-search { width: min(320px, 100%); height: 38px; border-radius: 999px; }
.sk-toolbar .sk-chip { width: 72px; height: 32px; border-radius: 999px; }
.sk-panel {
  background: #fff; border: 1px solid var(--cx-border); border-radius: 24px; overflow: hidden;
}
.sk-row {
  display: grid; gap: 12px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--cx-border);
}
.sk-row:last-child { border-bottom: 0; }
.sk-row-list { grid-template-columns: 1.4fr 1fr 1fr .8fr .9fr 60px; }
.sk-line { height: 12px; }
.sk-line.lg { height: 16px; width: 70%; }
.sk-line.sm { height: 10px; width: 45%; margin-top: 6px; }
.sk-avatar { width: 28px; height: 28px; border-radius: 50%; }
.sk-pager {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px;
  border-top: 1px solid var(--cx-border); background: #faf8f3;
}
.sk-pager .sk { height: 34px; border-radius: 999px; }
.sk-pager .sk-info { width: 140px; }
.sk-pager .sk-btns { width: 220px; }
.sk-pager .sk-size { width: 100px; }
.sk-kanban { display: flex; gap: 12px; overflow: hidden; padding-bottom: 8px; }
.sk-col {
  flex: 0 0 280px; background: rgba(255,255,255,.5); border-radius: 20px; padding: 12px;
  border: 1px solid var(--cx-border);
}
.sk-col-h { display: flex; justify-content: space-between; margin-bottom: 12px; }
.sk-col-h .sk { height: 14px; }
.sk-card {
  background: #fff; border-radius: 14px; padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--cx-border);
}
.sk-card .sk-line { margin-bottom: 8px; }
.sk-card .sk-line:last-child { margin-bottom: 0; }
.sk-form-panel {
  max-width: 860px; background: #fff; border: 1px solid var(--cx-border);
  border-radius: 24px; padding: 18px;
}
.sk-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.sk-field label.sk { width: 90px; height: 10px; margin-bottom: 8px; }
.sk-field .sk-input { height: 40px; width: 100%; border-radius: 14px; }
.sk-field.full { grid-column: 1 / -1; }
.sk-field.full .sk-input { height: 80px; }
.sk-form-actions { display: flex; gap: 8px; margin-top: 18px; }
.sk-form-actions .sk { height: 38px; width: 100px; border-radius: 999px; }
.sk-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.sk-stat {
  background: #fff; border: 1px solid var(--cx-border); border-radius: 24px; padding: 16px;
}
.sk-stat .sk { height: 12px; width: 60%; margin-bottom: 10px; }
.sk-stat .sk.num { height: 28px; width: 40%; margin-bottom: 0; }
.sk-mobile { display: none; }
.sk-mcard {
  background: #fff; border: 1px solid var(--cx-border); border-radius: 18px;
  padding: 14px; margin-bottom: 10px;
}
.sk-mcard .sk-line { margin-bottom: 8px; }
.sk-drawer { padding: 4px 0 20px; }
.sk-drawer .sk-form-grid { grid-template-columns: 1fr; }
.sk-drawer .sk-form-actions { position: sticky; bottom: 0; padding-top: 12px; background: #fff; }

turbo-frame#spa-main.is-loading { opacity: 1; }
turbo-frame#spa-main.is-skeleton .content { min-height: 40vh; }

@media (max-width: 900px) {
  .sk-stats { grid-template-columns: 1fr 1fr; }
  .sk-row-list { grid-template-columns: 1fr 1fr; }
  .sk-row-list .sk:nth-child(n+3) { display: none; }
  .sk-form-grid { grid-template-columns: 1fr; }
  .sk-desktop { display: none; }
  .sk-mobile { display: block; }
}
@media (max-width: 640px) {
  .sk-stats { grid-template-columns: 1fr; }
  .sk-body { padding: 12px 14px; }
  .sk-topbar { padding: 10px 14px; }
}

@media (hover: none) {
  .kanban-card:hover { box-shadow: var(--cx-shadow); }
  .table tbody tr:hover td { background: transparent; }
  .btn:hover { transform: none; }
}

/* Status admin */
.status-admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.status-form-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr 0.5fr;
  gap: 10px;
  margin-bottom: 10px;
}
.status-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cx-muted, #6b7280);
}
.status-flags label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.status-inline-form .btn { margin-top: 8px; }
.badge-teal { background: #dff7fb; color: #0b6b78; }
.badge-purple { background: #f0e9fb; color: #5b3d8a; }
@media (max-width: 1100px) {
  .status-admin-grid { grid-template-columns: 1fr; }
  .status-form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .status-form-grid { grid-template-columns: 1fr; }
}
