:root {
  --ink: #111111;
  --muted: #6b6b6b;
  --line: #e2e2e2;
  --accent: #5856d6;
  --accent-ink: #ffffff;
  --bg: #fafafa;
  --card: #ffffff;
  --truck-color: #6b4fa0;
  --solo-color: #e8b800;
  --done-color: #c9b8e8;
  --done-solo-color: #f7e8b8;
  --billed-color: #8c8c8c;
  --covered-color: #2f8f5b;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: #fff;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 10px;
}

.topbar .brand { display: flex; align-items: center; }
.topbar .brand-logo { display: block; height: 26px; width: auto; }

.topbar nav a {
  color: var(--ink);
  text-decoration: none;
  margin-left: 16px;
  opacity: 0.7;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topbar nav a.active { opacity: 1; border-bottom: 2px solid var(--accent); }

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  background: none;
  border: none;
  font: inherit;
  color: var(--ink);
  text-decoration: none;
  margin-left: 16px;
  opacity: 0.7;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 0;
}

.nav-dropdown-toggle.active { opacity: 1; border-bottom: 2px solid var(--accent); }

.nav-dropdown-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  min-width: 170px;
  flex-direction: column;
  z-index: 950;
  overflow: hidden;
  margin-top: 6px;
}

.nav-dropdown.open .nav-dropdown-panel { display: flex; }

.nav-dropdown-panel a {
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  opacity: 0.75;
  white-space: nowrap;
  margin-left: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.nav-dropdown-panel a:hover { background: #f4f4f4; opacity: 1; }
.nav-dropdown-panel a.active { opacity: 1; background: #f4f4f4; color: var(--accent); }

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 900;
}

@media (max-width: 680px) {
  .topbar .top-nav { display: none; }

  .bottom-nav {
    display: flex;
  }

  .bottom-nav a,
  .bottom-nav .nav-dropdown-toggle {
    flex: 1 1 0;
    min-width: 64px;
    text-align: center;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 10px 4px;
    opacity: 0.6;
    white-space: nowrap;
    margin-left: 0;
  }

  .bottom-nav .nav-dropdown-toggle {
    width: 100%;
  }

  .bottom-nav a.active,
  .bottom-nav .nav-dropdown-toggle.active {
    opacity: 1;
    border-top: 2px solid var(--accent);
    padding-top: 8px;
  }

  .bottom-nav .nav-dropdown {
    flex: 1 1 0;
    min-width: 64px;
    display: flex;
  }

  .bottom-nav .nav-dropdown-panel {
    top: auto;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    margin-bottom: 6px;
  }

  body { padding-bottom: 54px; }

  main { padding: 12px; }

  /* Month calendar: collapse job chips to small colored dots — tap the date
     number to open Day view for the full, readable list. */
  table.calendar td.day {
    height: 52px;
    padding: 3px 2px;
    font-size: 0.7rem;
  }

  .daynum {
    font-size: 0.8rem;
    padding: 2px;
  }

  table.calendar .chip {
    display: inline-block;
    width: 8px;
    height: 8px;
    padding: 0;
    margin: 1px;
    border-radius: 50%;
    font-size: 0;
    line-height: 0;
    vertical-align: middle;
  }

  .avail-badges { margin: 0; }

  /* Bigger, easier-to-hit tap targets */
  .btn {
    padding: 10px 16px;
    font-size: 0.95rem;
  }

  .checkbox-label {
    padding: 6px 0;
  }

  .checkbox-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  .hw-row input[type="number"] {
    font-size: 1rem;
    padding: 8px;
  }

  .cal-nav-btn {
    width: 34px;
    height: 34px;
    font-size: 1.3rem;
  }

  .cal-header h2, .cal-header h3 {
    font-size: 1.02rem;
  }

  .card {
    padding: 14px;
  }

  .card h3 {
    font-size: 1.05rem;
  }

  h2 {
    font-size: 1.3rem;
  }
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 18px;
}

h2 { margin-top: 0; }

.cal-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.cal-header h2, .cal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  text-align: center;
  overflow-wrap: break-word;
}

.cal-header-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  max-width: 320px;
}

.cal-nav-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.5rem;
  line-height: 1;
}

.cal-nav-btn:active { background: #f0f0f0; }

.today-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: underline;
}

table.calendar {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--card);
}

table.calendar th {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}

table.calendar td.day {
  vertical-align: top;
  border: 1px solid var(--line);
  height: 90px;
  width: 14.28%;
  padding: 4px;
  font-size: 0.8rem;
}

