/* ============================================================
   DevisFlow — Design System
   Inspiré de Linear / Stripe / Notion
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:       #6366f1;
  --primary-hover: #4f46e5;
  --primary-50:    #eef2ff;
  --primary-100:   #e0e7ff;

  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --success:       #10b981;
  --success-light: #d1fae5;
  --success-dark:  #065f46;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --warning-dark:  #92400e;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --danger-dark:   #991b1b;
  --info:          #3b82f6;
  --info-light:    #dbeafe;
  --info-dark:     #1d4ed8;
  --purple:        #8b5cf6;
  --purple-light:  #ede9fe;

  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --border-strong: #cbd5e1;
  --text:       #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;

  --sidebar-w:  240px;
  --header-h:   60px;
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --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,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  --transition: 150ms ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ============================================================
   Layout
   ============================================================ */
#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform var(--transition);
}
#sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.logo-text { font-size: 15px; font-weight: 700; color: var(--text); }
.logo-badge { font-size: 10px; background: var(--primary-50); color: var(--primary); padding: 1px 6px; border-radius: var(--radius-full); font-weight: 600; margin-left: 4px; }

#sidebar-nav { flex: 1; padding: 12px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 6px; }
.nav-section-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); padding: 8px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: var(--gray-100); color: var(--text); }
.nav-item.active { background: var(--primary-50); color: var(--primary); }
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: var(--radius-full);
  min-width: 18px; text-align: center;
}

#sidebar-user {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.user-card:hover { background: var(--gray-100); }
.avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main wrapper */
#main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Header */
#header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 40;
}
#header-title {
  font-size: 16px; font-weight: 600;
  flex: 1;
  min-width: 0;
}
#search-wrap {
  flex: 1; max-width: 360px;
  position: relative;
}
#search-input {
  width: 100%;
  padding: 7px 12px 7px 36px;
  background: var(--gray-100);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
#search-input:focus { background: var(--surface); border-color: var(--primary); }
#search-input::placeholder { color: var(--text-3); }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
#header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--gray-100); color: var(--text); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* Mobile menu toggle */
#menu-toggle { display: none; }

/* Page content */
#page-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   Page header
   ============================================================ */
.page-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px;
}
.page-title { font-size: 22px; font-weight: 700; flex: 1; }
.page-subtitle { font-size: 14px; color: var(--text-2); margin-top: 2px; }

