@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink: #f2ede4;
  --ink-dim: #b9b2a6;
  --bg: #141210;
  --bg-raised: #1c1916;
  --bg-card: #201c18;
  --line: #35302a;

  --red: #d7263d;
  --red-dim: #7a1522;
  --amber: #ffb703;
  --amber-dim: #8a6300;
  --green: #4caf7d;

  --radius: 3px;
  --font-display: 'Big Shoulders Display', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

:root[data-theme='light'] {
  --ink: #1c1916;
  --ink-dim: #6b6357;
  --bg: #f5f1e8;
  --bg-raised: #ffffff;
  --bg-card: #ffffff;
  --line: #ddd4c4;

  --red: #c81e37;
  --red-dim: #f6d4d8;
  --amber: #a8690a;
  --amber-dim: #f5e2bd;
  --green: #2f8f5b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  background-image:
    radial-gradient(ellipse at top left, rgba(215, 38, 61, 0.08), transparent 45%),
    radial-gradient(ellipse at bottom right, rgba(255, 183, 3, 0.05), transparent 50%);
}

h1, h2, h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0;
}

/* ---------------------------------------------------------- */
/* Hazard bar                                                  */
/* ---------------------------------------------------------- */

.hazard-bar {
  height: 6px;
  width: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--amber),
    var(--amber) 12px,
    #171310 12px,
    #171310 24px
  );
}

/* ---------------------------------------------------------- */
/* Views                                                       */
/* ---------------------------------------------------------- */

[hidden] {
  display: none !important;
}

.view-login {
  min-height: calc(100vh - 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 36px 32px;
  animation: rise 0.5s ease both;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto 10px;
  background: #ffffff;
  border-radius: 16px;
  padding: 10px;
  box-sizing: border-box;
}

.brand-tag {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------------------------------------------------------- */
/* Forms                                                       */
/* ---------------------------------------------------------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-dim);
}

.field input,
.field select,
.field textarea {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 183, 3, 0.15);
}

.field textarea {
  resize: vertical;
  font-family: var(--font-body);
}

.error-text {
  color: var(--red);
  font-size: 13px;
  margin: 0;
}

/* ---------------------------------------------------------- */
/* Buttons                                                     */
/* ---------------------------------------------------------- */

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(1px);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

.btn-accent {
  background: var(--amber);
  color: #201c18;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

/* ---------------------------------------------------------- */
/* App shell                                                    */
/* ---------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-inline {
  width: 40px;
  height: 40px;
  margin: 0;
  border-radius: 8px;
  padding: 5px;
}

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.tab {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--red);
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-dim);
}

.badge {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 11px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: var(--radius);
}

.content {
  padding: 28px;
  max-width: 1100px;
  margin: 0 auto;
}

.panel {
  display: none;
  animation: rise 0.35s ease both;
}

.panel.is-active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-size: 26px;
}

/* ---------------------------------------------------------- */
/* Cards / forms in panels                                     */
/* ---------------------------------------------------------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.form-card {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: rise 0.25s ease both;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-checkbox input {
  width: 16px;
  height: 16px;
}

.constructor-add {
  align-items: end;
  margin-bottom: 16px;
}

.constructor-actions {
  display: flex;
  gap: 6px;
}

.constructor-actions .btn {
  padding: 4px 10px;
  font-size: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------------------------------------------------------- */
/* Tables                                                       */
/* ---------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
}

thead th {
  text-align: left;
  background: var(--bg-raised);
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.empty {
  text-align: center;
  color: var(--ink-dim);
  font-family: var(--font-body);
  padding: 24px;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill-completada,
.pill-operativo {
  background: rgba(76, 175, 125, 0.15);
  color: var(--green);
}

.pill-programada,
.pill-en_proceso,
.pill-requiere_atencion {
  background: rgba(255, 183, 3, 0.15);
  color: var(--amber);
}

.pill-cancelada,
.pill-fuera_de_servicio {
  background: rgba(215, 38, 61, 0.15);
  color: var(--red);
}

/* ---------------------------------------------------------- */
/* Utility                                                      */
/* ---------------------------------------------------------- */

.is-hidden {
  display: none !important;
}

/* ---------------------------------------------------------- */
/* Toast                                                        */
/* ---------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  border-left-color: var(--red);
}

/* ---------------------------------------------------------- */
/* Responsive                                                   */
/* ---------------------------------------------------------- */

/* ---------------------------------------------------------- */
/* Reporte consolidado de visita                                */
/* ---------------------------------------------------------- */

.reporte-card {
  margin-top: 20px;
}

.reporte-encabezado {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.reporte-encabezado h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.reporte-encabezado p {
  color: var(--ink-dim);
  font-size: 13px;
  margin: 2px 0;
}

.reporte-datos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 6px 18px;
  margin: 10px 0;
  font-size: 13px;
}

.reporte-equipo {
  margin-bottom: 22px;
}

.reporte-equipo h3 {
  font-size: 16px;
  color: var(--amber);
  margin-bottom: 8px;
}

.reporte-hoja {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.reporte-hoja-head {
  background: var(--bg-raised);
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.reporte-hoja-meta {
  color: var(--ink-dim);
  font-size: 12px;
}

.reporte-tabla {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 13px;
}

.reporte-tabla td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.reporte-tabla tr:last-child td {
  border-bottom: none;
}

.reporte-pregunta {
  width: 45%;
}

.reporte-valor {
  width: 20%;
  font-weight: 600;
}

.reporte-obs {
  color: var(--ink-dim);
  font-style: italic;
}

.reporte-foto {
  max-width: 160px;
  max-height: 160px;
  border-radius: var(--radius);
  display: block;
}

.reporte-firma {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.reporte-firma-img {
  max-width: 260px;
  max-height: 140px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: block;
  margin-top: 8px;
}

@media print {
  .hazard-bar,
  .topbar,
  .panel-head,
  .table-wrap,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
    background-image: none;
    color: #000;
  }

  #reporte-visita {
    border: none;
    padding: 0;
  }

  .reporte-hoja {
    break-inside: avoid;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
  }

  .content {
    padding: 18px;
  }
}
