:root {
  --bg-canvas: #08080a;
  --bg-surface: #111114;
  --bg-elevated: #18181d;
  --bg-hover: #1f1f26;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text-primary: #fafafa;
  --text-secondary: #9e9ea8;
  --text-muted: #686873;
  --accent: #e61e32;
  --accent-fg: #ffffff;
  --cuecut-red: #e61e32;
  --brand-blue: #f4f4f6;
  --emerald: #22c55e;
  --amber: #f59e0b;
  --rose: #e61e32;
  --violet: #d4d4d8;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "SF Pro Text", "Helvetica Neue", sans-serif;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 15%, rgba(230, 30, 50, 0.14), transparent 55%), var(--bg-canvas);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-logo-svg {
  border-radius: 9px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.brand-row h1 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 740;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-row h1 span {
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(230, 30, 50, 0.14);
  border: 1px solid rgba(230, 30, 50, 0.32);
  color: #ff4d5e;
  letter-spacing: 0.08em;
}

.brand-row p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.sidebar-brand strong {
  display: block;
  font-size: 14px;
}

.sidebar-brand small {
  color: var(--text-secondary);
  font-size: 11px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(230, 30, 50, 0.14);
  border: 1px solid rgba(230, 30, 50, 0.28);
  color: #ffffff;
  font-weight: 620;
}

.nav-item.active .nav-icon {
  color: #ff3b4e;
  opacity: 1;
}

.nav-icon {
  width: 18px;
  text-align: center;
  opacity: 0.85;
}

.nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  font-size: 12.5px;
}

.dot-online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.sidebar-footer-actions {
  display: flex;
  gap: 4px;
}

/* Main Stage */
.main-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(12, 12, 15, 0.82);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.topbar p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

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

.server-endpoint-pill {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.view-container {
  padding: 24px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Cards & Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-card span {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
}

.kpi-card strong {
  display: block;
  font-size: 23px;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.kpi-card small {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}

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

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 18px;
}

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

.card-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
}

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

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.emerald { background: rgba(34, 197, 94, 0.14); color: #4ade80; border-color: rgba(34, 197, 94, 0.25); }
.badge.sky { background: rgba(56, 189, 248, 0.14); color: #38bdf8; border-color: rgba(56, 189, 248, 0.25); }
.badge.amber { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border-color: rgba(245, 158, 11, 0.25); }
.badge.rose { background: rgba(244, 63, 94, 0.14); color: #fb7185; border-color: rgba(244, 63, 94, 0.25); }
.badge.violet { background: rgba(168, 85, 247, 0.14); color: #c084fc; border-color: rgba(168, 85, 247, 0.25); }
.badge.muted { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }

/* CRM Kanban Board */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(225px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-col {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 420px;
}

.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.kanban-col-head strong {
  font-size: 12.5px;
}

.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.kanban-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.kanban-card strong {
  display: block;
  font-size: 13px;
}

.kanban-card-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Forms & Inputs */
input, select, textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-blue);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-stack label, .form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn.secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn.ghost:hover, .btn.secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn.danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.3);
}

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

.btn.full {
  width: 100%;
}

/* Funnel Bars */
.funnel-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 110px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.funnel-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: 999px;
}

/* Drawer & Modal */
.drawer-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.modal-backdrop {
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.drawer {
  width: min(620px, 94vw);
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-strong);
  padding: 22px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-sheet {
  width: min(540px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 22px 24px;
}

.timeline-item {
  border-left: 2px solid var(--border-strong);
  padding-left: 12px;
  margin-left: 4px;
  padding-bottom: 12px;
}

.timeline-item small {
  color: var(--text-muted);
  display: block;
  font-size: 11px;
}

.toast {
  margin: 14px 28px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
  font-size: 13px;
}

.notice.error {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.14);
  color: #fb7185;
  font-size: 12.5px;
}
