:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --panel-2: #222c42;
  --text: #e6ebf5;
  --muted: #93a1bd;
  --office: #2e7d32;
  --office-border: #43a047;
  --flight: #d4a017;
  --ok: #2e7d32;
  --warn: #c0392b;
  --line: #2c374f;
  --accent: #4c8bf5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

/* ---------- login ---------- */
/* Normal top-aligned flow (not 100vh flex-centering) so mobile keyboards and tap
   hit-testing behave — full-viewport centering breaks taps on some phones. */
.login-body {
  display: block; padding: 3rem 1rem;
}
.login-card {
  background: var(--panel); padding: 2rem; border-radius: 14px;
  width: 100%; max-width: 340px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 0.9rem;
  border: 1px solid var(--line);
}
.field-label { font-size: 0.85rem; color: var(--muted); margin-bottom: -0.4rem; }
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-card input, .login-card button {
  padding: 0.8rem; border-radius: 8px; border: 1px solid var(--line);
  font-size: 1rem;
}
.login-card input { background: var(--panel-2); color: var(--text); }
.login-card button {
  background: var(--accent); color: white; border: none; cursor: pointer; font-weight: 600;
}
.error { color: var(--warn); margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; }
.score {
  margin-left: auto; text-align: right; display: flex; flex-direction: column;
  padding: 0.2rem 0.8rem; border-radius: 10px; background: var(--panel-2);
}
.score-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.score-value { font-size: 1.5rem; font-weight: 700; }
.score.ok .score-value { color: #7bd88f; }
.score.warn .score-value { color: #ff8a80; }

.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 0.5rem 0.8rem; border-radius: 8px; cursor: pointer;
}

/* ---------- controls ---------- */
.controls {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--line);
}
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2);
}
.chip.office { background: var(--office); border-color: var(--office-border); color: #eafaea; }
.chip.flight { background: var(--flight); border-color: #e0b83a; color: #1a1400; }
.chip.weekend { background: #161d2c; }

/* ---------- calendar ---------- */
.calendar {
  display: grid; gap: 1rem; padding: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  align-items: start;
}
.month { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.month-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.8rem; background: var(--panel-2); font-weight: 600;
}
.month-counts { font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.dow {
  display: grid; grid-template-columns: 1.4rem repeat(7, 1fr);
  padding: 0.3rem 0.5rem 0; gap: 2px;
  font-size: 0.7rem; color: var(--muted); text-align: center;
}
.week {
  display: grid; grid-template-columns: 1.4rem repeat(7, 1fr);
  gap: 2px; padding: 2px 0.5rem; align-items: stretch;
}
.week-toggle {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 0.9rem; border-radius: 6px;
}
.week-toggle:hover { background: var(--panel-2); color: var(--text); }
.week-toggle:disabled { opacity: 0.3; cursor: default; }
.week-toggle:disabled:hover { background: transparent; color: var(--muted); }

.day {
  position: relative; min-height: 2.4rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.day.empty { background: transparent; border: none; cursor: default; }
.day.weekend { background: #161d2c; color: var(--muted); }
.day.office { background: var(--office); border-color: var(--office-border); color: #eafaea; font-weight: 600; }
/* Flight days (first/last of an office block) shade yellow, overriding office green. */
.day.flight { background: var(--flight); border-color: #e0b83a; color: #1a1400; font-weight: 600; }
.day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.day.out-of-range { opacity: 0.35; cursor: default; }
.day.past { opacity: 0.5; cursor: default; }  /* history: visible but read-only */

.week-belt {
  grid-column: 1 / -1;
  display: flex; justify-content: flex-end; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; color: var(--muted); padding: 1px 0.2rem 3px;
}
.week-belt .val { font-weight: 700; }
.week-belt.ok .val { color: #7bd88f; }
.week-belt.warn .val { color: #ff8a80; }
.week-belt .ramping { font-style: italic; opacity: 0.8; }

.footer { padding: 1rem; text-align: center; }
.backup { margin-top: 0.7rem; display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; }
.backup a, .linklike {
  color: var(--muted); text-decoration: underline; cursor: pointer;
  background: none; border: none; font: inherit; padding: 0;
}
.backup a:hover, .linklike:hover { color: var(--text); }
