:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}

.container-wide {
  max-width: 1200px;
}

.header {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f1419 100%);
  border-bottom: 1px solid var(--border);
  padding: 2rem 0;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field.full-width {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

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

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.section-header h2 {
  margin-bottom: 0;
}

.paper-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid #bbb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  color: #111;
  background: #fff;
}

.log-table th,
.log-table td {
  border: 1px solid #333;
  padding: 0.4rem 0.45rem;
  text-align: center;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
  min-width: 2.5rem;
}

.log-table thead th {
  background: #f5f5f5;
  font-weight: 600;
  font-size: 0.7rem;
  line-height: 1.25;
  color: #222;
}

.log-table tbody td {
  font-size: 0.85rem;
  height: 3.25rem;
}

.split-cell {
  padding: 0;
  min-width: 4.5rem;
}

.cell-split {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 3.25rem;
}

.cell-split span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.4rem;
}

.cell-split span + span {
  border-top: 1px solid #333;
}

.split-header {
  vertical-align: bottom;
  padding-bottom: 0.5rem;
}

.log-table #row-1 td {
  color: #999;
  font-style: italic;
  font-weight: 400;
}

.log-table #row-1 .cell-split span {
  color: #999;
  font-style: italic;
}

.log-table #row-2 td {
  color: #111;
  font-weight: 500;
}

.crew-cell {
  line-height: 1.35;
  min-width: 7rem;
}

.pilot-name {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.pilot-name:hover {
  color: #1a3a6b;
}

.log-table #row-1 .pilot-name {
  color: #999;
}

.log-table #row-1 .pilot-name:hover {
  color: #777;
}

.pilot-bubble {
  position: fixed;
  z-index: 200;
  max-width: 16rem;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid #333;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  font-size: 0.75rem;
  line-height: 1.4;
  color: #222;
  font-weight: 400;
  font-style: normal;
}

.pilot-bubble-text {
  margin: 0;
}

.notes-cell {
  padding: 0;
  min-width: 8rem;
}

.notes-cell textarea {
  width: 100%;
  height: 100%;
  min-height: 3rem;
  border: none;
  background: transparent;
  color: #111;
  font: inherit;
  padding: 0.35rem 0.45rem;
  resize: vertical;
  text-align: left;
}

.notes-cell textarea:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

.signature-cell {
  font-family: "Caveat", cursive;
  font-size: 1.35rem;
  font-weight: 600;
  color: #1a3a6b;
  min-width: 6rem;
  transform: rotate(-3deg);
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-secondary:hover {
  background: var(--border);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--success);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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