:root {
  color-scheme: light;
  --bg: #f4f5f1;
  --ink: #16201e;
  --muted: #62706b;
  --panel: #ffffff;
  --line: #d9dfd7;
  --accent: #1f5d50;
  --accent-strong: #18312f;
  --accent-soft: #dfece7;
  --gold: #b98d2f;
  --surface: #fbfcfa;
  --warn: #9b2f2f;
  --shadow: 0 14px 38px rgba(24, 49, 47, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  touch-action: manipulation;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  background: rgba(244, 245, 241, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.eyebrow,
.panel-heading p,
.log-panel p,
.summary-strip span {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 750;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.45rem, 1.25rem + 1vw, 2.1rem);
}

h2 {
  font-size: 1.08rem;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px 14px 34px;
}

.entry-panel,
.log-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-panel {
  padding: 16px;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: #e4ebe5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.view-tab {
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.view-tab.active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 6px 16px rgba(24, 49, 47, 0.12);
}

.app-view {
  min-width: 0;
}

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

.panel-heading.compact {
  align-items: center;
  padding: 16px 16px 0;
}

.data-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px 12px;
  background: linear-gradient(180deg, #fff 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--line);
}

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

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.checkbox-row input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

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

[hidden] {
  display: none !important;
}

input,
select,
textarea,
output {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid #cbd4cf;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfa;
  color: var(--ink);
  outline: none;
}

output {
  display: flex;
  align-items: center;
  font-weight: 800;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 93, 80, 0.14);
}

.location-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
}

.map-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ec;
}

.map-canvas {
  position: relative;
  width: 100%;
  height: 190px;
  overflow: hidden;
  background: #bec8b8;
  cursor: crosshair;
  touch-action: manipulation;
}

.map-canvas img {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
  user-select: none;
}

.map-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
}

.map-marker::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transform: translate(-50%, -50%);
}

.map-preview p {
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.actions,
.toolbar,
.filters {
  display: flex;
  gap: 10px;
}

.actions {
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 0 16px;
}

.primary-button {
  flex: 1;
  min-width: 0;
  background: var(--accent-strong);
  color: #fff;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  min-width: 46px;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.summary-strip div {
  position: relative;
  min-width: 0;
  padding: 14px 14px 13px;
  overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #edf3ef 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-strip div::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
  content: "";
}

.summary-strip div:nth-child(4)::before,
.summary-strip div:nth-child(5)::before {
  background: var(--gold);
}

.summary-strip strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 1.34rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-panel {
  overflow: hidden;
}

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.filters input {
  flex: 1;
}

.filters select {
  width: 100%;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  background: #fff;
}

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

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

th {
  background: #f8faf7;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

th:nth-child(n+4):nth-child(-n+8),
td:nth-child(n+4):nth-child(-n+8) {
  text-align: right;
}

td:nth-child(1),
td:nth-child(2) {
  font-weight: 800;
}

td:nth-child(4) {
  color: var(--accent-strong);
  font-weight: 900;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.sync-pill.saved {
  background: #e0eee8;
  color: var(--accent-strong);
}

.sync-pill.pending {
  background: #fff1ce;
  color: #77520b;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8faf7;
}

.data-view .summary-strip {
  margin-top: 0;
}

.text-button {
  margin-right: 8px;
  padding: 8px 0;
  background: transparent;
  color: var(--accent);
}

.map-link {
  display: inline-block;
  margin-left: 10px;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 800;
}

.entry-panel,
.log-panel,
.summary-strip,
.form-grid,
.panel-heading,
.data-title,
.filters,
.actions,
.toolbar,
.view-tabs {
  min-width: 0;
}

.danger {
  color: var(--warn);
}

.empty-state {
  display: none;
  padding: 24px 16px;
  text-align: center;
}

.empty-state.visible {
  display: block;
}

@media (max-width: 720px) {
  main {
    padding: 10px 8px 26px;
  }

  .app-header {
    gap: 10px;
    padding-inline: 12px;
  }

  .entry-panel {
    padding: 10px;
  }

  .view-tabs {
    margin-bottom: 10px;
  }

  .view-tab {
    min-height: 40px;
    font-size: 16px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr) minmax(96px, 112px);
    gap: 8px;
  }

  label {
    font-size: 0.76rem;
    gap: 5px;
  }

  input,
  select,
  textarea,
  output {
    font-size: 16px;
    min-height: 42px;
    padding: 7px 8px;
  }

  input[type="date"],
  input[type="time"] {
    width: 100%;
    max-width: 100%;
    font-size: 16px;
    padding-inline: 5px;
    -webkit-appearance: none;
    appearance: none;
  }

  input[type="date"]::-webkit-date-and-time-value,
  input[type="time"]::-webkit-date-and-time-value {
    margin: 0;
    min-width: 0;
    text-align: left;
  }

  .date-field,
  .time-field {
    overflow: hidden;
  }

  .time-field input {
    text-align: left;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0;
  }

  .summary-strip div:first-child {
    grid-column: 1 / -1;
  }

  .summary-strip div {
    padding: 10px 10px 10px 12px;
  }

  .summary-strip strong {
    font-size: 1.08rem;
  }

  .panel-heading {
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .panel-heading.compact {
    align-items: flex-start;
    padding: 12px 12px 0;
  }

  .data-title {
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
  }

  .data-title h2 {
    font-size: 1rem;
  }

  .toolbar {
    gap: 6px;
  }

  .secondary-button,
  .primary-button {
    min-height: 42px;
    padding-inline: 12px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  .location-row {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .map-canvas {
    height: 150px;
  }

  .filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 12px;
    background: #fff;
  }

  .filters select {
    width: 100%;
  }

  .table-wrap {
    padding: 10px;
    overflow-x: hidden;
    background: #f4f5f1;
  }

  table,
  tbody {
    display: block;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(24, 49, 47, 0.08);
  }

  td {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    min-height: 0;
    padding: 0;
    border: 0;
    text-align: left !important;
  }

  td > * {
    min-width: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  td:nth-child(1) {
    grid-column: 1 / -1;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    color: var(--accent-strong);
    font-size: 1rem;
  }

  td:nth-child(2),
  td:nth-child(3) {
    grid-column: 1 / -1;
    padding-bottom: 2px;
  }

  td:nth-child(2) {
    font-size: 1.02rem;
  }

  td:nth-child(3) {
    color: var(--muted);
  }

  td:nth-child(n+4):nth-child(-n+8) {
    min-height: 58px;
    padding: 8px;
    background: #f8faf7;
    border: 1px solid #e3e8e1;
    border-radius: 8px;
    font-weight: 900;
  }

  td:nth-child(4) {
    background: #e8f0ed;
  }

  td:nth-child(9) {
    grid-column: 1 / -1;
    padding-top: 4px;
  }

  td:nth-child(10) {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding-top: 4px;
  }

  td:nth-child(10)::before {
    display: none;
  }

  .text-button {
    margin-right: 0;
    padding: 8px 0;
  }
}
