* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body {
  display: flex;
}

#sidebar {
  width: 320px;
  min-width: 320px;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  background: #fafafa;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sidebar h1 {
  font-size: 1.15rem;
  margin: 0;
}

.hint {
  font-size: 0.85rem;
  color: #444;
  margin: 0;
}

button {
  padding: 9px 12px;
  font-size: 0.9rem;
  border: 1px solid #888;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #eef;
}

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

.download-mode {
  margin: 10px 0;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.85rem;
}

.download-mode legend {
  padding: 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
}

.download-mode label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  cursor: pointer;
}

button.active {
  background: #2f6fed;
  border-color: #2f6fed;
  color: #fff;
}

#downloadBtn {
  background: #2f6fed;
  border-color: #2f6fed;
  color: #fff;
  font-weight: 600;
}

#downloadBtn:disabled {
  background: #9bb6f0;
  border-color: #9bb6f0;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-row label {
  font-size: 0.85rem;
}

.field-row input {
  width: 80px;
  padding: 6px;
  border: 1px solid #aaa;
  border-radius: 4px;
}

#estimate {
  font-size: 0.85rem;
  padding: 8px;
  background: #eef2ff;
  border-radius: 6px;
}

#estimate.warn {
  background: #fdecea;
  color: #8a1f11;
}

#progressBar {
  width: 100%;
  height: 10px;
  background: #ddd;
  border-radius: 5px;
  overflow: hidden;
}

#progressFill {
  height: 100%;
  width: 0;
  background: #2f6fed;
  transition: width 0.15s linear;
}

#progressText {
  font-size: 0.8rem;
  color: #444;
  margin-top: 4px;
}

#status {
  font-size: 0.8rem;
  color: #333;
  white-space: pre-line;
}

.footnote {
  margin-top: auto;
  font-size: 0.72rem;
  color: #666;
}

#map {
  flex: 1;
  height: 100%;
  background: #f2efe9;
  position: relative;
}

#mapInfo {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.9);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
}

#map.selecting {
  cursor: crosshair;
}

/* ============================================================ GIS toolkit */
.gis-panel {
  border-top: 1px solid #ddd;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gis-panel h2 {
  font-size: 1rem;
  margin: 0;
}

.gis-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
  margin-top: 6px;
}

.gis-layers-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gis-layer {
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  background: #fff;
}

.gis-layer-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
}

.gis-layer-name {
  flex: 1;
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gis-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: none;
}

.gis-icon-btn {
  padding: 2px 6px;
  font-size: 0.8rem;
  line-height: 1;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f7f7f7;
  cursor: pointer;
}

.gis-icon-btn:hover {
  background: #e9eefc;
}

.gis-editor-collapsed {
  display: none;
}

.gis-editor-open {
  display: block;
  padding: 6px 10px 10px;
  border-top: 1px solid #eee;
}

.gis-editor-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gis-row label {
  font-size: 0.8rem;
  color: #333;
}

.gis-row input[type="text"],
.gis-row select {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid #bbb;
  border-radius: 4px;
  font-size: 0.8rem;
}

.gis-row input.gis-num {
  width: 70px;
  padding: 4px 6px;
  border: 1px solid #bbb;
  border-radius: 4px;
}

.gis-reset-btn {
  margin-top: 4px;
  padding: 6px 8px;
  font-size: 0.78rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #f7f7f7;
  cursor: pointer;
  width: 100%;
}

.gis-reset-btn:hover {
  background: #eef2ff;
}

/* ============================================================ RTL (Persian) */
body.rtl {
  direction: rtl;
}

body.rtl #sidebar {
  border-right: none;
  border-left: 1px solid #ddd;
}
