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

:root {
  --color-primary:   #16a34a;
  --color-primary-h: #15803d;
  --color-secondary: #2563eb;
  --color-danger:    #dc2626;
  --color-bg:        #f8fafc;
  --color-surface:   #ffffff;
  --color-border:    #e2e8f0;
  --color-text:      #1e293b;
  --color-muted:     #64748b;
  --radius:          8px;
  --shadow:          0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--color-secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
}

.navbar-actions { display: flex; gap: .5rem; align-items: center; }

/* ── Main layout ───────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

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

.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn-primary  { background: var(--color-primary);   color: #fff; }
.btn-primary:hover { background: var(--color-primary-h); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-ghost { background: transparent; color: var(--color-muted); }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.btn-ghost.active { color: var(--color-primary); font-weight: 600; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; }

/* ── Cards & surfaces ──────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
}

.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-section { margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--color-text); }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: .35rem; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}

.form-hint { display: block; margin-top: .35rem; color: var(--color-muted); font-size: .8rem; }

.checkbox-group { display: flex; align-items: center; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 500; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); }

.form-actions { display: flex; gap: .75rem; padding-top: .5rem; flex-wrap: wrap; }

/* ── Tab selection list ─────────────────────────────────────────────────────── */
.tabs-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.tab-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tab-item:hover { border-color: var(--color-primary); background: #f0fdf4; }
.tab-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); flex-shrink: 0; }
.tab-item-name { font-weight: 500; flex: 1; }
.tab-item-gid { font-size: .75rem; color: var(--color-muted); font-family: monospace; }

/* ── Auth page ─────────────────────────────────────────────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.auth-logo { font-size: 1.5rem; font-weight: 700; color: var(--color-primary); text-align: center; margin-bottom: .25rem; }
.auth-subtitle { text-align: center; color: var(--color-muted); margin-bottom: 1.75rem; font-size: .85rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footer { margin-top: 1.25rem; text-align: center; color: var(--color-muted); font-size: .8rem; }

/* ── Dashboard: stat card ──────────────────────────────────────────────────── */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: inline-block;
  box-shadow: var(--shadow);
}

.stat-label { font-size: .8rem; font-weight: 500; color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 2.5rem; font-weight: 700; color: var(--color-primary); line-height: 1.1; margin-top: .25rem; }

/* ── Dashboard: sheets grid ────────────────────────────────────────────────── */
.sheets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.sheet-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, transform .1s;
  text-align: center;
}

.sheet-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sheet-card-name { font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.sheet-card-count { font-size: 1.75rem; font-weight: 700; color: var(--color-primary); }
.sheet-card-label { font-size: .75rem; color: var(--color-muted); }

/* ── Chart ─────────────────────────────────────────────────────────────────── */
.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  height: 220px;
}

/* ── Kanban board ──────────────────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
}

.kanban-column {
  flex: 0 0 220px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 160px);
}

.kanban-column-header {
  padding: .75rem 1rem;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border-radius: var(--radius) var(--radius) 0 0;
}

.kanban-column-count {
  background: var(--color-border);
  color: var(--color-muted);
  font-size: .75rem;
  font-weight: 600;
  border-radius: 999px;
  padding: .1rem .5rem;
}

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

.kanban-column-body.drag-over {
  background: rgba(22,163,74,.06);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Lead card ─────────────────────────────────────────────────────────────── */
.lead-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: .75rem;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .1s;
  user-select: none;
}

.lead-card:hover { box-shadow: var(--shadow-md); }
.lead-card.dragging { opacity: .5; cursor: grabbing; }

.lead-card-name { font-weight: 600; font-size: .875rem; margin-bottom: .2rem; }
.lead-card-name-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 .2rem;
  text-align: left;
  width: 100%;
  font-family: inherit;
  font-weight: 600;
  font-size: .875rem;
  color: var(--color-primary);
  cursor: pointer;
}
.lead-card-name-btn:hover { text-decoration: underline; }
.lead-card-phone { color: var(--color-muted); font-size: .8rem; }
.lead-card-date { color: var(--color-muted); font-size: .75rem; margin-top: .25rem; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-fields {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.modal-field { display: flex; flex-direction: column; gap: .2rem; }

.modal-field-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.modal-field-value {
  font-size: .875rem;
  color: var(--color-text);
  word-break: break-word;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.loading-state { text-align: center; color: var(--color-muted); padding: 3rem; font-size: .9rem; }

@media (max-width: 640px) {
  .main-content { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .form-actions { flex-direction: column; }
}
