:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #eef3f7;
  --text: #17202a;
  --muted: #5d6875;
  --line: #d8e0e8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --ok: #16a34a;
  --warn: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warn);
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.error {
  background: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.sidebar,
.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  font: inherit;
  background: white;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  font: inherit;
  resize: vertical;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: var(--panel-soft);
  color: var(--text);
}

button.secondary:hover {
  background: var(--line);
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #8f1d14;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

button:disabled:hover {
  background: var(--danger);
}

.table-action {
  padding: 7px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.edit-form {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--panel-soft);
  border-radius: 8px;
}

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

.checkbox-label {
  align-items: center;
  align-self: end;
  display: flex;
  gap: 8px;
  min-height: 41px;
}

.checkbox-label input {
  width: auto;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--panel-soft);
  color: var(--accent-strong);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric {
  display: grid;
  gap: 8px;
}

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

.metric strong {
  font-size: 28px;
}

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

.stack {
  display: grid;
  gap: 10px;
}

.item {
  padding: 12px;
  background: var(--panel-soft);
  border-radius: 8px;
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-weight: 700;
}

.item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crew-code {
  font-weight: 800;
  letter-spacing: .04em;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr.selected td {
  background: #e8f5f2;
}

.alert {
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff1f0;
  color: var(--danger);
}

.signature {
  max-height: 64px;
  max-width: 260px;
  padding: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.flight-detail,
.aircraft-detail {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

h3 {
  margin: 0;
  font-size: 16px;
}

.detail-heading p {
  margin: 4px 0 0;
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--panel-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

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

.media-grid {
  margin-top: 12px;
}

.detail-card {
  min-width: 0;
  padding: 12px;
  background: var(--panel-soft);
  border-radius: 8px;
}

.detail-card h3 {
  margin-bottom: 10px;
}

.detail-section {
  margin-top: 16px;
}

.detail-section h3 {
  margin-bottom: 10px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h3 {
  margin-bottom: 0;
}

.inline-flight-detail {
  padding-top: 0;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, .4fr) minmax(0, 1fr);
  gap: 10px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.flight-image {
  display: block;
  max-width: 100%;
  max-height: 360px;
  padding: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: contain;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .metrics,
  .grid.two,
  .detail-grid,
  .media-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-heading {
    flex-direction: column;
  }
}
