:root {
  --bg: #f5f6f8;
  --sidebar-bg: #171a21;
  --sidebar-hover: #23272f;
  --accent: #4f7cff;
  --accent-dark: #3a5fd9;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --border: #e3e5e9;
  --card-bg: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}

#app-shell { display: flex; height: 100vh; width: 100vw; }

/* Sidebar */
#sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #cfd3dc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid #262b35; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
}
.brand-name { font-weight: 600; font-size: 15px; color: #fff; }
.nav-list { list-style: none; margin: 0; padding: 10px 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; cursor: pointer; font-size: 13.5px;
  color: #b7bcc7; transition: background .12s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; border-left: 3px solid var(--accent); padding-left: 15px; }
.nav-icon { width: 16px; text-align: center; opacity: .85; }
.sidebar-footer { padding: 12px 18px; font-size: 11px; color: #5b606c; border-top: 1px solid #262b35; }

/* Content */
#content { flex: 1; overflow-y: auto; padding: 28px 34px; }

h1.page-title { font-size: 20px; margin: 0 0 4px; }
p.page-subtitle { color: var(--text-muted); margin: 0 0 22px; font-size: 13px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.col { flex: 1; min-width: 220px; }

/* Cards */
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.stat-card { text-align: left; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* Buttons */
button, .btn {
  font-family: inherit; font-size: 13px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); padding: 8px 14px; cursor: pointer; transition: all .12s;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover, .btn.primary:hover { background: var(--accent-dark); color: #fff; }
button.danger { color: var(--red); }
button.danger:hover { border-color: var(--red); }
button.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; margin-top: 12px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 13.5px; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.checkbox-group { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.checkbox-row input { width: auto; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f9fafc; }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.toolbar input[type=text] { max-width: 280px; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.lead { background: #eef2ff; color: #4338ca; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.inactive { background: #f3f4f6; color: #6b7280; }
.badge.pastclient { background: #fef3c7; color: #92400e; }

/* Pipeline */
.pipeline-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.pipeline-col { flex: 0 0 240px; background: #eef0f3; border-radius: var(--radius); padding: 10px; min-height: 400px; }
.pipeline-col-header { font-weight: 600; font-size: 12.5px; text-transform: uppercase; color: var(--text-muted); padding: 4px 6px 10px; display: flex; justify-content: space-between; }
.deal-card {
  background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px;
  cursor: grab; font-size: 13px;
}
.deal-card:active { cursor: grabbing; }
.deal-card .deal-title { font-weight: 600; margin-bottom: 4px; }
.deal-card .deal-meta { color: var(--text-muted); font-size: 12px; }
.pipeline-col.drag-over { background: #dce4fb; }

/* Detail view */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.back-link { color: var(--accent); cursor: pointer; font-size: 13px; margin-bottom: 14px; display: inline-block; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.info-grid .k { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; }
.info-grid .v { font-size: 13.5px; margin-bottom: 8px; }

.activity-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-time { color: var(--text-muted); font-size: 11.5px; }
.activity-type-tag { font-size: 10.5px; text-transform: uppercase; font-weight: 700; color: var(--accent); margin-right: 6px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 480px; max-width: 90vw; max-height: 85vh; overflow-y: auto; }
.modal h2 { margin: 0 0 16px; font-size: 17px; }
.modal-close { float: right; cursor: pointer; color: var(--text-muted); font-size: 18px; }

/* Toast */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c1f26; color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.tag { display: inline-block; background: #eef2ff; color: #4338ca; padding: 3px 8px; border-radius: 5px; font-size: 11.5px; margin: 2px 4px 2px 0; }

.section-title { font-size: 14px; font-weight: 600; margin: 22px 0 10px; }

.intake-success { text-align: center; padding: 60px 20px; }
.intake-success .big-check { font-size: 48px; color: var(--green); margin-bottom: 10px; }

/* Auth screen */
.auth-screen {
  height: 100vh; width: 100vw; display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg);
}
.auth-card { background: #fff; border-radius: 10px; padding: 32px; width: 380px; max-width: 90vw; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.auth-brand .brand-name { font-size: 18px; font-weight: 700; }
.auth-subtitle { color: var(--text-muted); font-size: 12.5px; text-align: center; margin: -14px 0 18px; }
.auth-error { background: #fef2f2; color: var(--red); padding: 8px 12px; border-radius: 6px; font-size: 12.5px; margin-bottom: 10px; }
.auth-success { background: #f0fdf4; color: var(--green); padding: 8px 12px; border-radius: 6px; font-size: 12.5px; margin-bottom: 10px; }
.auth-link { color: var(--accent); cursor: pointer; font-size: 12.5px; text-align: center; margin-top: 14px; }
.auth-card button.primary { width: 100%; margin-top: 16px; padding: 10px; }

/* Admin console */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: #eef2ff; color: #4338ca; }
.role-badge.admin { background: #fef3c7; color: #92400e; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-dot.on { background: var(--green); }
.status-dot.off { background: var(--text-muted); }
.copy-box { background: #f5f6f8; border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 12.5px; word-break: break-all; margin: 8px 0; }

/* Quotes / print */
.print-only { display: none; }
@media print {
  .no-print, #sidebar, #toast-container { display: none !important; }
  #content { padding: 0; overflow: visible; }
  .print-only { display: block !important; }
  #quote-edit-card { display: none !important; }
  body, html { background: #fff; }
}
.quote-item-row input { width: 100%; }
