/* SGA Maintenance — mobile-first styles. Gym colors: red, black, white, grey. */
:root {
  --red: #c8102e;
  --red-dark: #9e0c24;
  --red-tint: #fdecef;
  --black: #111111;
  --ink: #1d1d1f;
  --grey-1: #f3f3f4;
  --grey-2: #e4e4e7;
  --grey-3: #a1a1aa;
  --grey-4: #6b6b73;
  --white: #ffffff;
  --green: #17803d;
  --green-tint: #e8f6ed;
  --amber: #b45309;
  --amber-tint: #fff4e0;
  --blue: #1d4ed8;
  --blue-tint: #e8efff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--grey-1);
}
body.has-nav { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); }
a { color: var(--red); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: .4rem 0 .8rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
.card h2:first-child, .card h2:first-of-type { margin-top: 0; }
p { margin: .4rem 0; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { background: var(--black); color: var(--white); border-bottom: 4px solid var(--red); position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top, 0); }
.topbar-inner { max-width: 960px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--white); text-decoration: none; font-weight: 700; }
.brand-mark { background: var(--red); color: var(--white); font-weight: 800; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; font-size: .9rem; }
.brand-text { font-size: 1.05rem; }
.topbar-back { color: var(--white); display: flex; width: 32px; height: 32px; margin-left: -6px; align-items: center; justify-content: center; }
.topbar-back svg { width: 24px; height: 24px; }
.topnav { display: none; gap: 4px; margin-left: 16px; }
.topnav a { color: #d4d4d8; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.topnav a.active, .topnav a:hover { color: var(--white); background: rgba(255,255,255,.12); }
.topbar-user { margin-left: auto; color: #d4d4d8; font-size: .85rem; text-decoration: none; }

/* ---------- bottom tab bar (phones) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--white); border-top: 1px solid var(--grey-2);
  padding-bottom: var(--safe-b); height: calc(var(--tabbar-h) + var(--safe-b));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--grey-4); text-decoration: none; font-size: .72rem; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--red); }

@media (min-width: 800px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body.has-nav { padding-bottom: 40px; }
}

/* ---------- layout ---------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 12px 16px; }
.narrow { max-width: 560px; margin: 0 auto; }
.section { margin-bottom: 1.6rem; }
.section-head, .title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: .8rem 0 .5rem; }
.title-row h1 { margin-bottom: .6rem; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 12px; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > * { margin-top: 0 !important; }
.center { text-align: center; }
.muted { color: var(--grey-4); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; word-break: break-word; }
.txt-red { color: var(--red); }
.txt-green { color: var(--green); }
.hello { margin-top: .2rem; }
.count { display: inline-block; min-width: 1.6em; padding: 0 .45em; border-radius: 99px; background: var(--grey-2); color: var(--ink); font-size: .85rem; text-align: center; vertical-align: middle; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-weight: 400; font-size: 16px; /* 16px stops iOS zoom */
  padding: 11px 12px; border: 1px solid #cfcfd4; border-radius: 10px; background: var(--white); color: var(--ink);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; padding: 4px 0; }
label.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--red); }
.field-label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
fieldset.urgency { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.urgency legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 6px; }
.urgency-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pill-urgent input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.pill-week input:checked + span { background: var(--amber); border-color: var(--amber); color: #fff; }
.pill-month input:checked + span { background: var(--black); border-color: var(--black); color: #fff; }
.pill input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.badge-pri { background: var(--grey-1); color: var(--grey-4); border: 1px solid var(--grey-2); }
.badge-overdue { background: var(--amber); color: #fff; }
.check-urgent { color: var(--red-dark); font-weight: 600 !important; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { flex: 1 1 180px; margin-top: 0 !important; }
.inline-form select { margin: 0; padding: 6px 10px; width: auto; }
.title-row select { width: auto; margin: 0; }
.loc-checks { padding-left: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 1rem; line-height: 1.2;
  padding: 12px 18px; min-height: 46px; border-radius: 10px; border: 1px solid transparent;
  background: var(--black); color: var(--white); text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: var(--white); color: var(--ink); border-color: #cfcfd4; }
.btn-link { background: none; color: var(--red); border: 0; padding: 6px 0; min-height: 0; font-weight: 600; }
.btn-block { display: flex; width: 100%; }
.btn-big { min-height: 56px; font-size: 1.08rem; }
.btn-sm { padding: 7px 12px; min-height: 36px; font-size: .88rem; }
.btn[disabled] { opacity: .6; cursor: default; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--grey-2); background: var(--white); font-size: 1.1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); list-style: none; }
.icon-btn[disabled] { opacity: .3; }
summary.icon-btn::-webkit-details-marker { display: none; }

/* ---------- flash ---------- */
.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 12px; border-left: 4px solid; background: var(--white); }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-ok { border-color: var(--green); background: var(--green-tint); }
.flash-error { border-color: var(--red); background: var(--red-tint); }
.flash-warn { border-color: var(--amber); background: var(--amber-tint); }
.flash-info { border-color: var(--blue); background: var(--blue-tint); }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--grey-2); color: var(--ink); white-space: nowrap; vertical-align: middle; }
.badge-submitted { background: var(--red-tint); color: var(--red-dark); }
.badge-in_progress { background: var(--amber-tint); color: var(--amber); }
.badge-completed { background: var(--green-tint); color: var(--green); }
.badge-urgent { background: var(--red); color: var(--white); }

