:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #68717d;
  --line: #d9dee6;
  --accent: #1466d6;
  --accent-dark: #0d4fa9;
  --warning: #a65f00;
  --area: #db6b1f;
  --shadow: 0 12px 30px rgba(20, 35, 55, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(380px, 440px) minmax(0, 1fr);
  height: 100vh;
  min-height: 640px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #eef2f6;
}

.app-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.25;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 3px 14px rgba(30, 43, 58, 0.05);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.upload-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 76px;
  justify-content: center;
  align-items: center;
  border: 1px dashed #9ba8b8;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  background: #f8fbff;
}

.upload-box small {
  color: var(--muted);
}

#kmlInput {
  display: none;
}

.file-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.file-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  background: #f6f8fb;
  border: 1px solid #e4e8ef;
  border-radius: 6px;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.config-grid h2 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.config-grid label {
  display: grid;
  gap: 6px;
}

.config-grid label:nth-last-child(-n + 2) {
  grid-column: 1 / -1;
}

.config-grid span {
  color: var(--muted);
  font-size: 12px;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  height: 34px;
  border: 1px solid #cfd6df;
  border-radius: 6px;
  padding: 0 9px;
  color: var(--text);
  background: #fff;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 8px;
}

button {
  height: 36px;
  border: 1px solid #c7d0dc;
  border-radius: 6px;
  background: #fff;
  color: #26313d;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  color: #fff;
}

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

.task-panel {
  flex: 1;
  min-height: 260px;
  display: flex;
  flex-direction: column;
}

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

.task-header h2 {
  margin: 0;
}

.task-header span {
  color: var(--muted);
  font-size: 12px;
}

.task-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  flex: 1;
}

.task-table.empty,
.file-list.empty {
  border: 0;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid #e8ecf2;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6fa;
  color: #4d5966;
  font-weight: 600;
}

tr {
  cursor: pointer;
}

tr:hover td,
tr.selected td {
  background: #edf5ff;
}

.type-pill {
  display: inline-flex;
  min-width: 34px;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  color: #fff;
  background: var(--accent);
}

.type-pill.area {
  background: var(--area);
}

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

.map-stage {
  position: relative;
  min-width: 0;
  background: #dde5ee;
}

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

.map-status {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #3b4652;
  font-size: 13px;
}

.map-status.hidden {
  display: none;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 52vh) minmax(420px, 48vh);
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .map-stage {
    order: 1;
    min-height: 420px;
  }
}
