:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2530;
  --muted: #6b7684;
  --line: #e3e7ec;
  --duty: #2563eb;
  --layover: #7c3aed;
  --off: #94a3b8;
  --standby: #d97706;
  --training: #e11d48;
  --absence: #78716c;
  --ground: #0891b2;
  --accent: #0f766e;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 1.5rem 2rem;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink);
}
header { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
h1 { font-size: 1.4rem; margin: 0; letter-spacing: .01em; }

.dropzone {
  border: 2px dashed var(--line); border-radius: 10px; background: var(--card);
  padding: .9rem 1.4rem; color: var(--muted); cursor: pointer; transition: border-color .15s;
}
.dropzone.hover { border-color: var(--accent); color: var(--accent); }
.filelink { color: var(--accent); text-decoration: underline; }
.filelink input { display: none; }

#summary { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
#summary h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
#meta { color: var(--muted); margin-bottom: .7rem; }
#actions { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: .85rem; }
button.primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: .55rem 1.1rem; font-size: .95rem; cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }


#calendar { display: flex; flex-direction: column; gap: 1rem; }
.month { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; }
.month h3 { margin: 0 0 .6rem; font-size: 1rem; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.wd { color: var(--muted); font-size: .72rem; text-transform: uppercase; text-align: center; padding-bottom: 2px; }
.day { min-width: 0; min-height: 64px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; background: #fff; display: flex; flex-direction: column; gap: 2px; }
.day.outside { background: var(--bg); opacity: .55; }
.day.blank { border: 0; background: transparent; }
.day .num { font-size: .72rem; color: var(--muted); }
.chip {
  display: block; width: 100%; border: 0; margin: 0; cursor: pointer; text-align: left;
  font: inherit; font-size: .72rem; line-height: 1.3; color: #fff;
  padding: 2px 6px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { filter: brightness(1.12); }
.chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.chip.flight, .chip.duty { background: var(--duty); }
.chip.layover { background: var(--layover); }
.chip.off { background: var(--off); }
.chip.standby { background: var(--standby); }
.chip.training { background: var(--training); }
.chip.absence { background: var(--absence); }
.chip.ground { background: var(--ground); }
.chip.excluded { background: #d3d8de; color: #98a1ac; text-decoration: line-through; }


#issues { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 12px; padding: .9rem 1.1rem; margin-top: 1rem; }
#issues h3 { margin: 0 0 .4rem; font-size: .95rem; color: #9a3412; }
#issues ul { margin: .2rem 0 .6rem 1.2rem; font-size: .85rem; color: #7c2d12; }
#issues summary { cursor: pointer; font-size: .85rem; color: #9a3412; }
#issues details ul { max-height: 240px; overflow-y: auto; }

.error { position: relative; color: #7f1d1d; background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; padding: .9rem 1.1rem; margin-bottom: 1rem; }
.error h3 { margin: 0 2rem .3rem 0; font-size: 1rem; color: #b91c1c; }
.error-summary { margin: 0 0 .3rem; font-weight: 600; overflow-wrap: anywhere; }
.error-help { margin: 0 0 .6rem; font-size: .85rem; }
.error-report, #unparsed-report {
  margin: 0; max-height: 50vh; overflow: auto; padding: .6rem .7rem; border-radius: 8px;
  background: #fff; border: 1px solid #fecaca; color: var(--ink);
  font: .75rem/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; user-select: text;
}
.error-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .8rem; margin-top: .6rem; }
.error-copied { font-size: .85rem; color: var(--accent); }
.error-close {
  position: absolute; top: .45rem; right: .55rem; width: 28px; height: 28px; border: 0; border-radius: 6px;
  background: transparent; color: #b91c1c; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.error-close:hover { background: #fee2e2; }
button.secondary { background: var(--card); color: var(--accent); border: 1px solid var(--accent); border-radius: 8px; padding: .4rem .9rem; font-size: .85rem; cursor: pointer; }
details.hint { margin-top: .7rem; }
details.hint summary { cursor: pointer; color: var(--accent); }
details.hint ol { margin: .4rem 0 .4rem 1.2rem; padding: 0; line-height: 1.6; }
details.hint a { color: var(--accent); }


/* ---- event popover ---- */
#event-popover {
  position: absolute; inset: auto; margin: 0;
  width: min(360px, calc(100vw - 16px)); max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 10px;
  padding: .85rem 1rem 1rem; box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
}
#event-popover.flight { border-top-color: var(--duty); }
#event-popover.layover { border-top-color: var(--layover); }
#event-popover.off { border-top-color: var(--off); }
#event-popover.standby { border-top-color: var(--standby); }
#event-popover.training { border-top-color: var(--training); }
#event-popover.absence { border-top-color: var(--absence); }
#event-popover.ground { border-top-color: var(--ground); }
#event-popover h3 { margin: .1rem 1.5rem .2rem 0; font-size: 1.05rem; }
.pop-type { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pop-time { font-size: .88rem; color: var(--ink); }
.pop-utc { font-size: .78rem; color: var(--muted); }
.pop-time + .pop-utc:empty { display: none; }
#pop-links { margin-top: .6rem; }
.pop-close {
  position: absolute; top: .4rem; right: .5rem; width: 28px; height: 28px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.pop-close:hover { background: var(--bg); color: var(--ink); }
#pop-links { display: flex; flex-wrap: wrap; gap: .4rem; }
#pop-links:empty { display: none; }
.pop-link {
  display: inline-block; padding: .35rem .7rem; border-radius: 6px; font-size: .82rem; font-weight: 600;
  background: var(--accent); color: #fff; text-decoration: none;
}
.pop-link:hover { filter: brightness(1.1); }
#pop-desc {
  margin: .7rem 0 0; white-space: pre-wrap;
  font: .78rem/1.55 ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted);
}
.pop-include {
  display: flex; align-items: center; gap: .45rem; margin-top: .8rem; padding-top: .7rem;
  border-top: 1px solid var(--line); font-size: .85rem; cursor: pointer;
}
#event-popover.excluded h3, #event-popover.excluded .pop-time { opacity: .45; text-decoration: line-through; }
.chip.timed { white-space: normal; text-overflow: clip; }
.chip-times { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: .3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-title { display: block; overflow-wrap: anywhere; }
#expiries { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; margin-top: 1rem; }
#expiries h3 { margin: 0 0 .5rem; font-size: 1rem; }
#expiries table { border-collapse: collapse; font-size: .88rem; }
#expiries th { text-align: left; font-weight: 600; padding: .2rem 1.5rem .2rem 0; font-variant-numeric: tabular-nums; }
#expiries td { padding: .2rem 0; color: var(--muted); }
.privacy { margin: -.6rem 0 1rem; font-size: .8rem; color: var(--muted); }
#hours { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin: -.3rem 0 .8rem; font-size: .9rem; }
#hours .hours-label { color: var(--muted); }
#hours b { font-variant-numeric: tabular-nums; }
#hours small { color: var(--muted); }
.day.today { background: #fef9c3; border-color: #facc15; box-shadow: inset 0 0 0 1px #facc15; }
.day.today .num { color: #854d0e; font-weight: 700; }

@media (max-width: 600px) {
  body { padding: 1rem; }
  .grid { gap: 2px; }
  .day { min-height: 48px; padding: 2px; }
  .chip { font-size: .6rem; padding: 1px 3px; }
  .chip.timed { padding: 1px 2px; }
  .chip-times { font-size: .56rem; letter-spacing: -.01em; }
  .chip-route { display: none; }
  .chip-title { overflow-wrap: break-word; hyphens: auto; }
}
#build { margin: 2rem 0 0; font-size: .75rem; color: var(--muted); text-align: center; }
