/* SkyBaron — dark cockpit theme */
:root {
  --bg: #0d1220;
  --bg2: #121a2e;
  --card: #18223a;
  --card2: #1e2a47;
  --line: #2a3a5f;
  --text: #e8edf7;
  --muted: #8b98b8;
  --accent: #4cc2ff;
  --good: #7ee787;
  --bad: #ff7b7b;
  --warn: #f2b64c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
h2 { font-size: 22px; margin-bottom: 14px; }
h3 { font-size: 15px; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 24px;
  height: 64px; padding: 0 18px;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.brand-logo { width: 38px; height: 38px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topstats { display: flex; gap: 26px; flex: 1; }
.topstat { display: flex; flex-direction: column; }
.topstat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.topstat-value { font-weight: 700; font-size: 16px; }
.timebox { text-align: right; }
.date { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.timecontrols { display: flex; gap: 4px; justify-content: flex-end; }
.tbtn {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px;
}
.tbtn.active { background: var(--accent); color: #08101f; border-color: var(--accent); font-weight: 700; }
.tbtn.step { border-style: dashed; }
.tbtn:hover { filter: brightness(1.2); }

/* ---------- layout ---------- */
#layout { display: flex; height: calc(100vh - 64px); }
#sidenav {
  width: 200px; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg2); border-right: 1px solid var(--line);
}
.navbtn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--muted);
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; text-align: left; width: 100%;
}
.navbtn:hover { background: var(--card); color: var(--text); }
.navbtn.active { background: var(--card2); color: var(--text); font-weight: 600; }
.navbtn .nico { width: 20px; text-align: center; }
.nav-spacer { flex: 1; }
.navbtn.danger:hover { color: var(--bad); }

#screen { flex: 1; overflow-y: auto; }
.screen-inner { padding: 22px 26px 60px; max-width: 1250px; }
.rowhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 14px; }
.rowhead h2 { margin: 0; }

