:root {
  --bg-top: #f4f6f8;
  --bg-bottom: #e9edf2;
  --ink-1: #1f2937;
  --ink-2: #526071;
  --card: #ffffff;
  --line: #d3dbe4;
  --brand: #1f3a5f;
  --brand-2: #182f4d;
  --accent: #2f4a6d;
  --warn: #7f1d1d;
  --chip-open: #1f3a5f;
  --chip-open-bg: #dbe7f5;
  --chip-closed: #5b6370;
  --chip-closed-bg: #e9edf2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink-1);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.login-card,
.panel-card,
.card,
.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: min(480px, 100%);
  padding: 24px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.login-title {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0.2px;
  color: #0f172a;
}

.login-subtitle {
  margin-top: 8px;
  color: var(--ink-2);
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.form-equipo-section {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  display: grid;
  gap: 12px;
}

.form-equipo-title {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  letter-spacing: 0.02em;
}

label {
  font-size: 13px;
  color: #475569;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 5px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  color: #0f172a;
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: #60a5fa;
}

.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-primary {
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  color: #ffffff;
}

.btn-secondary {
  background: #dbe2ea;
  color: #1f2937;
}

.btn-accent {
  background: var(--accent);
  color: #ffffff;
}

.btn-danger {
  background: var(--warn);
  color: #ffffff;
}

.btn-warning {
  background: #f59e0b;
  color: #ffffff;
}

.btn-warning:hover {
  background: #d97706;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-card {
  padding: 14px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-tabs {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.section-tab {
  border: 1px solid #dbe2ea;
  background: #ffffff;
  color: #1f2937;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
}

.section-tab.active {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.pill {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #e2e8f0;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.filters input[type="date"] {
  padding: 10px 12px;
}

.grid {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card {
  padding: 12px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
}

.card-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: #475569;
}

.badge-open,
.badge-closed {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge-open {
  color: var(--chip-open);
  background: var(--chip-open-bg);
}

.badge-closed {
  color: var(--chip-closed);
  background: var(--chip-closed-bg);
}

.card-meta {
  margin-top: 8px;
  color: #334155;
  display: grid;
  gap: 4px;
  font-size: 14px;
}

.card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty {
  text-align: center;
  color: #475569;
  padding: 24px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.44);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 20;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 16px;
}

.section {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.section h3 {
  margin-bottom: 8px;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kv-item {
  border-bottom: 1px solid #eef2f7;
  padding-bottom: 6px;
}

.kv-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
}

.kv-value {
  margin-top: 2px;
  color: #0f172a;
}

.dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dual-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fafcff;
}

.dual-title {
  font-size: 13px;
  font-weight: 800;
  color: #2f4a6d;
  margin-bottom: 8px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.notice {
  margin-top: 8px;
  color: #475569;
  font-size: 13px;
}

/* Dashboard de métricas - Nuevo diseño */
.metrics-dashboard {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}

.metrics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}

.metrics-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
}

.metrics-subtitle {
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 999px;
}

.metrics-grid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.metric-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  padding: 16px;
  border-radius: 12px;
  background: #ffffff;
  border-left: 4px solid;
}

.metric-box.total {
  border-left-color: #3b82f6;
}

.metric-box.en-camino {
  border-left-color: #f59e0b;
}

.metric-box.completados {
  border-left-color: #22c55e;
}

.metric-box.porcentaje {
  border-left-color: #8b5cf6;
}

.metric-data {
  display: flex;
  flex-direction: column;
}

.metric-number {
  font-size: 28px;
  font-weight: 800;
  color: #1f2937;
  line-height: 1;
}

.metric-desc {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
  font-weight: 600;
}

.metric-divider {
  width: 1px;
  height: 50px;
  background: linear-gradient(180deg, transparent, #cbd5e1, transparent);
}

.metrics-bar {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.progress-bg {
  background: #e2e8f0;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  background: linear-gradient(90deg, #22c55e, #16a34a);
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-label {
  text-align: center;
  font-size: 12px;
  color: #64748b;
  margin-top: 8px;
}

/* Sección de Equipo de Amarre */
.equipo-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed #e2e8f0;
}

.equipo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.equipo-title {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
}

.equipo-subtitle {
  font-size: 12px;
  color: #64748b;
  background: #fef3c7;
  padding: 4px 10px;
  border-radius: 999px;
}

.equipo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.equipo-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.equipo-card:hover {
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.card-equipo {
  margin-top: 4px;
  padding: 6px 10px;
  background: #dbe7f5;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1f3a5f;
  display: inline-block;
}

.equipo-comparativa {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.equipo-salida {
  padding: 6px 10px;
  background: #dbe7f5;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1f3a5f;
}

.equipo-entrada {
  padding: 6px 10px;
  background: #dcfce7;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #166534;
}

@media (max-width: 840px) {
  .filters,
  .toolbar,
  .kv,
  .dual {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    flex-direction: column;
    gap: 12px;
  }

  .metric-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #cbd5e1, transparent);
  }

  .metric-box {
    width: 100%;
  }

  .metrics-header {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .equipo-grid {
    grid-template-columns: 1fr;
  }

  .equipo-header {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .equipo-row {
    flex-direction: column;
    gap: 4px;
  }
}
