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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --dark: #1e293b;
  --gray: #64748b;
  --light-gray: #f1f5f9;
  --border: #e2e8f0;
  --white: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: .2s ease;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--dark);
  background: var(--light-gray);
  min-height: 100vh;
}

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

img { max-width: 100%; display: block; }

/* ─── Typography ────────────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ─── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 20px; max-width: 1200px; margin: 0 auto;
}
.navbar-brand {
  font-size: 1.25rem; font-weight: 800; color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.navbar-brand svg { width: 28px; height: 28px; }
.navbar-nav { display: flex; align-items: center; gap: 4px; }
.navbar-nav a {
  color: var(--gray); padding: 6px 10px; flex-shrink: 0; min-width: 60px; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; transition: var(--transition);
}
.navbar-nav a:hover, .navbar-nav a.active {
  color: var(--primary); background: var(--primary-light); text-decoration: none;
}
.navbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; cursor: pointer;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-menu {
  position: relative;
}
.user-menu-dropdown {
  position: absolute; right: 0; top: 42px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  min-width: 180px; padding: 6px; display: none; z-index: 200;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown a, .user-menu-dropdown button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; border-radius: var(--radius);
  color: var(--dark); font-size: .9rem; background: none; border: none;
  cursor: pointer; text-decoration: none; transition: var(--transition);
}
.user-menu-dropdown a:hover, .user-menu-dropdown button:hover {
  background: var(--light-gray); text-decoration: none;
}
.user-menu-dropdown .separator {
  height: 1px; background: var(--border); margin: 4px 0;
}

/* ─── Page Layout ───────────────────────────────────────────────────────────── */
.page { padding: 24px 0 60px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--dark); }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  background: var(--light-gray);
}

/* ─── Stat Cards ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat-card .stat-label {
  font-size: .8rem; font-weight: 600; color: var(--gray);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 1.75rem; font-weight: 800; color: var(--dark);
}
.stat-card .stat-value.success { color: var(--success); }
.stat-card .stat-value.warning { color: var(--warning); }
.stat-card .stat-value.primary { color: var(--primary); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); font-size: .9rem; font-weight: 600;
  border: none; cursor: pointer; transition: var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--light-gray); color: var(--dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* FAB - Floating Action Button */
.fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); cursor: pointer; border: none;
  transition: var(--transition); font-size: 1.5rem;
}
.fab:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .875rem; font-weight: 600; color: var(--dark);
  margin-bottom: 6px;
}
.form-label span.required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .9rem; color: var(--dark);
  background: var(--white); transition: var(--transition); outline: none;
  font-family: var(--font);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control.error { border-color: var(--danger); }
.form-select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .9rem; color: var(--dark);
  background: var(--white); transition: var(--transition); outline: none;
  cursor: pointer; font-family: var(--font);
}
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .78rem; color: var(--gray); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 4px; }

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

