/* ============================================================
   CEP — Consulting Execution Platform
   Design system
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6e9f0;
  --line-strong: #d6dbe6;
  --soft: #f1f4f9;

  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --primary-soft: #eef2ff;

  --dark: #0f172a;
  --dark-light: #1e293b;

  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;

  /* Sidebar (dark, brand-cohesive with the login hero) */
  --side-bg-1: #0b1220;
  --side-bg-2: #131c2e;
  --side-text: #c7d0e0;
  --side-muted: #7c89a3;
  --side-line: rgba(148, 163, 184, 0.14);
  --side-active: rgba(99, 102, 241, 0.18);

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

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);

  --z-modal: 1000;
  --z-toast: 1300;
  --z-debug: 1400;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

[hidden] {
  display: none !important;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.32);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.5);
  background-clip: padding-box;
}

.app-shell {
  min-height: 100vh;
}

/* ============================================================
   LOGIN  (preserved)
   ============================================================ */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.94)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
}

.login-hero {
  min-height: 100vh;
  color: white;
  padding: 64px 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.keplr-wordmark {
  width: fit-content;
  color: white;
  text-decoration: none;
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 56px;
}

.keplr-wordmark span,
.login-footer strong span {
  color: var(--primary);
}

.section-tag {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.16);
  color: #c4b5fd;
  border: 1px solid rgba(196, 181, 253, 0.22);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-hero h1 {
  max-width: 760px;
  margin: 22px 0 18px;
  font-size: clamp(42px, 6vw, 74px);
  line-height: 1.03;
  font-weight: 900;
}

.login-hero p {
  max-width: 620px;
  margin: 0;
  color: #cbd5e1;
  font-size: 18px;
  line-height: 1.65;
}

.login-insights {
  width: min(100%, 760px);
  margin-top: 42px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.login-insights article {
  min-height: 154px;
  padding: 18px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  align-content: start;
  gap: 10px;
}

.login-insights i {
  color: #a5b4fc;
  font-size: 28px;
}

.login-insights strong {
  font-size: 14px;
}

.login-insights span {
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.45;
}

.login-card-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.94), rgba(238, 242, 255, 0.92)),
    #f8fafc;
}

.login-panel {
  width: min(100%, 430px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.16);
  padding: 30px;
}

.login-copy {
  margin: 34px 0 22px;
}

.login-copy h2 {
  margin: 0;
  font-size: 30px;
  color: var(--dark);
  line-height: 1.15;
}

.login-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #c7d2fe;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-footer {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
}

.login-footer strong {
  color: var(--dark);
  font-size: 18px;
}

.auth-methods {
  display: grid;
  gap: 10px;
}

.method-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  transition: 0.16s ease;
}

.method-button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.method-button i {
  font-size: 22px;
  color: var(--primary);
}

.method-button strong {
  display: block;
  font-size: 14px;
}

.method-button span {
  color: var(--muted);
  font-size: 12px;
}

/* ============================================================
   FORMS & BUTTONS  (shared)
   ============================================================ */

.stack {
  display: grid;
  gap: 14px;
}

.otp-form {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.field-label {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

#otp-input {
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.28em;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input:disabled {
  background: var(--soft);
  color: var(--muted);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  transition: 0.16s ease;
  white-space: nowrap;
}

.primary-button {
  background: var(--primary);
  color: white;
  padding: 0 16px;
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.24);
}

.primary-button:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.secondary-button {
  background: white;
  color: #334155;
  border-color: var(--line-strong);
  padding: 0 14px;
  text-decoration: none;
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  background: var(--soft);
}

.danger-button {
  background: var(--red);
  color: white;
  padding: 0 14px;
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.22);
}

.danger-button:hover {
  background: #b91c1c;
}

.ghost-button {
  background: transparent;
  color: #334155;
  border-color: var(--line-strong);
  padding: 0 12px;
}

.icon-button {
  width: 40px;
  background: white;
  color: #475569;
  border-color: var(--line-strong);
  font-size: 19px;
}

.form-message,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* ============================================================
   WORKSPACE SHELL
   ============================================================ */

.workspace {
  height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg);
}

/* ---- Sidebar (dark) ---- */
.sidebar {
  height: 100vh;
  background: linear-gradient(180deg, var(--side-bg-1), var(--side-bg-2));
  border-right: 1px solid rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  color: var(--side-text);
}

.sidebar-header {
  height: 68px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--side-line);
  flex: 0 0 auto;
}

.sidebar .brand-title {
  color: #fff;
}

