/* ============================================================
   DOLLHOUZ CRM — Light Design System v3
   Font: Plus Jakarta Sans (Google Fonts)
   Accent: #0ea5e9 (sky blue)
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

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

:root {
  --bg:                #f0f4f8;
  --surface:           #ffffff;
  --surface2:          #f8fafc;
  --surface3:          #f1f5f9;
  --border:            #e2e8f0;
  --border2:           #cbd5e1;
  --text:              #0f172a;
  --text2:             #475569;
  --text3:             #64748b;
  --accent:            #0ea5e9;
  --accent-dim:        #e0f2fe;
  --accent-mid:        rgba(14,165,233,0.15);
  --accent-dark:       #0284c7;
  --danger:            #dc2626;
  --danger-dim:        #fee2e2;
  --success:           #059669;
  --success-dim:       #d1fae5;
  --warning:           #d97706;
  --warning-dim:       #fef3c7;
  --info:              #0369a1;
  --info-dim:          #e0f2fe;
  --radius:            10px;
  --radius-sm:         7px;
  --sidebar-w:         216px;
  --sidebar-w-collapsed: 56px;
  --topbar-h:          54px;
  --shadow:            0 1px 2px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-accent:     0 2px 10px rgba(14,165,233,0.28);
  --ease-out:          cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  transition: width 220ms var(--ease-out);
}

body.sidebar-collapsed .sidebar        { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main           { margin-left: var(--sidebar-w-collapsed); }

/* Logo row */
.sidebar-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 12px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-accent);
  text-decoration: none;
  transition: opacity 150ms;
}
.sidebar-logo-mark:hover { opacity: 0.85; }

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex: 1;
  overflow: hidden;
  transition: opacity 180ms var(--ease-out);
}

.sidebar-toggle {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: var(--text3);
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 120ms, color 120ms;
}
.sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

/* Hide text labels when collapsed */
body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .sidebar-user-info { opacity: 0; pointer-events: none; }
body.sidebar-collapsed .sidebar-logo-row {
  justify-content: center;
  gap: 0;
  padding: 0;
}
body.sidebar-collapsed .sidebar-logo-mark { display: none; }
body.sidebar-collapsed .sidebar-toggle {
  width: 32px;
  height: 32px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  padding: 6px 10px 3px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 180ms var(--ease-out);
}

/* Legacy class names — kept for any template that still uses them */
.nav-group-label  { display: none; }
.nav-group-divider{ display: none; }
.sidebar-spacer   { display: none; }
/* Legacy logo link — still works if used directly */
a.sidebar-logo {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  text-decoration: none;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out);
  width: 100%;
  text-align: left;
}
.nav-btn:hover  { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--accent-dim); color: var(--info); font-weight: 600; }

.nav-icon {
  width: 17px; height: 17px;
  flex-shrink: 0;
  color: currentColor;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 180ms var(--ease-out);
  flex: 1;
}

/* Legacy tooltip — hidden in new design */
.nav-btn .tip { display: none; }

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms var(--ease-out);
  overflow: hidden;
}
.sidebar-user:hover { background: var(--surface2); }

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

.sidebar-user-info { overflow: hidden; transition: opacity 180ms var(--ease-out); }
.sidebar-user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }
.sidebar-user-role { font-size: 10px; color: var(--text3); white-space: nowrap; }

/* ============================================================
   LAYOUT
   ============================================================ */

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 220ms var(--ease-out);
}

/* ============================================================
   TOPBAR
   ============================================================ */

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

