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

:root {
  --sidebar-w: 220px;
  --bg: #f1f5f9;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --card: #ffffff;
  --text: #0f172a;
  --text-2: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

html, body { height: 100%; }

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

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

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

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid #1e293b;
}

.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.logo-mark svg { width: 18px; height: 18px; color: white; }

.logo-text {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: .5px;
}

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

.nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--accent); color: #ffffff; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Main ──────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

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

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

/* ── Alerts ────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); color: white; }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger { background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-ghost { background: transparent; color: var(--text-2); padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-icon { padding: 7px; }

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

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* ── Stat Cards ────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
}

.stat-card.accent { border-top: 3px solid var(--accent); }
.stat-card.success { border-top: 3px solid var(--success); }
.stat-card.warning { border-top: 3px solid var(--warning); }
.stat-card.danger  { border-top: 3px solid var(--danger); }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.td-actions { text-align: right; white-space: nowrap; }

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  max-width: 640px;
}

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

.form-grid .span-2 { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}

.form-group textarea { resize: vertical; min-height: 90px; }
.form-group select { cursor: pointer; }

.form-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
}

.badge-active   { background: #d1fae5; color: #065f46; }
.badge-completed { background: #e0e7ff; color: #3730a3; }
.badge-on-hold  { background: #fef3c7; color: #92400e; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-won      { background: #d1fae5; color: #065f46; }
.badge-lost     { background: #fee2e2; color: #991b1b; }
.badge-overdue  { background: #fee2e2; color: #991b1b; }

/* ── Dashboard ─────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.week-header {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 2px;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.task-row:last-child { border-bottom: none; }
.task-row:hover { background: #f8fafc; }
.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; }

.task-check form { margin: 0; }

.task-check input[type="checkbox"] {
  width: 17px; height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 11.5px; color: var(--text-2); margin-top: 1px; }
.task-due { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.task-due.overdue { color: var(--danger); font-weight: 600; }

/* ── Assignee Counter ──────────────────────────────────────────────── */
.assignee-list { display: flex; flex-direction: column; gap: 10px; }

.assignee-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.assignee-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.assignee-name { flex: 1; font-weight: 500; font-size: 13px; }
.assignee-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: #eef2ff;
  padding: 2px 9px;
  border-radius: 20px;
}

/* ── Search ────────────────────────────────────────────────────────── */
.search-form { display: flex; gap: 8px; }
.search-input {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  width: 280px;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }

