:root {
  color-scheme: light;
  --bg: #f6f8f6;
  --panel: #ffffff;
  --ink: #102016;
  --muted: #667765;
  --line: #dbe4da;
  --green: #1f5b2a;
  --green-2: #12331b;
  --green-3: #d7efd8;
  --yellow: #fff6d9;
  --yellow-line: #f3c64e;
  --orange: #b85e00;
  --red: #b91c1c;
  --blue: #1d63b7;
  --soil: #7a5d3a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0d2815;
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 44px 36px 38px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.24);
}

.login-logo {
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
}

.login-card h1,
.login-card p {
  text-align: center;
}

.login-card h1 {
  margin: 0;
  color: var(--green);
  font-size: 22px;
}

.login-card p {
  color: var(--muted);
  margin: 4px 0 28px;
}

.login-card h2 {
  font-size: 18px;
  margin: 0 0 18px;
}

.login-card small {
  display: block;
  text-align: center;
  color: var(--muted);
  margin-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #465946;
  font-weight: 700;
  font-size: 13px;
  margin-top: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5cb;
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 400;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(31, 91, 42, 0.22);
  border-color: var(--green);
}

textarea {
  resize: vertical;
}

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #cdd7cc;
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  font-weight: 700;
}

.btn-secondary:hover,
.icon-button:hover {
  background: #eef4ee;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--green-2);
  color: #eef8ef;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand img {
  width: 36px;
  height: 36px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #a9d0ad;
  font-size: 12px;
}

.nav {
  display: grid;
  padding: 14px 0;
}

.nav-group {
  color: #77d076;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 12px 14px 6px;
}

.nav-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border: 0;
  background: transparent;
  color: #e9f5e9;
  text-align: left;
  font-weight: 700;
}

.nav-item span {
  width: 20px;
  text-align: center;
  color: #b7d8b8;
}

.nav-item.active,
.nav-item:hover {
  background: #1b4d22;
}

.user-box {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2f7f37;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.user-box strong,
.user-box span {
  display: block;
}

.user-box span {
  color: #8ad58b;
  font-size: 12px;
}

.main {
  min-width: 0;
}

.topbar {
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.version-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
}

.version-pill,
.badge.green,
.status-apto {
  background: var(--green-3);
  color: #215b25;
}

.badge.red,
.status-no-volar {
  background: #ffdfe2;
  color: var(--red);
}

.badge.blue {
  background: #e0efff;
  color: var(--blue);
}

.badge.soil {
  background: #eee5d8;
  color: var(--soil);
}

.badge.orange,
.status-revisar {
  background: #fff0cf;
  color: var(--orange);
}

.view {
  display: none;
  padding: 24px 16px 40px;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.table-card,
.form-card,
.panel,
.check-row,
.notam-card,
.role-grid article,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(18, 51, 27, 0.05);
}

.metric {
  padding: 18px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 4px 0 2px;
  color: var(--green-2);
  font-size: 30px;
}

.metric:nth-child(4) strong {
  color: #e26c00;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 14px;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
}

.table-card {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

th {
  background: #eef4ef;
  color: #405340;
  font-size: 13px;
}

td {
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: 0;
}

.search {
  margin-bottom: 16px;
  min-height: 52px;
}

.check-list {
  display: grid;
  gap: 10px;
}

.check-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.check-row strong,
.check-row span,
.check-row small {
  display: block;
}

.check-row span,
.check-row small {
  color: var(--muted);
}

.check-icon {
  font-size: 24px;
}

.notice {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--yellow-line);
  border-radius: 8px;
  background: var(--yellow);
  color: #6a4700;
}

.form-card {
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.check-result {
  margin-top: 16px;
}

.check-summary {
  border: 1px solid var(--yellow-line);
  background: var(--yellow);
  color: #5b4400;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}

.check-summary.ok {
  border-color: #aed9b0;
  background: #eff9ef;
  color: #174c20;
}

.check-summary.danger {
  border-color: #f0a8a8;
  background: #fff0f0;
  color: var(--red);
}

.query-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 14px 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #405340;
}

.notam-card {
  padding: 16px;
  margin-top: 12px;
}

.notam-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.notam-raw,
.tree {
  background: #092811;
  color: #bdf2bc;
  border-radius: 8px;
  padding: 16px;
  overflow: auto;
  line-height: 1.6;
  font-size: 13px;
}

.ai-box {
  margin-top: 14px;
  border: 1px solid #a4d9a9;
  background: #f0fbf1;
  border-radius: 8px;
  padding: 16px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  color: #405340;
  font-size: 13px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

#map {
  height: calc(100vh - 140px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 16px;
}

.compact-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.compact-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfdfb;
}

.role-grid,
.architecture-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.role-grid article,
.architecture-grid article,
.empty-state {
  padding: 16px;
}

.architecture-grid ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #385138;
}

.architecture-grid li {
  margin: 7px 0;
}

.empty-state {
  max-width: 760px;
}

.empty-state p {
  color: var(--muted);
  line-height: 1.6;
}

.modal {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(540px, calc(100vw - 28px));
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.28);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.modal form {
  margin: 0;
}

.modal header,
.modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.modal footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  margin-top: 18px;
}

.modal label {
  margin-left: 22px;
  margin-right: 22px;
}

.modal header button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: #edf3ee;
  color: #405340;
  font-size: 24px;
  line-height: 1;
}

.sidebar-shade {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    width: 240px;
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-shade.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    z-index: 15;
  }

  .metric-grid,
  .role-grid,
  .architecture-grid,
  .map-layout {
    grid-template-columns: 1fr;
  }

  #map {
    height: 460px;
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .view {
    padding: 18px 12px 32px;
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .version-pill {
    display: none;
  }

  .check-row {
    grid-template-columns: 28px 1fr;
  }

  .check-row > :last-child {
    grid-column: 2;
  }

  .login-card {
    padding: 34px 24px;
  }
}
