:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f4;
  color: #18242d;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

button {
  font: inherit;
  border: 1px solid #126d62;
  border-radius: 6px;
  background: #126d62;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 34px;
  padding: 7px 11px;
}

button:disabled {
  background: #d9e0e6;
  border-color: #d9e0e6;
  color: #71808e;
  cursor: not-allowed;
}

.ns-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
}

.app-header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #d4dbe1;
  display: flex;
  gap: 18px;
  min-height: 58px;
  padding: 6px 18px;
}

.home-link {
  color: #126d62;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.title-block {
  min-width: 0;
  flex: 1;
}

.title-block h1 {
  font-size: 1.1rem;
  margin: 0;
}

.title-block p {
  color: #5b6b78;
  font-size: 0.8rem;
  margin: 2px 0 0;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.status {
  color: #5b6b78;
  font-size: 0.82rem;
}

.status[data-kind="error"] {
  color: #c92a2a;
  font-weight: 700;
}

.workspace {
  display: flex;
  min-height: 0;
}

.panel {
  display: flex;
  flex: none;
  flex-direction: column;
  min-width: 0;
  width: 54%;
}

.panel-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 24px;
}

/* 表の行を押したときの詳しい内容（左パネルの下半分） */
.detail {
  background: #fff;
  border-top: 3px solid #126d62;
  box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex: none;
  flex-direction: column;
  height: 50%;
  min-height: 0;
}

.detail[hidden] {
  display: none;
}

.detail-head {
  align-items: center;
  border-bottom: 1px solid #e3e8ec;
  display: flex;
  gap: 10px;
  padding: 8px 16px;
}

.detail-head h2 {
  flex: 1;
  font-size: 0.95rem;
  margin: 0;
}

.detail-close {
  background: #fff;
  border-color: #cfd8df;
  color: #40505e;
  min-height: 28px;
  padding: 3px 10px;
}

#detail-body {
  overflow-y: auto;
  padding: 10px 16px 18px;
}

.detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.85rem;
  margin: 0 0 10px;
}