/* ── Filters ───────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s;
  text-decoration: none;
}

.filter-tab:hover { color: var(--text); background: var(--card); }
.filter-tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ── Empty State ───────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-2);
}

.empty-state svg { width: 40px; height: 40px; opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: 13.5px; margin-bottom: 16px; }

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

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--border); }

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Detail sections ───────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  font-size: 13.5px;
}

.detail-label { color: var(--text-2); font-weight: 500; font-size: 12px; }
.detail-value { color: var(--text); }

/* ── Value highlight ───────────────────────────────────────────────── */
.value-large {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

/* ── Misc ──────────────────────────────────────────────────────────── */
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-2 { color: var(--text-2); }
.text-sm { font-size: 12.5px; }
.font-medium { font-weight: 500; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Calendar ──────────────────────────────────────────────────────── */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.cal-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-period-title {
  font-size: 18px;
  font-weight: 700;
  min-width: 200px;
  text-align: center;
}

.cal-actions { display: flex; gap: 8px; }

/* Month grid */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-day-header {
  background: #f8fafc;
  text-align: center;
  padding: 10px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-2);
}

.cal-day {
  background: var(--card);
  min-height: 110px;
  padding: 7px 8px;
  cursor: pointer;
  transition: background .1s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.cal-day:hover { background: #f0f4ff; color: inherit; }
.cal-day.other-month { background: #fafafa; }
.cal-day.other-month .cal-day-num { color: #cbd5e1; }
.cal-day.is-today { background: #eef2ff; }

.cal-day-num {
  font-size: 13px;
  font-weight: 500;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  margin-bottom: 5px;
}

.cal-day.is-today .cal-day-num {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.cal-event {
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.cal-event.type-task {
  background: #eef2ff;
  color: #3730a3;
}

.cal-event.type-task.done {
  background: #f0fdf4;
  color: #166534;
  text-decoration: line-through;
  opacity: .7;
}

.cal-event.type-note {
  background: #fef3c7;
  color: #92400e;
}

.cal-more {
  font-size: 11px;
  color: var(--text-2);
  padding: 1px 6px;
  cursor: pointer;
}

/* Week grid */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.week-col {
  background: var(--card);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.week-col-header {
  padding: 12px 10px 10px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  text-align: center;
}

.week-col-name {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--text-2);
}

.week-col-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 2px;
  text-decoration: none;
  color: var(--text);
  display: block;
}

.week-col.is-today .week-col-num { color: var(--accent); }
.week-col.is-today .week-col-header { background: #eef2ff; }

.week-col-events {
  padding: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.week-event {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-event.type-task { background: #eef2ff; color: #3730a3; }
.week-event.type-task.done { background: #f0fdf4; color: #166534; text-decoration: line-through; }
.week-event.type-note { background: #fef3c7; color: #92400e; }

.week-col-add {
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 4px;
}

.week-col-add a {
  font-size: 11px;
  color: var(--text-2);
  padding: 3px 6px;
  border-radius: 5px;
  text-decoration: none;
  transition: background .1s;
}

.week-col-add a:hover { background: var(--bg); color: var(--accent); }

/* Day view */
.day-view-header {
  margin-bottom: 24px;
}

.day-view-date {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

.day-view-weekday {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 2px;
}

.day-section { margin-bottom: 20px; }

.day-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-2);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.day-event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.day-event-card .color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.day-event-info { flex: 1; }
.day-event-title { font-weight: 600; font-size: 14px; }
.day-event-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.day-event-actions { display: flex; gap: 6px; align-items: center; }

/* ── Settings ──────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

.member-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.member-card:last-child { border-bottom: none; }
.member-card:hover { background: #f8fafc; }

.member-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 600; font-size: 14px; }
.member-role { font-size: 12px; color: var(--text-2); }

.member-inactive { opacity: .45; }

.color-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1.5px var(--border);
  display: inline-block;
  vertical-align: middle;
}

.ics-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12.5px;
  font-family: monospace;
  word-break: break-all;
  color: var(--text-2);
}

.sync-steps { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sync-steps li {
  display: flex;
  gap: 10px;
  font-size: 13px;
}

.step-num {
  width: 22px; height: 22px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

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

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.timeline-icon svg { width: 15px; height: 15px; }

.timeline-icon.kind-activity  { background: #ede9fe; color: #7c3aed; }
.timeline-icon.kind-task       { background: #dbeafe; color: #2563eb; }
.timeline-icon.kind-task.done  { background: #dcfce7; color: #16a34a; }

.timeline-card { flex: 1; min-width: 0; }

.timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.timeline-title { font-weight: 600; font-size: 13.5px; }
.timeline-date  { font-size: 12px; color: var(--text-2); margin-left: auto; white-space: nowrap; }

.timeline-body {
  font-size: 13px;
  color: var(--text);
  margin: 4px 0;
  white-space: pre-line;
}

.timeline-meta {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.timeline-meta span { display: flex; align-items: center; gap: 4px; }

.timeline-actions { display: flex; gap: 6px; margin-top: 6px; }

/* Activity type badges */
.act-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.act-badge.visit        { background:#ede9fe; color:#6d28d9; }
.act-badge.phone-call   { background:#d1fae5; color:#065f46; }
.act-badge.email        { background:#dbeafe; color:#1d4ed8; }
.act-badge.meeting      { background:#fef3c7; color:#92400e; }
.act-badge.quote-sent   { background:#fce7f3; color:#9d174d; }
.act-badge.other        { background:#f1f5f9; color:#475569; }

/* New-contact indicator */
.new-contact-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

/* ── Quick-Log Panel (Dashboard) ────────────────────────────────────── */
.quick-log-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  overflow: hidden;
}

.quick-log-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.quick-log-toggle:hover { background: #f8fafc; }
.quick-log-toggle svg   { width: 16px; height: 16px; color: var(--accent); }
.quick-log-toggle .chevron { margin-left: auto; transition: transform .2s; }
.quick-log-toggle.open .chevron { transform: rotate(180deg); }

.quick-log-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
  display: none;
}
.quick-log-body.open { display: block; }

.quick-log-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  margin-top: 14px;
  align-items: end;
}

.quick-log-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.quick-log-summary { margin-top: 10px; }
.quick-log-summary textarea { resize: vertical; min-height: 60px; }

/* ── Sidebar user block ─────────────────────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 0 12px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
}

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-logout {
  font-size: 11px;
  color: #64748b;
}
.sidebar-user-logout:hover { color: #94a3b8; }

/* ── Auth pages (login / setup) ─────────────────────────────────────── */
.auth-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.auth-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

.auth-form .form-group { margin-bottom: 16px; }

/* ── Mobile bottom nav ──────────────────────────────────────────────── */
.mobile-nav {
  display: none;  /* hidden on desktop */
}

/* ── Responsive — tablet and phone ─────────────────────────────────── */
@media (max-width: 768px) {

  /* Hide desktop sidebar */
  .sidebar { display: none; }

  /* Main takes full width */
  .main {
    margin-left: 0;
    padding-bottom: 64px;  /* room for bottom nav */
  }

  .topbar { padding: 0 16px; }

  .content { padding: 16px; }

  /* Show mobile bottom nav */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--sidebar-bg);
    height: 60px;
    z-index: 200;
    border-top: 1px solid #1e293b;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #64748b;
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    transition: color .15s;
  }

  .mobile-nav-item svg { width: 20px; height: 20px; }
  .mobile-nav-item:hover { color: #94a3b8; }
  .mobile-nav-item.active { color: var(--accent); }

  /* Single-column grids */
  .stats-grid         { grid-template-columns: 1fr 1fr; }
  .dashboard-grid     { grid-template-columns: 1fr; }
  .form-grid          { grid-template-columns: 1fr !important; }
  .detail-grid        { grid-template-columns: 1fr 1fr; }
  .settings-grid      { grid-template-columns: 1fr; }
  .quick-log-grid     { grid-template-columns: 1fr 1fr; }
  .quick-log-grid-2   { grid-template-columns: 1fr; }

  /* span-2 has no effect on single-column grid */
  .form-group.span-2  { grid-column: span 1; }

  /* Tables scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Page header stacks vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header-actions { flex-wrap: wrap; }

  /* Topbar actions wrap */
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* Auth card full width on small screens */
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 15px; }
}

