/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #060610;
  --bg-alt: #0a0a16;
  --surface: #0f0f1c;
  --surface-2: #151525;
  --surface-3: #1c1c30;
  --border: rgba(255,255,255,0.07);
  --border-focus: rgba(124,92,191,0.55);
  --purple: #7c5cbf;
  --purple-light: #9b7fe0;
  --purple-dim: rgba(124,92,191,0.12);
  --blue: #4a9eff;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --text: #eaeaf2;
  --text-muted: #7070a0;
  --text-sub: #50507a;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow: 0 12px 40px rgba(0,0,0,0.5);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Login ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 65% 15%, rgba(124,92,191,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 85%, rgba(192,96,160,0.07) 0%, transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid rgba(124,92,191,0.15);
  border-radius: 22px;
  padding: 48px 40px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(124,92,191,0.06);
}
.login-logo {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.login-logo span { color: var(--purple-light); }
.login-logo img { height: 40px; width: auto; }
.login-sub {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 36px;
}
.login-error {
  color: var(--red);
  font-size: 0.83rem;
  text-align: center;
  margin-top: 14px;
  min-height: 18px;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124,92,191,0.1);
}
.form-group input::placeholder { color: rgba(112,112,160,0.5); }
.form-group textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.form-group select { cursor: pointer; }
.form-group small { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .form-group.full { grid-column: span 2; }
.form-grid .form-group.span3 { grid-column: span 3; }
.form-divider { grid-column: span 2; border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.form-section-label {
  grid-column: span 2;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sub);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--purple), #9060c8);
  color: white;
  box-shadow: 0 4px 16px rgba(124,92,191,0.35);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.14) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,92,191,0.45); }
.btn-primary:hover::after { transform: translateX(100%); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); border-color: rgba(255,255,255,0.14); }
.btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.btn-full { width: 100%; }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.18); }
.btn-danger:hover { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.3); }
.btn-success { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.18); }
.btn-success:hover { background: rgba(34,197,94,0.18); border-color: rgba(34,197,94,0.3); }