.sidebar .brand-subtitle {
  color: var(--side-muted);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 22px;
  flex: 0 0 auto;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.brand-title {
  margin: 0;
  font-weight: 800;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.nav-list {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-group {
  margin-top: 14px;
}

.nav-group:first-child {
  margin-top: 2px;
}

.nav-group-label {
  padding: 6px 12px 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--side-muted);
}

.nav-link {
  position: relative;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--side-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  transition: 0.14s ease;
}

.nav-link i {
  font-size: 19px;
  color: var(--side-muted);
  transition: 0.14s ease;
}

.nav-link span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-link:hover i {
  color: #c7d2fe;
}

.nav-link.active {
  background: var(--side-active);
  color: #fff;
}

.nav-link.active i {
  color: #a5b4fc;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.nav-link.soon {
  cursor: default;
  color: var(--side-muted);
}

.nav-link.soon:hover {
  background: transparent;
  color: var(--side-muted);
}

.nav-link.soon i {
  opacity: 0.6;
}

.nav-soon {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--side-muted);
  border: 1px solid var(--side-line);
  border-radius: 999px;
  padding: 2px 6px;
}

/* ---- User card (dark) ---- */
.user-card-wrap {
  position: relative;
  padding: 12px;
  border-top: 1px solid var(--side-line);
  flex: 0 0 auto;
}

.user-card {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--side-text);
  border-radius: var(--radius-sm);
}

.user-card:hover {
  background: rgba(255, 255, 255, 0.07);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  flex: 0 0 auto;
}

.user-card-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  margin: 1px 0 0;
  color: var(--side-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-caret {
  color: var(--side-muted);
  font-size: 14px;
  transition: transform 0.15s ease;
}

.user-card[aria-expanded="true"] .user-card-caret {
  transform: rotate(180deg);
}

.user-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 40;
}

.user-menu[hidden] {
  display: none;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

.user-menu-item:hover {
  background: var(--soft);
}

.user-menu-item i {
  font-size: 16px;
  color: var(--muted);
}

/* ---- Main panel ---- */
.main-panel {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 68px;
  flex: 0 0 auto;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.kicker {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

.topbar h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

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

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1180px;
  margin: 0 auto;
}

/* ============================================================
   PANELS & CARDS
   ============================================================ */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.panel-header .muted {
  margin: 3px 0 0;
}

.panel-body {
  padding: 20px;
}

/* When a table is the direct child of a panel, let it sit flush */
.panel > .data-table {
  border: none;
  border-radius: 0;
}

/* ---- Metric cards ---- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  transition: 0.16s ease;
}

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

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.metric-icon.indigo {
  background: var(--primary-soft);
  color: var(--primary);
}

.metric-icon.green {
  background: var(--green-soft);
  color: var(--green);
}

.metric-icon.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.metric-icon.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.metric-icon.red {
  background: var(--red-soft);
  color: var(--red);
}

.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.metric-value {
  margin: 2px 0 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--soft);
  color: var(--muted);
}

.badge i {
  font-size: 13px;
}

.badge.indigo {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.badge.green {
  background: var(--green-soft);
  color: var(--green);
}

.badge.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.red {
  background: var(--red-soft);
  color: var(--red);
}

.badge.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

/* ============================================================
   DASHBOARD EXTRAS
   ============================================================ */

.dashboard-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 28px;
  color: #fff;
  background:
    radial-gradient(1200px 200px at 90% -40%, rgba(99, 102, 241, 0.5), transparent),
    linear-gradient(135deg, #111a2e, #1e293b);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.dashboard-hero h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
}

.dashboard-hero p {
  margin: 8px 0 0;
  max-width: 640px;
  color: #cbd5e1;
  line-height: 1.55;
}

.dashboard-hero .badge {
  margin-bottom: 14px;
  background: rgba(99, 102, 241, 0.18);
  color: #c4b5fd;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: 0.16s ease;
}

.quick-action:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.quick-action .qa-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--primary-soft);
  color: var(--primary);
  flex: 0 0 auto;
}

.quick-action strong {
  display: block;
  font-size: 14px;
}

.quick-action span {
  color: var(--muted);
  font-size: 12.5px;
}

/* ============================================================
   TOOLS
   ============================================================ */

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

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: 0.16s ease;
}

.tool-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.tool-card > .badge {
  align-self: flex-start;
}

.tool-card h3 {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.tool-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  flex: 1;
}

.tool-meta-list {
  list-style: none;
  margin: 0;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 8px;
}

.tool-meta-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.tool-meta-list li i {
  font-size: 15px;
  color: var(--primary);
}

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

.tool-card .button-row {
  justify-content: space-between;
}

/* ============================================================
   TABLES
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 12px 16px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background 0.12s ease;
}

.data-table tbody tr:hover {
  background: var(--soft);
}

.data-table strong {
  font-weight: 700;
}

/* ============================================================
   EMPTY / LOADING STATES
   ============================================================ */

.empty-state {
  min-height: 140px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  color: var(--muted);
  font-size: 14px;
}