.topbar-left { display: flex; flex-direction: column; gap: 1px; }

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.topbar-sub { font-size: 11px; color: var(--text3); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */

.page-content { padding: 24px; flex: 1; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: all 120ms var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost {
  background: var(--surface);
  color: var(--text2);
  border-color: var(--border2);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: rgba(220,38,38,0.2);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(5,150,105,0.2);
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-mid);
}
.btn-accent:hover { background: var(--accent-mid); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn-icon svg { width: 15px; height: 15px; }

/* ============================================================
   CARDS
   ============================================================ */

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

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

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ============================================================
   STAT CARDS
   ============================================================ */

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

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.stat-value.accent  { color: var(--accent); }
.stat-value.danger  { color: var(--danger); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }

.stat-sub { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* ============================================================
   GRIDS
   ============================================================ */

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-section { margin-bottom: 24px; }

/* ============================================================
   FORMS
   ============================================================ */

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

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }

.form-label { font-size: 12px; font-weight: 500; color: var(--text2); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}

.form-input::placeholder { color: var(--text3); }
.form-textarea { resize: vertical; min-height: 80px; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-actions { display: flex; gap: 10px; padding-top: 8px; grid-column: 1 / -1; }

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--surface2);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 100ms; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td { padding: 11px 14px; font-size: 13px; color: var(--text); vertical-align: middle; }

.td-muted  { color: var(--text2); }
.td-right  { text-align: right; }
.td-center { text-align: center; }

/* ============================================================
   BADGES / TAGS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Lead statuses */
.badge-new           { background: var(--info-dim);    color: var(--info); }
.badge-contacted     { background: var(--warning-dim); color: var(--warning); }
.badge-qualified     { background: var(--accent-dim);  color: var(--accent); }
.badge-proposal_sent { background: #ede9fe; color: #6d28d9; }
.badge-negotiating   { background: var(--warning-dim); color: var(--warning); }
.badge-converted     { background: var(--success-dim); color: var(--success); }
.badge-lost          { background: var(--danger-dim);  color: var(--danger); }
.badge-unresponsive  { background: var(--surface3);    color: var(--text3); }

/* Deal stages */
.badge-new_inquiry  { background: var(--info-dim);    color: var(--info); }
.badge-quoted       { background: var(--warning-dim); color: var(--warning); }
.badge-confirmed    { background: var(--accent-dim);  color: var(--accent); }
.badge-in_treatment { background: #ede9fe; color: #6d28d9; }
.badge-completed    { background: var(--success-dim); color: var(--success); }

/* Quote statuses */
.badge-draft    { background: var(--surface3);    color: var(--text2); }
.badge-sent     { background: var(--info-dim);    color: var(--info); }
.badge-accepted { background: var(--success-dim); color: var(--success); }
.badge-rejected { background: var(--danger-dim);  color: var(--danger); }
.badge-expired  { background: var(--surface3);    color: var(--text3); }

/* General */
.badge-in_progress { background: var(--warning-dim); color: var(--warning); }

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
  pointer-events: none;
  max-width: 320px;
}

.toast.show    { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(5,150,105,0.3);  color: var(--success); }
.toast.error   { border-color: rgba(220,38,38,0.3);  color: var(--danger); }
.toast.warning { border-color: rgba(215,119,6,0.3);  color: var(--warning); }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
}

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

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

.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--text2); border-radius: 6px; cursor: pointer;
  transition: all 120ms;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body   { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ============================================================
   KANBAN BOARD
   ============================================================ */

.kanban-board {
  display: flex; gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  min-height: 400px;
}

.kanban-col {
  flex: 0 0 220px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 300px;
  display: flex; flex-direction: column; gap: 8px;
}

.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.kanban-col-title { font-size: 11px; font-weight: 600; color: var(--text2); }

.col-count {
  background: var(--surface); color: var(--text3);
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  border: 1px solid var(--border);
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: box-shadow 150ms var(--ease-out), transform 150ms var(--ease-out);
  user-select: none;
  box-shadow: var(--shadow);
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }

.kanban-ghost   { opacity: 0.3; background: var(--accent-dim); border-color: var(--accent-mid); }
.kanban-dragging { transform: rotate(1.5deg); box-shadow: 0 8px 24px rgba(0,0,0,0.15); cursor: grabbing; }

.card-name     { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.card-meta     { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.card-followup { font-size: 10px; color: var(--warning); margin-bottom: 6px; }
.card-link     { font-size: 11px; color: var(--accent); font-weight: 500; text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* ============================================================
   NOTES TIMELINE
   ============================================================ */

.notes-timeline { display: flex; flex-direction: column; gap: 0; }

.note-entry {
  display: flex; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.note-entry:last-child { border-bottom: none; }

.note-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.note-body  { flex: 1; }
.note-meta  { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.note-text  { font-size: 13px; color: var(--text); line-height: 1.6; white-space: pre-wrap; word-break: break-all; overflow-wrap: break-word; }

.note-input-row { display: flex; gap: 8px; margin-top: 12px; }
.note-input-row textarea {
  flex: 1;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 13px; color: var(--text); outline: none;
  resize: none; min-height: 70px; font-family: inherit;
  transition: border-color 120ms var(--ease-out);
}
.note-input-row textarea:focus { border-color: var(--accent); }

/* ============================================================
   FILE ATTACHMENTS
   ============================================================ */

.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.file-icon {
  width: 28px; height: 28px;
  background: var(--accent-dim); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); flex-shrink: 0;
}

.file-name { flex: 1; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: var(--text3); white-space: nowrap; }

/* ============================================================
   DETAIL PAGE LAYOUT
   ============================================================ */

.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.detail-main   { display: flex; flex-direction: column; gap: 20px; }
.detail-side   { display: flex; flex-direction: column; gap: 16px; }

/* ============================================================
   INFO ROWS
   ============================================================ */

.info-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.info-item  { display: flex; flex-direction: column; gap: 3px; }
.info-label { font-size: 11px; font-weight: 500; color: var(--text3); }
.info-value { font-size: 14px; color: var(--text); }
.info-value.muted { color: var(--text2); }

/* ============================================================
   STAGE PIPELINE BAR
   ============================================================ */

.pipeline { display: flex; gap: 2px; margin: 16px 0; }

.pipeline-step {
  flex: 1; height: 4px;
  background: var(--border); border-radius: 2px;
  transition: background 200ms; cursor: pointer;
}
.pipeline-step.active { background: var(--accent); }
.pipeline-step.past   { background: var(--accent-mid); }
.pipeline-step.danger { background: var(--danger); }

/* ============================================================
   AVATAR INITIALS
   ============================================================ */

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-transform: uppercase;
}

/* ============================================================
   SEARCH + FILTER BARS
   ============================================================ */

.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }

.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text3);
}

.search-input {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  padding: 8px 12px 8px 32px; font-size: 13px; color: var(--text); outline: none;
  transition: border-color 120ms var(--ease-out);
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }

.filter-select {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 8px 28px 8px 12px;
  font-size: 13px; color: var(--text); outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; cursor: pointer;
  transition: border-color 120ms var(--ease-out);
}
.filter-select:focus { border-color: var(--accent); }

.view-toggle {
  display: flex; background: var(--surface);
  border: 1px solid var(--border2); border-radius: var(--radius-sm); overflow: hidden;
}

.view-btn {
  padding: 7px 12px; background: transparent; border: none;
  color: var(--text2); font-size: 12px; cursor: pointer;
  transition: all 120ms var(--ease-out);
  display: flex; align-items: center; gap: 5px;
}
.view-btn.active { background: var(--accent-dim); color: var(--accent); }
.view-btn svg    { width: 13px; height: 13px; }

/* ============================================================
   SECTION HEADERS (inside page)
   ============================================================ */

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title  { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; color: var(--text3); text-align: center;
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3  { font-size: 15px; color: var(--text2); margin-bottom: 6px; }
.empty-state p   { font-size: 13px; line-height: 1.6; }

/* ============================================================
   BREADCRUMB
   ============================================================ */

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); margin-bottom: 16px; }
.breadcrumb a       { color: var(--accent); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep     { color: var(--text3); }

/* ============================================================
   LOADING SPINNER
   ============================================================ */

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */

.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border2); border-radius: 20px; cursor: pointer;
  transition: background 200ms; border: 1px solid var(--border);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 14px; height: 14px; left: 2px; top: 2px;
  background: var(--surface); border-radius: 50%;
  transition: all 200ms; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ============================================================
   MULTI-SELECT CHECKBOXES
   ============================================================ */

.checkbox-group { display: flex; flex-wrap: wrap; gap: 6px; }

.checkbox-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 12px; color: var(--text2); cursor: pointer;
  transition: all 120ms var(--ease-out); user-select: none;
}
.checkbox-pill input  { display: none; }
.checkbox-pill.checked { background: var(--accent-dim); border-color: var(--accent-mid); color: var(--accent); }

