/* ── agente.ceo App — Agrícola, terroso, confiable ──────────────── */

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

:root {
  --green-900: #1a3a2a;
  --green-800: #245b3a;
  --green-700: #2d7a4f;
  --green-600: #3c9d63;
  --green-500: #4caf50;
  --green-400: #66bb6a;
  --green-100: #c8e6c9;
  --brown-800: #5d4037;
  --brown-600: #8d6e63;
  --brown-100: #d7ccc8;
  --gold-500: #ffb300;
  --gold-200: #ffe082;
  --amber-500: #ff9800;

  --primary: #3c9d63;
  --primary-hover: #2d7a4f;
  --primary-light: rgba(60,157,99,0.12);
  --primary-glow: rgba(60,157,99,0.25);
  --accent: #5d4037;
  --accent-light: #d7ccc8;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-hover: #f0ede6;
  --surface-alt: #f0ede6;
  --border: #d7ccc8;
  --border-light: #e8e0d8;
  --text: #3e2723;
  --text-secondary: #5d4037;
  --text-muted: #8d6e63;
  --danger: #c62828;
  --danger-light: rgba(198,40,40,0.1);
  --warning: #e65100;
  --warning-light: rgba(230,81,0,0.1);
  --info: #1565c0;
  --info-light: rgba(21,101,192,0.1);
  --success: #2e7d32;
  --success-light: rgba(46,125,50,0.1);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 3px rgba(62,39,35,0.08);
  --shadow: 0 2px 8px rgba(62,39,35,0.1);
  --shadow-lg: 0 4px 20px rgba(62,39,35,0.12);
  --sidebar-width: 260px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition: 200ms ease;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Error Screen ─────────────────────────────────────────────── */
.error-screen, .loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg);
}
.error-card, .loading-screen {
  text-align: center;
  padding: 48px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
}
.error-icon { font-size: 64px; margin-bottom: 16px; }
.error-card h1 { font-size: 24px; margin-bottom: 8px; color: var(--text); }
.error-card p { color: var(--text-secondary); margin-bottom: 8px; }
.error-hint { font-size: 14px; color: var(--text-muted); margin-top: 16px; }

.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen p { color: var(--text-muted); }

/* ── Layout ───────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--green-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}
.sidebar-business {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-left-color: var(--green-400);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}
.sidebar-footer .user-name { color: #fff; font-weight: 600; display: block; margin-bottom: 2px; }
.sidebar-footer .user-phone { font-size: 12px; }

/* ── Mobile Header ────────────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--green-900);
  color: #fff;
}
.mobile-logo { font-weight: 700; font-size: 15px; }
.hamburger {
  background: none; border: none; color: #fff;
  font-size: 24px; cursor: pointer; padding: 4px 8px;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -100%; top: 0; bottom: 0; z-index: 100;
    transition: left var(--transition);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay.open { display: block; }
  .mobile-header { display: flex; }
  .main-content { padding: 16px !important; }
}

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  background: var(--bg);
}
.page { display: none; }
.page.active { display: block; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.card-subtitle { font-size: 13px; color: var(--text-muted); }

/* ── Stats Grid ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 20px;
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); margin-top: 4px; }
.stat-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

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

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-info { background: var(--info-light); color: var(--info); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--surface-alt); color: var(--text-muted); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { min-height: 80px; resize: vertical; }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; margin-bottom: 4px; color: var(--text-secondary); }
.empty-state p { font-size: 14px; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-info { background: var(--info); color: #fff; }
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* ── Page Header ──────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 28px; font-weight: 800; color: var(--text); }
.page-header p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ── Match detail ─────────────────────────────────────────────── */
.timeline {
  padding-left: 24px;
  border-left: 2px solid var(--primary);
  margin-top: 12px;
}
.timeline-item {
  position: relative;
  padding: 8px 0 16px 16px;
  font-size: 14px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -30px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}
.timeline-item .event-name { font-weight: 600; color: var(--text); }
.timeline-item .event-time { font-size: 12px; color: var(--text-muted); }
.timeline-item .event-note { margin-top: 4px; color: var(--text-secondary); }

/* ── Price table highlight ────────────────────────────────────── */
.price-highlight { font-weight: 700; }
.price-offer { color: var(--amber-500); }
.price-demand { color: var(--info); }
.price-transaction { color: var(--success); }

/* ── Section Divider ──────────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 32px 0 16px;
}
.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}
.section-divider span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── Create Card ──────────────────────────────────────────────── */
.create-card {
  background: linear-gradient(135deg, var(--primary-light), var(--surface));
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.create-card:hover { border-color: var(--primary-hover); background: var(--primary-light); }
.create-card-title { font-size: 14px; font-weight: 600; color: var(--primary); }
.create-card-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 32px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}
