/* Farm Animal Tracker — dark charcoal & amber, mobile-first */

/* The `hidden` attribute must win over every class that sets display
   (e.g. .modal and .login-wrap use display:flex). Without this, hidden
   panels — the modal, the login screen, the role picker — stay visible
   and block all taps. */
[hidden] { display: none !important; }

:root {
  --bg: #1a1d21;
  --bg2: #22262b;
  --card: #2a2f35;
  --line: #3a4048;
  --text: #f2ede4;
  --muted: #a8a29a;
  --amber: #e8a33d;
  --amber-dark: #c98a2b;
  --green: #43a047;
  --red: #d45d5d;
  --grey-green: #8fa98f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); }
a { color: var(--amber); }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px; width: 100%; max-width: 380px; text-align: center; }
.login-card .logo { font-size: 48px; }
.login-card h1 { font-size: 22px; margin-top: 8px; }
.login-card form { text-align: left; margin-top: 16px; }

/* ---- Top bar & tabs ---- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 17px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.role-badge { background: var(--amber); color: #1a1d21; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; }
.tabs { display: flex; gap: 4px; padding: 8px 12px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 53px; z-index: 20; }
.tab { flex: 1; min-width: 76px; min-height: 44px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 15px; font-weight: 600; border-radius: 10px; cursor: pointer; }
.tab.active { background: var(--card); color: var(--amber); border-color: var(--line); }

.view { max-width: 860px; margin: 0 auto; padding: 16px 14px 90px; }

/* ---- Cards, grids, lists ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat .num { font-size: 30px; font-weight: 800; color: var(--amber); line-height: 1.1; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat .num.warn { color: var(--red); }
.row { display: flex; align-items: center; gap: 10px; }
.row.space { justify-content: space-between; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 56px; }
.list-item:last-child { border-bottom: none; }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--bg2); border: 1px solid var(--line); flex-shrink: 0; }
.thumb.placeholder { display: flex; align-items: center; justify-content: center; font-size: 26px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.pill.pregnant, .pill.high { background: #3a2a12; color: var(--amber); border-color: var(--amber-dark); }
.pill.open, .pill.medium { background: #33291a; color: #e8c07a; border-color: #6b5a33; }
.pill.resolved, .pill.low { background: #22301f; color: #9ccc9f; border-color: #3d5a3a; }
.pill.grazing { background: #1e3a1f; color: #7cc47f; border-color: var(--green); }
.pill.resting { background: #3a2a12; color: var(--amber); border-color: var(--amber-dark); }
.pill.ready { background: #2c332c; color: var(--grey-green); border-color: #556655; }
.pill.done { text-decoration: line-through; opacity: 0.6; }

/* ---- Forms & buttons ---- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px;
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--amber); }
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px; font-size: 16px; font-weight: 700;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg2);
  color: var(--text); cursor: pointer;
}
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1a1d21; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn.big { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.check { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--line); background: transparent; cursor: pointer; font-size: 16px; color: var(--amber); }
.check.done { border-color: var(--green); background: var(--green); color: #fff; }
.task-title { flex: 1; }
.task-title.done { text-decoration: line-through; opacity: 0.55; }
.due { font-size: 13px; color: var(--muted); white-space: nowrap; }
.due.overdue { color: var(--red); font-weight: 700; }

/* ---- Map ---- */
.map { height: 340px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.map.small { height: 220px; }
.leaflet-container { background: #20242a; font-family: inherit; }
.hint { font-size: 13px; color: var(--muted); background: var(--bg2); border: 1px dashed var(--line); border-radius: 8px; padding: 10px; margin: 10px 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---- Modal & toast ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 18px 16px 28px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--amber); color: #1a1d21; font-weight: 700; padding: 12px 20px; border-radius: 999px; z-index: 60; box-shadow: 0 4px 18px rgba(0,0,0,0.4); }

/* ---- Arena week grid ---- */
.arena-grid { width: 100%; min-width: 640px; border-collapse: collapse; background: var(--card); }
.arena-grid th, .arena-grid td { border: 1px solid var(--line); padding: 4px; font-size: 13px; text-align: center; vertical-align: top; }
.arena-grid th { background: var(--bg2); }
.arena-grid td { height: 44px; cursor: pointer; }
.arena-grid td:hover { background: #2f353c; }
.booking { background: var(--amber); color: #1a1d21; border-radius: 8px; padding: 4px 6px; font-size: 12px; line-height: 1.3; cursor: pointer; text-align: left; }
.booking.lesson { background: transparent; color: var(--amber); border: 1px solid var(--amber); }
.waiver-text { white-space: pre-wrap; word-wrap: break-word; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 14px; line-height: 1.5; max-height: 50vh; overflow-y: auto; }

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .modal { align-items: center; padding: 20px; }
  .modal-card { border-radius: 16px; }
}