/* ============================================================
   Cards / Surface
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text); }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-delta { font-size: 12px; margin-top: 6px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ============================================================
   Status Badges
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-draft    { background: var(--gray-100); color: var(--gray-600); }
.badge-draft::before { background: var(--gray-400); }
.badge-sent     { background: var(--info-light); color: var(--info-dark); }
.badge-sent::before { background: var(--info); }
.badge-viewed   { background: var(--purple-light); color: #5b21b6; }
.badge-viewed::before { background: var(--purple); }
.badge-accepted { background: var(--success-light); color: var(--success-dark); }
.badge-accepted::before { background: var(--success); }
.badge-refused  { background: var(--danger-light); color: var(--danger-dark); }
.badge-refused::before { background: var(--danger); }
.badge-expired  { background: var(--warning-light); color: var(--warning-dark); }
.badge-expired::before { background: var(--warning); }
.badge-success  { background: var(--success-light); color: var(--success-dark); }
.badge-success::before { background: var(--success); }
.badge-danger   { background: var(--danger-light); color: var(--danger-dark); }
.badge-danger::before { background: var(--danger); }

/* Temperature badges */
.temp-cold { background: #dbeafe; color: #1d4ed8; }
.temp-warm { background: #fed7aa; color: #c2410c; }
.temp-hot  { background: #fecaca; color: #b91c1c; }
.temp-vip  { background: #fef9c3; color: #a16207; }

/* AI score */
.ai-score {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-full);
}
.ai-score.high   { background: var(--success-light); color: var(--success-dark); }
.ai-score.medium { background: var(--warning-light); color: var(--warning-dark); }
.ai-score.low    { background: var(--danger-light); color: var(--danger-dark); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  cursor: pointer; border: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 2px 8px rgba(99,102,241,.35); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-icon { padding: 8px; }
.btn-icon.btn-sm { padding: 6px; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px; color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.form-control::placeholder { color: var(--text-3); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-help { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-control.error { border-color: var(--danger); }

/* ============================================================
   Table
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table, .data-table { width: 100%; border-collapse: collapse; background: var(--surface); }
thead tr { background: var(--gray-50); border-bottom: 1px solid var(--border); }
th { padding: 11px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
td { padding: 13px 16px; font-size: 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--gray-50); }
.td-mono { font-variant-numeric: tabular-nums; }
.th-right, .td-right { text-align: right; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============================================================
   Kanban / Pipeline
   ============================================================ */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
  min-height: 400px;
}
.kanban-col {
  min-width: 240px;
  flex-shrink: 0;
  background: var(--gray-50);
  border-radius: var(--radius-lg);
  padding: 12px;
  border: 1px solid var(--border);
}
.kanban-col-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.kanban-col-label { font-size: 13px; font-weight: 600; flex: 1; }
.kanban-col-count {
  font-size: 11px; font-weight: 600;
  background: var(--border); color: var(--text-2);
  padding: 2px 7px; border-radius: var(--radius-full);
}
.kanban-cards { display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.kanban-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.kanban-card-client { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; }
.kanban-card-amount { font-size: 13px; font-weight: 700; color: var(--text); }
.kanban-card-date { font-size: 11px; color: var(--text-3); }

/* ============================================================
   Timeline
   ============================================================ */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute; left: 7px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -24px; top: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.timeline-dot.created  { border-color: var(--gray-400); }
.timeline-dot.sent     { border-color: var(--info); background: var(--info); }
.timeline-dot.viewed   { border-color: var(--purple); background: var(--purple); }
.timeline-dot.accepted { border-color: var(--success); background: var(--success); }
.timeline-dot.refused  { border-color: var(--danger); background: var(--danger); }
.timeline-dot.reminded { border-color: var(--warning); background: var(--warning); }
.timeline-dot.note_added { border-color: var(--primary); background: var(--primary); }
.timeline-time { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.timeline-desc { font-size: 13px; color: var(--text-2); }

/* ============================================================
   Empty states
   ============================================================ */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-desc { font-size: 14px; color: var(--text-2); max-width: 340px; margin-bottom: 20px; }

/* ============================================================
   Modal
   ============================================================ */
#modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 100;
  align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
#modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.05);
  animation: modal-in .15s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(4px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.modal-lg  { max-width: 760px; }
.modal-xl  { max-width: 960px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-title { font-size: 17px; font-weight: 700; flex: 1; }
.modal-close { color: var(--text-3); transition: color var(--transition); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ============================================================
   Toast
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px; max-width: 380px;
  pointer-events: all;
  animation: toast-in .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.success { background: #064e3b; border-left: 3px solid var(--success); }
.toast.error   { background: #7f1d1d; border-left: 3px solid var(--danger); }
.toast.warning { background: #78350f; border-left: 3px solid var(--warning); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.toast-msg { font-size: 12px; opacity: .8; }

/* ============================================================
   Auth pages
   ============================================================ */
#auth-container {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-50) 0%, #ffffff 60%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 44px; height: 44px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 800;
}
.auth-logo-name { font-size: 22px; font-weight: 800; }
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 28px; }
.auth-divider { text-align: center; font-size: 12px; color: var(--text-3); margin: 20px 0; position: relative; }
.auth-divider::before {
  content: '';
  position: absolute; top: 50%; left: 0; right: 0; height: 1px;
  background: var(--border);
}
.auth-divider span { background: var(--surface); padding: 0 12px; position: relative; }
.auth-link { color: var(--primary); font-weight: 500; cursor: pointer; }
.auth-link:hover { text-decoration: underline; }

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}
.dashboard-grid .card-full { grid-column: 1 / -1; }
.chart-wrap { height: 220px; position: relative; }

/* ============================================================
   Quote form — items table
   ============================================================ */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 0; }
.items-table th { padding: 8px 10px; font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--gray-50); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.items-table td { padding: 6px 6px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.items-table .item-input { width: 100%; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; font-size: 13px; transition: border-color var(--transition), background var(--transition); }
.items-table .item-input:focus { border-color: var(--primary); background: var(--surface); outline: none; }
.items-table .item-input:hover { background: var(--gray-50); }
.item-total { font-size: 13px; font-weight: 600; color: var(--text); text-align: right; padding-right: 10px; }
.add-item-btn { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); padding: 8px 12px; margin-top: 4px; border-radius: var(--radius); }
.add-item-btn:hover { background: var(--primary-50); }
.quote-totals { min-width: 280px; margin-left: auto; }
.total-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.total-line.subtotal { color: var(--text-2); }
.total-line.discount { color: var(--success); }
.total-line.tva { color: var(--text-2); }
.total-line.grand { font-size: 18px; font-weight: 700; color: var(--primary); border-top: 2px solid var(--primary); padding-top: 10px; margin-top: 4px; }

/* ============================================================
   Signature pad
   ============================================================ */
.sig-pad-wrap {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  padding: 4px;
  cursor: crosshair;
}
#signature-canvas { display: block; border-radius: var(--radius); }

/* ============================================================
   Filters / Tabs
   ============================================================ */
.filter-tabs {
  display: flex; gap: 4px;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
}
.filter-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.filter-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.filter-tab:hover:not(.active) { color: var(--text); }
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px; background: var(--surface);
  color: var(--text); outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}

/* ============================================================
   Notifications
   ============================================================ */
.notif-list { display: flex; flex-direction: column; }
.notif-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: var(--primary-50); }
.notif-item.unread:hover { background: var(--primary-100); }
.notif-dot-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 5px; }
.notif-dot-indicator.read { background: transparent; }
.notif-body { flex: 1; }
.notif-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.notif-msg { font-size: 13px; color: var(--text-2); }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ============================================================
   Public quote page
   ============================================================ */
.public-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 32px 20px;
}
.public-quote-card {
  max-width: 760px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.public-quote-header {
  padding: 32px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
  background: linear-gradient(135deg, var(--primary-50), white);
}
.public-quote-body { padding: 32px; }
.public-actions {
  display: flex; gap: 12px; margin-top: 32px; justify-content: center;
}
.public-actions .btn { min-width: 160px; justify-content: center; }

/* ============================================================
   Responsiveness
   ============================================================ */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  #main-wrapper { margin-left: 0; }
  #menu-toggle { display: flex; }
  #page-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  #search-wrap { display: none; }
  .page-header { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
}

/* ============================================================
   Utilities
   ============================================================ */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; color: var(--text-3);
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sidebar overlay for mobile */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 49;
}

/* ============================================================
   Autocomplete / Dropdown
   ============================================================ */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
}
.autocomplete-dropdown .ac-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.autocomplete-dropdown .ac-item:last-child { border-bottom: none; }
.autocomplete-dropdown .ac-item:hover { background: var(--gray-50); }
.autocomplete-dropdown .ac-item strong { display: block; color: var(--text); }
.autocomplete-dropdown .ac-item small { color: var(--text-3); }
.autocomplete-dropdown .ac-empty { padding: 10px 12px; font-size: 13px; color: var(--text-3); text-align: center; }

/* Product picker modal */
.product-picker-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.product-picker-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.product-picker-modal .picker-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.product-picker-modal .picker-body { flex: 1; overflow-y: auto; padding: 12px; }
.product-picker-modal .picker-search { padding: 12px 20px 0; }
.product-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex; align-items: center; gap: 12px;
}
.product-card:hover { border-color: var(--primary); background: var(--primary-50); }
.product-card .pc-name { font-weight: 500; font-size: 14px; }
.product-card .pc-meta { font-size: 12px; color: var(--text-3); }
.product-card .pc-price { margin-left: auto; font-weight: 600; font-size: 14px; color: var(--primary); white-space: nowrap; }

/* Admin page */
.plan-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600;
}
.plan-free { background: var(--gray-100); color: var(--gray-600); }
.plan-starter { background: var(--info-light); color: var(--info-dark); }
.plan-pro { background: var(--purple-light); color: #5b21b6; }
.plan-unlimited { background: var(--success-light); color: var(--success-dark); }

/* Products page */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.product-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.product-item:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.product-item .pi-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.product-item .pi-cat { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); margin-bottom: 8px; }
.product-item .pi-desc { font-size: 13px; color: var(--text-2); margin-bottom: 12px; min-height: 18px; }
.product-item .pi-price { font-size: 20px; font-weight: 700; color: var(--text); }
.product-item .pi-unit { font-size: 12px; color: var(--text-3); }
.product-item .pi-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
#sidebar-overlay.open { display: block; }
