@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --bg: #f1f5f9;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-deep: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --orange: #ea580c;
  --ok: #047857;
  --bad: #be123c;
  --warn: #b45309;
  --sidebar: #0b1220;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --display: var(--font);
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(15, 118, 110, 0.08), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(234, 88, 12, 0.06), transparent 50%),
    var(--bg);
}

.crm-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.crm-shell.guest { grid-template-columns: 1fr; }
.crm-aside {
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: #e5eef8;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand strong { display: block; font-family: var(--font); font-size: 1.05rem; letter-spacing: -0.01em; }
.brand small { display: block; color: rgba(229,238,248,.5); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; margin-top: .15rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: .72rem; letter-spacing: -0.04em; color: #fff;
  background: linear-gradient(145deg, #F97316, #EA580C 55%, #C2410C);
  box-shadow: 0 8px 20px rgba(234, 88, 12, .35);
  border: 1.5px solid rgba(255,255,255,.3);
  flex-shrink: 0;
}

.nav-section { display: flex; flex-direction: column; gap: .35rem; }
.nav-label {
  font-size: .65rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(229,238,248,.4); padding: 0 .75rem; margin-top: .35rem;
}
.crm-aside nav { display: flex; flex-direction: column; gap: .25rem; }
.crm-aside a {
  color: rgba(229,238,248,.78); text-decoration: none;
  padding: .7rem .85rem; border-radius: 12px; font-weight: 600; font-size: .92rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.crm-aside a:hover { background: rgba(255,255,255,.06); color: #fff; }
.crm-aside a.active {
  background: linear-gradient(135deg, rgba(15,118,110,.35), rgba(15,118,110,.12));
  color: #fff;
  box-shadow: inset 3px 0 0 #2dd4bf;
}
.nav-warn {
  font-size: .62rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  background: #F59E0B; color: #1c1917; padding: .15rem .4rem; border-radius: 999px;
}
.user {
  margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 1rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.user-meta strong { display: block; font-size: .92rem; }
.user-meta small { color: rgba(229,238,248,.5); font-size: .75rem; }
.user button {
  background: transparent; border: 1px solid rgba(255,255,255,.12); color: #9ec1ff;
  border-radius: 10px; padding: .45rem .7rem; cursor: pointer; text-align: left;
}
.user button:hover { background: rgba(255,255,255,.06); }

.crm-main { padding: 1.5rem 1.75rem 2.5rem; min-width: 0; }
.crm-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem 1.15rem; border-radius: 16px; margin-bottom: 1rem;
  border: 1px solid rgba(245, 158, 11, .35);
  background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
}
.crm-banner p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }

.page-hero {
  display: flex; justify-content: space-between; align-items: end; gap: 1rem;
  margin-bottom: 1.15rem;
}
.eyebrow {
  margin: 0 0 .35rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--accent-deep);
}
.page-hero h1, h1 {
  margin: 0; font-family: var(--font); font-size: 1.75rem;
  letter-spacing: -0.015em; font-weight: 700;
}
.lede, .page-hero p { margin: .35rem 0 0; color: var(--muted); max-width: 52ch; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 1.15rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.panel h2 { margin: 0 0 .85rem; font-family: var(--font); font-size: 1.05rem; letter-spacing: -0.01em; }
.sec-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.sec-row h2 { margin: 0; }
.sec-row a { color: var(--accent-deep); font-weight: 600; text-decoration: none; font-size: .9rem; }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem;
}
.stat-grid.dense { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: .95rem 1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .15rem;
}
.stat span { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat strong { font-family: var(--font); font-size: 1.55rem; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .78rem; }
.stat.ok { border-color: rgba(4, 120, 87, .2); background: linear-gradient(160deg, #ecfdf5, #fff); }
.stat.warn { border-color: rgba(180, 83, 9, .22); background: linear-gradient(160deg, #fffbeb, #fff); }
.stat.bad { border-color: rgba(190, 18, 60, .2); background: linear-gradient(160deg, #fff1f2, #fff); }

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.filter-panel .filter-grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr 1.2fr; gap: .75rem 1rem;
}
.check-field { display: flex; flex-direction: column; gap: .45rem; justify-content: end; padding-bottom: .35rem; }
.check-field label { font-size: .85rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }

.field { margin-bottom: .15rem; }
.field label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }
.field input, .field .pwd, .field textarea, .modal-card input, .modal-card select,
.panel input[type="date"], .panel input[type="text"], .panel input[type="password"], .panel input[type="number"] {
  width: 100%; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); font: inherit;
}
.field input:focus, .field .pwd:focus, select:focus, .panel input:focus {
  outline: none; border-color: rgba(15, 118, 110, .45); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.field-grid .full { grid-column: 1 / -1; }
.feature-row { display: flex; flex-wrap: wrap; gap: .85rem; margin-top: .85rem; }
.feature-row label { font-size: .88rem; color: var(--ink); display: flex; gap: .4rem; align-items: center; }

select {
  -webkit-appearance: none; appearance: none; width: 100%; min-height: 2.65rem;
  border: 1px solid var(--line); border-radius: 12px; padding: .65rem 2.4rem .65rem .85rem;
  color: var(--ink); background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6.5 9.5L12 15l5.5-5.5' stroke='%230f766e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center; cursor: pointer;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .8rem .7rem; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: middle; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.sub { color: var(--muted); font-size: .8rem; margin-top: .15rem; }

.pill {
  display: inline-grid; place-items: center; min-height: 1.45rem; padding: 0 .55rem;
  border-radius: 999px; background: #e2e8f0; font-size: .68rem; font-weight: 800;
  letter-spacing: .04em; margin-right: .25rem;
}
.pill.PendingCrmApproval, .pill.PendingEmailVerification { background: #fef3c7; color: #92400e; }
.pill.Trial { background: #ffedd5; color: #9a3412; }
.pill.Active { background: #ccfbf1; color: #115e59; }
.pill.Expired, .pill.Rejected { background: #ffe4e6; color: #9f1239; }
.pill.Suspended { background: #e2e8f0; color: #334155; }

.btn, .okbtn, .nobtn, .ghost, .login-card button {
  border: 0; border-radius: 12px; padding: .65rem 1rem; cursor: pointer;
  font-weight: 700; font-size: .9rem; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: .35rem;
}
.btn.primary { background: linear-gradient(145deg, #14b8a6, #0f766e); color: #fff; }
.btn.ok, .okbtn { background: var(--ok); color: #fff; }
.btn.bad, .nobtn { background: var(--bad); color: #fff; }
.btn.ghost, .ghost { background: #e2e8f0; color: var(--ink); }
.btn.sm { padding: .4rem .7rem; font-size: .8rem; border-radius: 10px; }
.btn.full, .full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.pager { display: flex; justify-content: center; align-items: center; gap: .75rem; margin-top: 1rem; }

.crm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.crm-list li {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .75rem .85rem; border-radius: 12px; border: 1px solid var(--line); background: #f8fafc;
}
.crm-list strong { display: block; }
.crm-list small { color: var(--muted); font-size: .78rem; }

.bar-list { display: flex; flex-direction: column; gap: .65rem; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 48px; gap: .75rem; align-items: center; }
.bar { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e); border-radius: 999px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login-card {
  width: min(440px, 100%); background: #fff; border-radius: 22px; border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .1); padding: 2rem;
}
.auth-brand { text-align: center; margin-bottom: 1.35rem; user-select: none; }
.auth-brand .brand-mark { margin: 0 auto .85rem; width: 56px; height: 56px; font-size: .95rem; border-radius: 16px; }
.auth-brand h1 { margin: 0 0 .35rem; font-size: 1.45rem; outline: none; }
.auth-brand p { margin: 0; color: var(--muted); }
.hint { font-size: .82rem; color: var(--muted); text-align: center; margin-top: 1rem; }
.err { background: #ffe4e6; color: var(--bad); padding: .75rem .9rem; border-radius: 12px; margin-bottom: 1rem; }
.ok { background: #ecfdf5; color: var(--ok); padding: .75rem .9rem; border-radius: 12px; margin-bottom: 1rem; }
.muted { color: var(--muted); }
.twofa-panel h2 { margin: 0 0 .35rem; font-size: 1.1rem; }
.twofa-box { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-top: 1rem; }
.twofa-box img { border-radius: 12px; border: 1px solid var(--line); }

@media (max-width: 1100px) {
  .stat-grid, .stat-grid.dense { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-2, .filter-panel .filter-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .crm-shell.authed { grid-template-columns: 1fr; }
  .crm-aside { position: sticky; top: 0; z-index: 20; }
}
@media (max-width: 640px) {
  .split-2, .filter-panel .filter-grid, .field-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
}

.legal-admin-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.legal-preview {
  margin: .75rem 0 0; white-space: pre-wrap; font-family: inherit; font-size: .86rem;
  line-height: 1.5; color: #334155; max-height: 160px; overflow: hidden;
  background: #f8fafc; border-radius: 12px; padding: .85rem;
  border: 1px solid var(--line);
}
.legal-editor { width: 100%; min-height: 220px; font-family: inherit; }
.check-row { display: flex; align-items: center; gap: .55rem; margin-top: .75rem; font-size: .9rem; }
.lux-crm-backdrop {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 1rem;
  background: rgba(15, 23, 42, .5); backdrop-filter: blur(4px);
}
.lux-crm-modal {
  width: min(720px, 100%); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 20px; border: 1px solid var(--line);
  box-shadow: 0 28px 70px rgba(15, 23, 42, .28); padding: 1.25rem 1.35rem 1.4rem;
}
.lux-crm-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.lux-crm-head h2 { margin: .15rem 0 0; font-size: 1.25rem; }
@media (max-width: 900px) {
  .legal-admin-grid { grid-template-columns: 1fr; }
}