/* ============================================================
   HELPERS
   ============================================================ */

.hidden        { display: none !important; }
.text-accent   { color: var(--accent); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-muted    { color: var(--text2); }
.text-dim      { color: var(--text3); }
.fw-700        { font-weight: 600; }
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.mt-4          { margin-top: 4px; }
.mt-8          { margin-top: 8px; }
.mt-12         { margin-top: 12px; }
.mt-16         { margin-top: 16px; }
.mt-20         { margin-top: 20px; }
.mb-4          { margin-bottom: 4px; }
.mb-8          { margin-bottom: 8px; }
.mb-12         { margin-bottom: 12px; }
.mb-16         { margin-bottom: 16px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span-2 { grid-column: span 1; }
}

@media (max-width: 600px) {
  .page-content  { padding: 16px; }
  .topbar        { padding: 0 16px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .kanban-board  { flex-direction: column; }
  .kanban-col    { flex: none; width: 100%; }
  .filter-bar    { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   PHOTO GALLERY
   ============================================================ */

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 88px));
  gap: 6px;
}

.photo-thumb {
  position: relative; width: 88px; height: 88px;
  border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--border); flex-shrink: 0;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 200ms ease; }
.photo-thumb:hover img { transform: scale(1.05); }

.photo-thumb-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 6px; opacity: 0; transition: opacity 180ms ease;
}
.photo-thumb:hover .photo-thumb-overlay { opacity: 1; }
.photo-thumb-name { font-size: 10px; color: #fff; text-align: center; word-break: break-all; line-height: 1.3; }
.photo-gallery-empty { padding: 28px 0; text-align: center; color: var(--text3); font-size: 13px; }
.photo-delete-btn {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  background: rgba(220,38,38,0.85); color: #fff;
  border: none; border-radius: 50%;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  z-index: 5; padding: 0;
}
.photo-thumb:hover .photo-delete-btn { display: flex; }

/* Lightbox */
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.lightbox-overlay.hidden { display: none; }
.lightbox-img-wrap { position: relative; max-width: 88vw; max-height: 88vh; display: flex; align-items: center; justify-content: center; }
.lightbox-img-wrap img { max-width: 88vw; max-height: 82vh; border-radius: var(--radius); object-fit: contain; box-shadow: 0 24px 80px rgba(0,0,0,0.6); }

.lightbox-close {
  position: fixed; top: 20px; right: 24px;
  background: rgba(255,255,255,0.12); border: none; color: #fff;
  font-size: 22px; width: 38px; height: 38px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 150ms;
}
.lightbox-close:hover { background: rgba(255,255,255,0.24); }

.lightbox-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.12); border: none; color: #fff;
  font-size: 22px; width: 44px; height: 60px; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 150ms;
}
.lightbox-nav:hover     { background: rgba(255,255,255,0.24); }
.lightbox-nav.prev      { left: 16px; }
.lightbox-nav.next      { right: 16px; }
.lightbox-nav:disabled  { opacity: 0.25; cursor: default; }

