:root {
  color-scheme: dark;
  --bg: #10131a;
  --panel: #171c25;
  --panel-2: #1e2531;
  --line: #2b3444;
  --text: #e7edf6;
  --muted: #8b97a8;
  --accent: #d4a24e;
  --accent-2: #7ec8c0;
  --danger: #e06c75;
  --ok: #7dbe8a;
  --font: "Segoe UI", "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

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

a { color: var(--accent-2); }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 4.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #0c0f14;
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.mark {
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1.15;
}
.sub {
  color: #d5deea;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.brand-mark {
  width: 3.4rem;
  height: 3.4rem;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 6px;
}
.fleet {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1;
  min-width: 0;
}
.fleet-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  flex-shrink: 0;
}
.fleet-mark svg {
  width: 2.15rem;
  height: 2.15rem;
  transform: rotate(45deg);
}
.fleet-mark span {
  color: #d5deea;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.views { display: flex; gap: 0.35rem; }

.view-btn, .tail, .day, .sector, .cell, .actions button, .event button, .upload {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.view-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}
.view-btn.on { border-color: var(--accent); background: #2a2418; color: var(--accent); }

.tails {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.tail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.45rem 0.7rem;
  flex-shrink: 0;
}

.tail span { color: var(--muted); font-size: 0.75rem; }
.tail.on, .day.on, .sector.on { border-color: var(--accent); background: #2a2418; }

.top-end {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  margin-left: auto;
}

.exports {
  display: flex;
  gap: 0.55rem;
  font-size: 0.85rem;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.exports a,
.exports button.export-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.85rem;
  line-height: 1.25;
}
.exports a:hover,
.exports button.export-btn:hover {
  border-color: var(--accent);
}
.exports a.export-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.banner {
  background: #3a1f24;
  color: #ffd5d8;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.hidden { display: none !important; }

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
}
.toast {
  background: #1a2e24;
  color: #c8e6d0;
  border: 1px solid #2f5a40;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.ghost {
  visibility: hidden;
  pointer-events: none;
}

/* Drop ghosted top-bar slots from layout (top min-height keeps bar height stable). */
.top .ghost {
  display: none !important;
}

.session-bar {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.profile-wrap {
  position: relative;
}

.profile-btn {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  overflow: hidden;
}

.profile-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.profile-btn:hover,
.profile-btn[aria-expanded="true"],
.profile-btn.on {
  border-color: var(--accent);
  color: var(--accent);
}

.profile-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 60;
  width: 13.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  padding: 0.85rem 0.75rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.profile-menu-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  padding: 0.15rem 0.35rem 0.25rem;
}

.profile-menu-avatar {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.profile-menu-avatar svg {
  width: 1.35rem;
  height: 1.35rem;
}

.profile-menu-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  max-width: 100%;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
}

.profile-menu-name > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-pilot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
  color: var(--accent);
}

.profile-pilot svg {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}

.profile-menu-role {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: #2a2418;
  border: 1px solid rgba(212, 162, 78, 0.35);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.profile-menu-rule {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.1rem 0;
}

.profile-menu-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 0.45rem 0.5rem;
  font-size: 0.85rem;
  text-align: left;
}

.profile-menu-action:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.profile-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.25rem 2rem;
}

.profile-head h2 {
  margin: 0 0 0.25rem;
}

.profile-head .meta {
  margin: 0;
}

.profile-password {
  max-width: 22rem;
  margin-top: 1.35rem;
}

.profile-password h3 {
  margin: 0;
}

.profile-logout svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--muted);
}

.profile-logout:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.profile-logout:hover svg {
  color: var(--danger);
}

.login-gate {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(ellipse at 20% 10%, #1a2230 0%, transparent 55%),
    radial-gradient(ellipse at 80% 90%, #1c1810 0%, transparent 50%),
    var(--bg);
}
.login-card {
  width: min(22rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.4rem 1.35rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.login-brand { margin-bottom: 0.25rem; }
.login-card .field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}
.login-card .field span { color: var(--muted); }
.login-card input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}
.login-submit {
  margin-top: 0.25rem;
  background: #2a2418;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
}
.login-error {
  color: #ffd5d8;
  background: #3a1f24;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  margin: 0;
}
.cell.readonly {
  display: inline-block;
  padding: 0.2rem 0.35rem;
  cursor: default;
  border-color: transparent;
  background: transparent;
}

.date-pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.date-pick .flight-date-input {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.date-pick-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.date-pick-btn svg {
  width: 1rem;
  height: 1rem;
}

.date-pick-btn:hover,
.date-pick-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.date-pick-cal {
  position: absolute;
  z-index: 70;
  top: calc(100% + 0.35rem);
  left: 0;
  width: 17rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 0.65rem 0.7rem 0.55rem;
}

.date-pick-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.date-pick-month {
  font-size: 0.85rem;
  font-weight: 600;
}

.date-pick-nav-btn {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.date-pick-nav-btn:hover {
  border-color: var(--accent);
}

.date-pick-dows,
.date-pick-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
}

.date-pick-dows {
  margin-bottom: 0.25rem;
}

.date-pick-dows span {
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
  padding: 0.15rem 0;
}

.date-pick-pad {
  min-height: 1.85rem;
}

.date-pick-day {
  min-height: 1.85rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.date-pick-day {
  cursor: pointer;
}

button.date-pick-day:hover {
  border-color: var(--accent);
  background: #2a2418;
}

.date-pick-day.on {
  border-color: var(--accent);
  background: #2a2418;
  color: var(--accent);
  font-weight: 700;
}

.date-pick-day.today:not(.on) {
  border-color: var(--line);
}

.date-pick-day.off {
  color: #4a5568;
  opacity: 0.45;
  cursor: not-allowed;
}

.date-pick-note {
  margin: 0.45rem 0 0;
  font-size: 0.7rem;
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
  .imports-head { flex-direction: column; }
}