/* ─── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--light-gray); }
th {
  padding: 10px 12px; text-align: left; font-size: .8rem;
  font-weight: 700; color: var(--gray); text-transform: uppercase;
  letter-spacing: .05em; border-bottom: 2px solid var(--border);
}
td {
  padding: 12px; border-bottom: 1px solid var(--border);
  font-size: .9rem; color: var(--dark);
}
tbody tr:hover { background: var(--light-gray); }
tbody tr:last-child td { border-bottom: none; }

/* ─── Status Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.badge-borrador { background: #f1f5f9; color: var(--gray); }
.badge-enviado { background: #fef3c7; color: var(--warning); }
.badge-aceptado { background: #dcfce7; color: var(--success); }
.badge-rechazado { background: #fee2e2; color: var(--danger); }
.badge-expirado { background: #f1f5f9; color: #94a3b8; }

/* ─── Auth Pages ────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-light) 0%, #e0f2fe 100%);
  padding: 20px;
}
.auth-card {
  background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px; padding: 40px;
}
.auth-logo {
  text-align: center; margin-bottom: 28px;
}
.auth-logo .brand-text {
  font-size: 1.6rem; font-weight: 800; color: var(--primary);
}
.auth-logo .tagline {
  font-size: .85rem; color: var(--gray); margin-top: 4px;
}
.auth-tabs {
  display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 10px; text-align: center; cursor: pointer;
  font-weight: 600; font-size: .9rem; color: var(--gray);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: var(--transition);
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Quote Lines ───────────────────────────────────────────────────────────── */
.lines-table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}
.lines-table th {
  background: var(--primary); color: white; padding: 8px 10px;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  font-weight: 700;
}
.lines-table td { padding: 6px 4px; vertical-align: middle; }
.lines-table td input, .lines-table td select {
  width: 100%; padding: 6px 8px; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .85rem; color: var(--dark);
  background: var(--white); outline: none; font-family: var(--font);
}
.lines-table td input:focus, .lines-table td select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.1);
}
.lines-table .btn-remove {
  background: none; border: none; color: var(--danger);
  cursor: pointer; padding: 4px; border-radius: 4px; font-size: 1rem;
  display: flex; align-items: center;
}
.lines-table .btn-remove:hover { background: #fee2e2; }
.lines-table .line-total { font-weight: 700; color: var(--dark); white-space: nowrap; }

.quote-totals {
  background: var(--light-gray); border-radius: var(--radius); padding: 16px;
  min-width: 260px;
}
.quote-totals .total-row {
  display: flex; justify-content: space-between; padding: 4px 0; font-size: .9rem;
}
.quote-totals .total-row.grand {
  font-size: 1.2rem; font-weight: 800; color: var(--primary);
  border-top: 2px solid var(--border); margin-top: 8px; padding-top: 10px;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: .9rem; display: flex; align-items: flex-start; gap: 10px;
}
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.alert-info { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }

/* ─── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--gray);
}
.empty-state svg { width: 64px; height: 64px; opacity: .4; margin: 0 auto 16px; }
.empty-state h3 { color: var(--dark); margin-bottom: 8px; }

/* ─── Loading ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; z-index: 500; overflow-y: auto;
}
.modal {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  margin: auto;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.btn-close {
  background: none; border: none; cursor: pointer; color: var(--gray);
  font-size: 1.25rem; line-height: 1; padding: 2px;
}
.btn-close:hover { color: var(--dark); }

/* ─── Upload area ───────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: var(--transition); position: relative;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-preview {
  width: 100px; height: 100px; border-radius: var(--radius);
  object-fit: contain; margin: 0 auto; border: 1px solid var(--border);
}

/* ─── Plan Badge ────────────────────────────────────────────────────────────── */
.plan-badge {
  font-size: .7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: .05em;
}
.plan-beta { background: #fef3c7; color: #92400e; }
.plan-starter { background: #dbeafe; color: #1e40af; }
.plan-pro { background: #fce7f3; color: #9d174d; }

/* ─── Toast notifications ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.toast {
  background: var(--dark); color: white; padding: 12px 20px;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: .875rem; animation: slideUp .3s ease;
  display: flex; align-items: center; gap: 8px; max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Search ────────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex; gap: 8px; align-items: center;
}
.search-bar input {
  flex: 1; padding: 8px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .9rem; outline: none;
  font-family: var(--font); transition: var(--transition);
}
.search-bar input:focus { border-color: var(--primary); }

/* ─── Action menus ──────────────────────────────────────────────────────────── */
.actions-cell { display: flex; gap: 4px; align-items: center; }
.action-btn {
  background: none; border: none; cursor: pointer; padding: 5px;
  border-radius: var(--radius); color: var(--gray); font-size: .85rem;
  transition: var(--transition); display: inline-flex; align-items: center;
}
.action-btn:hover { background: var(--light-gray); color: var(--dark); }
.action-btn.danger:hover { background: #fee2e2; color: var(--danger); }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .navbar-nav { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 24px; }
  th, td { padding: 8px; font-size: .8rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}

/* ─── Dropdown select for status ────────────────────────────────────────────── */
.status-select {
  padding: 4px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .8rem; cursor: pointer;
  background: white; font-family: var(--font);
}

/* ─── Mobile nav ────────────────────────────────────────────────────────────── */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-top: 1px solid var(--border);
  padding: 8px 0 env(safe-area-inset-bottom); z-index: 90;
}
.mobile-nav-inner { display: flex; justify-content: flex-start; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; padding: 0 4px; scrollbar-width: none; } .mobile-nav-inner::-webkit-scrollbar { display: none; }
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--gray); font-size: .7rem; font-weight: 600;
  padding: 6px 10px; flex-shrink: 0; min-width: 60px; border-radius: var(--radius);
  text-decoration: none; transition: var(--transition);
}
.mobile-nav-item.active, .mobile-nav-item:hover {
  color: var(--primary); text-decoration: none;
}
.mobile-nav-item svg { width: 22px; height: 22px; }
@media (max-width: 768px) {
  .mobile-nav { display: block; }
  .page { padding-bottom: 80px; }
  .fab { bottom: 80px; }
}

/* ─── Misc ──────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--gray); }
.text-small { font-size: .8rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; } .mt-5 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.d-flex { display: flex; } .align-center { align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.font-bold { font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
