:root {
  --bg:      #0f172a;
  --surface: #1e293b;
  --border:  #334155;
  --text:    #f1f5f9;
  --muted:   #94a3b8;
  --green:   #22c55e;
  --amber:   #f59e0b;
  --red:     #ef4444;
  --blue:    #38bdf8;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ─────────────────────────────────────────────────────── */

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.01em;
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header .display-name {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Main Content ──────────────────────────────────────────────────── */

.view {
  display: none;
  flex: 1;
  padding: 20px 16px;
}

.view.active {
  display: block;
}

/* ── Auth Container (login.html) ───────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: var(--bg);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
}

.auth-container .auth-logo {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 8px;
}

.auth-container .auth-tagline {
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 28px;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Forms ─────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
  min-height: 48px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
}

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}

.btn:active {
  opacity: 0.85;
}

.btn-primary {
  background: var(--blue);
  color: #0f172a;
  width: 100%;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-sm {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 0.875rem;
}

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

/* ── Aircraft Selector ─────────────────────────────────────────────── */

.aircraft-selector {
  margin-bottom: 20px;
}

.aircraft-selector select {
  font-size: 1rem;
  font-weight: 600;
  color: var(--blue);
}

/* ── File Upload ───────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--blue);
  background: rgba(56, 189, 248, 0.05);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.upload-zone .upload-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.upload-zone .upload-hint {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Progress ──────────────────────────────────────────────────────── */

.progress-indicator {
  display: none;
  text-align: center;
  padding: 32px 0;
}

.progress-indicator.active {
  display: block;
}

.progress-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-text {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ── Error Message ─────────────────────────────────────────────────── */

.error-msg {
  display: none;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--red);
  font-size: 0.9rem;
  margin-top: 16px;
}

.error-msg.active {
  display: block;
}

/* ── Section Headings ──────────────────────────────────────────────── */

.view-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Import Banner ─────────────────────────────────────────────────── */

.import-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid var(--blue);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.import-banner-icon {
  font-size: 1.25rem;
  color: var(--blue);
  flex-shrink: 0;
}

.import-banner-text {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.4;
}

.import-banner-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
  line-height: 1;
}

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

/* ── Debrief View ──────────────────────────────────────────────────── */

.debrief-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.status-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.debrief-headline {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

.debrief-meta {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 3px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 10px;
}

.card ul {
  list-style: none;
  padding: 0;
}

.card ul li {
  padding: 4px 0;
  font-size: 0.9375rem;
  color: var(--text);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.card ul li::before {
  content: "•";
  color: var(--blue);
  flex-shrink: 0;
}

.card ul li:empty {
  display: none;
}

/* Status badge colors */
.status-ok    .card-title { color: var(--green); }
.status-caution .card-title { color: var(--amber); }
.status-warning .card-title { color: var(--red); }

/* Collapsible full text */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.collapsible-header .toggle-icon {
  transition: transform 0.2s;
  color: var(--muted);
}

.collapsible-header.open .toggle-icon {
  transform: rotate(180deg);
}

.collapsible-body {
  display: none;
  margin-top: 12px;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

.collapsible-body.open {
  display: block;
}

/* ── History View ──────────────────────────────────────────────────── */

.flight-list {
  list-style: none;
}

.flight-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.flight-item:hover {
  border-color: var(--blue);
}

.flight-item .flight-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.flight-item .flight-info {
  flex: 1;
  min-width: 0;
}

.flight-item .flight-headline {
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flight-item .flight-date {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 2px;
}

.flight-item .flight-chevron {
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Footer Actions ────────────────────────────────────────────────── */

.view-footer {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.view-footer .btn {
  flex: 1;
}

/* ── Auth Toggle Link ──────────────────────────────────────────────── */

.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

/* ── Loading skeleton ──────────────────────────────────────────────── */

.skeleton {
  background: var(--surface);
  border-radius: 6px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Utility ───────────────────────────────────────────────────────── */

.text-muted { color: var(--muted); }
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }

.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

.hidden { display: none !important; }

/* ── Empty state ───────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.9375rem;
}
