/* ============================================================
   CRM  —  Industrial Utilitarian Design System
   Typefaces: DM Mono (labels/data) + Syne (headings)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@600;700;800&display=swap');

:root {
  --bg:         #0e0f11;
  --surface:    #16181c;
  --surface2:   #1e2027;
  --border:     #2a2d36;
  --accent:     #f97316;
  --accent2:    #47c8ff;
  --danger:     #ff4757;
  --success:    #2ecc71;
  --warning:    #f39c12;
  --text:       #e8eaf0;
  --muted:      #6b7280;
  --mono:       'DM Mono', monospace;
  --display:    'Syne', sans-serif;
  --radius:     4px;
  --transition: 150ms ease;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--mono);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin: 0;
}
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem;  }
h4, h5, h6 { font-size: 0.82rem; }

svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

p { margin: 0; }

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1;
}

.sidebar-logo span {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-top: 4px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  padding: 12px 20px 4px;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-family: var(--mono);
  transition: color var(--transition), background var(--transition);
  border-left: 2px solid transparent;
}

.nav-item:hover  { color: var(--text);   background: var(--surface2); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(249,115,22,0.08); }

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

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

.sidebar-footer a { color: var(--muted); text-decoration: none; }
.sidebar-footer a:hover { color: var(--danger); }

.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  flex: 1;
}

.content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-title {
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-body { padding: 20px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}

.stat-label { font-size: 0.65rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--display); font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1.1; margin: 6px 0 4px; }
.stat-sub   { font-size: 0.72rem; color: var(--muted); }

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

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

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.td-mono { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.badge-new          { background: rgba(71,200,255,0.15); color: var(--accent2); }
.badge-qualified    { background: rgba(249,115,22,0.15);  color: var(--accent); }
.badge-proposal     { background: rgba(243,156,18,0.2);   color: var(--warning); }
.badge-negotiation  { background: rgba(243,156,18,0.3);   color: #f5b942; }
.badge-won          { background: rgba(46,204,113,0.2);   color: var(--success); }
.badge-lost         { background: rgba(255,71,87,0.15);   color: var(--danger); }
.badge-sent         { background: rgba(71,200,255,0.15);  color: var(--accent2); }
.badge-opened       { background: rgba(46,204,113,0.2);   color: var(--success); }
.badge-draft        { background: var(--surface2);         color: var(--muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary  { background: var(--accent);  color: #ffffff; }
.btn-primary:hover { background: #ea6a0a; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--muted); }

.btn-danger { background: rgba(255,71,87,0.15); color: var(--danger); border: 1px solid rgba(255,71,87,0.3); }
.btn-danger:hover { background: rgba(255,71,87,0.25); }

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

.btn svg { width: 14px; height: 14px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type=text],input[type=email],input[type=tel],input[type=password],
input[type=number],input[type=date],select,textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition);
}

input:focus,select:focus,textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249,115,22,0.2);
}

textarea { resize: vertical; min-height: 80px; }
select { appearance: none; cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Search bar ── */
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 14px; height: 14px; pointer-events: none; }
.search-wrap input { padding-left: 32px; }

/* ── Pipeline Board ── */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(180px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.pipeline-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 400px; }

.pipeline-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pipeline-col-title { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
.pipeline-col-count { font-size: 0.7rem; color: var(--muted); }

.pipeline-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.lead-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}

.lead-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.lead-card-name  { font-size: 0.8rem; font-weight: 500; margin-bottom: 4px; }
.lead-card-company { font-size: 0.72rem; color: var(--muted); }
.lead-card-value { font-family: var(--display); font-size: 0.95rem; font-weight: 700; color: var(--accent); margin-top: 8px; }

/* ── Notes timeline ── */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-dot svg { width: 13px; height: 13px; }

.timeline-body { flex: 1; }
.timeline-meta { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform 0.2s;
}

.modal-backdrop.open .modal { transform: translateY(0); }

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

.modal-title { font-family: var(--display); font-size: 1rem; font-weight: 700; }

.modal-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px; line-height: 1; font-size: 1.2rem;
}

.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Flash alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 0.82rem; margin-bottom: 20px; border-left: 3px solid; }
.alert-success { background: rgba(46,204,113,0.1); border-color: var(--success); color: var(--success); }
.alert-error   { background: rgba(255,71,87,0.1);  border-color: var(--danger);  color: var(--danger); }
.alert-info    { background: rgba(71,200,255,0.1); border-color: var(--accent2); color: var(--accent2); }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 18px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  transition: color var(--transition);
}

.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Utilities ── */
.flex     { display: flex; }
.items-center { align-items: center; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.justify-between { justify-content: space-between; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-sm  { font-size: 0.78rem; }
.text-xs  { font-size: 0.7rem; }
.font-display { font-family: var(--display); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full   { width: 100%; }
.grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(249,115,22,0.05) 0%, transparent 70%);
}

.login-box {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
}

.login-logo {
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.04em;
  margin-bottom: 6px;
}

.login-sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 30px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .pipeline-board { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Checkbox / radio reset ── */
input[type=checkbox],
input[type=radio] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}
