:root {
  --wall: #D3D7DC;
  --board: #FCFCFA;
  --frame-hi: #D2D6DB;
  --frame-lo: #8E959E;
  --ink: #1E2328;
  --soft: #5B636D;
  --ghost: #C9CED4;
  --blue: #1F4FBF;
  --red: #C62828;
  --green: #1E7D3A;
  --orange: #D9730D;
  --marker: "Permanent Marker", "Comic Sans MS", cursive;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--wall);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.4;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 10px 110px;
}

.loading { text-align: center; color: var(--soft); padding-top: 30vh; font-family: var(--marker); font-size: 22px; }

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 12px;
}
.top h1 {
  font-family: var(--marker);
  font-weight: 400;
  font-size: 30px;
  margin: 0;
  line-height: 1;
  color: var(--ink);
}
.top .links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.back {
  font-family: var(--body);
  font-weight: 700;
  font-size: 16px;
  background: none;
  border: none;
  color: var(--blue);
  padding: 8px 4px;
  cursor: pointer;
}

/* The board: aluminum frame around a white surface */
.board {
  background: var(--board);
  border: 9px solid;
  border-color: var(--frame-hi) var(--frame-lo) var(--frame-lo) var(--frame-hi);
  border-radius: 7px;
  box-shadow: 0 3px 0 rgba(30, 35, 40, .18), inset 0 0 0 1px #E8EAEC;
  padding: 16px 14px 18px;
  position: relative;
}
.board + .board { margin-top: 14px; }

.board h2 {
  font-family: var(--marker);
  font-weight: 400;
  font-size: 26px;
  margin: 0 0 2px;
  line-height: 1.15;
}
.board h3 {
  font-family: var(--marker);
  font-weight: 400;
  font-size: 21px;
  margin: 18px 0 8px;
}
.addr { color: var(--soft); margin: 0 0 10px; }
.muted { color: var(--soft); }
.small { font-size: 15px; }

/* Job picker */
.jobpick label { display: block; font-weight: 700; margin-bottom: 4px; }