/* ---------- cards / KPIs ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px;
}
.card.empty { color: var(--muted); text-align: center; padding: 40px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi.wide { grid-column: 1 / -1; }
.kpi.rank-kpi { border-color: var(--accent); }
.kpi-sub-inline { font-size: 13px; color: var(--muted); font-weight: 400; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.repbar { height: 10px; background: var(--bg); border-radius: 6px; margin-top: 8px; overflow: hidden; }
.repbar-fill { height: 100%; background: linear-gradient(90deg, var(--bad), var(--warn), var(--good)); border-radius: 6px; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.charts canvas { width: 100%; height: 180px; display: block; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.threecol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.effect { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.effect:last-child { border-bottom: none; }
.effect.neutral { color: var(--muted); }
.effect.alert-losing { color: var(--bad); }

.logline { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.logline:last-child { border-bottom: none; }
.logline.good { color: var(--good); }
.logline.bad { color: var(--bad); }
.logline.event { color: var(--warn); }
.logweek {
  display: inline-block; min-width: 48px; color: var(--muted);
  font-size: 12px; font-variant-numeric: tabular-nums;
}

/* ---------- tables ---------- */
.tablecard { padding: 6px 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; padding: 10px 8px 6px; border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 8px; border-bottom: 1px solid rgba(42,58,95,.5); }
.table tr:last-child td { border-bottom: none; }
.table.plain td { padding: 6px 0; }
.table.plain td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.total td { border-top: 1px solid var(--line); font-weight: 700; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- buttons / badges ---------- */
.btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08101f; font-weight: 700; }
.btn.danger { border-color: #6e3a3a; color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 16px; }

.badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 20px; vertical-align: middle; margin-left: 6px;
}
.badge.own { background: #1d4030; color: var(--good); }
.badge.lease { background: #203354; color: var(--accent); }
.badge.bad { background: #4b2020; color: var(--bad); }
.badge.rating-A { background: #1d4030; color: var(--good); }
.badge.rating-B { background: #203354; color: var(--accent); }
.badge.rating-C { background: #4a3a17; color: var(--warn); }
.badge.rating-D { background: #4b2020; color: var(--bad); }

/* ---------- fleet & market ---------- */
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.plane-card { display: flex; flex-direction: column; gap: 8px; }
.plane-art { width: 100%; height: 90px; object-fit: contain; opacity: .95; }
.plane-head { font-size: 15px; }
.plane-blurb { font-size: 13px; color: var(--muted); font-style: italic; }
.plane-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.market-prices { display: flex; gap: 18px; font-size: 13px; }
.condrow { display: flex; align-items: center; gap: 8px; }
.condrow .condbar { flex: 1; }
.condbar { height: 7px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.condbar-fill { height: 100%; background: var(--good); border-radius: 5px; }
.condbar-fill.low { background: var(--warn); }
.plane-route { font-size: 13px; }
.plane-stats.ops span { color: var(--text); background: var(--bg); padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.cabin-tag { color: var(--accent) !important; font-weight: 600; }
.cost-strip {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted);
}
.logline.milestone { color: #ffd76e; font-weight: 600; }
.logline.rival { color: var(--warn); }
.logline.rivalquiet { color: var(--muted); }
.table td.indent { padding-left: 18px; color: var(--muted); }

/* ---------- market share / competition ---------- */
.sharecell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.sharebar { width: 64px; height: 8px; background: var(--bg); border-radius: 5px; overflow: hidden; flex-shrink: 0; }
.sharebar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); border-radius: 5px; }
.sharebar-fill.losing { background: linear-gradient(90deg, var(--bad), var(--warn)); }
.contest-note {
  margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  background: rgba(242, 182, 76, .08); border: 1px dashed rgba(242, 182, 76, .4);
  font-size: 13px;
}

/* ---------- leaderboard ---------- */
.lb-you td { background: rgba(76, 194, 255, .08); }
.lb-rank { font-weight: 700; white-space: nowrap; }
.lb-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; }

.credit-row { margin-bottom: 12px; font-size: 14px; }
.loan-form { display: flex; flex-direction: column; gap: 10px; }
.loan-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.loan-form input, .loan-form select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
}

/* ---------- map ---------- */
.map-screen { max-width: none; }
.map-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.map-toolbar h2 { margin: 0; }
.map-hint { flex: 1; color: var(--muted); font-size: 13px; }
.map-holder { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #0a1020; }
#worldmap { width: 100%; height: auto; display: block; }
.map-sea { fill: #0a1224; }
.map-land { fill: #1c2a48; stroke: #2c4066; stroke-width: .7; }
.map-airport { fill: #55688f; stroke: #0a1224; stroke-width: .8; cursor: pointer; }
.map-airport.active { fill: var(--accent); }
.map-airport.hub { fill: var(--warn); }
.map-airport.selected { stroke: #fff; stroke-width: 2; }
.airport-hit { fill: transparent; cursor: pointer; }
.airport-group:hover .map-airport { stroke: #fff; stroke-width: 1.5; }
.airport-label {
  fill: #b8c6e4; font-size: 9px; text-anchor: middle; pointer-events: none;
  font-family: inherit;
}
.route-arc {
  fill: none; stroke: var(--accent); stroke-width: 1.6; opacity: .8; cursor: pointer;
}
.route-arc:hover { stroke-width: 3; opacity: 1; }
.route-arc.grounded { stroke: var(--bad); stroke-dasharray: 5 4; }
.route-arc.contested { stroke-width: 2.4; opacity: 1; filter: drop-shadow(0 0 3px rgba(242, 182, 76, .6)); }
.rival-arc {
  fill: none; stroke-width: 1.2; opacity: .35; stroke-dasharray: 4 4; pointer-events: auto;
}
.rival-arc.hot { opacity: .7; stroke-width: 1.6; }
.contested-marker { font-size: 11px; text-anchor: middle; pointer-events: none; }
.plane-marker {
  fill: #fff; stroke: #0a1224; stroke-width: .6;
  pointer-events: none;
  filter: drop-shadow(0 0 3px rgba(76, 194, 255, .7));
}
.hub-pulse {
  fill: none; stroke: var(--warn); stroke-width: 1.5;
  animation: hubpulse 2.2s ease-out infinite;
  pointer-events: none;
}
@keyframes hubpulse {
  0%   { r: 6; opacity: .9; }
  100% { r: 20; opacity: 0; }
}
.map-legend { display: flex; gap: 22px; margin-top: 10px; color: var(--muted); font-size: 13px; align-items: center; }
.map-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #55688f; margin-right: 6px; }
.map-legend .dot.hub { background: var(--warn); }
.map-legend .dot.active { background: var(--accent); }
.map-legend .arcline { display: inline-block; width: 22px; height: 2px; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.map-legend .arcline.rival {
  height: 0; border-top: 2px dashed #8899bb; background: none;
}

/* ---------- setup ---------- */
.setup {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 600px at 50% -10%, #1b2a4d, var(--bg));
}
.setup-card {
  width: 520px; max-width: 92vw; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 34px; text-align: center;
}
.setup-logo { width: 74px; height: 74px; margin-bottom: 8px; }
.setup-card h1 { font-size: 34px; letter-spacing: .02em; }
.tagline { color: var(--muted); margin: 10px 0 24px; }
.setup-grid { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.setup-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.setup-grid input[type=text], .setup-grid select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 15px;
}
.swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.selected { border-color: #fff; }
.setup-actions { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 8, 18, .72);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  width: 560px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
}
.modal h3 { color: var(--text); text-transform: none; font-size: 19px; letter-spacing: 0; }
.modal p { margin: 12px 0; color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-actions.column { flex-direction: column; align-items: stretch; }
.event-icon { font-size: 44px; text-align: center; margin-bottom: 6px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font-size: 14px;
}
.form-grid input[type=range] { padding: 0; accent-color: var(--accent); }
.route-preview { margin-top: 14px; background: var(--bg); border-radius: 10px; padding: 14px; }
.preview-grid {
  display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 6px 12px; font-size: 14px;
}
.preview-grid span { color: var(--muted); }
.warn { color: var(--warn); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 10px 16px; border-radius: 8px; font-size: 14px;
  opacity: 0; transform: translateX(20px); transition: all .3s;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: none; }
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.rival { border-left-color: var(--warn); }

/* ---------- confetti ---------- */
.confetti-piece {
  position: fixed; top: -16px; width: 8px; height: 14px;
  z-index: 200; pointer-events: none; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(108vh) rotate(720deg); opacity: .75; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi.wide { grid-column: 1 / -1; }
  .charts, .twocol, .threecol { grid-template-columns: 1fr; }
  .topstats { gap: 14px; }
}
@media (max-width: 800px) {
  #sidenav { width: 60px; }
  .navbtn { justify-content: center; padding: 10px 0; }
  .navbtn .nico { width: auto; }
  .navbtn span + * { display: none; }
  #sidenav .navbtn { font-size: 0; }
  #sidenav .navbtn .nico { font-size: 16px; }
}