/* ---------- lists / rows ---------- */
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; color: inherit; text-decoration: none; min-height: 60px; }
a.row:active { background: var(--grey-1); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
.row-desc { font-size: .88rem; color: var(--grey-4); overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions form { display: flex; gap: 6px; }
.row-num { color: var(--grey-3); font-variant-numeric: tabular-nums; width: 1.6em; text-align: right; flex: none; }
.row-off { opacity: .55; }
.chev { color: var(--grey-3); font-size: 1.6rem; line-height: 1; }

.menu { position: relative; }
.menu-body { position: absolute; right: 0; top: 46px; z-index: 10; width: min(300px, 80vw); background: var(--white); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 14px; }
.menu-body form + form { margin-top: 10px; border-top: 1px solid var(--grey-2); padding-top: 6px; }

/* locations on home / checks */
.loc-list { display: flex; flex-direction: column; gap: 8px; }
.loc-row { display: flex; align-items: center; gap: 12px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; color: inherit; text-decoration: none; min-height: 68px; }
.loc-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.loc-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--grey-3); }
.loc-row.done .loc-dot { background: var(--green); }
.loc-row.todo .loc-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-tint); }

/* ---------- weekly check form ---------- */
.check-head h1 { margin-bottom: 0; }
.progress-bar { position: sticky; top: 56px; z-index: 5; background: var(--grey-1); padding: 8px 0; display: flex; align-items: center; gap: 12px; font-size: .88rem; font-weight: 600; }
.progress { flex: 1; height: 8px; background: var(--grey-2); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
.eq-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
fieldset.eq { margin: 0; border: 0; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; border-left: 5px solid var(--grey-2); scroll-margin-top: 110px; }
fieldset.eq.is-ok { border-left-color: var(--green); }
fieldset.eq.is-repair { border-left-color: var(--red); }
fieldset.eq.is-missing { box-shadow: 0 0 0 2px var(--red); }
fieldset.eq > legend { float: left; width: 100%; padding: 0; font-weight: 700; font-size: 1.05rem; margin-bottom: 10px; }
.eq-open { clear: both; margin: -4px 0 8px; color: var(--amber); }
.seg { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { position: relative; font-weight: 600; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: 8px; border-radius: 10px; border: 2px solid var(--grey-2); background: var(--white); font-size: .95rem; line-height: 1.15; }
.seg-ok input:checked + span { background: var(--green); border-color: var(--green); color: var(--white); }
.seg-repair input:checked + span { background: var(--red); border-color: var(--red); color: var(--white); }
.seg input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.eq-detail { display: none; margin-top: 12px; }
.eq-detail > * + * { margin-top: 10px; }
fieldset.eq.is-repair .eq-detail { display: block; }
.submit-bar { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b)); padding: 10px 0; background: linear-gradient(to top, var(--grey-1) 70%, transparent); }
@media (min-width: 800px) { .submit-bar { bottom: 0; } }