/* App tiles */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 16px; }
.tile {
  text-align: left;
  background: transparent;
  border: 3px solid var(--ink);
  border-radius: 12px 6px 14px 5px;
  padding: 14px 14px 12px;
  cursor: pointer;
  font-family: var(--body);
  color: var(--ink);
}
.tile:nth-child(1) { border-color: var(--blue); }
.tile:nth-child(2) { border-color: var(--green); }
.tile:nth-child(3) { border-color: var(--red); }
.tile .name { font-family: var(--marker); font-size: 24px; display: block; line-height: 1.1; }
.tile .blurb { display: block; margin-top: 4px; }
.tile .role { display: block; margin-top: 8px; font-weight: 700; font-size: 15px; color: var(--soft); }
.tile[disabled] { border-color: var(--ghost); color: var(--soft); cursor: default; }
.tile[disabled] .name { color: #A4AAB1; }

/* Delivery board rows */
.cols, .row {
  display: grid;
  grid-template-columns: 31% 19% 14% 36%;
  align-items: center;
}
.cols {
  font-family: var(--marker);
  font-size: 18px;
  border-bottom: 3px solid var(--ink);
  padding: 4px 6px 4px 10px;
}
.row {
  width: 100%;
  border: none;
  border-bottom: 1px solid #E3E6E9;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 10px 6px 10px 10px;
  cursor: pointer;
  position: relative;
  min-height: 46px;
}
.row:hover { background: #F3F5F8; }
.row .c { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 6px; }
.row .sub { font-weight: 700; }
.row .day, .row .time { color: var(--blue); font-weight: 700; }
.row.newday { border-top: 2px solid #B9BFC6; }
.row.today::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 5px;
  border-radius: 3px;
  background: var(--red);
}
.row.today .day { color: var(--red); }
.row.done .c { text-decoration: line-through; text-decoration-thickness: 2px; color: #8D949C; }
.row.pending { background: #FFF4E8; }
.row.pending .c { color: var(--orange); }
.row.pending .sub { color: #A45200; }
.row.denied .c { color: #A3A9B0; text-decoration: line-through; }
.tag {
  font-family: var(--body);
  font-size: 12px;
  font-weight: 700;
  border: 2px solid currentColor;
  border-radius: 10px;
  padding: 0 6px;
  margin-left: 6px;
  vertical-align: 1px;
  text-decoration: none;
  display: inline-block;
}
.row.denied .tag { color: var(--red); }

.empty { padding: 26px 8px; color: var(--soft); text-align: center; }
.empty .marker { font-family: var(--marker); font-size: 22px; color: #A4AAB1; display: block; margin-bottom: 6px; }

.banner {
  border: 3px solid var(--orange);
  border-radius: 10px 4px 10px 4px;
  padding: 8px 12px;
  margin: 8px 0 12px;
  color: #8A4500;
  font-weight: 700;
}

.toggles { display: flex; gap: 14px; align-items: center; margin: 4px 0 10px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; }

/* Marker tray: the main actions sit on the ledge under the board */
.tray {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(#C4C9CF, #A9AFB7);
  border-top: 2px solid #E1E4E8;
  display: flex;
  gap: 10px;
  justify-content: center;
  z-index: 5;
}
.tray .btn { min-width: 170px; }

/* Buttons and fields */
.btn {
  font-family: var(--body);
  font-weight: 700;
  font-size: 17px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--board);
  color: var(--ink);
  padding: 10px 18px;
  cursor: pointer;
  min-height: 44px;
}
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.red { background: #fff; border-color: var(--red); color: var(--red); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--blue); padding: 8px 10px; }
.btn.small { font-size: 15px; padding: 6px 12px; min-height: 36px; }
.btn[disabled] { opacity: .5; cursor: default; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 700; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=date], input[type=time], input[inputmode], select, textarea {
  width: 100%;
  font-family: var(--body);
  font-size: 17px;
  color: var(--ink);
  background: #fff;
  border: 2px solid #9EA5AD;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 46px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.codebox { font-size: 26px !important; letter-spacing: 6px; text-align: center; }

.err { color: var(--red); font-weight: 700; margin: 8px 0 0; }

/* Dialog */
dialog {
  border: 9px solid;
  border-color: var(--frame-hi) var(--frame-lo) var(--frame-lo) var(--frame-hi);
  border-radius: 7px;
  background: var(--board);
  color: var(--ink);
  padding: 16px;
  width: min(520px, calc(100vw - 20px));
  max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(30, 35, 40, .45); }
dialog h2 { font-family: var(--marker); font-weight: 400; font-size: 24px; margin: 0 0 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; justify-content: flex-end; }
.actions .left { margin-right: auto; }
.detail { margin: 0 0 6px; }
.detail b { display: inline-block; min-width: 92px; }
.booked { background: #F1F4F8; border-radius: 8px; padding: 8px 10px; margin: -4px 0 12px; font-size: 15px; }
.booked ul { margin: 4px 0 0; padding-left: 18px; }

/* Admin */
.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid #E3E6E9; padding: 10px 2px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list li .grow { flex: 1 1 200px; min-width: 0; }
.list li .email { color: var(--soft); font-size: 15px; overflow-wrap: anywhere; }
.access { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.access label { font-size: 13px; font-weight: 700; color: var(--soft); display: block; }
.access select { min-height: 40px; padding: 6px 8px; font-size: 16px; }
.pill { font-size: 13px; font-weight: 700; border: 2px solid var(--green); color: var(--green); border-radius: 10px; padding: 0 7px; }
.pill.off { border-color: #A4AAB1; color: #7D848C; }
.inline-form { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .inline-form.three { grid-template-columns: 1.3fr 1fr 1fr auto; align-items: end; }
  .inline-form.two { grid-template-columns: 1fr 1.4fr auto; align-items: end; }
  .inline-form .field { margin-bottom: 0; }
}

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
  max-width: calc(100vw - 30px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--red); }

/* Sign in */
.signin { max-width: 440px; margin: 10vh auto 0; }
.signin h1 { font-family: var(--marker); font-weight: 400; font-size: 44px; margin: 0 0 4px; }

/* Phones */
@media (max-width: 560px) {
  body { font-size: 16px; }
  #app { padding: 8px 6px 110px; }
  .board { padding: 12px 8px 14px; border-width: 7px; }
  .cols { font-size: 15px; padding-left: 8px; }
  .row { padding: 10px 2px 10px 8px; font-size: 14px; }
  .row .c { padding-right: 4px; }
  .cols, .row { grid-template-columns: 30% 19% 16% 35%; }
  .tray .btn { min-width: 0; flex: 1; }
  .top h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
.access .pill { grid-column: 1 / -1; justify-self: start; }
