/* ============================
   VARIABLES & RESET
   ============================ */
:root {
  --primary: #059669;
  --primary-dark: #047857;
  --primary-light: #D1FAE5;
  --primary-50: #ECFDF5;
  --secondary: #10B981;
  --accent: #34D399;

  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-input: #F1F5F9;

  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --text-on-primary: #FFFFFF;

  --border: #E2E8F0;
  --border-focus: #059669;

  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  --success: #059669;
  --success-light: #D1FAE5;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.06);

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --sidebar-w: 260px;
  --header-h: 64px;
  --nav-h: 64px;

  --transition: 0.2s ease;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ============================
   LAYOUT - MOBILE FIRST
   ============================ */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Header móvil */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

.header-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
}

.header-search {
  flex: 1;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}

.header-search input:focus {
  border-color: var(--border-focus);
  background: white;
}

.header-search .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

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

/* Bottom nav (móvil) */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  transition: color var(--transition);
  min-width: 56px;
}

.nav-item svg { width: 22px; height: 22px; }

.nav-item.active { color: var(--primary); }

.nav-item.active svg { stroke: var(--primary); }

/* Sidebar (desktop) */
.sidebar {
  display: none;
}

/* Main content */
.main-content {
  margin-top: var(--header-h);
  margin-bottom: var(--nav-h);
  padding: 16px;
  flex: 1;
}

/* Desktop layout */
@media (min-width: 768px) {
  .bottom-nav { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100dvh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    z-index: 200;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
  }

  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--primary);
  }

  .sidebar-logo .logo-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
  }

  .sidebar-nav { flex: 1; padding: 0 12px; }

  .sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    width: 100%;
    text-align: left;
    transition: all var(--transition);
    margin-bottom: 4px;
  }

  .sidebar-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

  .sidebar-nav-item:hover {
    background: var(--primary-50);
    color: var(--primary);
  }

  .sidebar-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
  }

  .app-header {
    left: var(--sidebar-w);
    padding: 0 24px;
  }

  .main-content {
    margin-left: var(--sidebar-w);
    margin-bottom: 0;
    padding: 24px;
  }
}

/* Window Controls Overlay — elimina la franja negra del OS en PWA de escritorio */
@media (display-mode: window-controls-overlay) {
  /* Header funciona como barra de título arrastrable */
  .app-header {
    -webkit-app-region: drag;
    padding-right: max(env(titlebar-area-inset-right, 0px), 16px);
  }
  /* Los hijos del header siguen siendo clicables */
  .app-header > * { -webkit-app-region: no-drag; }
  /* Zona del logo del sidebar también es arrastrable */
  .sidebar { -webkit-app-region: drag; }
  .sidebar * { -webkit-app-region: no-drag; }
}

/* ============================
   CARDS
   ============================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

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

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

/* ============================
   STAT CARDS (Dashboard)
   ============================ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(5, 1fr); gap: 16px; }
}

/* 5ª card sola en su fila en móvil → ocupa el ancho completo */
@media (max-width: 767px) {
  .stats-grid > .stat-card:last-child:nth-child(odd) { grid-column: span 2; }
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
  user-select: none;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}

.stat-card:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-arrow {
  position: absolute;
  top: 14px;
  right: 14px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .18s ease, transform .18s ease;
  color: var(--text-light);
  font-size: 1rem;
  line-height: 1;
}

.stat-card:hover .stat-arrow {
  opacity: 1;
  transform: translateX(0);
}

.stat-card .stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 2px;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ============================
   BUTTONS
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active { transform: none; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }

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

.btn-wa {
  background: #25D366;
  color: white;
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: 0.8rem;
}
.btn-wa:hover { background: #128C7E; transform: scale(1.03); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-muted);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); }
.btn-icon svg { width: 16px; height: 16px; }

/* FAB */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 16px;
  width: 52px; height: 52px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 99;
  transition: all var(--transition);
}

.fab:hover { background: var(--primary-dark); transform: scale(1.08); }
.fab svg { width: 24px; height: 24px; }

@media (min-width: 768px) {
  .fab { bottom: 24px; right: 24px; }
}

/* ============================
   FORMS
   ============================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-control {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  transition: all var(--transition);
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--border-focus);
  background: white;
  box-shadow: 0 0 0 3px rgba(5,150,105,.1);
}

.form-control::placeholder { color: var(--text-light); }

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' fill='none' viewBox='0 0 24 24' stroke='%2364748B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }

.form-hint { font-size: 0.75rem; color: var(--text-light); }
.form-error { font-size: 0.75rem; color: var(--danger); }

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

/* ============================
   AUTOCOMPLETE
   ============================ */
