:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #162027;
  --muted: #65727c;
  --line: #d9e0e4;
  --accent: #13795b;
  --accent-strong: #0d5d45;
  --warn: #b35c00;
  --passed: #8b969d;
  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: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.topbar,
.tabs,
#status {
  padding-inline: clamp(16px, 3vw, 32px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-block: 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  letter-spacing: 0;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
}

.import-panel,
.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-badge {
  min-height: 40px;
  min-width: 58px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fbfb;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
}

.file-button,
button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  background: var(--accent-strong);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

input,
select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

input[type="number"] {
  width: 84px;
}

select {
  min-width: min(60vw, 290px);
}

.tabs {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab-button {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
}

.tab-button:hover,
.tab-button.active {
  background: #e7f2ee;
  color: var(--accent-strong);
}

.tab-panel {
  display: none;
  min-height: 0;
  position: relative;
}

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

.notifications {
  display: none;
  gap: 8px;
  padding: 10px clamp(16px, 3vw, 32px);
  overflow-x: auto;
  background: #fff8ec;
  border-bottom: 1px solid #ead7b6;
}

.notifications.visible {
  display: flex;
}

.notification {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid #dfc28b;
  border-radius: 8px;
  background: #fffdf8;
}

.notification.critical {
  border-color: #d58b85;
  background: #fff1f0;
}

.notification div {
  display: grid;
  gap: 2px;
}

.notification strong {
  font-size: 0.92rem;
}

.notification span {
  color: var(--muted);
  font-size: 0.82rem;
}

.notification button {
  min-height: 32px;
  padding-inline: 10px;
}

.notification.status-seen {
  background: #f8fbff;
}

.notification.status-preparing {
  background: #eef8f4;
}

#mapTab {
  min-height: 520px;
}

#map {
  height: calc(100vh - 166px);
  min-height: 520px;
  width: 100%;
}

.empty-state {
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(245, 247, 248, 0.9);
  border: 1px dashed var(--line);
  border-radius: 8px;
  pointer-events: none;
}

.empty-state.hidden {
  display: none;
}

.user-marker {
  position: relative;
  min-width: 42px;
  min-height: 28px;
  padding: 0 8px;
  display: inline-grid;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #2f80ed;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  box-shadow: 0 3px 10px rgba(22, 32, 39, 0.28);
}

.user-marker span {
  font-size: 0.65rem;
  font-weight: 750;
}

.user-marker.own {
  background: var(--accent);
}

.user-marker.athlete {
  background: #c43d32;
}

.user-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  background: inherit;
}

.table-wrap {
  overflow: auto;
  height: calc(100vh - 166px);
  min-height: 460px;
  background: var(--panel);
}

.athlete-panel {
  min-height: calc(100vh - 166px);
  padding: clamp(14px, 3vw, 28px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 18px);
  background: #eef3f1;
}

.athlete-button {
  min-height: clamp(96px, 18vh, 170px);
  border: 0;
  border-radius: 8px;
  padding: 18px;
  color: #ffffff;
  font-size: clamp(1.2rem, 3vw, 2.1rem);
  font-weight: 850;
  letter-spacing: 0;
  box-shadow: 0 8px 18px rgba(22, 32, 39, 0.16);
}

.athlete-button span {
  overflow-wrap: anywhere;
}

.athlete-button.ok {
  background: #13795b;
}

.athlete-button.feed {
  background: #1f6fbd;
}

.athlete-button.attention {
  background: #b35c00;
}

.athlete-button.mechanical {
  background: #37424a;
}

.athlete-button.critical {
  background: #b42318;
}

.athlete-button:hover {
  filter: brightness(0.94);
}

.athlete-button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.communication-panel {
  min-height: calc(100vh - 166px);
  padding: clamp(14px, 3vw, 28px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 18px);
  align-content: start;
  background: #eef3f1;
}

.contact-button {
  min-height: clamp(120px, 24vh, 220px);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  text-decoration: none;
  color: #ffffff;
  background: #13795b;
  box-shadow: 0 8px 18px rgba(22, 32, 39, 0.16);
}

.contact-button span {
  font-size: clamp(1.35rem, 3vw, 2.3rem);
  font-weight: 850;
}

.contact-button small {
  font-size: 0.95rem;
  font-weight: 700;
}

.contact-button.whatsapp {
  background: #13795b;
}

.contact-button.facetime {
  background: #1f6fbd;
}

.contact-button.tel {
  background: #37424a;
}

.contact-button.disabled {
  opacity: 0.42;
  pointer-events: none;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfb;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0;
}

tr.passed {
  color: var(--passed);
  background: #f4f5f5;
}

tr.next {
  background: #e6f5ee;
  box-shadow: inset 4px 0 0 var(--accent);
  font-weight: 700;
}

.point-name {
  display: grid;
  gap: 2px;
}

.point-meta {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.crew-cell {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.crew-note {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.crew-task {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
}

.crew-task input {
  min-height: auto;
}

.crew-task.done span {
  color: var(--passed);
  text-decoration: line-through;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 32px);
  align-items: start;
}

.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.admin-section.wide {
  grid-column: 1 / -1;
}

.admin-section h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

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

.config-facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.config-facts div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.config-facts dt {
  color: var(--muted);
}

.config-facts dd {
  margin: 0;
}

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

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

.point-meta-list {
  display: grid;
  gap: 12px;
}

.point-meta-editor {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.point-meta-editor h3 {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.95rem;
  letter-spacing: 0;
}

.point-meta-editor h3 span {
  color: var(--muted);
  font-weight: 500;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
  font: inherit;
}

.contact-row {
  display: grid;
  grid-template-columns: 1fr 130px 1.4fr;
  gap: 10px;
}

.segment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.segment-row > span:first-child {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.admin-empty {
  margin: 0;
}

#status {
  min-height: 34px;
  display: flex;
  align-items: center;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

@media (max-width: 780px) {
  .topbar,
  .import-panel,
  .admin-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .import-panel,
  .control-row {
    width: 100%;
  }

  .file-button,
  button,
  .session-badge,
  select {
    width: 100%;
  }

  #map,
  .table-wrap {
    height: calc(100vh - 250px);
    min-height: 420px;
  }

  .athlete-panel {
    grid-template-columns: 1fr;
  }

  .communication-panel,
  .contact-row {
    grid-template-columns: 1fr;
  }

  .segment-row,
  .config-facts div {
    grid-template-columns: 1fr;
  }

  .notification {
    grid-template-columns: 1fr;
    min-width: min(88vw, 360px);
  }

  .notification button {
    width: 100%;
  }
}
