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

:root {
  --bg: #f5f5f5;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #e0e0e0;
  --sidebar-active: #0f3460;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #0f3460;
  --accent-light: #e8eef6;
  --border: #e0e0e0;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --radius: 8px;
}

body {
  font-family: 'League Spartan', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* Layout */
.app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand p {
  font-size: 13px;
  color: var(--sidebar-text);
  margin-top: 2px;
}

.nav-links {
  list-style: none;
  padding: 12px 0;
}

.nav-link {
  display: block;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s;
}

.nav-link:hover {
  background: rgba(255,255,255,0.05);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}

/* Main content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* Pages */
.page { }
.page.hidden { display: none; }

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

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
}

.search-input {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  width: 300px;
  outline: none;
  transition: border-color 0.15s;
}

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

/* Card list */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card-row:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-name {
  font-size: 15px;
  font-weight: 600;
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.card-row-right {
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
}

.badge-sold {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--green-light);
  color: var(--green);
}

.badge-open {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
}

.badge-followup {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: #fff3e0;
  color: #e65100;
}

.badge-lost {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: #ffebee;
  color: #c62828;
}

/* Detail pages */
.btn-back {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 16px;
}

.btn-back:hover {
  text-decoration: underline;
}

/* Editable header card */
.detail-header-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  position: relative;
}

.editable-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-field {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.edit-field:hover {
  background: var(--bg);
}

.edit-field:focus {
  border-color: var(--accent);
  background: #fff;
}

.edit-name {
  font-size: 24px;
  font-weight: 700;
  padding: 4px 8px;
}

.edit-row {
  display: flex;
  gap: 8px;
}

.edit-wide {
  flex: 2;
}

.edit-row .edit-field {
  flex: 1;
}

.btn-save {
  position: absolute;
  top: 20px;
  right: 24px;
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-save:hover { opacity: 0.85; }
.btn-save.hidden { display: none; }

.save-status {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 13px;
  color: var(--green);
  font-weight: 500;
}

/* Pipeline Board (Home) */
.pipeline-board {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 120px);
}

.pipeline-column {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.column-header.column-new {
  background: var(--accent);
  color: #fff;
}

.column-header.column-followup {
  background: #e65100;
  color: #fff;
}

.column-header.column-pending {
  background: #1565c0;
  color: #fff;
}

.column-header.column-sold {
  background: var(--green);
  color: #fff;
}

.column-title {
  font-size: 14px;
  font-weight: 700;
}

.column-count {
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,0.25);
  padding: 2px 8px;
  border-radius: 10px;
}

.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pipeline-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.pipeline-card-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.pipeline-card-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.pipeline-card-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Pipeline (Lead Detail) */
.pipeline {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.pipeline-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}

.pipeline-stages {
  display: flex;
  align-items: center;
  gap: 0;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 0.15s;
}

.stage:hover {
  background: var(--bg);
}

.stage-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: #fff;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.stage.active .stage-dot {
  border-color: var(--accent);
  background: var(--accent);
  transform: scale(1.15);
}

.stage.completed .stage-dot {
  border-color: var(--green);
  background: var(--green);
}

.stage.is-pending .stage-dot {
  border-color: #1565c0;
  background: #1565c0;
}

.stage.is-sold .stage-dot {
  border-color: var(--green);
  background: var(--green);
}

.stage.is-lost .stage-dot {
  border-color: #c62828;
  background: #c62828;
}

.stage-label {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.15s;
}

.stage.active .stage-label {
  color: var(--accent);
}

.stage.completed .stage-label {
  color: var(--green);
}

.stage.is-pending .stage-label {
  color: #1565c0;
}

.stage.is-sold .stage-label {
  color: var(--green);
}

.stage.is-lost .stage-label {
  color: #c62828;
}

.stage-connector {
  flex: 1;
  height: 3px;
  background: var(--border);
  transition: background 0.2s;
}

.stage-connector.completed {
  background: var(--green);
}

.stage-outcomes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage.outcome {
  flex-direction: row;
  gap: 10px;
  padding: 6px 16px;
}

.stage.outcome .stage-dot {
  width: 22px;
  height: 22px;
}

/* Lead info grid */
.lead-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.info-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.info-value {
  font-size: 16px;
  font-weight: 600;
}

.edit-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}

.edit-textarea:focus {
  border-color: var(--accent);
}

.btn-small {
  margin-top: 8px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-small:hover { opacity: 0.85; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

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

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

.tab-content { }
.tab-content.hidden { display: none; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 14px;
}

.empty-state.hidden { display: none; }

/* Estimate cards in detail view */
.estimate-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.estimate-card-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.estimate-number {
  font-size: 14px;
  font-weight: 600;
}

.estimate-date {
  font-size: 13px;
  color: var(--text-muted);
}

.estimate-total {
  font-size: 16px;
  font-weight: 700;
}

/* Files */
.files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
}

.file-row a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 8px;
}

.file-row a:hover { text-decoration: underline; }

.file-delete {
  background: none;
  border: none;
  color: #c62828;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
}

.file-delete:hover { background: rgba(198, 40, 40, 0.1); }

.btn-upload {
  display: inline-block;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-upload:hover { opacity: 0.9; }

/* Loading */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand h1 { display: none; }
  .sidebar-brand p { display: none; }
  .nav-link { padding: 10px; text-align: center; font-size: 12px; }
  .content { padding: 16px; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .search-input { width: 100%; }
  .client-info { flex-direction: column; gap: 4px; }
  .pipeline-board { grid-template-columns: 1fr; height: auto; }
  .column-cards { max-height: 300px; }
  .lead-info-grid { grid-template-columns: 1fr; }
  .edit-row { flex-direction: column; }
}
