/* ── App Shell ── */
.app-body { background: var(--bg); color: var(--fg); font-family: var(--font-body); min-height: 100vh; }

.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-icon { font-size: 1.3rem; }
.brand-name { color: var(--fg); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--accent-dim); color: var(--fg); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(61,245,167,0.15); }
.nav-icon { font-size: 0.9rem; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 16px 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent-dim);
  border: 1px solid rgba(61,245,167,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 600; truncate; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 0.72rem; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--fg-muted);
  font-size: 0.78rem; padding: 6px 12px; border-radius: 6px;
  cursor: pointer; width: 100%; transition: all 0.15s;
}
.btn-logout:hover { border-color: rgba(255,80,80,0.4); color: #ff6060; }

/* ── Main Content ── */
.app-main {
  padding: 40px 48px;
  max-width: 1100px;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.page-sub {
  color: var(--fg-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.header-actions { display: flex; gap: 10px; align-items: center; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #0a0a0f;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.15); color: var(--fg); }

.btn-danger {
  background: rgba(255, 80, 80, 0.12);
  border: 1px solid rgba(255,80,80,0.25);
  color: #ff6060;
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-danger:hover { background: rgba(255,80,80,0.2); }
.btn-sm { font-size: 0.78rem; padding: 5px 12px; }

.full-width { width: 100%; text-align: center; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: rgba(61,245,167,0.15); }
.stat-card-label { font-size: 0.78rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.stat-card-number { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-card-number.accent { color: var(--accent); }
.stat-card-sub { font-size: 0.78rem; color: var(--fg-muted); }

/* ── Status Banner ── */
.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 24px;
  border: 1px solid;
}
.status-banner a { color: var(--accent); }
.status-active { background: rgba(61,245,167,0.07); border-color: rgba(61,245,167,0.2); }
.status-inactive { background: rgba(255,170,0,0.07); border-color: rgba(255,170,0,0.2); color: #ffaa00; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-active .status-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }
.status-inactive .status-dot { background: #ffaa00; }

/* ── Quick Grid ── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.2s, transform 0.15s;
}
.quick-card:hover { border-color: rgba(61,245,167,0.2); transform: translateY(-2px); }
.quick-icon { font-size: 1.6rem; flex-shrink: 0; }
.quick-body { flex: 1; }
.quick-body h3 { font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; margin-bottom: 3px; }
.quick-body p { font-size: 0.82rem; color: var(--fg-muted); }
.quick-arrow { color: var(--fg-muted); font-size: 1.1rem; }

/* ── Alerts ── */
.alert-error {
  background: rgba(255,80,80,0.1);
  border: 1px solid rgba(255,80,80,0.25);
  color: #ff8080;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.alert-success {
  background: rgba(61,245,167,0.08);
  border: 1px solid rgba(61,245,167,0.2);
  color: var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* ── Forms ── */
.field-group { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-label { font-size: 0.82rem; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.field-hint { font-size: 0.78rem; color: var(--fg-muted); margin-top: -2px; }
.required { color: var(--accent); }

.field-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.field-input:focus { border-color: rgba(61,245,167,0.4); }
.field-input::placeholder { color: rgba(138,136,145,0.5); }
.field-textarea { resize: vertical; min-height: 80px; }

select.field-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a8891' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

input[type="time"].field-input, input[type="datetime-local"].field-input { cursor: pointer; }

.form-actions { margin-top: 8px; }

/* ── Toggle ── */
.toggle-group { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.toggle-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; gap: 16px; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 100px; transition: 0.2s;
}
.toggle-track::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: var(--fg-muted); border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent-dim); border-color: rgba(61,245,167,0.3); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(20px); background: var(--accent); }

/* ── Radio Chips / Day Picker ── */
.delay-options, .day-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.radio-chip, .day-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.radio-chip input, .day-chip input { display: none; }
.radio-chip:hover, .day-chip:hover { border-color: rgba(61,245,167,0.3); }
.radio-chip.selected, .day-chip.selected { background: var(--accent-dim); border-color: rgba(61,245,167,0.35); color: var(--accent); font-weight: 600; }

.char-count { font-size: 0.75rem; color: var(--fg-muted); text-align: right; margin-top: 4px; }
.char-count.over { color: #ff6060; }

/* ── Settings Layout ── */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}
.settings-section-header { margin-bottom: 28px; }
.settings-section-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; margin-bottom: 4px; }
.settings-section-sub { font-size: 0.88rem; color: var(--fg-muted); }
.settings-form { display: flex; flex-direction: column; gap: 20px; }

/* ── Data Table ── */
.data-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted);
  border-bottom: 1px solid var(--border); background: var(--bg-elevated);
}
.data-table td { padding: 14px 16px; font-size: 0.88rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.td-phone { font-family: var(--font-display); font-weight: 500; }
.muted { color: var(--fg-muted); }
.inline-form { display: inline; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 0.72rem; font-weight: 600; text-transform: capitalize;
  letter-spacing: 0.04em;
}
.badge-new { background: rgba(255,170,0,0.12); color: #ffaa00; border: 1px solid rgba(255,170,0,0.2); }
.badge-contacted { background: rgba(100,160,255,0.12); color: #6699ff; border: 1px solid rgba(100,160,255,0.2); }
.badge-converted { background: rgba(61,245,167,0.1); color: var(--accent); border: 1px solid rgba(61,245,167,0.2); }
.badge-lost { background: rgba(255,80,80,0.1); color: #ff8080; border: 1px solid rgba(255,80,80,0.2); }

.source-tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 0.7rem; background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--fg-muted); text-transform: lowercase;
}

/* ── Mini stats ── */
.mini-stats { display: flex; align-items: center; gap: 12px; font-size: 0.88rem; margin-bottom: 20px; color: var(--fg-muted); }
.mini-stat strong { color: var(--fg); }
.mini-stat.new-c strong { color: #ffaa00; }
.mini-stat.accent-c strong { color: var(--accent); }
.mini-divider { color: var(--border); }

/* ── Filter Tabs ── */
.filter-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.filter-tab {
  padding: 8px 16px; font-size: 0.85rem; font-weight: 500; color: var(--fg-muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.filter-tab:hover { color: var(--fg); }
.filter-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Select (small) ── */
.select-sm {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--fg);
  border-radius: 6px; padding: 4px 8px; font-size: 0.78rem; cursor: pointer;
  appearance: none;
}

/* ── Appointments List ── */
.appt-list { display: flex; flex-direction: column; gap: 12px; }

.appt-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px; display: flex; align-items: center; gap: 20px;
  transition: border-color 0.2s;
}
.appt-card:hover { border-color: rgba(61,245,167,0.15); }
.appt-cancelled { opacity: 0.45; }

.appt-time {
  min-width: 90px; text-align: center; padding-right: 20px;
  border-right: 1px solid var(--border);
}
.appt-date { font-size: 0.78rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.appt-hour { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--accent); margin: 2px 0; }
.appt-dur { font-size: 0.72rem; color: var(--fg-muted); }

.appt-body { flex: 1; }
.appt-name { font-family: var(--font-display); font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.appt-contact { display: flex; gap: 16px; font-size: 0.82rem; color: var(--fg-muted); margin-bottom: 4px; }
.appt-service { font-size: 0.8rem; color: var(--fg-muted); background: var(--bg-elevated); display: inline-block; padding: 2px 8px; border-radius: 4px; }

.appt-meta { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.appt-actions { display: flex; gap: 8px; align-items: center; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.modal-open { display: flex; }

.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; animation: modal-in 0.18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

.modal-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; margin-bottom: 24px; }
.modal-form { display: flex; flex-direction: column; gap: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

/* ── Auth Pages ── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; }
.auth-brand { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--accent); text-decoration: none; display: block; margin-bottom: 28px; }
.auth-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.auth-sub { font-size: 0.88rem; color: var(--fg-muted); margin-bottom: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-switch { font-size: 0.85rem; color: var(--fg-muted); margin-top: 20px; text-align: center; }
.auth-switch a { color: var(--accent); text-decoration: none; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 80px 24px; color: var(--fg-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; color: var(--fg); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; max-width: 360px; margin: 0 auto; line-height: 1.65; }

/* ── Hero CTA button (landing page) ── */
.hero-cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #0a0a0f;
  font-family: var(--font-display); font-weight: 600; font-size: 1rem;
  padding: 14px 32px; border-radius: 10px; text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  margin-top: 32px;
}
.hero-cta:hover { opacity: 0.88; transform: translateY(-2px); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app-main { padding: 24px 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .appt-card { flex-wrap: wrap; }
  .appt-time { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; width: 100%; text-align: left; }
}
