/* TwoX Dashboard Design System - Dark Glassmorphism with Dedicated Full-Screen Login Page & RBAC */
:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(26, 35, 54, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(139, 92, 246, 0.3);
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.06) 0%, transparent 40%);
}

/* FULL SCREEN LOGIN PAGE STYLING */
.login-screen-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #090d16 100%);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(20px);
  transition: opacity 0.3s ease;
}

.login-card-box {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(139, 92, 246, 0.3);
  width: 100%;
  max-width: 440px;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(139, 92, 246, 0.2);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.login-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: white;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.login-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 13px;
  color: #a5b4fc;
}

.login-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.login-input-field {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.login-input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.login-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  margin-top: 8px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
}

.login-credentials-hint {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.login-credentials-hint code {
  color: #34d399;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

/* User Profile Selector & Dropdown Options */
.user-role-option {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-role-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Sidebar Styling */
.app-sidebar {
  width: var(--sidebar-width);
  background: rgba(13, 17, 28, 0.9);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-badge {
  font-size: 10px;
  background: rgba(139, 92, 246, 0.2);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.05) 100%);
  color: #c4b5fd;
  border-left: 3px solid var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.api-status-card {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.status-info {
  display: flex;
  flex-direction: column;
}

.status-label {
  font-size: 11px;
  color: var(--text-muted);
}

.status-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}

/* Main Container */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px;
  max-width: 1600px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.header-title-group h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.header-title-group p {
  color: var(--text-secondary);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* Button Component */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.45);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Metrics Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px 24px;
  transition: all 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

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

.metric-title {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.metric-footer {
  font-size: 12px;
  color: var(--text-muted);
}

/* Content Container Card */
.content-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 14px;
  flex: 1;
  max-width: 400px;
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 14px;
  width: 100%;
}

.filter-group {
  display: flex;
  gap: 10px;
}

.filter-select {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* View Switcher Toggle Buttons */
.view-toggle-group {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.view-toggle-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

/* CRM KANBAN BOARD & DRAG AND DROP STYLING */
.crm-kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}

.kanban-column {
  background: rgba(15, 23, 42, 0.6);
  border: 2px dashed transparent;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 550px;
  max-height: 780px;
  transition: all 0.2s ease;
}

.kanban-column.drag-over {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
}

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.kanban-column-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-count-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.kanban-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
}

.kanban-lead-card {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
}

.kanban-lead-card:active {
  cursor: grabbing;
}

.kanban-lead-card.dragging {
  opacity: 0.4;
  transform: scale(0.96);
  border: 1px dashed var(--primary);
}

.kanban-lead-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.kanban-lead-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.kanban-lead-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.kanban-checklist-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.kanban-chk-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.kanban-chk-pill.ok {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.kanban-chk-pill.missing {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 14px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 14px;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

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

/* CALENDAR GRID STYLING */
.mkt-calendar-header-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  text-align: center;
}

.mkt-calendar-day-header {
  padding: 10px 4px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mkt-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.mkt-calendar-cell {
  min-height: 140px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.mkt-calendar-cell:hover {
  background: rgba(26, 35, 54, 0.7);
  border-color: rgba(255, 255, 255, 0.15);
}

.mkt-calendar-cell.empty-cell {
  background: rgba(0, 0, 0, 0.15);
  border-color: transparent;
  min-height: 100px;
}

.mkt-calendar-date-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.mkt-calendar-date-badge.has-event {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.mkt-event-card {
  background: rgba(30, 41, 59, 0.9);
  border-radius: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--primary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mkt-event-card:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.mkt-event-title {
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 4px;
  line-height: 1.3;
}

.mkt-event-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* Image Thumbnails */
.thumb-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumb-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Days Tag Containers */
.days-container {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.day-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  color: var(--text-secondary);
}

.cell-bold {
  font-weight: 600;
  color: var(--text-main);
}

.cell-subtext {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Modal Drawer */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 650px;
  border-radius: 16px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.close-btn:hover {
  color: var(--text-main);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-val {
  font-size: 13px;
  font-weight: 500;
}

/* Spinner Loading */
.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}


/* TwoX visual refinement: practical operations desk, not a template */
:root {
  --twox-ink: #17212b;
  --twox-muted: #66727d;
  --twox-line: #d9e0e5;
  --twox-paper: #f7f8f9;
  --twox-blue: #155a7a;
  --twox-orange: #e07a34;
}
body { background: var(--twox-paper) !important; color: var(--twox-ink) !important; }
.login-screen-backdrop { background: #edf1f3 !important; }
.login-card-box { border: 1px solid var(--twox-line) !important; border-radius: 8px !important; box-shadow: 0 10px 30px rgba(23,33,43,.10) !important; }
.login-brand-icon, .brand-icon { background: var(--twox-blue) !important; box-shadow: none !important; }
.app-sidebar { background: #fff !important; border-right: 1px solid var(--twox-line) !important; box-shadow: none !important; }
.brand-title, .login-title { letter-spacing: -.02em !important; }
.nav-item { border-radius: 5px !important; color: #53616c !important; }
.nav-item.active { background: #e8f0f4 !important; color: var(--twox-blue) !important; border-left: 3px solid var(--twox-orange) !important; }
.card, .dashboard-card, .stat-card, .panel, .content-card { border: 1px solid var(--twox-line) !important; border-radius: 7px !important; box-shadow: 0 2px 8px rgba(23,33,43,.04) !important; background: #fff !important; }
button, .btn { border-radius: 5px !important; box-shadow: none !important; }
.btn-primary { background: var(--twox-blue) !important; }
input, select, textarea { border-radius: 5px !important; border-color: #c8d2d9 !important; }
h1, h2, h3 { letter-spacing: -.018em !important; }
.badge, .brand-badge { border-radius: 4px !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* Operations desk pass: reduce visual noise and restore hierarchy */
.page-content, .main-content { max-width: 1440px; }
.section-header, .content-header { margin-bottom: 22px; }
.metric-card, .stat-card { min-height: 92px !important; padding: 16px !important; }
.metric-card .metric-icon, .stat-card .metric-icon { width: 28px !important; height: 28px !important; font-size: 0 !important; background: transparent !important; }
.metric-title { font-size: 11px !important; letter-spacing: .02em !important; font-weight: 600 !important; color: var(--twox-muted) !important; }
.metric-value { font-size: 26px !important; font-weight: 650 !important; color: var(--twox-ink) !important; }
.card-header-bar, .section-header { border-bottom: 1px solid var(--twox-line) !important; }
.table-container, table { border-color: var(--twox-line) !important; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(21,90,122,.28) !important; outline-offset: 2px; }
@media (max-width: 760px) { .metric-card, .stat-card { min-height: 76px !important; } .metric-value { font-size: 22px !important; } }
.overview-intro { display:flex; justify-content:space-between; align-items:flex-end; gap:16px; padding:4px 0 18px; border-bottom:1px solid var(--twox-line); }
.overview-intro h1 { font-size:30px; font-weight:650; margin:0; }
.overview-intro p { margin:6px 0 0; color:var(--twox-muted); }
.content-card { background:#fff !important; }
.content-card[style*="linear-gradient"] { background:#fff !important; }
@media (max-width:760px) { .overview-intro { align-items:flex-start; flex-direction:column; } .overview-intro h1 { font-size:25px; } }
