:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef5f1;
  --text: #121a16;
  --muted: #52655c;
  --line: #c4d2ca;
  --primary: #14765d;
  --primary-dark: #0e5443;
  --accent: #d88424;
  --danger: #b83228;
  --ok: #197449;
  --warning: #87510b;
  --shadow: 0 18px 46px rgba(18, 26, 22, 0.12);
  --soft-shadow: 0 8px 22px rgba(18, 26, 22, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(20, 118, 93, 0.12), rgba(244, 247, 245, 0) 300px),
    var(--bg);
  color: var(--text);
  font-size: 16px;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 82px;
  padding: 14px clamp(16px, 4vw, 32px);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  display: block;
  border-radius: 12px;
  object-fit: cover;
  background: #000;
  box-shadow: 0 8px 18px rgba(18, 26, 22, 0.22);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p,
.user-meta,
.muted {
  color: var(--muted);
}

.brand p {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 600;
}

.main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 26px) clamp(14px, 3vw, 26px) 112px;
  flex: 1;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 91, 0.14), transparent 32%),
    linear-gradient(135deg, #f7faf8 0%, #e8f2ed 100%);
}

.login-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 30px);
}

.login-title {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 20px;
}

.login-title h1 {
  margin: 0;
  font-size: 25px;
}

.login-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  font-weight: 700;
  font-size: 14px;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 16px;
  min-height: 58px;
  outline: none;
  font-size: 17px;
}

.search-input {
  font-size: 19px;
  font-weight: 700;
}

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

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.16);
}

.btn {
  min-height: 58px;
  border-radius: 12px;
  padding: 15px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--soft-shadow);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(31, 111, 91, 0.22);
}

.btn.primary:hover {
  background: var(--primary-dark);
}

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

.btn.ghost {
  background: #fff;
  border: 1px solid var(--line);
}

.btn.large {
  width: 100%;
  min-height: 124px;
  justify-content: flex-end;
  padding: 22px;
  align-items: flex-start;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  text-align: left;
}

.btn.large::before {
  content: "";
  position: absolute;
  inset: 16px 16px auto auto;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(20, 118, 93, 0.12);
}

.btn.large.primary::before {
  background: rgba(255, 255, 255, 0.2);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions {
  align-items: center;
  justify-content: flex-end;
}

.action-title {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.action-help {
  display: block;
  margin-top: 7px;
  font-size: 14px;
  color: rgba(18, 26, 22, 0.72);
  font-weight: 700;
}

.btn.primary .action-help {
  color: rgba(255, 255, 255, 0.84);
}

.action-ingreso {
  background: var(--primary);
}

.action-salida {
  background: #fff7ed;
  border: 1px solid #edc78f;
}

.action-lista {
  background: #eef6ff;
  border: 1px solid #b8d7f5;
}

.action-padron {
  background: #f1f7ed;
  border: 1px solid #b8d4ac;
}

.dashboard-grid.two-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-shortcut {
  min-width: 220px;
}

.compact-actions {
  gap: 6px;
}

.compact-actions .btn {
  min-height: 38px;
  padding: 8px 10px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0 20px;
}

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

.summary-grid div {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbf9);
  display: grid;
  align-content: center;
  gap: 2px;
  box-shadow: var(--soft-shadow);
}

.summary-grid strong {
  font-size: 36px;
  line-height: 1;
  color: var(--primary-dark);
}

.summary-grid span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.section {
  margin-top: 18px;
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

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

.panel-header h2,
.section h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.stack {
  display: grid;
  gap: 12px;
}

.worker-list {
  display: grid;
  gap: 8px;
}

.worker-item {
  text-align: left;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  gap: 4px;
  box-shadow: 0 5px 16px rgba(24, 33, 29, 0.05);
}

.worker-item:hover {
  border-color: var(--primary);
  background: #f9fcfa;
}

.worker-item strong {
  font-size: 16px;
  line-height: 1.25;
}

.worker-item span {
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.pill.ok {
  background: #e1f3e9;
  color: var(--ok);
}

.pill.warn {
  background: #fff1d9;
  color: var(--warning);
}

.pill.danger {
  background: #f8e6e2;
  color: var(--danger);
}

.pill.neutral {
  background: #edf0ef;
  color: #52655c;
}

.missing-row td {
  background: #fafbfa;
  color: #52655c;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  font-size: 13px;
  color: #334139;
  white-space: nowrap;
}

tbody tr:hover td {
  background: #fbfdfb;
}

tr:last-child td {
  border-bottom: 0;
}

.camera-box {
  display: grid;
  gap: 12px;
}

.camera-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #101714;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  position: relative;
}

.camera-preview.compact {
  aspect-ratio: 16 / 10;
  min-height: 160px;
  border-radius: 10px;
}

.camera-preview video,
.camera-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-placeholder {
  position: absolute;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  pointer-events: none;
}

.camera-preview::after {
  content: "";
  position: absolute;
  inset: 18% 8%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  pointer-events: none;
}

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

.dni-photo-card p {
  margin: 4px 0 0;
  font-size: 13px;
}

.dni-photo-card summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
}

.dni-photo-card summary::-webkit-details-marker {
  display: none;
}

.dni-photo-card summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.notice {
  border-radius: 12px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.notice.error {
  border-color: #f0b0aa;
  background: #fff3f1;
  color: var(--danger);
}

.notice.success {
  border-color: #a6d9bf;
  background: #effaf4;
  color: var(--ok);
}

.install-card {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 30;
  width: min(520px, calc(100% - 24px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(31, 111, 91, 0.24);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 44px rgba(24, 33, 29, 0.22);
}

.install-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.worker-form-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbf9);
  box-shadow: var(--soft-shadow);
}

.form-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.form-card-header h3 {
  margin: 0;
  font-size: 20px;
}

.form-card-header p {
  margin: 4px 0 0;
}

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

.field-wide {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.evidence-list,
.history-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.evidence-item,
.history-item {
  width: 100%;
  text-align: left;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: grid;
  gap: 4px;
}

.evidence-item:hover {
  border-color: var(--primary);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(18, 28, 24, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}

.photo-modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.photo-full {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 10px;
  background: #101714;
}

.footer-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .dashboard-grid,
  .summary-grid,
  .admin-layout,
  .worker-form-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .form-card-header {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .main {
    padding: 12px 12px 112px;
  }

  .topbar {
    position: static;
  }

  .brand h1 {
    font-size: 18px;
  }

  .user-meta {
    width: 100%;
    font-size: 14px;
    font-weight: 700;
  }

  .btn.large {
    min-height: 118px;
  }

  .action-title {
    font-size: 22px;
  }

  .worker-item {
    padding: 12px 14px;
    gap: 3px;
  }

  .worker-item strong {
    font-size: 15px;
  }

  .worker-item span {
    font-size: 12px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .btn-row .btn {
    flex: 1 1 150px;
  }

  .install-card {
    align-items: stretch;
    flex-direction: column;
  }

  .login-panel,
  .panel {
    border-radius: 12px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid strong {
    font-size: 34px;
  }

  table {
    min-width: 680px;
  }
}
