:root {
  --panel: rgba(255, 255, 255, 0.97);
  --text: #17202a;
  --muted: #607080;
  --line: rgba(16, 24, 40, 0.12);
  --line-strong: rgba(16, 24, 40, 0.2);
  --shadow: 0 14px 38px rgba(15, 23, 42, 0.16);
  --radius: 16px;
  --focus: #245ea8;
}

* { box-sizing: border-box; }
html, body, #app-shell, #viewDiv { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: #eef2f6;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
#app-shell { position: relative; }
#viewDiv { position: absolute; inset: 0; }

.map-header {
  position: absolute; z-index: 10; top: 18px; left: 64px; right: 18px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  pointer-events: none;
}
.title-card {
  max-width: 615px; padding: 14px 16px 15px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.eyebrow, .command-eyebrow {
  margin: 0 0 4px; font-size: 11px; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; color: #536273;
}
h1 { margin: 0; font-size: 24px; line-height: 1.12; letter-spacing: -0.025em; }
.subtitle { margin: 7px 0 0; max-width: 560px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.data-state {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  font-size: 12px; font-weight: 650; white-space: nowrap;
}
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: #d97706; box-shadow: 0 0 0 4px rgba(217,119,6,.13); }
.data-state.ready .state-dot { background: #16803c; box-shadow: 0 0 0 4px rgba(22,128,60,.13); }
.data-state.error .state-dot { background: #c62828; box-shadow: 0 0 0 4px rgba(198,40,40,.13); }

.command-card {
  position: absolute; z-index: 12; right: 18px; bottom: 22px; width: min(450px, calc(100vw - 390px));
  padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.command-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.command-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.no-ai-badge {
  flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; background: #eef7f1; color: #237044;
  font-size: 9.5px; font-weight: 760; letter-spacing: .02em;
}
.command-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#command-input {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 12px;
  outline: none; background: white; color: var(--text); font-size: 12.5px;
}
#command-input:focus { border-color: rgba(36,94,168,.68); box-shadow: 0 0 0 3px rgba(36,94,168,.12); }
#command-submit {
  height: 44px; padding: 0 16px; border: 0; border-radius: 12px; background: #1f5f9f; color: white;
  font-size: 12px; font-weight: 760; cursor: pointer;
}
#command-submit:hover { background: #194f85; }
#command-submit:disabled { opacity: .55; cursor: wait; }
.command-response {
  min-height: 34px; margin-top: 9px; padding: 9px 10px; border-radius: 10px; background: #f5f8fb;
  font-size: 11px; line-height: 1.4; color: #465667;
}
.command-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.command-examples button {
  border: 1px solid var(--line); border-radius: 999px; background: white; color: #435466; padding: 5px 8px;
  font-size: 9.5px; font-weight: 680; cursor: pointer;
}
.command-examples button:hover { background: #f2f6f9; border-color: var(--line-strong); }
.command-help { margin-top: 8px; font-size: 9.5px; line-height: 1.35; color: #788593; }

.control-card {
  position: absolute; z-index: 12; left: 18px; bottom: 22px; width: 330px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  box-shadow: var(--shadow); backdrop-filter: blur(10px); overflow: visible;
}
.control-section { padding: 13px 15px; }
.control-section + .control-section { border-top: 1px solid var(--line); }
.search-section, .operator-section { position: relative; }
.search-section { border-radius: var(--radius) var(--radius) 0 0; }
.search-section label, .section-heading-row h2 {
  display: block; margin: 0 0 8px; font-size: 13px; font-weight: 760; letter-spacing: -0.01em;
}
.search-wrap, .operator-wrap { position: relative; }
#well-search, #operator-filter {
  width: 100%; height: 42px; padding: 0 40px 0 12px; border: 1px solid var(--line-strong);
  border-radius: 11px; outline: none; background: #fff; color: var(--text); font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#operator-filter { padding-right: 12px; }
#well-search::placeholder, #operator-filter::placeholder { color: #8a96a3; }
#well-search:focus, #operator-filter:focus { border-color: rgba(36,94,168,.65); box-shadow: 0 0 0 3px rgba(36,94,168,.12); }
.clear-search {
  position: absolute; top: 50%; right: 8px; width: 28px; height: 28px; transform: translateY(-50%);
  border: 0; border-radius: 8px; background: transparent; color: #667482; font-size: 20px; line-height: 1; cursor: pointer;
}
.clear-search:hover { background: #f0f3f6; }
.search-hint, .operator-hint { margin-top: 7px; font-size: 10.5px; line-height: 1.35; color: var(--muted); }
.search-results, .operator-results {
  position: absolute; z-index: 30; left: 15px; right: 15px; max-height: 300px; overflow-y: auto;
  border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; box-shadow: 0 16px 35px rgba(15,23,42,.2);
}
.search-results { top: 83px; }
.operator-results { top: 91px; z-index: 31; }
.search-message, .operator-message { padding: 12px; font-size: 12px; color: var(--muted); }
.search-result, .operator-result {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid #edf0f2;
  background: #fff; text-align: left; cursor: pointer;
}
.search-result:last-child, .operator-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result:focus-visible, .operator-result:hover, .operator-result:focus-visible { background: #f5f8fb; outline: none; }
.operator-result { font-size: 12px; font-weight: 690; color: #263746; }
.operator-summary { margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; font-weight: 650; color: #536273; }
.operator-summary.is-filtered { color: #245ea8; }
.result-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.result-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 740; color: #243342; }
.result-status { flex: 0 0 auto; font-size: 10px; font-weight: 700; color: #5f6d79; }
.result-meta { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: #75818d; }
.section-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-heading-row h2 { margin: 0; }
.text-button { border: 0; padding: 2px 0; background: transparent; color: #356ca9; font-size: 10.5px; font-weight: 700; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.status-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.status-chip {
  display: flex; align-items: center; gap: 8px; min-width: 0; height: 36px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: #344250;
  font-size: 11.5px; font-weight: 680; cursor: pointer;
  transition: opacity .15s ease, background .15s ease, border-color .15s ease, transform .08s ease;
}
.status-chip:hover { background: #f7f9fb; }
.status-chip:active { transform: translateY(1px); }
.status-chip[aria-pressed="false"] { opacity: .42; background: #f3f5f7; }
.status-chip[aria-pressed="true"] { border-color: rgba(23,32,42,.27); }
.status-chip:focus-visible { outline: 3px solid rgba(36,94,168,.18); outline-offset: 1px; }
.filter-summary { margin-top: 9px; font-size: 10.5px; color: var(--muted); }
.marker {
  display: inline-block; flex: 0 0 auto; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid white; box-shadow: 0 0 0 1px rgba(15,23,42,.22);
}
.marker-active { background: #219653; }
.marker-idle { background: #f59e0b; }
.marker-permitted { background: #2563eb; }
.marker-plugged { background: #6b7280; }
.marker-canceled { background: #dc2626; }
.marker-other { background: #4b5563; }
.zoom-help { display: flex; flex-direction: column; gap: 3px; }
.zoom-help strong { font-size: 11.5px; }
.zoom-help span { font-size: 10.5px; line-height: 1.4; color: var(--muted); }
.source-line { padding: 0 15px 13px; font-size: 9.5px; line-height: 1.35; color: #7b8794; }

.esri-popup__main-container { border-radius: 16px; overflow: hidden; box-shadow: 0 18px 42px rgba(15,23,42,.22); }
.esri-popup__header-title { font-weight: 780; }
.esri-feature__content-element { margin-top: 0; }
.esri-popup__button { border-radius: 8px; }

@media (max-width: 980px) {
  .command-card { right: 10px; bottom: 10px; width: 390px; }
  .control-card { left: 10px; bottom: 10px; }
}

@media (max-width: 760px) {
  .map-header { left: 56px; top: 10px; right: 10px; }
  .title-card { padding: 11px 12px; }
  .eyebrow, .subtitle, .data-state { display: none; }
  h1 { font-size: 18px; }
  .command-card {
    left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 34vh; overflow-y: auto;
  }
  .control-card {
    left: 10px; right: 10px; bottom: calc(34vh + 20px); width: auto; max-height: 50vh; overflow-y: auto;
  }
  .search-results, .operator-results { position: fixed; left: 20px; right: 20px; max-height: 190px; }
  .search-results { top: auto; bottom: calc(84vh - 62px); }
  .operator-results { top: auto; bottom: calc(84vh - 175px); }
  .status-filters { grid-template-columns: repeat(3, 1fr); }
  .status-chip { padding: 0 8px; }
  .source-line { display: none; }
  .command-examples { display: none; }
}
