@font-face {
  font-family: 'Avenir';
  src: url('./fonts/Avenir_Light.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('./fonts/Avenir_Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('./fonts/Avenir_Medium.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('./fonts/Avenir_Black.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('./fonts/Avenir_Black.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
}

:root {
  --bg: #F8FAFC;
  --surface: #ffffff;
  --surface-soft: #F1F5F9;
  --brand-900: #003B75;
  --brand-700: #005EB8;
  --brand-500: #00796B;
  --muted: #455A64;
  --line: #CFD8DC;
  --danger: #DC2626;
  --ok: #10B981;
  --warning: #D97706;
  --radius: 16px;
  --shadow: 0 18px 42px rgba(0, 94, 184, 0.10);
  --font-ui: "Avenir", "Avenir Next", "Gill Sans", "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--brand-900);
  background:
    radial-gradient(circle at 0% 0%, rgba(0, 121, 107, 0.22), rgba(0, 121, 107, 0) 35%),
    radial-gradient(circle at 100% 0%, rgba(0, 94, 184, 0.16), rgba(0, 94, 184, 0) 30%),
    var(--bg);
  padding: 18px;
}

.app {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.gate {
  width: min(520px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.gate-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 59, 117, 0.08);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.gate-title {
  margin: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  line-height: 1.15;
}

.gate-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-error {
  margin: 0;
  border: 1px solid #efbcbc;
  border-radius: 10px;
  background: #fff3f3;
  color: #8d2f2f;
  padding: 8px 10px;
  font-size: 0.86rem;
  display: none;
}

.login-error.show {
  display: block;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 59, 117, 0.08);
  padding: 16px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: linear-gradient(120deg, rgba(0, 94, 184, 0.12), rgba(0, 121, 107, 0.14));
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-wrap {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  border: 1px solid rgba(0, 94, 184, 0.22);
  background: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 7px;
  background: #fff;
  display: block;
}

.logo-fallback {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--brand-700);
  letter-spacing: 0.04em;
  display: none;
}

.title {
  margin: 0;
  line-height: 1.1;
  font-size: clamp(1.2rem, 2.5vw, 1.85rem);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.header-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-meta strong {
  color: var(--brand-900);
}

.session-line {
  font-size: 0.82rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-soft);
  display: grid;
  gap: 4px;
}

.stat-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 800;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }

label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--brand-900);
  padding: 10px 11px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea {
  resize: vertical;
  min-height: 84px;
  max-height: 220px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(0, 94, 184, 0.16);
}

.helper {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.auth-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
  display: grid;
  gap: 9px;
}

.auth-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.auth-requirement {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-summary {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--brand-900);
  font-size: 0.88rem;
}

.auth-summary strong {
  color: var(--brand-900);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, opacity 120ms ease;
}

button:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(120deg, var(--brand-700), var(--brand-500));
  color: #fff;
}

.btn-soft {
  background: #E1F0FF;
  color: var(--brand-700);
}

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

.btn-ok {
  background: #D1FAE5;
  color: var(--ok);
}

.btn-warning {
  background: #FEF3C7;
  color: var(--warning);
}

.btn-primary:hover,
.btn-soft:hover,
.btn-danger:hover,
.btn-ok:hover,
.btn-warning:hover {
  opacity: 0.92;
}

@keyframes blinkAlert {
  0% { background-color: #FEF3C7; border-color: #F59E0B; color: #B45309; }
  100% { background-color: #FFFBEB; border-color: #FCD34D; color: #D97706; }
}

.date-display-readonly {
  background: #f0f7f5;
  border: 2px solid var(--brand-500);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  margin-bottom: 6px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.01em;
}

.date-display-readonly:not(.captured) {
  animation: blinkAlert 1s infinite alternate;
}

.date-display-readonly.captured {
  color: var(--ok);
  border-color: var(--ok);
  background: #F0FDF4;
  animation: none;
}

.btn-date-capture {
  width: 100%;
  background: linear-gradient(120deg, var(--brand-700), var(--brand-500));
  color: #fff;
  font-size: 0.9rem;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  border: none;
  transition: transform 120ms ease, opacity 120ms ease;
}

.btn-date-capture:hover { opacity: 0.9; }
.btn-date-capture:active { transform: translateY(1px); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.toolbar .left,
.toolbar .right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

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

.log-list {
  display: grid;
  gap: 10px;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.item-title {
  margin: 0;
  font-size: 1rem;
}

.item-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.badge.alta { background: #ffe9e2; color: #8f3d2f; border-color: #f4c6b9; }
.badge.rutina { background: #e7f4ff; color: #2b6188; border-color: #cde5f8; }
.badge.extraordinaria { background: #fff5df; color: #866219; border-color: #f1dea8; }
.badge.auth-ok { background: #e3f6eb; color: #216f43; border-color: #c8e8d6; }
.badge.auth-missing { background: #ffecec; color: #943636; border-color: #f2bcbc; }

.meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid #d9e8e4;
  background: #fafdfc;
  border-radius: 12px;
  padding: 8px;
}

.meta-item {
  display: grid;
  gap: 3px;
}

.meta-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.meta-value {
  font-size: 0.9rem;
  word-break: break-word;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.check {
  border-radius: 999px;
  border: 1px solid #d2e4de;
  background: #f7fcfa;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #32544c;
}

.text-note {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
  color: #35544d;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  background: #fbfefd;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 30, 26, 0.52);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 20;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #d5e6e2;
  box-shadow: 0 28px 55px rgba(8, 30, 26, 0.35);
  padding: 16px;
  display: grid;
  gap: 10px;
}

.modal h3 {
  margin: 0;
  font-size: 1.02rem;
}

.notice-modal {
  width: min(470px, 100%);
  gap: 12px;
  border: 1px solid #cfe3dd;
  background: linear-gradient(180deg, #ffffff, #f7fcfa);
}

.notice-title {
  margin: 0;
  font-size: 1.06rem;
  color: var(--brand-900);
}

.notice-message {
  margin: 0;
  border: 1px solid #d6e8e3;
  border-radius: 10px;
  background: #f2faf8;
  padding: 11px;
  color: #214f46;
  font-size: 0.95rem;
  line-height: 1.42;
  white-space: pre-wrap;
}

.confirm-modal {
  width: min(500px, 100%);
  gap: 12px;
  border: 1px solid #cfe3dd;
  background: linear-gradient(180deg, #ffffff, #f7fcfa);
}

.auth-modal {
  width: min(520px, 100%);
  gap: 12px;
  border: 1px solid #cfe3dd;
  background: linear-gradient(180deg, #ffffff, #f7fcfa);
}

.auth-field {
  display: grid;
  gap: 6px;
}

.legend {
  margin: 0;
  border-radius: 10px;
  border: 1px solid #d3e6e0;
  background: #f2faf8;
  padding: 10px;
  font-weight: 700;
  color: #204c43;
  line-height: 1.4;
}

.signature-canvas-wrap {
  border: 1px solid #d0e4de;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}

canvas {
  width: 100%;
  height: 220px;
  border-radius: 8px;
  border: 1px dashed #bfd9d1;
  background: repeating-linear-gradient(
    180deg,
    #ffffff 0,
    #ffffff 26px,
    #f8fcfb 26px,
    #f8fcfb 52px
  );
  touch-action: none;
  display: block;
}

.checks-box {
  border: 1px solid #d1e4df;
  border-radius: 10px;
  padding: 10px;
  background: #fafdfc;
  display: grid;
  gap: 8px;
}

.checks-box p {
  margin: 0;
  font-size: 0.84rem;
  color: #3f6159;
}

.checks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checks-row label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #cee0db;
  border-radius: 999px;
  padding: 6px 11px;
  background: #fff;
  color: #34554d;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
}

.checks-row input {
  margin: 0;
  width: auto;
  accent-color: var(--brand-700);
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .col-8,
  .col-6,
  .col-4,
  .col-3 {
    grid-column: span 6;
  }
}

@media (max-width: 740px) {
  body {
    padding: 11px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-brand {
    width: 100%;
  }
  .header-meta {
    justify-items: start;
    text-align: left;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .col-8,
  .col-6,
  .col-4,
  .col-3 {
    grid-column: span 12;
  }
  .meta {
    grid-template-columns: 1fr;
  }
  .toolbar .left,
  .toolbar .right {
    width: 100%;
  }
  .toolbar input,
  .toolbar select,
  .toolbar button {
    flex: 1;
    min-width: 0;
  }
}