/* photos */
.photo-input { display: flex; flex-direction: column; gap: 8px; }
.btn-photo { align-self: flex-start; font-weight: 600; }
.btn-photo svg { width: 20px; height: 20px; }
.photo-previews, .photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.photo-previews:empty { display: none; }
.photo-previews .pv { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--grey-2); }
.photo-previews img, .photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-previews .pv-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.photos { margin-top: 10px; }
.photo { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--grey-2); }

/* ---------- reports ---------- */
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.report-head h1 { margin: 0 0 .2rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 700; color: var(--red); margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.facts div { min-width: 0; }
.facts dt { font-size: .75rem; color: var(--grey-4); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.item { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; border-left: 5px solid var(--red); }
.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.no-underline { text-decoration: none; }
.table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--grey-2); vertical-align: top; }
.table th { background: var(--grey-1); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--grey-4); }
.danger-zone { margin-top: 24px; text-align: center; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.grid-table th, .grid-table td { padding: 6px; border-bottom: 1px solid var(--grey-2); text-align: center; white-space: nowrap; }
.grid-table thead th { position: sticky; top: 0; background: var(--grey-1); font-size: .78rem; }
.grid-table thead th a { color: var(--ink); }
.grid-table tbody th { text-align: left; position: sticky; left: 0; background: var(--white); font-weight: 600; }
.cell { display: inline-block; min-width: 72px; padding: 5px 8px; border-radius: 8px; text-decoration: none; font-weight: 600; color: var(--grey-3); }
.cell-ok { background: var(--green-tint); color: var(--green); }
.cell-repair { background: var(--red-tint); color: var(--red-dark); }
.cell-missed { background: var(--grey-1); color: var(--grey-4); border: 1px dashed var(--grey-3); }
.cell-pending { background: var(--amber-tint); color: var(--amber); }

.timeline { list-style: none; padding: 0 0 0 18px; margin: 0 0 16px; border-left: 2px solid var(--grey-2); }
.timeline li { position: relative; padding: 0 0 16px 12px; }
.timeline li::before { content: ""; position: absolute; left: -26px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--white); border: 3px solid var(--red); }
.tl-head { margin-bottom: 4px; }

.status-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.pill span { display: flex; align-items: center; justify-content: center; min-height: 48px; text-align: center; border: 2px solid var(--grey-2); border-radius: 10px; font-size: .9rem; padding: 4px; line-height: 1.15; }
.pill-submitted input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.pill-in_progress input:checked + span { background: var(--amber); border-color: var(--amber); color: #fff; }
.pill-completed input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.tabs a { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--white); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); }
.tabs a.active { background: var(--black); color: var(--white); }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 12px 0; }

/* login */
.login { padding-top: 6vh; }
.login-head { text-align: center; margin-bottom: 18px; }
.login-mark { display: inline-block; background: var(--red); color: #fff; font-weight: 800; font-size: 1.6rem; letter-spacing: .05em; padding: 8px 16px; border-radius: 12px; }
.login-head h1 { margin: 12px 0 0; }

/* print */
@media print {
  body { background: #fff; padding: 0 !important; font-size: 12px; }
  .topbar, .tabbar, .no-print, .flash { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .card, .row, .item, .facts, .table, .table-scroll { box-shadow: none; border: 1px solid #ddd; }
  .item, tr { break-inside: avoid; }
  .photos { grid-template-columns: repeat(6, 1fr); }
  a { color: inherit; text-decoration: none; }
}