.detail-summary b {
  font-variant-numeric: tabular-nums;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.detail h3 {
  color: #40505e;
  font-size: 0.82rem;
  margin: 10px 0 4px;
}

.detail .daily svg {
  max-height: 150px;
}

table.accounts {
  border-collapse: collapse;
  font-size: 0.8rem;
  width: 100%;
}

.accounts th,
.accounts td {
  border-bottom: 1px solid #e3e8ec;
  padding: 3px 6px;
  text-align: left;
  white-space: nowrap;
}

.accounts thead th {
  background: #f4f7f9;
  color: #40505e;
}

.accounts td.memo-cell {
  white-space: normal;
  min-width: 180px;
}

.memo-text {
  margin-right: 6px;
}

.muted {
  color: #8a97a3;
}

.memo-edit {
  background: #fff;
  border-color: #cfd8df;
  color: #126d62;
  font-size: 0.75rem;
  min-height: 0;
  padding: 1px 7px;
}

.memo-edit-row {
  display: flex;
  gap: 4px;
}

.memo-input {
  border: 1px solid #126d62;
  border-radius: 4px;
  flex: 1;
  font: inherit;
  min-width: 160px;
  padding: 3px 6px;
}

.memo-save,
.memo-cancel {
  flex: none;
  white-space: nowrap;
  font-size: 0.75rem;
  min-height: 0;
  padding: 2px 8px;
}

.memo-cancel {
  background: #fff;
  border-color: #cfd8df;
  color: #40505e;
}

.error-text {
  color: #c92a2a;
}

.accounts .n {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.workspace.is-map-hidden .map-panel {
  display: none;
}

/* 表と地図の境目（多良間村 農地マップの「表と地図」と同じ作り）。ドラッグで幅、ボタンで ◀ 縮める／○ 半分／▶ 地図を隠す */
.split-bar {
  background: #d4dbe1;
  cursor: col-resize;
  flex: none;
  position: relative;
  touch-action: none;
  width: 8px;
}

.split-bar:hover {
  background: #9fb3bf;
}

.split-buttons {
  background: #fff;
  border: 1px solid #cfd8df;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 4px;
  left: 50%;
  padding: 4px 2px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.split-buttons button {
  background: transparent;
  border: none;
  border-radius: 50%;
  color: #126d62;
  font-size: 0.72rem;
  height: 22px;
  line-height: 22px;
  min-height: 0;
  padding: 0;
  width: 22px;
}

.split-buttons button:hover {
  background: #e3efec;
}

.split-buttons button.is-on {
  background: #126d62;
  color: #fff;
}

/* 地図を隠したときは境目が右端に来るので、ボタンを内側へ寄せる */
.workspace.is-map-hidden .split-buttons {
  left: auto;
  right: 2px;
  transform: translateY(-50%);
}

/* 表を細くしたときは、地区・撮影済み・割合の列だけにする */
.panel.is-narrow .districts th:nth-child(2),
.panel.is-narrow .districts td:nth-child(2),
.panel.is-narrow .districts th:nth-child(3),
.panel.is-narrow .districts td:nth-child(3),
.panel.is-narrow .districts th:nth-child(n + 6),
.panel.is-narrow .districts td:nth-child(n + 6) {
  display: none;
}

.panel.is-narrow .note,
.panel.is-narrow .how,
.panel.is-narrow .tile-sub {
  display: none;
}

.map-panel {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
}

#map {
  height: 100%;
  width: 100%;
}

.tiles {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.tile {
  background: #fff;
  border: 1px solid #d4dbe1;
  border-radius: 8px;
  padding: 10px 12px;
}

.tile-label {
  color: #5b6b78;
  font-size: 0.78rem;
}

.tile-value {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin-top: 2px;
}

.tile-value small {
  color: #5b6b78;
  font-size: 0.8rem;
  font-weight: 400;
}

.tile-sub {
  color: #5b6b78;
  font-size: 0.75rem;
  margin-top: 2px;
}

.block {
  background: #fff;
  border: 1px solid #d4dbe1;
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px 12px;
}

.block h2 {
  font-size: 0.95rem;
  margin: 0 0 6px;
}

.note,
.how {
  color: #40505e;
  font-size: 0.8rem;
}

.note {
  margin: 0 0 8px;
}

.bar-legend {
  color: #40505e;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8rem;
  gap: 4px 14px;
  margin: 0 0 8px;
}

.sw-bar {
  border-radius: 3px;
  display: inline-block;
  height: 10px;
  margin-right: 5px;
  vertical-align: -1px;
  width: 18px;
}

.sw-bar-done {
  background: #2f9e44;
}

.sw-bar-near {
  background: #74c0fc;
}

.sw-bar-todo {
  background: #e9ecef;
  box-shadow: inset 0 0 0 1px #cfd8df;
}

.panel.is-narrow .bar-legend {
  display: none;
}

.how ul {
  margin: 0;
  padding-left: 1.2em;
}

.how li {
  margin-bottom: 4px;
}

.daily svg {
  display: block;
  width: 100%;
  max-height: 180px;
}

.daily .axis {
  stroke: #cfd8df;
  stroke-width: 1;
}

.daily .bar-value {
  fill: #18242d;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.daily .bar-label {
  fill: #5b6b78;
  font-size: 11px;
}

.detail .daily .bar:hover path {
  fill: #0b4f47;
}

.chart-wrap {
  position: relative;
}

.chart-tip {
  background: #fff;
  border: 1px solid #cfd8df;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.78rem;
  min-width: 170px;
  padding: 6px 9px;
  pointer-events: none;
  position: absolute;
  z-index: 10;
}

.chart-tip[hidden] {
  display: none;
}

.chart-tip table {
  border-collapse: collapse;
  width: 100%;
}

.chart-tip td {
  padding: 1px 0;
}

.chart-tip td.n {
  font-variant-numeric: tabular-nums;
  padding-left: 12px;
  text-align: right;
}

.chart-tip i,
.chart-legend i {
  border-radius: 2px;
  display: inline-block;
  height: 10px;
  margin-right: 5px;
  vertical-align: -1px;
  width: 10px;
}

.tip-title {
  font-weight: 700;
  margin-bottom: 3px;
}

.tip-sub {
  border-top: 1px solid #e3e8ec;
  color: #5b6b78;
  margin-top: 4px;
  padding-top: 3px;
}

.chart-legend {
  color: #40505e;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.78rem;
  gap: 4px 14px;
  margin-top: 4px;
}

.daily .bar:focus {
  outline: none;
}

.daily .bar:focus rect,
.daily .bar:hover rect {
  fill: rgba(18, 109, 98, 0.06);
}

.empty {
  color: #5b6b78;
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
}

table.districts {
  border-collapse: collapse;
  font-size: 0.8rem;
  width: 100%;
}

.districts th,
.districts td {
  border-bottom: 1px solid #e3e8ec;
  padding: 4px 5px;
  text-align: left;
  white-space: nowrap;
}

.districts thead th {
  background: #f4f7f9;
  color: #40505e;
  font-weight: 700;
  position: sticky;
  top: 0;
}

.districts .n {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.districts td.place {
  color: #40505e;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.districts td.memo-col {
  color: #18242d;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.districts .island-row {
  background: #f4f7f9;
  font-weight: 700;
}

.districts .total-row {
  border-top: 2px solid #9aa7b2;
  font-weight: 700;
}

.districts tr[data-key] {
  cursor: pointer;
}

.districts .district-row th {
  font-weight: 400;
  padding-left: 16px;
}

.districts tr[data-key]:hover,
.districts tr[data-key]:focus {
  background: #e6f4f1;
  outline: none;
}

.districts .is-selected {
  background: #d3eee8;
}

.bar-cell {
  width: 64px;
}

.progress {
  background: #e9ecef;
  border-radius: 4px;
  display: flex;
  height: 10px;
  overflow: hidden;
  width: 64px;
}

.p-done {
  background: #2f9e44;
}

.p-near {
  background: #74c0fc;
}

.zoom-level {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #cfd8df;
  border-radius: 6px;
  color: #40505e;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  padding: 4px 9px;
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 12px;
}

.legend {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #cfd8df;
  border-radius: 6px;
  bottom: 24px;
  font-size: 0.78rem;
  left: 12px;
  padding: 8px 10px;
  position: absolute;
}

.legend div + div {
  margin-top: 4px;
}

.sw {
  border: 1px solid #333;
  display: inline-block;
  height: 12px;
  margin-right: 6px;
  vertical-align: -2px;
  width: 18px;
}

.sw-old {
  background: #ed5151;
}

.sw-new {
  background: #ffd400;
}

.sw-done {
  background: #2f9e44;
}

.sw-near {
  background: #ffd400;
  border: 2.5px solid #1c7ed6;
}

.sw-photo {
  background: #fff;
  border: 1.5px solid #000;
  border-radius: 50%;
  height: 9px;
  width: 9px;
  margin-left: 4px;
  margin-right: 11px;
}

.sr-only {
  clip: rect(0 0 0 0);
  height: 1px;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

@media (max-width: 900px) {
  .ns-app {
    height: auto;
  }

  .app-header {
    flex-wrap: wrap;
  }

  .workspace {
    flex-direction: column;
  }

  .panel {
    width: auto !important;
  }

  .detail {
    height: auto;
  }

  .split-bar {
    display: none;
  }

  .workspace.is-map-hidden .map-panel,
  .map-panel {
    display: block;
    flex: none;
    height: 70vh;
    order: -1;
  }
}