table.calendar td.muted { color: #c6c6c6; background: #f4f4f4; }
table.calendar td.today { background: #eeeefb; }

.chip {
  display: block;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-size: 0.7rem;
  padding: 2px 4px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.form-field { margin-bottom: 12px; }

.field-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.time-select-row {
  display: flex;
  gap: 6px;
}

.time-select-row select {
  flex: 1;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

.computed-value {
  padding: 8px;
  background: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  color: var(--ink);
}

.hw-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}

.hw-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.hw-row:last-child { border-bottom: none; }
.hw-row:nth-child(odd) { background: #fafafa; }

.hw-label { font-size: 0.85rem; color: var(--ink); flex: 1; }

.hw-row input[type="number"] {
  width: 60px;
  flex-shrink: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: center;
}

.card > h3,
.card > .card-header-row {
  margin: -16px -16px 14px -16px;
  padding: 12px 16px;
  background: #f2f2f0;
  border-bottom: 1px solid var(--line);
  border-radius: 7px 7px 0 0;
}

.card > h3,
.card-header-row h3 {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 1rem;
  white-space: nowrap;
}

.card-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 10px;
}

.card-header-row h3 {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}

.card-header-actions { display: flex; gap: 8px; }
.card-header-actions form { margin: 0; }

.form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.form input, .form textarea, .form select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  color: var(--ink);
}

.collection-address-extra {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.collection-address-extra label { flex: 1; margin-bottom: 0; }

.btn-link {
  display: inline-block;
  background: none;
  border: none;
  padding: 4px 0;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.collection-address-extra .btn-link {
  margin-bottom: 8px;
  white-space: nowrap;
}

.btn-link:hover { text-decoration: underline; }

dl.info {
  margin: 0;
}

dl.info dt {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

dl.info dd {
  margin: 0 0 10px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: break-word;
}

dl.info dd:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.hw-summary-list div { margin-bottom: 2px; }

.gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.thumb {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-overlay.open { display: flex; }

.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}
.muted-text { color: var(--muted); font-size: 0.85rem; }

#imageInput { margin-bottom: 8px; }

.error-banner {
  background: #fdecea;
  border: 1px solid #e5b4ac;
  color: #a33c2c;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.reset-banner {
  background: #eafaf0;
  border: 1px solid #b8e0c7;
  color: #1e4a30;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.view-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.view-tabs a {
  padding: 7px 14px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.view-tabs a.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.daynum {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  color: inherit;
  text-decoration: none;
}

.time-grid {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

.hour-gutter {
  position: relative;
  width: 52px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
}

.hour-label {
  position: absolute;
  left: 0;
  right: 6px;
  text-align: right;
  font-size: 0.68rem;
  color: var(--muted);
  transform: translateY(-50%);
  white-space: nowrap;
}

.day-cols {
  display: flex;
  flex: 1;
  min-width: 0;
}

.day-cols.single .day-col { min-width: 260px; }

.day-col {
  flex: 1;
  min-width: 100px;
  border-right: 1px solid var(--line);
}

.day-col:last-child { border-right: none; }

.day-col-header {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  background: #f4f4f4;
}

.day-col-header a { color: var(--ink); text-decoration: none; }
.day-col-header.today { background: #eeeefb; }

.day-col-body {
  position: relative;
  background-image: repeating-linear-gradient(
    to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent 60px
  );
}

.event {
  position: absolute;
  height: 40px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  font-size: 0.68rem;
  padding: 2px 4px;
  text-decoration: none;
  overflow: hidden;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-sizing: border-box;
}

.event-time { font-weight: 600; }
.event-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chip-truck, .event-truck { background: var(--truck-color); color: #fff; }
.chip-solo, .event-solo { background: var(--solo-color); color: #3d2e00; }
.chip-other, .event-other { background: var(--accent); color: var(--accent-ink); }
.chip-done, .event-done { background: var(--done-color); color: #3a2d57; }
.chip-done-solo, .event-done-solo { background: var(--done-solo-color); color: #5c4400; }
.chip-billed, .event-billed { background: var(--billed-color); color: #fff; }

.legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 12px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 2px;
}

.legend-dot.truck { background: var(--truck-color); }
.legend-dot.solo { background: var(--solo-color); }
.legend-dot.done { background: var(--done-color); }
.legend-dot.done-solo { background: var(--done-solo-color); }
.legend-dot.billed { background: var(--billed-color); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.avail-badges {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin: 2px 0;
}

.avail-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.avail-badge.covered { background: var(--covered-color); }
.avail-badge.uncovered { background: #c0392b; }

.avail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.avail-row:last-child { border-bottom: none; }
.avail-row-main { flex: 1; font-size: 0.9rem; }
.avail-row-covered { margin: 0; }

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-chip {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.notif-badge {
  background: #c0392b;
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
}

.logout-form { margin: 0; }

.logout-btn {
  background: none;
  border: none;
  color: var(--ink);
  opacity: 0.6;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
}

.login-main {
  max-width: 360px;
  margin: 60px auto;
  padding: 0 18px;
}

.login-main h2 { text-align: center; }

.login-logo {
  display: block;
  height: 36px;
  width: auto;
  margin: 0 auto 28px;
}

.checkbox-group {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ts-grid { margin-bottom: 14px; }

.ts-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--card);
  overflow: hidden;
}

.ts-day summary {
  padding: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}

.ts-day[open] summary { border-bottom: 1px solid var(--line); }

.ts-day-body { padding: 12px; }
.ts-day-body .form-field, .ts-day-body label { margin-bottom: 10px; }
.ts-day-body .form-field:last-child, .ts-day-body label:last-child { margin-bottom: 0; }

.ts-total { text-align: right; font-size: 1rem; }

.notif-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.notif-row:last-child { border-bottom: none; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  animation: toast-fade 2.5s ease forwards;
}

@keyframes toast-fade {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

.bill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.bill-row:last-child { border-bottom: none; }
.bill-row-main { display: flex; flex-direction: column; gap: 2px; }
.bill-row-main a { color: var(--ink); }
