:root {
  --bg: #081124;
  --surface: #0d1b38;
  --surface-raised: #132a52;
  --border: #223a63;
  --text: #eef1f6;
  --text-muted: #8b96b3;
  --accent: #96c600;
  --accent-text: #0d1b38;
  --accent-dim: #263300;
  --accent-hover: #80a800;
  --ok: #96c600;
  --err: #e2604f;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 15px;
  color: var(--text);
}
.topbar .brand span { color: var(--accent); }

.topbar nav a {
  margin-left: 18px;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.topbar nav a:hover { color: var(--text); text-decoration: none; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.sync-now-form { line-height: 0; }

.sync-now-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--sans);
}
.sync-now-btn:hover { background: var(--accent-hover); }

.current-user {
  font-size: 12.5px;
  color: var(--text-muted);
}
.current-user:hover {
  color: var(--text);
  text-decoration: underline;
}

.logout-form { line-height: 0; }

.logout-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--sans);
}
.logout-btn:hover { color: var(--text); border-color: var(--text-muted); }

.logo-chip {
  background: #ffffff;
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  line-height: 0;
}

.logo-chip img {
  height: 34px;
  width: auto;
  display: block;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 28px 80px;
}

h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 22px;
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}
tr:hover td { background: var(--surface-raised); }

tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--border);
  font-weight: 700;
}
tfoot tr:hover td { background: transparent; }

.unclaimed-row td { color: var(--text-muted); font-style: italic; }
.unclaimed-note { font-style: normal; font-size: 12px; }

.commissions-note {
  border-left: 3px solid var(--accent);
  font-size: 13.5px;
  color: var(--text-muted);
}
.commissions-note strong { color: var(--text); }

.empty-state {
  color: var(--text-muted);
  padding: 30px 0;
  text-align: center;
  font-size: 14px;
}

/* --- Sales Page --------------------------------------------------- */

main.wide { max-width: 1180px; }

.month-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.month-picker label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.month-picker select {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--sans);
}

.month-picker a {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
}
.month-picker a:hover { color: var(--text); text-decoration: none; }
.month-picker a.month-toggle-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.stat-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stat-tile {
  flex: 1 1 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 20px;
}

.stat-tile .stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-tile .stat-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-tile .stat-sub {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.delta-up { color: var(--ok); }
.delta-down { color: var(--err); }

.chart-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: stretch;
}

.chart-panel {
  flex: 1 1 480px;
  min-width: 0;
}

.chart-panel h2 {
  font-size: 14px;
  margin: 0 0 4px;
  color: var(--text);
}

.chart-panel .chart-total {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.chart-svg-wrap {
  position: relative;
}

.chart-svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
  font-size: 12.5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.legend-item .legend-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s;
  z-index: 5;
}

.chart-tooltip.visible { opacity: 1; }

.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-tooltip .tt-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}

.chart-tooltip .tt-total {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

/* --- Sync status footer -------------------------------------------- */

.sync-footer {
  position: sticky;
  bottom: 0;
  padding: 10px 28px;
  font-size: 12.5px;
  text-align: center;
  border-top: 1px solid var(--border);
}

.sync-footer-running {
  background: var(--surface);
  color: var(--text-muted);
}

.sync-footer-failed {
  background: var(--surface);
  color: var(--err);
}

.data-as-of {
  padding: 6px 28px 10px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  text-align: center;
  transition: opacity 1s ease;
}

.data-as-of.fading {
  opacity: 0;
}

/* --- Job drill-down / detail pages --------------------------------- */

.breadcrumb {
  font-size: 13px;
  margin: 0 0 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 24px;
  font-size: 13.5px;
}

.detail-grid .detail-label,
.detail-note .detail-label {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.detail-note {
  margin-top: 16px;
  font-size: 13.5px;
  white-space: pre-wrap;
}

/* --- Customers page -------------------------------------------------- */

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  max-width: 480px;
}
.search-bar input[type="text"] {
  flex: 1;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--sans);
}
.search-bar button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 9px 18px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.search-bar button:hover { background: var(--accent-hover); }

/* --- Users page ------------------------------------------------------ */

.table-scroll {
  overflow-x: auto;
}

.panel-heading {
  font-size: 15px;
  margin: 0 0 16px;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.actions-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.role-select,
.inline-form input[type="text"],
.inline-form input[type="password"] {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: var(--sans);
}

.crew-name-input { width: 150px; }

.small-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  white-space: nowrap;
}
.small-btn:hover { background: var(--accent-hover); }

.small-btn-danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.small-btn-danger:hover { background: var(--err); color: var(--bg); }

.kind-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.stacked-form {
  display: flex;
  flex-direction: column;
  max-width: 320px;
  gap: 4px;
}
.stacked-form label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 10px;
}
.stacked-form input, .stacked-form select {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--sans);
}
.stacked-form button {
  margin-top: 16px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 10px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.stacked-form button:hover { background: var(--accent-hover); }

.users-error { margin-bottom: 16px; }

.vip-badge, .legacy-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
  vertical-align: middle;
}
.vip-badge {
  background: var(--accent-dim);
  color: var(--accent);
}
.legacy-badge {
  background: var(--surface-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* --- Bird flyby (jess's login easter egg) --------------------------- */

.bird-flyby {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.bird {
  position: absolute;
  opacity: 0;
  animation-fill-mode: forwards;
}

.bird-eagle {
  width: 90px;
  top: 14%;
  left: -140px;
  color: var(--text-muted);
  animation-name: fly-across-eagle;
  animation-duration: 6s;
  animation-timing-function: linear;
}

.bird-hummingbird {
  width: 40px;
  top: 34%;
  left: -70px;
  color: var(--accent);
  animation-name: fly-across-hummingbird;
  animation-duration: 4s;
  animation-delay: 1.2s;
  animation-timing-function: linear;
}

.bird .wing-left, .bird .wing-right {
  transform-origin: 50% 50%;
  animation-name: wing-flap;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  animation-direction: alternate;
}
.bird-eagle .wing-left, .bird-eagle .wing-right { animation-duration: 0.35s; }
.bird-hummingbird .wing-left, .bird-hummingbird .wing-right { animation-duration: 0.07s; }

@keyframes fly-across-eagle {
  0%   { transform: translate(0, 0); opacity: 0; }
  6%   { opacity: 0.8; }
  50%  { transform: translate(55vw, -40px); }
  94%  { opacity: 0.8; }
  100% { transform: translate(calc(100vw + 240px), 15px); opacity: 0; }
}

@keyframes fly-across-hummingbird {
  0%   { transform: translate(0, 0); opacity: 0; }
  6%   { opacity: 0.9; }
  35%  { transform: translate(30vw, 25px); }
  65%  { transform: translate(60vw, -20px); }
  94%  { opacity: 0.9; }
  100% { transform: translate(calc(100vw + 160px), 5px); opacity: 0; }
}

@keyframes wing-flap {
  from { transform: scaleY(1); }
  to   { transform: scaleY(0.35); }
}

@media (prefers-reduced-motion: reduce) {
  .bird-flyby { display: none; }
}

/* --- Pest Techs page -------------------------------------------------- */

.pest-transferred-row td { color: var(--text-muted); }

.small-btn-done {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.small-btn-done:hover { color: var(--text); border-color: var(--text-muted); }