.lightbox-counter {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); color: rgba(255,255,255,0.8);
  font-size: 12px; padding: 5px 14px; border-radius: 20px;
}

.lightbox-caption {
  position: fixed; bottom: 52px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.55); font-size: 11px;
  max-width: 60vw; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.photo-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm); padding: 20px; text-align: center;
  color: var(--text3); font-size: 12px; cursor: pointer;
  transition: border-color 150ms, color 150ms; margin-top: 10px;
}
.photo-upload-zone:hover { border-color: var(--accent-mid); color: var(--accent); }
.photo-upload-zone input { display: none; }

/* ============================================================
   FEED ITEMS — dashboard list rows (replaces raw inline divs)
   ============================================================ */

.feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.feed-item:last-child { border-bottom: none; }
a.feed-item:hover { background: var(--surface2); margin: 0 -20px; padding-left: 20px; padding-right: 20px; }

.feed-item-main { flex: 1; min-width: 0; }
.feed-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.feed-item:hover .feed-item-name { color: var(--accent); }
.feed-item-sub  { font-size: 11px; color: var(--text3); margin-top: 2px; }
.feed-item-value { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; flex-shrink: 0; }

/* ============================================================
   CLICKABLE TABLE ROWS
   ============================================================ */

tbody tr.has-link { cursor: pointer; }
tbody tr.has-link:hover { background: var(--surface2); }

/* Row sub-text (replaces inline style="font-size:11px;color:var(--text3)") */
.row-sub  { font-size: 11px; color: var(--text3); margin-top: 2px; }
.row-date { font-size: 12px; color: var(--text2); }

/* ============================================================
   COLUMN RESIZE GRIPS
   ============================================================ */

.th-inner  { display: flex; align-items: center; gap: 0; }

.col-grip {
  display: inline-block; flex-shrink: 0;
  width: 5px; align-self: stretch; min-height: 18px;
  margin-left: 6px; background: var(--border); border-radius: 3px;
  cursor: col-resize; opacity: 0.6;
  transition: background 120ms, opacity 120ms;
}
.col-grip:hover { background: var(--accent); opacity: 1; }