.autocomplete-wrap { position: relative; }

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  transition: background var(--transition);
}

.autocomplete-item:hover, .autocomplete-item.focused { background: var(--primary-50); }

.autocomplete-item .item-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
}

.autocomplete-create {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-weight: 500;
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
  transition: background var(--transition);
}

.autocomplete-create:hover { background: var(--primary-50); }

/* ============================
   MODAL
   ============================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .2s ease;
}

@media (min-width: 768px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp .25s ease;
  overflow: hidden;
}

@media (min-width: 768px) {
  .modal {
    border-radius: var(--radius-lg);
    max-height: 88dvh;
    animation: scaleIn .2s ease;
  }
}

.modal-sm { max-width: 380px; }
.modal-lg { max-width: 700px; }

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

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ============================
   BADGES / STATUS
   ============================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.badge-pending   { background: var(--warning-light); color: #92400E; }
.badge-partial   { background: var(--info-light);    color: #1E40AF; }
.badge-paid      { background: var(--success-light); color: var(--success); }
.badge-overdue   { background: var(--danger-light);  color: var(--danger); }

.badge-order-pending    { background: #FEF3C7; color: #92400E; }
.badge-order-in_progress{ background: var(--info-light); color: #1E40AF; }
.badge-order-ready      { background: var(--primary-light); color: var(--primary); }
.badge-order-delivered  { background: var(--success-light); color: var(--success); }
.badge-order-cancelled  { background: #F1F5F9; color: var(--text-muted); }

/* ============================
   LIST ITEMS
   ============================ */
.list-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.item-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.item-card.overdue { border-left: 3px solid var(--danger); }
.item-card.paid    { border-left: 3px solid var(--primary); }

/* Countdown timer on order cards */
.order-countdown {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  width: fit-content;
}
.order-countdown.ok      { background: var(--success-light); color: var(--success); }
.order-countdown.warning { background: #FEF3C7; color: #92400E; }
.order-countdown.urgent  { background: var(--danger-light);  color: var(--danger);
  animation: pulse-urgent 1s ease-in-out infinite; }
.order-countdown.overdue { background: var(--danger); color: #fff;
  animation: pulse-urgent 1.2s ease-in-out infinite; }
@keyframes pulse-urgent {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

.item-avatar {
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}

.item-avatar.danger { background: var(--danger-light); color: var(--danger); }
.item-avatar.warning{ background: var(--warning-light); color: var(--warning); }
.item-avatar.info   { background: var(--info-light); color: var(--info); }
.item-avatar.order  { background: #EDE9FE; color: #6D28D9; }

.item-body { flex: 1; min-width: 0; }

.item-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.item-amount {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.item-amount.danger { color: var(--danger); }
.item-amount.success { color: var(--primary); }

/* ============================
   TABS
   ============================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-btn:hover:not(.active) { color: var(--text); }

/* ============================
   ORDERS - ITEMS TABLE
   ============================ */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.items-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-input);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  border-radius: 4px;
}

.items-table td {
  padding: 8px 10px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.items-table tr:last-child td { border-bottom: none; }

.items-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--bg-input);
  outline: none;
  transition: border-color var(--transition);
}

.items-table input:focus { border-color: var(--border-focus); background: white; }

.items-table .col-name { min-width: 120px; }
.items-table .col-qty  { width: 70px; }
.items-table .col-price{ width: 90px; }
.items-table .col-sub  { width: 90px; text-align: right; font-weight: 600; }
.items-table .col-act  { width: 36px; }

@media (max-width: 767px) {
  .items-table thead { display: none; }

  .items-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 10px;
    margin-bottom: 10px;
    background: var(--bg-card);
  }

  .items-table td {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-light);
    width: 100%;
    text-align: left !important;
  }

  .items-table tbody tr:last-child td:last-child,
  .items-table td.col-act { border-bottom: none; }

  .items-table td[data-label]::before {
    content: attr(data-label);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    min-width: 88px;
    flex-shrink: 0;
  }

  .items-table td > input { flex: 1; min-width: 0; }
  .items-table .col-qty,
  .items-table .col-price { width: auto; }
  .items-table .col-sub   { font-weight: 700; }
  .items-table .col-act   { justify-content: flex-end; }
}

.order-total-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 0;
  border-top: 2px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
}

/* ============================
   NOTES GRID
   ============================ */
.notes-grid {
  columns: 2;
  gap: 12px;
}

@media (min-width: 768px) { .notes-grid { columns: 3; } }
@media (min-width: 1200px) { .notes-grid { columns: 4; } }

