:root {
  --bg: #050505;
  --panel: #121214;
  --panel-soft: #171719;
  --card: #151518;
  --border: #2f2f36;
  --line: #3a2a20;
  --orange: #ff6a00;
  --orange-2: #e34a00;
  --pink: #ff2f86;
  --text: #ffffff;
  --muted: #b9c0cf;
  --success: #80e28a;
  --danger: #ff4d6d;
  --warning: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

body {
  background:
    linear-gradient(135deg, rgba(255, 106, 0, .08), transparent 28%),
    linear-gradient(180deg, #050505 0%, #0b0b0d 46%, #050505 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 106, 0, .55);
  background: linear-gradient(90deg, #050505 0%, #15110e 70%, #2a1205 100%);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border: 2px solid var(--orange);
  border-radius: 16px;
  background: #111;
  padding: 4px;
  box-shadow: 0 0 18px rgba(255, 106, 0, .35);
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.brand h1 span {
  color: var(--orange);
}

.brand p {
  margin: 5px 0 0;
  color: #ffd7a8;
  font-size: 13px;
  font-weight: 700;
}

.topbar-actions,
.quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.run-btn,
.upload-btn,
.ghost-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 0;
  padding: 10px 16px;
  color: #fff;
  font-weight: 900;
  white-space: nowrap;
}

.run-btn,
.upload-btn {
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  box-shadow: 0 12px 26px rgba(255, 106, 0, .24);
}

.run-btn.secondary {
  background: linear-gradient(135deg, #ff8a1c, #c43000);
}

.ghost-btn {
  border: 1px solid rgba(255, 106, 0, .55);
  color: #ffb16b;
  background: rgba(255, 106, 0, .075);
}

.ghost-btn.danger {
  border-color: rgba(255, 77, 109, .65);
  color: #ff9fb3;
  background: rgba(255, 77, 109, .08);
}

.run-btn:hover,
.upload-btn:hover,
.ghost-btn:hover {
  filter: brightness(1.08);
}

.status-strip {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr 1fr;
  gap: 1px;
  border-bottom: 1px solid #222;
  background: #222;
}

.status-strip > div {
  min-width: 0;
  padding: 13px 18px;
  background: #0b0b0d;
}

.status-strip small,
.metric small,
.card small,
.finance small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-strip strong,
.metric strong,
.card strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  overflow-x: auto;
  gap: 0;
  padding-left: 28px;
  border-bottom: 1px solid #222;
  background: #070707;
}

.tab {
  min-width: 104px;
  padding: 15px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: #bfc8d8;
  background: transparent;
  font-size: 13px;
  font-weight: 900;
}

.tab.active {
  color: #fff;
  background: #211006;
  border-bottom-color: var(--orange);
}

.workspace {
  padding: 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel {
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 36px rgba(0, 0, 0, .35);
}

.panel-title {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 106, 0, .45);
  background: linear-gradient(90deg, #1b100b, #331606, #e34a00);
  font-size: 20px;
  font-weight: 900;
}

.panel-body {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.form-grid.compact {
  grid-template-columns: 1.4fr .7fr 1fr;
}

label {
  display: grid;
  gap: 7px;
  color: #c9d2e3;
  font-weight: 800;
}

.full {
  margin-top: 14px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #333842;
  border-radius: 8px;
  padding: 11px 12px;
  color: #fff;
  background: #0d0d10;
  outline: none;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(255, 106, 0, .85);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, .12);
}

.quick-row {
  margin-top: 14px;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 24px;
  border: 1px dashed rgba(255, 106, 0, .75);
  border-radius: 8px;
  background: rgba(255, 106, 0, .045);
  text-align: center;
}

.upload-zone strong {
  font-size: 22px;
}

.upload-zone span {
  margin-top: 6px;
  color: var(--muted);
}

.hidden-file {
  position: absolute;
  left: -99999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.metric-grid,
.card-grid,
.finance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric,
.card,
.finance {
  min-height: 76px;
  border: 1px solid #2d2d34;
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #17171b, #111113);
}

.finance .value {
  margin-top: 7px;
  font-size: 20px;
  font-weight: 900;
}

.finance.good .value {
  color: var(--success);
}

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

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.thumb {
  overflow: hidden;
  border: 1px solid #2d2d34;
  border-radius: 8px;
  background: #101014;
}

.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #050506;
}

.thumb div {
  padding: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.progress {
  overflow: hidden;
  height: 12px;
  margin-top: 14px;
  border-radius: 999px;
  background: #09090b;
  border: 1px solid #2d2d34;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--pink));
  transition: width .25s ease;
}

.damage-list {
  display: grid;
  gap: 12px;
}

.damage {
  border: 1px solid #2d2d34;
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  padding: 14px;
  background: #101014;
}

.damage h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.damage p,
.narrative p,
.report p {
  color: #d3d8e5;
  line-height: 1.48;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #101013;
}

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

th {
  color: #ffd7a8;
  border-bottom: 1px solid rgba(255, 106, 0, .55);
  font-size: 12px;
  text-transform: uppercase;
}

td small {
  color: var(--muted);
}

.badge {
  display: inline-block;
  border: 1px solid rgba(255, 106, 0, .5);
  border-radius: 999px;
  padding: 4px 9px;
  color: #ffb16b;
  background: rgba(255, 106, 0, .08);
  font-size: 12px;
  font-weight: 900;
}

.badge.good {
  border-color: rgba(128, 226, 138, .5);
  color: var(--success);
  background: rgba(128, 226, 138, .08);
}

.badge.warn {
  border-color: rgba(255, 209, 102, .5);
  color: var(--warning);
  background: rgba(255, 209, 102, .08);
}

.badge.danger {
  border-color: rgba(255, 77, 109, .55);
  color: #ff9fb3;
  background: rgba(255, 77, 109, .08);
}

.report {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.chat-messages {
  display: grid;
  gap: 10px;
  max-height: 52vh;
  min-height: 280px;
  overflow: auto;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #2d2d34;
  border-radius: 8px;
  background: #08080a;
}

.chat-message {
  max-width: min(820px, 92%);
  border: 1px solid #31313a;
  border-radius: 8px;
  padding: 11px 13px;
  background: #16161b;
}

.chat-message.operator {
  justify-self: end;
  border-color: rgba(255, 106, 0, .55);
  background: #291406;
}

.chat-message.assistant { justify-self: start; }
.chat-message strong { color: #ffd7a8; }
.chat-message p { margin: 7px 0 0; line-height: 1.45; white-space: pre-wrap; }

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.chat-compose textarea { min-height: 72px; }
.chat-proposal { margin-top: 12px; }
.chat-change-preview { border: 1px solid rgba(255, 209, 102, .6); border-radius: 8px; padding: 14px; background: rgba(255, 209, 102, .06); }
.chat-change-preview strong { color: var(--warning); }
.chat-change-preview p, .chat-change-preview li { color: #e1e6f0; line-height: 1.45; }

@media (max-width: 560px) {
  .chat-compose { grid-template-columns: 1fr; }
}

.report-section,
.narrative {
  border: 1px solid #2d2d34;
  border-radius: 8px;
  padding: 16px;
  background: #111114;
}

.report-section h3 {
  margin: 0 0 12px;
  color: #ffd7a8;
}

.ghost-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 106, 0, .55);
  border-radius: 8px;
  padding: 10px 16px;
  color: #ffb16b;
  background: rgba(255, 106, 0, .075);
  font-weight: 900;
  text-decoration: none;
}

.location-actions {
  margin: 14px 0;
}

.location-media {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.location-media figure {
  overflow: hidden;
  margin: 0;
  border: 1px solid #2f2f36;
  border-radius: 8px;
  background: #08080a;
}

.location-media img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #050506;
}

.location-media figcaption,
.muted-note {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.croqui-card {
  margin-top: 14px;
  border: 1px solid rgba(255, 106, 0, .35);
  border-radius: 8px;
  padding: 12px;
  background: #0d0d10;
}

.croqui-card h4 {
  margin: 0 0 10px;
  color: #ffd7a8;
}

.croqui-card p {
  margin: 10px 0 0;
  color: #d8deeb;
}

.croqui-svg {
  display: block;
  width: 100%;
  max-height: 420px;
  border-radius: 8px;
  background: #0b0b0d;
}

.croqui-card-premium {
  background: #080d10;
}

.croqui-rendered {
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 720px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: #0b0f12;
}

.croqui-rendered svg,
.croqui-rendered-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.croqui-layered-scene {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: #111;
}

.croqui-layered-map,
.croqui-layered-overlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.croqui-layered-map {
  object-fit: cover;
}

.croqui-layered-map.missing {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.croqui-layered-overlay {
  pointer-events: none;
}

.croqui-premium-bitmap {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: #111;
}

.croqui-premium-pending {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(255, 106, 0, .28);
  border-radius: 8px;
  padding: 14px;
  background: #0b0b0d;
}

.croqui-premium-pending strong {
  color: #ffd7a8;
}

.croqui-premium-pending span {
  color: var(--muted);
  line-height: 1.5;
}

.croqui-premium-pending details {
  color: #d8deeb;
}

pre {
  overflow: auto;
  max-height: 66vh;
  margin-top: 14px;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 14px;
  color: #e8edf7;
  background: #050506;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .tabs {
    padding-left: 0;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 12px;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }

  .brand h1 {
    font-size: 23px;
  }

  .topbar-actions,
  .quick-row {
    width: 100%;
  }

  .run-btn,
  .upload-btn,
  .ghost-btn,
  .ghost-link {
    width: 100%;
  }

  .location-media {
    grid-template-columns: 1fr;
  }
}
