* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #232736;
  --border: #2a2e3d;
  --text: #e4e6f0;
  --text-dim: #8b8fa3;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ========== Login ========== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 0.875rem;
  margin-bottom: 2rem;
  font-style: italic;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card input {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-card button {
  padding: 0.75rem;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.15s;
}

.login-card button:hover {
  background: var(--accent-hover);
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ========== Header ========== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.version {
  font-size: 0.75rem;
  color: var(--text-dim);
}

nav {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.nav-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.current-user {
  font-size: 0.8rem;
  font-weight: 600;
}

.logout-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.logout-btn:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

/* ========== Main ========== */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* ========== Buttons ========== */
.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

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

.btn-secondary {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  padding: 0.5rem 1rem;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

/* ========== Dashboard ========== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.dash-card.span-2 {
  grid-column: span 2;
}

.dash-card-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.overdue-header {
  color: var(--danger);
}

.badge-count {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  background: rgba(108, 99, 255, 0.15);
  color: var(--accent);
  font-weight: 700;
}

.badge-count.danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.stats-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
  min-width: 100px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.dash-list-item {
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.1s;
}

.dash-list-item:hover {
  background: var(--surface-hover);
}

.dash-item-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dash-item-title {
  font-weight: 600;
}

.dash-item-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.dash-item-right {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Pipeline bar chart */
.pipeline-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  height: 180px;
  padding-top: 1rem;
}

.pipe-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.pipe-bar {
  width: 100%;
  max-width: 60px;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}

.pipe-bar-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  text-align: center;
}

.pipe-bar-value {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* ========== Kanban Board ========== */
.pipeline-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.pipeline-toolbar h2 {
  font-size: 1.25rem;
}

.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 400px;
}

.kanban-column {
  min-width: 220px;
  max-width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 3px solid var(--accent);
  border-radius: 10px 10px 0 0;
}

.kanban-col-count {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 400;
}

.kanban-col-body {
  padding: 0.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  min-height: 100px;
}

.kanban-col-body.drag-over {
  background: rgba(108, 99, 255, 0.05);
}

.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.kanban-card:hover {
  border-color: var(--accent);
}

.kanban-card.dragging {
  opacity: 0.5;
}

.kanban-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.kanban-card-location {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.kanban-card-value {
  font-weight: 600;
  color: var(--success);
}

.kanban-card-days {
  color: var(--text-dim);
}

.kanban-card-mfgs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.mfg-tag {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.2);
  border-radius: 4px;
  color: var(--accent);
}

/* ========== List Views ========== */
.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.list-toolbar h2 {
  font-size: 1.25rem;
}

.toolbar-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.toolbar-search {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  width: 220px;
}

.toolbar-search:focus {
  outline: none;
  border-color: var(--accent);
}

.toolbar-select {
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
}

.data-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.data-row {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  gap: 1rem;
}

.data-row:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.data-row-main {
  flex: 1;
}

.data-row-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.data-row-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.data-row-right {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.data-row-tags {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.2);
  border-radius: 10px;
  font-size: 0.65rem;
  color: var(--text-dim);
}

.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(108, 99, 255, 0.1);
  color: var(--accent);
}

/* ========== Search ========== */
.search-header {
  margin-bottom: 1.5rem;
}

.search-header h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
}

.search-bar input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-result-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.search-result-type.contact {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.search-result-type.company {
  background: rgba(96, 165, 250, 0.15);
  color: var(--info);
}

.search-result-type.deal {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

/* ========== Detail Views ========== */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.detail-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.detail-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
}

.back-btn {
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.back-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.detail-section.span-2 {
  grid-column: span 2;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.field-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-value {
  font-size: 0.9rem;
}

.field-value a {
  color: var(--accent);
  text-decoration: none;
}

.field-value a:hover {
  text-decoration: underline;
}

/* Stage badge */
.stage-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group.span-2 {
  grid-column: span 2;
}

.form-group label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ========== Role Badge ========== */
.role-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(108, 99, 255, 0.15);
  color: var(--accent);
}

/* ========== Admin Nav Button ========== */
.nav-admin-btn {
  border-color: rgba(108, 99, 255, 0.3);
  color: var(--accent);
}

.nav-admin-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ========== Admin Panel ========== */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.admin-header h2 {
  font-size: 1.25rem;
}

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.admin-tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.admin-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-content {
  min-height: 400px;
}

/* Admin cards and tables */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.admin-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(42, 46, 61, 0.5);
}

.admin-table tr:hover td {
  background: rgba(108, 99, 255, 0.03);
}

.admin-table .btn-sm {
  margin-right: 0.25rem;
}

/* Admin stats grid */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.admin-stat-value {
  font-size: 2rem;
  font-weight: 700;
}

.admin-stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Stage color swatch */
.stage-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 0.4rem;
}

/* Status indicators for active/inactive users */
.status-active {
  color: var(--success);
}

.status-inactive {
  color: var(--danger);
}

/* Admin settings form */
.settings-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.settings-form .form-group {
  margin-bottom: 0;
}

/* Backup section */
.backup-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.backup-actions {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.backup-btn {
  padding: 1rem 1.5rem;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 200px;
}

.backup-download {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.backup-download:hover {
  background: rgba(52, 211, 153, 0.2);
}

.backup-restore {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--warning);
}

.backup-restore:hover {
  background: rgba(251, 191, 36, 0.2);
}

.backup-btn-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.backup-btn-desc {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* ── Confidential Banner ── */
.confidential-banner {
  background: #2D3436;
  color: #f39c12;
  text-align: center;
  padding: 0.35rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: #aaa;
  border-top: 1px solid #e8e8e8;
  margin-top: auto;
}
.footer-mascot { position: absolute; bottom: 4px; height: 40px; width: auto; border-radius: 4px; opacity: 0.85; }
.footer-mascot:hover { opacity: 1; }
.footer-mascot-left { left: 12px; }
.footer-mascot-right { right: 12px; }