.preview-loading {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.preview-loading strong {
  font-size: 14px;
}

.preview-loading p {
  margin: 4px 0 0;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}

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

/* ============================================================
   SECURITY / AUTH CARDS
   ============================================================ */

.auth-method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.auth-card i {
  font-size: 26px;
  color: var(--primary);
}

.auth-card h4 {
  margin: 4px 0 0;
  font-size: 15px;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  flex: 1;
}

.auth-card .button-row {
  margin-top: 6px;
  justify-content: space-between;
}

.totp-setup {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: start;
}

.totp-setup canvas {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

@media (max-width: 640px) {
  .totp-setup {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   WIZARDS  (tools)
   ============================================================ */

.wizard .panel-header {
  align-items: flex-start;
}

.wizard-steps {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
}

.crm-tabs {
  gap: 8px;
}

.crm-tab.active {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

.crm-tab.active:hover {
  background: var(--primary-strong);
}

.wizard-step {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wizard-step strong {
  font-size: 13px;
  color: var(--muted);
}

.wizard-step span {
  font-size: 11.5px;
  color: var(--muted-2);
}

.wizard-step.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.wizard-step.active strong {
  color: var(--primary-strong);
}

.wizard-step.done {
  border-color: #bbf7d0;
  background: var(--green-soft);
}

.wizard-step.done strong {
  color: var(--green);
}

.wizard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.summary-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.summary-card h4 {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-card p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.info-tile {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.info-tile i {
  font-size: 24px;
  color: var(--primary);
}

.info-tile h4 {
  margin: 6px 0 4px;
  font-size: 14px;
}

.info-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tool-intro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.14s ease;
}

.checkbox-option:hover {
  border-color: var(--line-strong);
  background: var(--soft);
}

.checkbox-option input {
  width: auto;
  accent-color: var(--primary);
}

/* ---- Progress ---- */
.progress-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  gap: 14px;
}

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

.progress-header h4 {
  margin: 0;
  font-size: 15px;
}

.progress-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.progress-header strong {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  transition: width 0.3s ease;
}

.progress-feed {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.progress-feed > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  font-size: 13px;
}

.progress-feed strong {
  font-weight: 700;
}

.progress-feed span:last-child {
  color: var(--muted);
  margin-left: auto;
  text-align: right;
}

.result-box {
  margin: 0;
  padding: 14px;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-state {
  min-height: 160px;
  padding: 28px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}

.error-state i {
  font-size: 32px;
}

.error-state strong {
  color: #991b1b;
}

.error-state span {
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.45;
}

.inline-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: 0.14s ease;
}

.inline-action:hover {
  background: var(--soft);
  border-color: var(--primary);
  color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-backdrop,
.tool-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-in 0.15s ease;
}

#debug-modal {
  z-index: var(--z-debug);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(100%, 520px);
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: pop-in 0.16s ease;
}

.modal-wide {
  width: min(100%, 780px);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 800;
}

.modal p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---- Tool modal (large) ---- */
.tool-modal {
  position: relative;
  width: min(100%, 920px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s ease;
}

.tool-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.tool-modal-close:hover {
  background: var(--soft);
  color: var(--text);
}

.tool-modal .wizard {
  border: none;
  box-shadow: none;
  border-radius: var(--radius-lg);
}

.user-editor-perms {
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
  display: grid;
  gap: 10px;
}

.user-editor-perms .info-tile {
  background: var(--panel);
}

.user-editor-perms .info-tile h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

/* ---- Debug modal ---- */
.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.debug-grid code {
  display: block;
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  word-break: break-all;
}

.debug-label {
  display: block;
  margin: 14px 0 5px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ============================================================
   TOASTS  (fixed, above modals)
   ============================================================ */

#alert-region {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, calc(100vw - 36px));
  pointer-events: none;
}

#alert-region:empty {
  display: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

.toast-icon {
  font-size: 20px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.toast.success {
  border-color: #bbf7d0;
}

.toast.success .toast-icon {
  color: var(--green);
}

.toast.error {
  border-color: #fecaca;
}

.toast.error .toast-icon {
  color: var(--red);
}

.toast.info .toast-icon {
  color: var(--blue);
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-body p {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

.toast-close {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted-2);
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.toast-close:hover {
  background: var(--soft);
  color: var(--text);
}

.alert-action {
  margin-top: 8px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.alert-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.loading {
  opacity: 0.65;
  pointer-events: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
  }

  .sidebar-header {
    height: auto;
    border: none;
    padding: 6px 8px;
  }

  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 4px;
    gap: 4px;
  }

  .nav-group {
    margin: 0;
  }

  .nav-group-label {
    display: none;
  }

  .nav-link.soon {
    display: none;
  }

  .user-card-wrap {
    border: none;
    margin-left: auto;
    width: auto;
    padding: 4px;
  }

  .user-menu {
    left: auto;
    right: 12px;
    width: 240px;
  }

  .main-panel {
    height: auto;
  }

  .content {
    padding: 18px;
  }

  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-hero {
    display: none;
  }

  .wizard-steps {
    grid-auto-flow: row;
  }
}
