:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

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

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.25), transparent),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-card .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

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

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-brand span { color: var(--accent); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover, .nav-link.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active { color: var(--accent); font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.main {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-x: auto;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h2 { font-size: 1.5rem; font-weight: 700; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card .label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; margin-top: 0.25rem; }
.stat-card.highlight { border-color: var(--accent); background: rgba(59, 130, 246, 0.08); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.toolbar input, .toolbar select { width: auto; min-width: 180px; }

.search-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: stretch;
}

.search-box {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 0.85rem;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-icon { color: var(--muted); flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.65rem 0;
  min-width: 0;
}

.search-input:focus { outline: none; box-shadow: none; }

.filter-select {
  width: auto;
  min-width: 140px;
}

.list-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.list-meta em { font-style: normal; color: var(--text); }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pagination-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pagination .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Table / cards */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface2); color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-planificacion { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.badge-en_progreso { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge-completado { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-cancelado { background: rgba(107, 114, 128, 0.3); color: #9ca3af; }
.badge-asignado { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-confirmado { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge-pagado { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-pendiente { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }

.assign-row-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.assign-row-actions .tarifa-input { width: 100px; }

.pagado-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: center;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
}

.btn-assign {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.65rem;
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-assign:hover {
  background: rgba(34, 197, 94, 0.22);
}

.modal-wide {
  max-width: 520px;
}

.btn-calendar {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-calendar:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--accent);
  text-decoration: none;
}

.btn-calendar:active {
  transform: scale(0.97);
}

.btn-calendar .icon-calendar {
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .btn-calendar span {
    display: none;
  }
  .btn-calendar {
    padding: 0.5rem;
  }
  .btn-assign {
    padding: 0.45rem 0.5rem;
    font-size: 0.75rem;
  }
}

.event-cards { display: grid; gap: 0.75rem; }

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.event-card:hover { border-color: var(--accent); }
.event-card h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.event-card .meta { font-size: 0.85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 1rem; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.detail-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.detail-item .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.detail-item .value { margin-top: 0.25rem; font-weight: 500; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.panel h3 { font-size: 1rem; margin-bottom: 1rem; }

.assign-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.assign-row:last-child { border-bottom: none; }

.assign-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.assign-form-personal {
  grid-column: 1 / -1;
  max-width: 100%;
}

.personal-picker {
  position: relative;
}

.personal-picker-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0.75rem;
}

.personal-picker-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.personal-picker-field input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.6rem 0;
  min-width: 0;
}

.personal-picker-field input:focus {
  outline: none;
  box-shadow: none;
}

.personal-picker-list {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}

.personal-picker-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 1rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.personal-picker-option:hover,
.personal-picker-option:focus {
  background: rgba(59, 130, 246, 0.12);
  outline: none;
}

.personal-picker-empty {
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }
.alert-warning { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.3); color: #fcd34d; }
.alert-success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: #86efac; }

.empty { text-align: center; padding: 3rem; color: var(--muted); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin-bottom: 1rem; }

.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; }

.loading { color: var(--muted); padding: 2rem; text-align: center; }

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 0.75rem; }
  .sidebar-brand { border: none; margin: 0; padding: 0 1rem; }
  .nav-link { padding: 0.5rem 1rem; }
  .sidebar-footer { display: none; }
  .assign-form { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}
