:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-secondary: #64748b;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 150ms ease;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Layout */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.topbar-inner { display: flex; align-items: center; gap: 2rem; width: 100%; max-width: 1400px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 1.25rem; color: var(--color-primary); letter-spacing: -0.02em; }
.nav { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.nav-link { padding: 0.5rem 1rem; border-radius: var(--radius-md); font-weight: 500; color: var(--color-text); transition: all var(--transition); }
.nav-link:hover { background: var(--color-primary-light); color: var(--color-primary); }
.nav-link.active { background: var(--color-primary); color: #fff; }
.nav-link.btn-primary { background: var(--color-primary); color: #fff; }
.nav-link.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }
.nav-link.btn-ghost { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.nav-link.btn-ghost:hover { background: var(--color-bg); border-color: var(--color-primary); color: var(--color-primary); }

.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem; font-size: 0.875rem; font-weight: 600;
  border-radius: var(--radius-md); border: none; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #475569; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-ghost:hover:not(:disabled) { background: var(--color-bg); border-color: var(--color-primary); color: var(--color-primary); }
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; }

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--color-border); }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--color-border); background: var(--color-bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--color-text); margin-bottom: 0.5rem; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.625rem 0.875rem; font-size: 0.9375rem;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-input::placeholder { color: var(--color-text-light); }
.form-textarea { min-height: 120px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-help { font-size: 0.8125rem; color: var(--color-text-muted); margin-top: 0.375rem; }
.form-error { font-size: 0.8125rem; color: var(--color-danger); margin-top: 0.375rem; }

/* Input with icon */
.input-wrapper { position: relative; }
.input-icon { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--color-text-light); pointer-events: none; }
.form-input.has-icon { padding-left: 2.75rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.625rem; font-size: 0.75rem; font-weight: 600; border-radius: 9999px; }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-success { background: #d1fae5; color: var(--color-success); }
.badge-warning { background: #fef3c7; color: var(--color-warning); }
.badge-danger { background: #fee2e2; color: var(--color-danger); }
.badge-gray { background: var(--color-bg); color: var(--color-secondary); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th, .table td { padding: 0.875rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { font-weight: 600; color: var(--color-text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; background: var(--color-bg); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--color-bg); }
.table tbody tr:last-child td { border-bottom: none; }

/* Grid */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Page Header */
.page-header { margin-bottom: 2rem; }
.page-title { font-size: 1.75rem; font-weight: 700; color: var(--color-text); margin-bottom: 0.5rem; }
.page-subtitle { color: var(--color-text-muted); font-size: 1rem; }

/* Hero */
.hero { text-align: center; padding: 4rem 1.5rem; background: linear-gradient(135deg, var(--color-primary-light) 0%, #e0e7ff 100%); border-radius: var(--radius-lg); margin-bottom: 2rem; }
.hero h1 { font-size: 2.5rem; font-weight: 800; color: var(--color-text); margin-bottom: 1rem; line-height: 1.2; }
.hero p { font-size: 1.125rem; color: var(--color-text-muted); max-width: 600px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Empty State */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--color-text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.125rem; font-weight: 600; color: var(--color-text); margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1.5rem; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  opacity: 0; visibility: hidden; transition: all var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 500px; width: 100%; max-height: 90vh; overflow: hidden; transform: scale(0.95); transition: transform var(--transition); }
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--color-border); }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-close { background: none; border: none; padding: 0.5rem; color: var(--color-text-muted); cursor: pointer; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
.modal-body { padding: 1.5rem; overflow-y: auto; max-height: 60vh; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; padding: 1rem 1.5rem; border-top: 1px solid var(--color-border); background: var(--color-bg); }

/* Alerts */
.alert { padding: 1rem 1.25rem; border-radius: var(--radius-md); font-size: 0.875rem; display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* Avatar */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--color-primary-light); color: var(--color-primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.125rem; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: 100%; right: 0; margin-top: 0.5rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); min-width: 200px; padding: 0.5rem; opacity: 0; visibility: hidden; transform: translateY(-8px); transition: all var(--transition); z-index: 100; }
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.625rem 1rem; border: none; background: none; text-align: left; font-size: 0.875rem; color: var(--color-text); border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition); }
.dropdown-item:hover { background: var(--color-bg); color: var(--color-primary); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: #fef2f2; }
.dropdown-divider { height: 1px; background: var(--color-border); margin: 0.5rem 0; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--color-border); margin-bottom: 1.5rem; }
.tab { padding: 0.75rem 1.25rem; font-weight: 500; color: var(--color-text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: all var(--transition); }
.tab:hover { color: var(--color-primary); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* Chat */
.chat-container { display: flex; flex-direction: column; height: 600px; background: var(--color-surface); border-radius: var(--radius-lg); border: 1px solid var(--color-border); overflow: hidden; }
.chat-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 1rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.chat-message { display: flex; gap: 0.75rem; max-width: 80%; }
.chat-message.own { align-self: flex-end; flex-direction: row-reverse; }
.chat-message-avatar { flex-shrink: 0; }
.chat-message-content { background: var(--color-bg); padding: 0.75rem 1rem; border-radius: var(--radius-lg); border-bottom-left-radius: 4px; }
.chat-message.own .chat-message-content { background: var(--color-primary); color: #fff; border-radius: var(--radius-lg); border-bottom-right-radius: 4px; }
.chat-message-sender { font-size: 0.75rem; font-weight: 600; color: var(--color-text-muted); margin-bottom: 0.25rem; }
.chat-message.own .chat-message-sender { color: rgba(255,255,255,0.7); }
.chat-message-text { font-size: 0.875rem; line-height: 1.5; }
.chat-message-time { font-size: 0.6875rem; color: var(--color-text-light); margin-top: 0.375rem; text-align: right; }
.chat-message.own .chat-message-time { color: rgba(255,255,255,0.6); }
.chat-input { padding: 1rem 1.5rem; border-top: 1px solid var(--color-border); display: flex; gap: 0.75rem; }
.chat-input .form-input { flex: 1; }

/* Project Items */
.item-row { display: flex; align-items: center; gap: 1rem; padding: 1rem; background: var(--color-bg); border-radius: var(--radius-md); margin-bottom: 0.75rem; }
.item-type { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.item-type.personal { background: #dbeafe; color: var(--color-primary); }
.item-type.material { background: #fef3c7; color: var(--color-warning); }
.item-type.servicio { background: #d1fae5; color: var(--color-success); }
.item-info { flex: 1; }
.item-title { font-weight: 600; font-size: 0.875rem; }
.item-meta { display: flex; gap: 1rem; font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* Offer Card */
.offer-card { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 1.25rem; margin-bottom: 1rem; transition: all var(--transition); }
.offer-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.offer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.offer-provider { display: flex; align-items: center; gap: 0.75rem; }
.offer-price { font-size: 1.5rem; font-weight: 700; color: var(--color-primary); }
.offer-proposal { color: var(--color-text-muted); font-size: 0.9375rem; line-height: 1.6; margin-bottom: 1rem; }
.offer-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.offer-meta { display: flex; gap: 1rem; font-size: 0.75rem; color: var(--color-text-muted); }

/* Profile Card */
.profile-card { text-align: center; padding: 2rem; }
.profile-avatar { margin: 0 auto 1rem; }
.profile-name { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.25rem; }
.profile-role { color: var(--color-text-muted); font-size: 0.875rem; margin-bottom: 1rem; }
.profile-fields { text-align: left; margin-top: 1.5rem; }
.profile-field { margin-bottom: 1rem; }
.profile-field-label { font-size: 0.75rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.profile-field-value { color: var(--color-text); }

/* Admin Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { padding: 1.5rem; }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.25rem; margin-bottom: 0.75rem; }
.stat-icon.blue { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon.green { background: #d1fae5; color: var(--color-success); }
.stat-icon.orange { background: #fef3c7; color: var(--color-warning); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--color-text); line-height: 1; }
.stat-label { font-size: 0.875rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* Responsive */
@media (max-width: 768px) {
  .topbar { padding: 0 1rem; }
  .nav { display: none; }
  .container { padding: 1.5rem 1rem; }
  .hero h1 { font-size: 2rem; }
  .hero-actions { flex-direction: column; }
  .btn { width: 100%; }
  .page-title { font-size: 1.5rem; }
  .chat-container { height: calc(100vh - 64px); border-radius: 0; }
  .table { display: block; overflow-x: auto; }
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.3s ease forwards; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 20px; height: 20px; border: 2px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* Focus visible */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-light); }