:root {
  --bg: #0c0e12;
  --bg-card: #12151c;
  --bg-input: #1a1e28;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaed;
  --text-dim: #8b919a;
  --accent: #00e5ff;
  --accent-hover: #00b8d4;
  --accent-text: #12151c;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --header-h: 56px;
  --radius: 8px;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-display: "Syne", system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

::selection {
  background: var(--accent);
  color: var(--accent-text);
}

.site-header {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: var(--header-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 14, 18, 0.94);
  backdrop-filter: blur(16px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.site-header .brand-link {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  text-decoration: none;
  opacity: 0.92;
  transition: opacity 0.15s;
}

.site-header .brand-link:hover {
  opacity: 1;
}

.site-header .brand-link img {
  display: block;
  height: 26px;
  width: auto;
}

.header-divider {
  width: 1px;
  height: 28px;
  flex-shrink: 0;
  background: var(--border);
}

.product-lockup {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.product-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.product-tag {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.site-header .header-link {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.site-header .header-link:hover {
  color: var(--accent);
}

.btn-consult {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.18);
  transition: filter 0.15s, box-shadow 0.15s;
}

.btn-consult:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 32px rgba(0, 229, 255, 0.28);
}

.btn-consult-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(0, 229, 255, 0.35);
  box-shadow: none;
}

.btn-consult-ghost:hover {
  background: rgba(0, 229, 255, 0.08);
  filter: none;
}

.btn-consult-block {
  width: 100%;
}

.usage-meter {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.usage-meter.low {
  color: var(--orange);
  border-color: rgba(245, 158, 11, 0.35);
}

.usage-meter.exhausted {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.35);
}

.schedule-card {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.05), transparent);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-card-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.schedule-card-text {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}

.limit-modal-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 16px;
}

.limit-modal-content {
  max-width: 420px;
}

#app {
  display: flex;
  height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
}

/* Sidebar */
#sidebar {
  width: 380px;
  min-width: 380px;
  height: 100%;
  overflow-y: auto;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-intro {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

/* Sections */
.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 3px;
}

.tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.tab:hover:not(.active) {
  color: var(--text);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Inputs */
.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus {
  border-color: var(--accent);
}

select.input {
  cursor: pointer;
}

label {
  font-size: 12px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

.row {
  display: flex;
  gap: 10px;
}

.col {
  flex: 1;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* File drop */
.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 13px;
  color: var(--text-dim);
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--accent);
  color: var(--text);
}

/* Address results */
.address-results {
  display: none;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.address-result {
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
}

.address-result:hover {
  background: var(--border);
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  align-self: flex-start;
}

/* Advanced */
.advanced summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  user-select: none;
  padding: 6px 0;
}

.advanced[open] summary {
  margin-bottom: 8px;
}

/* Checkbox */
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px !important;
  color: var(--text) !important;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Lot info */
.lot-info {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 12px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.metric-row span:last-child {
  font-weight: 600;
}

/* Progress */
.progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

.progress-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* Results */
.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.result-card {
  background: var(--bg-input);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.result-value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Error */
.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  color: #fca5a5;
  line-height: 1.4;
}

/* Plots */
.plots-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plots-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.plots-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.plot-item {
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  color: var(--text-dim);
  transition: all 0.15s;
}

.plot-item:hover {
  border-color: var(--accent);
  color: var(--text);
}

.plot-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

#plot-display {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: none;
  margin-top: 4px;
}

#plot-display[src] {
  display: block;
}

#plot-display.loading {
  display: block;
  min-height: 200px;
  opacity: 0.3;
  background: var(--bg-input) url("/static/spinner.svg") center no-repeat;
}

/* Result actions */
.result-actions {
  display: flex;
  gap: 8px;
}

/* Saved designs */
.saved-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.saved-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.saved-item:hover {
  border-color: var(--accent);
}

.saved-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.saved-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.saved-item-date {
  font-size: 11px;
  color: var(--text-dim);
}

.saved-item-metrics {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.saved-item-metrics span {
  white-space: nowrap;
}

.saved-item-metrics b {
  color: var(--text);
  font-weight: 600;
}

.saved-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.saved-item-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.saved-item-actions button:hover {
  background: var(--border);
  color: var(--text);
}

.saved-item-actions .del-btn:hover {
  color: var(--red);
}

/* Comparison modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.compare-table-wrap {
  overflow: auto;
  padding: 16px 20px;
}

.compare-table {
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.compare-table th,
.compare-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.compare-table th:first-child,
.compare-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.3px;
}

.compare-table th {
  color: var(--text);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.compare-table th .col-name {
  display: block;
  font-size: 13px;
}

.compare-table th .col-date {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
}

.compare-table td.best {
  color: var(--green);
  font-weight: 700;
}

/* Satellite toggle */
.sat-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.sat-toggle:hover {
  border-color: var(--accent);
}

.sat-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Map */
#map {
  flex: 1;
  height: 100%;
  background: var(--bg);
}

/* Leaflet overrides */
.leaflet-container {
  background: #1a1d27;
}

.leaflet-control-attribution {
  background: rgba(15, 17, 23, 0.8) !important;
  color: var(--text-dim) !important;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

@media (max-width: 640px) {
  .site-header {
    padding: 0 12px;
    gap: 12px;
  }

  .product-tag {
    display: none;
  }

  .site-header .header-link {
    display: none;
  }

  .btn-consult {
    padding: 8px 14px;
    font-size: 12px;
  }
}
