:root {
  color-scheme: light;
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --primary: #155e75;
  --primary-dark: #0e4f63;
  --soft: #ecfeff;
  --soft-line: #a5f3fc;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  min-height: 100svh;
  position: relative;
  padding: max(56px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  width: min(100%, 460px);
}

.screen-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 2px;
}

.brand {
  align-items: center;
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  text-align: center;
}

.brand-logo {
  display: block;
  height: auto;
}

.brand-logo-top {
  margin-bottom: 10px;
  max-width: 104px;
  width: 100%;
}

h1 {
  color: var(--primary);
  font-size: 29px;
  font-weight: 900;
  line-height: 1;
  margin: 0;
}

#attendance-view + #live-map-view,
.screen-content:has(#attendance-view:not(.hidden)) .brand {
  margin-bottom: 8px;
}

.panel {
  background: var(--card);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  padding: 16px;
}

.login-footer-logo {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.brand-logo-bottom {
  max-width: 96px;
  width: 100%;
}

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

label span,
legend {
  color: #334155;
  display: block;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 8px;
}

#attendance-view legend {
  display: none;
}

input[type="text"],
input[type="password"],
input:not([type]) {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 18px;
  min-height: 52px;
  padding: 12px 14px;
  width: 100%;
}

input:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(21, 94, 117, 0.16);
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.segmented {
  background: #e2e8f0;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
  padding: 6px;
}

.segmented label {
  margin: 0;
}

.segmented input {
  inline-size: 1px;
  opacity: 0;
  position: absolute;
}

.segmented span {
  align-items: center;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: 16px;
  font-weight: 800;
  justify-content: center;
  margin: 0;
  min-height: 40px;
}

.segmented input:checked + span {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.primary-button {
  align-items: center;
  background: var(--primary);
  border: 0;
  border-radius: 8px;
  color: #fff;
  display: flex;
  font-size: 17px;
  font-weight: 900;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  width: 100%;
}

.primary-button:active {
  background: var(--primary-dark);
}

.primary-button:disabled {
  opacity: 0.7;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--primary);
  font-weight: 800;
  padding: 8px;
}

.session-actions {
  display: flex;
  justify-content: flex-end;
  position: absolute;
  right: 16px;
  top: max(10px, env(safe-area-inset-top));
}

.logout-button {
  background: #dc2626;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  padding: 7px 12px;
}

.logout-button:active {
  background: #b91c1c;
}

.user-card {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  display: flex;
  margin-bottom: 14px;
  min-height: 0;
  padding: 10px 12px;
}

.employee-name,
.employee-rut {
  margin: 0;
}

.chile-datetime {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  margin: 0 0 6px;
}

.employee-name {
  font-size: 17px;
  font-weight: 900;
}

.employee-rut {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.status-message {
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  margin: 10px 0 0;
  min-height: 20px;
  text-align: center;
}

.status-message.error {
  background: #fef2f2;
  color: #991b1b;
  padding: 12px;
}

.status-message.success {
  background: #ecfdf5;
  color: #166534;
  padding: 12px;
}

.map-panel {
  background: var(--card);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  margin-top: 14px;
  overflow: hidden;
  padding: 14px;
}

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

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

.map-panel-title {
  color: #334155;
  font-size: 14px;
  font-weight: 800;
  margin: 0;
}

.map-panel-help {
  color: #166534;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 8px;
}

.map-action-button {
  background: #e2e8f0;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  min-height: 32px;
  padding: 6px 10px;
}

.map-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 0 0 12px;
}

.live-map {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  height: 280px;
  overflow: hidden;
  width: 100%;
}

.user-map-icon,
.allowed-map-icon {
  align-items: center;
  border-radius: 999px;
  color: #fff;
  display: flex;
  font-size: 14px;
  font-weight: 900;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.user-map-icon {
  background: #0f766e;
  border: 2px solid #ccfbf1;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.22);
}

.allowed-map-icon {
  background: #16a34a;
  border: 2px solid #dcfce7;
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.2);
}

.allowed-location-tooltip {
  background: #0f172a !important;
  border: 0 !important;
  border-radius: 999px !important;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
  color: #fff !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 6px 10px !important;
}

.allowed-location-tooltip:before {
  display: none !important;
}

.leaflet-control-locate {
  margin-top: 6px !important;
  margin-left: 0 !important;
}

.leaflet-control-locate a {
  align-items: center;
  background: #111827 !important;
  border-radius: 4px !important;
  color: #fff !important;
  display: flex !important;
  height: 30px !important;
  justify-content: center;
  width: 30px !important;
}

.leaflet-control-locate a:hover {
  background: #1f2937 !important;
  color: #fff !important;
}

.leaflet-control-locate.active a,
.leaflet-control-locate.following a {
  background: #111827 !important;
  color: #fff !important;
}

.leaflet-control-locate .leaflet-control-locate-location-arrow {
  color: #fff !important;
  font-size: 17px !important;
  fill: #fff !important;
  stroke: #fff !important;
}

.leaflet-control-locate .leaflet-control-locate-location-arrow::before {
  color: #fff !important;
}

.leaflet-control-locate .leaflet-control-locate-location-arrow svg,
.leaflet-control-locate .leaflet-control-locate-location-arrow path {
  fill: #fff !important;
  stroke: #fff !important;
}

.leaflet-control-locate a .leaflet-control-locate-location-arrow,
.leaflet-control-locate a .leaflet-control-locate-location-arrow::before {
  color: #fff !important;
  fill: #fff !important;
  stroke: #fff !important;
  filter: brightness(0) invert(1);
}

.leaflet-touch .leaflet-bar.leaflet-control-locate a {
  line-height: 30px !important;
}

.leaflet-top.leaflet-left .leaflet-control-zoom,
.leaflet-top.leaflet-left .leaflet-control-locate {
  margin-left: 10px !important;
}

.leaflet-control-zoom a {
  background: #111827 !important;
  color: #fff !important;
  border-color: #111827 !important;
  text-shadow: none !important;
}

.leaflet-control-zoom a:hover {
  background: #1f2937 !important;
  color: #fff !important;
}

.leaflet-touch .leaflet-bar a {
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
}

.mobile-toast {
  border-radius: 12px !important;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18) !important;
  padding: 14px 16px !important;
}

.swal2-container.swal2-top {
  padding-top: max(68px, env(safe-area-inset-top)) !important;
}

.hidden {
  display: none;
}

@media (max-height: 760px) {
  .app-shell {
    padding-top: max(60px, env(safe-area-inset-top));
  }

  .brand {
    margin-bottom: 12px;
  }

  .brand-logo-top {
    max-width: 92px;
  }

  h1 {
    font-size: 26px;
  }

  .login-footer-logo {
    margin-top: 10px;
  }

  .brand-logo-bottom {
    max-width: 80px;
  }

  .live-map {
    height: 260px;
  }
}
