* { box-sizing: border-box; margin: 0; padding: 0; font-family: Tahoma, Verdana, Arial, sans-serif; font-size: 11px; }

/* Custom Retro Scrollbar Styling */
::-webkit-scrollbar {
  width: 16px;
  height: 16px;
  background-color: #ece9d8;
}
::-webkit-scrollbar-track {
  background: #ece9d8;
  border: 1px solid #808080;
  background-image: repeating-linear-gradient(45deg, #d4d0c8, #d4d0c8 1px, #ece9d8 1px, #ece9d8 2px);
}
::-webkit-scrollbar-thumb {
  background-color: #ece9d8;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  box-shadow: inset 1px 1px 0px #fff, inset -1px -1px 0px #000;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #e0e0e0;
}
::-webkit-scrollbar-button {
  background-color: #ece9d8;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  width: 16px;
  height: 16px;
}

body {
  background-color: #d4d0c8;
  color: #000;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 4px;
  user-select: none;
}

header.top-toolbar {
  background: #ece9d8;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.brand { font-weight: bold; color: #000080; font-size: 12px; }

.toolbar-stats {
  display: flex; gap: 12px; background: #fff; padding: 2px 8px;
  border: 2px solid; border-color: #808080 #ffffff #ffffff #808080;
}
.stat-item { display: flex; gap: 4px; align-items: center; }
.stat-item .val { font-weight: bold; color: #000; }
.stat-item .lbl { color: #404040; text-transform: uppercase; font-size: 10px; }

.btn {
  background: #ece9d8;
  color: #000;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  padding: 2px 8px;
  cursor: pointer;
  font-weight: bold;
}
.btn:active, .btn.active {
  border-color: #808080 #ffffff #ffffff #808080;
  background: #e0e0e0;
}

.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0px;
  min-height: 0;
}

.view-bar {
  background: #ece9d8;
  padding: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #808080;
  margin-bottom: 4px;
}
.tab-btn {
  padding: 3px 10px;
  background: #d4d0c8;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  cursor: pointer;
  font-weight: bold;
}
.tab-btn.active {
  background: #fff;
  border-color: #808080 #ffffff #ffffff #808080;
}

:root {
  --label-width: 90px;
  --base-day-width: 280px;
  --zoom: 1;
}

.gantt-container {
  flex: 1;
  min-height: 150px;
  overflow: auto;
  background: #fff;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  position: relative;
  cursor: default;
}
.gantt-container.grab-mode { cursor: grab; }
.gantt-container.grabbing { cursor: grabbing; }

.gantt-grid { display: inline-block; min-width: 100%; }

.gantt-header {
  display: flex;
  background: #000080;
  color: #fff;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 20;
}

.gantt-row {
  display: flex;
  border-bottom: 1px solid #c0c0c0;
  height: 52px;
  position: relative;
}
.gantt-row:nth-child(even) { background: #f9f9f9; }

.gantt-label {
  width: var(--label-width);
  min-width: var(--label-width);
  max-width: var(--label-width);
  background: #ece9d8;
  border-right: 2px solid #808080;
  padding: 4px;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: sticky;
  left: 0;
  z-index: 10;
}

.day-header {
  width: calc(var(--base-day-width) * var(--zoom));
  min-width: calc(var(--base-day-width) * var(--zoom));
  text-align: center;
  border-right: 1px solid #ffffff;
  background: #000080;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.day-title { padding: 2px 0; border-bottom: 1px solid #404080; }

.hours-row {
  display: flex;
  flex: 1;
  background: #101060;
  font-size: 8px;
  font-weight: normal;
  overflow: hidden;
}
.hour-cell {
  border-right: 1px solid #303090;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d0d0ff;
  white-space: nowrap;
  overflow: hidden;
  font-size: 7px;
}

.day-zone {
  width: calc(var(--base-day-width) * var(--zoom));
  min-width: calc(var(--base-day-width) * var(--zoom));
  position: relative;
  height: 100%;
  border-right: 1px solid #c0c0c0;
  background: #fff;
}

.day-zone.grid-hours {
  background-image: linear-gradient(to right, #f0f0f0 1px, transparent 1px);
  background-size: calc((var(--base-day-width) * var(--zoom)) / 24) 100%;
}
.day-zone.grid-minutes {
  background-image: linear-gradient(to right, #e0e0e0 1px, transparent 1px);
  background-size: calc((var(--base-day-width) * var(--zoom)) / 96) 100%;
}

.timeline-blocks-wrapper {
  position: absolute;
  top: 0; left: var(--label-width);
  height: 100%;
  display: flex;
  pointer-events: none;
}

.flight-block {
  position: absolute;
  top: 3px;
  height: 44px;
  background: #008080;
  border: 1px solid #000;
  color: #fff;
  font-size: 9px;
  padding: 1px 3px;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 1px 1px 0px #000;
  z-index: 5;
  pointer-events: auto;
}

.flight-block .tier-1, .flight-block .tier-3 {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  opacity: 0.9;
}

.flight-block .tier-2 {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  font-weight: bold;
}

.flight-block .dur-badge {
  background: rgba(0, 0, 0, 0.4);
  color: #80ffff;
  padding: 0 3px;
  border-radius: 2px;
  font-weight: normal;
  font-size: 8px;
}

/* Turnaround / Buffer indicator */
.turnaround-block {
  position: absolute;
  top: 3px;
  height: 44px;
  background: repeating-linear-gradient(
    45deg,
    #a0a0a0,
    #a0a0a0 4px,
    #d0d0d0 4px,
    #d0d0d0 8px
  );
  border: 1px dashed #555;
  color: #000;
  font-size: 8px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  pointer-events: none;
  opacity: 0.85;
}

.ground-block {
  position: absolute;
  top: 18px;
  height: 14px;
  background: #ffeb3b;
  border: 1px solid #c0a000;
  color: #333;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  overflow: hidden;
  white-space: nowrap;
  font-weight: bold;
  opacity: 0.9;
}

.error-block {
  position: absolute;
  top: 8px;
  height: 34px;
  background: #ff0000;
  color: #ffffff;
  border: 2px solid #800000;
  font-size: 8px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  overflow: hidden;
  white-space: nowrap;
}

.panel-resizer {
  height: 6px;
  background: #ece9d8;
  border-top: 1px solid #ffffff;
  border-bottom: 1px solid #808080;
  cursor: ns-resize;
  margin: 2px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-resizer::after {
  content: "•••";
  color: #808080;
  font-size: 8px;
  letter-spacing: 2px;
}

.bottom-panel {
  height: 180px;
  min-height: 80px;
  max-height: 350px;
  background: #ece9d8;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  display: flex;
  flex-direction: column;
}
.bottom-header {
  padding: 3px 6px;
  background: #000080;
  color: #fff;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.day-columns {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: #808080;
  padding: 2px;
  overflow-x: auto;
}
.day-column { background: #fff; display: flex; flex-direction: column; overflow: hidden; }
.day-col-title { background: #d4d0c8; padding: 2px; text-align: center; font-weight: bold; border-bottom: 1px solid #808080; }
.day-col-list { flex: 1; padding: 4px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }

.flight-card {
  background: #ece9d8;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  padding: 3px;
  cursor: grab;
}
.card-head { display: flex; justify-content: space-between; font-weight: bold; color: #000; }
.card-route { color: #000080; }

/* Context Menu */
.context-menu {
  position: fixed;
  background: #ece9d8;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.4);
  z-index: 2000;
  min-width: 220px;
  display: none;
}
.context-menu-header {
  background: #000080;
  color: #fff;
  padding: 4px 8px;
  font-weight: bold;
  font-size: 10px;
}
.context-menu-item {
  padding: 5px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #d0d0d0;
  position: relative;
}
.context-menu-item:hover { background: #000080; color: #fff; }
.context-menu-item.danger:hover { background: #a00000; }
.context-menu-sub {
  background: #ece9d8;
  color: #000;
  padding: 3px 6px;
  display: flex;
  gap: 4px;
  border-top: 1px solid #b0b0b0;
}
.sub-btn {
  flex: 1;
  padding: 3px 6px;
  background: #fff;
  border: 1px solid #808080;
  cursor: pointer;
  text-align: center;
  font-size: 9px;
  font-weight: bold;
}
.sub-btn:hover { background: #000080; color: #fff; }

/* Modals & Alerts */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #ece9d8;
  border: 2px solid;
  border-color: #ffffff #000 #000 #ffffff;
  width: 440px;
  padding: 2px;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.5);
}
.modal-header {
  background: #000080; color: #fff;
  padding: 3px 6px; font-weight: bold;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header.error-header { background: #a00000; }
.modal-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.modal-msg-container { display: flex; gap: 10px; align-items: center; }
.modal-icon { font-size: 24px; }
.form-group { display: flex; flex-direction: column; gap: 2px; }
.form-group input, textarea.schedule-input {
  border: 2px solid; border-color: #808080 #ffffff #ffffff #808080;
  padding: 3px; font-family: monospace; background: #fff;
}

/* Retro Custom Dropdown / Select Control */
select, .form-group select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: #fff;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><rect width="16" height="16" fill="%23ece9d8"/><path d="M0,0 L16,0 L16,1 L1,1 L1,16 L0,16 Z" fill="%23ffffff"/><path d="M15,0 L16,0 L16,16 L0,16 L0,15 L15,15 Z" fill="%23808080"/><polygon points="4,6 12,6 8,11" fill="%23000000"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0px center;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  padding: 3px 22px 3px 4px;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 11px;
  color: #000;
  border-radius: 0;
  cursor: pointer;
  outline: none;
}
select:focus {
  outline: 1px dotted #000;
}
select:disabled {
  background-color: #d4d0c8;
  color: #808080;
  cursor: not-allowed;
}
select option {
  background-color: #fff;
  color: #000;
  padding: 2px 4px;
}

textarea.schedule-input { width: 100%; height: 140px; }
.modal-footer { padding: 4px; display: flex; justify-content: flex-end; gap: 6px; }

/* Schedule Matrix Table inside Settings Modal */
.schedule-matrix-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #808080;
}
.schedule-matrix-table th, .schedule-matrix-table td {
  border: 1px solid #d0d0d0;
  padding: 4px;
  text-align: center;
}
.schedule-matrix-table th { background: #ece9d8; font-weight: bold; }

/* =====================================================================
   ADDITIONS (DB edition) — same retro visual language as the MVP
   ===================================================================== */

header.top-toolbar { flex-wrap: wrap; gap: 4px; }

/* App wrapper blurred while the period setup is open (from planner_intro) */
.app-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: filter 0.3s ease;
}
.app-wrapper.blurred { filter: blur(5px); pointer-events: none; }

/* Initial setup modal (from planner_intro) */
.initial-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4); display: flex;
  align-items: center; justify-content: center; z-index: 5000;
}
.initial-modal-overlay.hidden { display: none; }

.retro-window {
  background: #ece9d8; border: 2px solid;
  border-color: #ffffff #000000 #000000 #ffffff;
  box-shadow: 4px 4px 10px rgba(0,0,0,0.5); padding: 2px;
}
.window-header {
  background: #000080; color: #fff; padding: 4px 8px;
  font-weight: bold; display: flex; justify-content: space-between; align-items: center;
}
fieldset.retro-fieldset { border: 1px solid #808080; padding: 8px; }
fieldset.retro-fieldset legend { font-weight: bold; padding: 0 4px; }

input[type="date"], input[type="password"], .retro-input {
  background-color: #fff; border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  padding: 3px 5px; font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 11px; color: #000; outline: none; border-radius: 0;
}

#init-aircraft-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 4px;
  max-height: 180px; overflow-y: auto; background: #fff; padding: 4px;
  border: 2px solid; border-color: #808080 #ffffff #ffffff #808080;
}
#init-aircraft-list label { display: flex; gap: 4px; align-items: center; cursor: pointer; }

/* Period (season) view */
.day-header.weekend .day-title { background: #000060; }
.flight-block.cancelled {
  background: #808080 !important;
  text-decoration: line-through;
  opacity: 0.6;
}
.flight-block .ovr-mark { color: #ffff80; }
.day-column.out-of-period { background: #d4d0c8; }

/* Saving indicator */
.stat-item .val.saving { color: #a06000; }
.stat-item .val.err { color: #a00000; }

/* Users table */
.users-table td.left, .users-table th.left { text-align: left; }

/* ---------- Menu bar (File / Aircraft / Airports / ...) ---------- */
.menubar {
  display: flex;
  align-items: stretch;
  background: #ece9d8;
  border: 1px solid #808080;
  border-bottom-color: #808080;
  margin-bottom: 4px;
  height: 24px;
  position: relative;
  z-index: 2600;
}
.menubar .menu { position: relative; display: flex; align-items: stretch; }
.menubar .menu-title {
  display: flex; align-items: center;
  padding: 0 12px;
  cursor: pointer;
  font-size: 12px;
  color: #000;
}
.menubar .menu:hover .menu-title { background: #d4d0c8; }
.menubar .menu.open .menu-title { background: #000080; color: #fff; }
.menubar .menu-drop {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid #808080;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.35);
  z-index: 2700;
}
.menubar .menu.open .menu-drop { display: block; }
.menubar .menu-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid #e4e4e4;
  white-space: nowrap;
}
.menubar .menu-item:last-child { border-bottom: none; }
.menubar .menu-item:hover { background: #000080; color: #fff; }
.menubar .menu-sep { height: 0; border-top: 2px solid #d4d0c8; }
.menubar-user { margin-left: auto; display: flex; align-items: center; padding: 0 10px; color: #404040; }

.bases-display {
  background: #fff; padding: 2px 6px; font-weight: bold; color: #000080; cursor: pointer;
  border: 2px solid; border-color: #808080 #ffffff #ffffff #808080; min-width: 60px;
}

/* ---------- Out of period (week partially outside loaded period) ---------- */
.day-zone.out-of-period {
  background: repeating-linear-gradient(45deg, #e8e8e8, #e8e8e8 4px, #f4f4f4 4px, #f4f4f4 8px);
}
.day-header.out-of-period .day-title { background: #505080; }

/* ---------- Big window: lists & reports ---------- */
.modal-overlay.win-overlay { z-index: 2500; }
.modal.win-modal {
  width: 94vw; height: 88vh;
  display: flex; flex-direction: column;
}
.win-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 5px; border-bottom: 1px solid #808080; background: #ece9d8;
}
.win-toolbar .sep { width: 1px; align-self: stretch; background: #808080; margin: 0 2px; }
.win-toolbar input[type="text"], .win-toolbar input:not([type]) {
  border: 2px solid; border-color: #808080 #ffffff #ffffff #808080; padding: 3px; background: #fff;
}
.win-body {
  flex: 1; overflow: auto; background: #fff; margin: 4px;
  border: 2px solid; border-color: #808080 #ffffff #ffffff #808080;
}
.win-status { padding: 3px 6px; color: #404040; border-top: 1px solid #fff; }

.filter-panel {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start;
  padding: 5px; background: #ece9d8; border-bottom: 1px solid #808080;
}
.filter-panel fieldset { border: 1px solid #808080; padding: 4px 6px; }
.filter-panel legend { font-weight: bold; padding: 0 3px; }
.col-chooser { display: flex; flex-wrap: wrap; gap: 2px 10px; max-width: 760px; }
.col-chooser label { display: flex; gap: 3px; align-items: center; cursor: pointer; white-space: nowrap; }
select[multiple] { background-image: none; padding: 2px; }

.data-table { border-collapse: collapse; width: 100%; background: #fff; }
.data-table th {
  position: sticky; top: 0; z-index: 2;
  background: #ece9d8; font-weight: bold; text-align: left;
  border: 1px solid #b0b0b0; padding: 3px 5px; white-space: nowrap; cursor: default;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { background: #e0e0e0; }
.data-table td { border: 1px solid #e0e0e0; padding: 2px 5px; white-space: nowrap; }
.data-table tbody tr:nth-child(even) { background: #f7f7f7; }
.data-table tbody tr:hover { background: #d0d0e0; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table td.num { text-align: right; font-family: monospace; }
.data-table td.code { font-family: monospace; font-weight: bold; }
.data-table td.warn { color: #a00000; font-weight: bold; }
.data-table td.muted { color: #808080; }
.data-table tr.cancelled-row td { color: #808080; text-decoration: line-through; }
.data-table .color-swatch { display: inline-block; width: 10px; height: 10px; border: 1px solid #000; vertical-align: middle; }
.data-table .btn { padding: 0 5px; }
textarea.ssim-output { width: 100%; height: 100%; min-height: 300px; border: none; font-family: monospace; font-size: 11px; padding: 6px; resize: none; }