.note-card {
  break-inside: avoid;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.note-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.note-card.pinned::before {
  content: '📌';
  position: absolute;
  top: 10px; right: 10px;
  font-size: 0.85rem;
}

.note-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.note-content {
  font-size: 0.82rem;
  line-height: 1.55;
  opacity: .85;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
}

.note-footer {
  margin-top: 12px;
  font-size: 0.72rem;
  opacity: .65;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================
   NOTE COLORS
   ============================ */
.note-yellow  { background: #FFFBEB; border-color: #FDE68A; }
.note-green   { background: #ECFDF5; border-color: #A7F3D0; }
.note-blue    { background: #EFF6FF; border-color: #BFDBFE; }
.note-pink    { background: #FFF1F2; border-color: #FECDD3; }
.note-purple  { background: #FAF5FF; border-color: #E9D5FF; }
.note-orange  { background: #FFF7ED; border-color: #FED7AA; }
.note-white   { background: #FFFFFF; border-color: #E2E8F0; }

/* ============================
   SEARCH RESULT OVERLAY
   ============================ */
.search-results {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 99;
  max-height: 60dvh;
  overflow-y: auto;
  padding: 12px;
}

@media (min-width: 768px) {
  .search-results {
    left: var(--sidebar-w);
    margin: 8px 24px;
    top: 70px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
  }
}

.search-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 8px 4px 4px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover { background: var(--primary-50); }

/* ============================
   PAGE HEADER
   ============================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.page-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================
   FILTERS
   ============================ */
.filters-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: white;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.filter-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.filter-chip:hover:not(.active) { border-color: var(--text-muted); color: var(--text); }

/* ============================
   EMPTY STATE
   ============================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 12px;
}

.empty-state svg {
  width: 64px; height: 64px;
  color: var(--text-light);
  opacity: .6;
}

.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.empty-state p  { font-size: 0.85rem; color: var(--text-light); max-width: 260px; }

/* ============================
   TOAST
   ============================ */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  right: 16px;
  left: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 768px) {
  #toast-container {
    left: auto;
    bottom: 24px;
    right: 24px;
    min-width: 300px;
    max-width: 380px;
  }
}

.toast {
  background: var(--text);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight .3s ease;
  pointer-events: all;
}

.toast.success { background: var(--primary); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ============================
   PROGRESS BAR (deudas)
   ============================ */
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width .5s ease;
}

.progress-fill.danger { background: var(--danger); }

/* ============================
   CLIENT DETAIL
   ============================ */
.client-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.client-avatar-lg {
  width: 64px; height: 64px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  flex-shrink: 0;
}

.client-info { flex: 1; min-width: 0; }
.client-name { font-size: 1.2rem; font-weight: 700; }
.client-phone { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }
.client-stats { display: flex; gap: 16px; margin-top: 8px; }
.client-stat { font-size: 0.78rem; color: var(--text-muted); }
.client-stat b { color: var(--text); }

.client-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* ============================
   ORDER STATUS TIMELINE
   ============================ */
.status-timeline {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 12px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 60px;
}

.status-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  z-index: 1;
}

.status-dot svg { width: 13px; height: 13px; color: var(--text-light); }
.status-dot.done { background: var(--primary); border-color: var(--primary); }
.status-dot.done svg { color: white; }
.status-dot.current { background: var(--primary-light); border-color: var(--primary); }
.status-dot.current svg { color: var(--primary); }

.status-line {
  height: 2px;
  flex: 1;
  background: var(--border);
  min-width: 20px;
}

.status-line.done { background: var(--primary); }

.status-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.status-label.active { color: var(--primary); font-weight: 600; }

/* ============================
   PAYMENT SECTION
   ============================ */
.payment-info {
  background: var(--primary-50);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 12px;
}

.payment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.payment-row:last-child { margin-bottom: 0; }
.payment-row .label { color: var(--text-muted); }
.payment-row .value { font-weight: 600; }
.payment-row.total .value { font-size: 1.1rem; color: var(--primary); }
.payment-row.remaining .value { color: var(--danger); }

/* ============================
   ANIMATIONS
   ============================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ============================
   SCROLLBAR CUSTOM
   ============================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ============================
   UTILS
   ============================ */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.flex     { display: flex; }
.flex-1   { flex: 1; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2   { gap: 8px; }
.gap-3   { gap: 12px; }
.mt-4    { margin-top: 16px; }
.mb-4    { margin-bottom: 16px; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.font-bold  { font-weight: 700; }
.w-full  { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