/* ── Dashboard Layout ── */
.dashboard { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: linear-gradient(180deg, #0c0c1e 0%, #080816 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}
.sidebar-logo {
  padding: 20px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.sidebar-logo img { height: 32px; width: auto; border-radius: 7px; }
.sidebar-logo span { color: var(--purple-light); }
.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: rgba(124,92,191,0.1);
  color: var(--purple-light);
  border-left-color: var(--purple-light);
}
.nav-item svg { flex-shrink: 0; opacity: 0.55; transition: opacity 0.15s; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: 230px;
  padding: 36px 36px 80px;
  min-height: 100vh;
  background: var(--bg);
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  gap: 16px;
}
.page-header h1 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--text) 60%, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-header .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 3px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}
.stat-card:hover { border-color: rgba(124,92,191,0.22); transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0,0,0,0.3); }
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: rgba(74,158,255,0.12); color: var(--blue); box-shadow: 0 0 20px rgba(74,158,255,0.1); }
.stat-icon.green { background: rgba(34,197,94,0.12); color: var(--green); box-shadow: 0 0 20px rgba(34,197,94,0.1); }
.stat-icon.purple { background: rgba(124,92,191,0.12); color: var(--purple-light); box-shadow: 0 0 20px rgba(124,92,191,0.1); }
.stat-icon.orange { background: rgba(245,158,11,0.12); color: var(--orange); box-shadow: 0 0 20px rgba(245,158,11,0.1); }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { font-size: 0.73rem; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* ── Section Card ── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}
.section-header h2 { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.filter-group select {
  padding: 6px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.filter-group select:focus { border-color: var(--border-focus); }

/* ── Data Tables ── */
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 18px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 18px;
  font-size: 0.858rem;
  border-bottom: 1px solid rgba(255,255,255,0.035);
  vertical-align: middle;
  color: var(--text);
}
.data-table tr:hover td { background: rgba(124,92,191,0.03); }
.data-table tr:last-child td { border-bottom: none; }

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.empty-state-icon { font-size: 2.2rem; margin-bottom: 12px; opacity: 0.35; }
.empty-state p { margin-top: 6px; color: var(--text-sub); font-size: 0.82rem; }

/* ── Status Badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-badge.new { background: rgba(74,158,255,0.1); color: var(--blue); border: 1px solid rgba(74,158,255,0.18); }
.status-badge.contacted, .status-badge.pending, .status-badge.in_progress { background: rgba(245,158,11,0.1); color: var(--orange); border: 1px solid rgba(245,158,11,0.18); }
.status-badge.quoted { background: rgba(124,92,191,0.1); color: var(--purple-light); border: 1px solid rgba(124,92,191,0.18); }
.status-badge.won, .status-badge.active, .status-badge.paid, .status-badge.completed { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.18); }
.status-badge.lost, .status-badge.cancelled, .status-badge.overdue { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.18); }

/* ── Action Buttons ── */
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.action-btn {
  padding: 5px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.action-btn:hover { background: var(--surface-3); color: var(--text); border-color: rgba(255,255,255,0.14); }
.action-btn.primary { border-color: rgba(124,92,191,0.3); color: var(--purple-light); background: rgba(124,92,191,0.08); }
.action-btn.primary:hover { background: rgba(124,92,191,0.15); border-color: rgba(124,92,191,0.45); }
.action-btn.danger { border-color: rgba(239,68,68,0.22); color: var(--red); background: rgba(239,68,68,0.06); }
.action-btn.danger:hover { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); }

/* ── Activity List ── */
.activity-list { padding: 4px 0; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: rgba(124,92,191,0.03); }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--purple-light);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(155,127,224,0.5);
}
.activity-text { flex: 1; font-size: 0.858rem; }
.activity-time { font-size: 0.72rem; color: var(--text-sub); white-space: nowrap; }

/* ── Payments Summary ── */
.payments-summary { display: flex; gap: 16px; margin-bottom: 24px; }
.summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  flex: 1;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.summary-item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--purple), #9060c8);
  opacity: 0.4;
}
.summary-item:hover { border-color: rgba(124,92,191,0.2); }
.summary-label { display: block; font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; margin-bottom: 8px; }
.summary-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; }
.summary-value.pending { color: var(--orange); }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-content {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid rgba(124,92,191,0.15);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(124,92,191,0.06);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(0,0,0,0.15);
}
.modal-header-left h3 { font-size: 1.05rem; font-weight: 700; }
.modal-header-left p { font-size: 0.82rem; color: var(--text-muted); margin-top: 3px; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  margin-left: 12px;
}
.modal-close:hover { background: rgba(239,68,68,0.1); color: var(--red); border-color: rgba(239,68,68,0.2); }
.modal-body { padding: 24px 26px; overflow-y: auto; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.modal-actions .btn-primary { flex: 1; min-width: 140px; }

.modal-info {
  padding: 12px 14px;
  background: rgba(124,92,191,0.07);
  border: 1px solid rgba(124,92,191,0.14);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.55;
}
.modal-info strong { color: var(--text); }

.result-box {
  display: none;
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(34,197,94,0.07);
  border: 1px solid rgba(34,197,94,0.18);
  border-radius: var(--radius-sm);
}
.result-box.show { display: block; }
.result-box-label { font-size: 0.78rem; font-weight: 700; color: var(--green); margin-bottom: 6px; }
.result-box a { color: var(--purple-light); font-size: 0.82rem; word-break: break-all; text-decoration: none; }
.result-box a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; padding: 24px; }
}
@media (max-width: 700px) {
  .sidebar { position: fixed; transform: translateX(-100%); z-index: 100; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .payments-summary { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .form-group.full { grid-column: span 1; }
}
