:root {
  --bg: #f4f3ee;
  --card: #ffffff;
  --ink: #1c2b22;
  --muted: #5c6b62;
  --line: #ddd8cc;
  --green: #2e5d40;
  --green-soft: #e3ede6;
  --amber: #9a6b16;
  --amber-soft: #f3e8d2;
  --red: #da291c; /* Tractor Supply red */
  --red-soft: #fbe6e3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 20px 12px 48px; }

header { text-align: center; margin-bottom: 14px; }
h1 { margin: 0; font-size: 26px; letter-spacing: 0.3px; }
header h1::after {
  content: ""; display: block; width: 58px; height: 4px;
  background: var(--red); border-radius: 2px; margin: 8px auto 0;
}
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.monthbar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 0 8px;
}
.monthname { font-size: 19px; font-weight: 600; }
.navbtn {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  width: 42px; height: 38px; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink);
}
.navbtn:active { background: var(--green-soft); }

.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); margin-bottom: 4px;
}

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.day {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  min-height: 74px; padding: 4px; cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
}
.day.empty { background: transparent; border: none; cursor: default; }
.day.past { opacity: 0.45; }
.day.today { border: 2px solid var(--green); }
.day.blocked { background: #eceae3; }
.day .num { font-size: 12px; font-weight: 600; color: var(--muted); }
.day.today .num { color: var(--green); }
.day .full { font-size: 10px; color: var(--red); font-weight: 700; text-transform: uppercase; }
.day .closed { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; }

.chip {
  font-size: 10px; line-height: 1.25; padding: 1px 4px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--green-soft); color: var(--green); font-weight: 600;
}
.chip.rec { background: var(--amber-soft); color: var(--amber); }
.chip.more { background: #ecebe4; color: var(--muted); }

.legend { display: flex; gap: 14px; justify-content: center; align-items: center; margin: 12px 0; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.dot.every { background: var(--amber-soft); border: 1px solid var(--amber); }
.dot.booked { background: var(--green-soft); border: 1px solid var(--green); }

footer { text-align: center; margin-top: 24px; font-size: 13px; color: var(--muted); }
.sep { margin: 0 8px; }
.linkbtn {
  background: none; border: none; color: var(--green); font-size: 13px;
  cursor: pointer; text-decoration: underline; padding: 0; font-family: inherit;
}

.hidden { display: none !important; }

.gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gatecard {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  border-top: 4px solid var(--red);
  padding: 28px 24px; width: 100%; max-width: 360px; text-align: center;
}
.gatecard h1 { font-size: 24px; }
.gatecard h1::after {
  content: ""; display: block; width: 46px; height: 3px;
  background: var(--red); border-radius: 2px; margin: 8px auto 0;
}

.overlay {
  position: fixed; inset: 0; background: rgba(20, 30, 24, 0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.sheet {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0; padding: 18px 18px 28px;
  max-height: 86vh; overflow-y: auto;
}
@media (min-width: 600px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 14px; padding-bottom: 20px; }
}
.sheethead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.sheethead h2 { margin: 0; font-size: 19px; }

.slot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
}
.slot .who { font-weight: 600; font-size: 15px; }
.slot .when { color: var(--muted); font-size: 13px; }
.slot .tag { font-size: 11px; color: var(--amber); font-weight: 700; }
.slot .actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn {
  background: var(--green); color: #fff; border: none; border-radius: 10px;
  padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:active { opacity: 0.85; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.ghost { background: var(--card); color: var(--red); border: 1px solid var(--line); }
.btn.plain { background: var(--card); color: var(--ink); border: 1px solid var(--line); }

.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.stack input, .stack select, .timerow select {
  font-size: 15px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-family: inherit; width: 100%;
}
.timerow { display: flex; align-items: center; gap: 8px; }
.timerow span { color: var(--muted); font-size: 13px; flex-shrink: 0; }
#horizonForm { margin-bottom: 6px; }
#horizonInput { width: 72px; flex: none; }

.msg { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 10px; }
.msg.err { background: var(--red-soft); color: var(--red); }
.msg.ok { background: var(--green-soft); color: var(--green); }
.msg.ok .pin { font-size: 26px; font-weight: 800; letter-spacing: 3px; display: block; margin-top: 4px; }

.sheetactions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.adminpanel {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-top: 20px;
}
.adminhead { display: flex; justify-content: space-between; align-items: center; }
.adminpanel h3 { margin: 12px 0 2px; font-size: 15px; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }

.wdrow { display: flex; gap: 4px; }
.wdrow label {
  flex: 1; text-align: center; font-size: 12px; padding: 8px 0;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; user-select: none;
}
.wdrow input { display: none; }
.wdrow label.on { background: var(--green); color: #fff; border-color: var(--green); }

.recrule {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-size: 13px;
}
