:root {
  --navy: #1a3a63;
  --navy-dark: #0f2947;
  --navy-light: #2d5490;
  --accent: #2f6fed;
  --accent-light: #eaf1ff;
  --grey-bg: #f3f5f9;
  --grey-bg-2: #eceff5;
  --grey-border: #e0e5ed;
  --grey-border-strong: #c9d1de;
  --red: #c0392b;
  --red-bg: #fdecea;
  --green: #1e8e3e;
  --green-bg: #e8f6ec;
  --text: #1f2937;
  --text-muted: #667085;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 30, 54, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 30, 54, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 30, 54, 0.14);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--grey-bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------------- Barra superior ---------------- */
.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 58px;
  box-shadow: 0 2px 10px rgba(15, 41, 71, 0.25);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.topbar .brand::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6fb3ff;
  box-shadow: 0 0 0 4px rgba(111, 179, 255, 0.25);
  flex-shrink: 0;
}
.topbar nav {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  color: #c3d2ea;
  text-decoration: none;
  margin-left: 4px;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 7px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.topbar nav a.active { color: #fff; background: rgba(255,255,255,0.14); }
.topbar nav .sep { margin-left: 10px; margin-right: 2px; color: rgba(255,255,255,0.25); }
.topbar nav .user-name { margin-left: 6px; color: #eef2f9; font-size: 13.5px; padding: 8px 6px; }

/* ---------------- Layout general ---------------- */
.container {
  max-width: 1020px;
  margin: 32px auto;
  padding: 0 20px;
}
.card {
  background: #fff;
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  padding: 28px 30px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
h1 { font-size: 23px; color: var(--navy); margin-top: 0; margin-bottom: 6px; letter-spacing: -.01em; }
h2 { font-size: 16px; color: var(--navy); }
.subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 0; margin-bottom: 22px; line-height: 1.5; }

/* ---------------- Tablas ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--grey-border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--grey-border); }
th {
  background: var(--grey-bg-2);
  color: var(--navy);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
tr.no-encontrado { background: var(--red-bg); }
tr.no-encontrado:hover { background: #fbe1de; }
tr.no-encontrado td { color: var(--red); }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, var(--accent) 0%, #1d5bd6 100%);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(47, 111, 237, 0.3);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { box-shadow: 0 5px 14px rgba(47, 111, 237, 0.4); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-secondary {
  background: #fff;
  color: var(--navy);
  border: 1.5px solid var(--grey-border-strong);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--grey-bg-2); border-color: var(--navy-light); box-shadow: none; transform: none; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------------- Formularios ---------------- */
input[type=text], input[type=password], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--grey-border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 6px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input[type=text]:focus, input[type=password]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
input[type=text]::placeholder, textarea::placeholder { color: #a3aebd; }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23667085'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
  cursor: pointer;
}
label { font-size: 13px; font-weight: 700; color: #44506a; display: block; margin-top: 16px; margin-bottom: 0; }
label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  color: var(--text);
  background: var(--grey-bg-2);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
}
label.checkbox-label input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }

/* Secciones agrupadas del formulario */
.form-section {
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  padding: 20px 22px 24px;
  margin-top: 20px;
  background: #fbfcfe;
}
.form-section:first-of-type { margin-top: 24px; }
.form-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.form-section-title .badge-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
@media (max-width: 620px) {
  .field-row { grid-template-columns: 1fr; }
}

/* Zona de subir archivo tipo "dropzone" */
.dropzone {
  margin-top: 6px;
  border: 2px dashed var(--grey-border-strong);
  border-radius: var(--radius);
  background: #fff;
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  position: relative;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-light); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.dropzone .dz-icon { font-size: 26px; margin-bottom: 8px; }
.dropzone .dz-title { font-weight: 700; color: var(--navy); font-size: 14px; }
.dropzone .dz-title u { color: var(--accent); text-decoration: none; }
.dropzone .dz-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.dropzone .dz-filename {
  display: none;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  border-radius: 6px;
  padding: 6px 10px;
}
.dropzone.has-file .dz-filename { display: inline-block; }

/* Banner de plantilla descargable */
.template-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--accent-light);
  border: 1px solid #cfe0fb;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 22px;
}
.template-banner .tb-text { font-size: 13.5px; color: var(--navy); max-width: 560px; line-height: 1.5; }
.template-banner .tb-text strong { color: var(--navy-dark); }

/* ---------------- Alertas ---------------- */
.alert {
  padding: 13px 16px 13px 44px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
}
.alert::before {
  position: absolute;
  left: 16px;
  top: 12px;
  font-weight: 700;
  font-size: 13px;
}
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #f5c6cb; }
.alert-error::before { content: "✕"; }
.alert-ok { background: var(--green-bg); color: var(--green); border: 1px solid #c3ecce; }
.alert-ok::before { content: "✓"; }
.alert-info { background: var(--accent-light); color: var(--navy); border: 1px solid #cfe0fb; }
.alert-info::before { content: "i"; font-style: italic; }

/* ---------------- Insignias de marca ---------------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-turck { background: #dbe9ff; color: #1a4a8a; }
.badge-banner { background: #fde9d0; color: #a05a00; }
.badge-autonics { background: #e3dcf9; color: #5a2ea6; }
.badge-smc { background: #dcf3e6; color: #157347; }

.totales { text-align: right; font-size: 15px; margin-top: 14px; color: var(--text-muted); }
.totales strong { color: var(--navy); font-size: 19px; }

/* ---------------- Login ---------------- */
body:has(.login-box) { background: linear-gradient(160deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-light) 100%); min-height: 100vh; }
.login-box { max-width: 380px; margin: 0 auto; padding-top: 12vh; }
.login-box .card { box-shadow: var(--shadow-lg); border: none; }
.login-box h1 { text-align: center; }
.login-box .subtitle { text-align: center; }

footer.pie { text-align: center; color: #99a3b3; font-size: 12px; margin: 40px 0 20px; }
