:root {
  --primary: #02825a;
  --primary-hover: #036b4a;
  --primary-light: #d1fae5;
  --primary-50: #ecfdf5;
  --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;
  --red: #ef4444;
  --green: #22c55e;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; background: var(--gray-900); color: white;
  padding: 24px 16px; display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 800; margin-bottom: 32px; padding: 0 8px;
}
.sidebar .brand svg { flex-shrink: 0; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--gray-400);
  font-size: 14px; font-weight: 500; transition: all 0.15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); color: white; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: white; }
.sidebar nav a i { width: 20px; text-align: center; font-size: 16px; }
.sidebar .user-info {
  padding: 12px 8px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px; color: var(--gray-400); margin-top: auto;
}
.sidebar .user-info .name { color: white; font-weight: 600; }

/* Hamburger menu toggle (mobile) */
.menu-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 1001;
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: var(--primary); color: white; font-size: 20px;
  cursor: pointer; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 998;
}
.main { flex: 1; padding: 24px 32px; max-width: calc(100vw - 260px); }
.main-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.main-header h1 { font-size: 24px; font-weight: 700; }

/* Cards */
.card {
  background: white; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--gray-100);
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-header .badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 20px; }

/* Stats */
.stat-card { text-align: center; padding: 20px; }
.stat-card .value { font-size: 32px; font-weight: 800; color: var(--gray-900); }
.stat-card .label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  font-family: inherit; border: none; cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  transition: border-color 0.2s; outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2,130,90,0.1);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th {
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-100);
}
table td { padding: 10px 12px; font-size: 14px; border-bottom: 1px solid var(--gray-100); }
table tr:hover td { background: var(--gray-50); }

/* Status badges */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
}
.status-stock { background: var(--gray-100); color: var(--gray-600); }
.status-vendido { background: #dcfce7; color: #166534; }
.status-rentado { background: #dbeafe; color: #1e40af; }
.status-reparacion { background: #fef3c7; color: #92400e; }
.status-completada { background: #dcfce7; color: #166534; }
.status-pendiente { background: #fef3c7; color: #92400e; }
.status-en_proceso { background: #dbeafe; color: #1e40af; }
.status-cancelada { background: #fee2e2; color: #991b1b; }

/* Alerts */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal {
  background: white; border-radius: var(--radius); padding: 32px;
  width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
}
.modal h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: var(--gray-200);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -20px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2px solid white;
}
.timeline-item .date { font-size: 12px; color: var(--gray-400); }
.timeline-item .desc { font-size: 14px; color: var(--gray-700); margin-top: 2px; }

/* QR sticker preview */
.qr-sticker {
  display: inline-block; border: 2px dashed var(--gray-300);
  padding: 12px; border-radius: var(--radius-sm); text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
  .menu-toggle { display: flex; }
  .sidebar { display: none; position: fixed; top: 0; left: 0; z-index: 999;
    width: 280px; height: 100vh; transform: translateX(-100%);
    transition: transform 0.3s ease; }
  .sidebar.open { display: flex; transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main { max-width: 100vw; padding: 16px; padding-top: 60px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* PWA */
@media (display-mode: standalone) {
  .sidebar { padding-top: 48px; }
}
