/* ropes.weleber.net. Mobile first: the primary user is a member holding a
   phone in one hand and a rope in the other. Touch targets are 44px+. */

:root {
    --navy: #1f3a5f;
    --accent: #eb6834;
    --ink: #222;
    --muted: #5d5d5d;
    --line: #ddd;
    --bg: #fafafa;
    --card: #fff;
    --ok: #1f5d3a;
    --ok-bg: #e2f5ea;
    --warn: #7a4a00;
    --warn-bg: #fff1d6;
    --err: #7a1f1f;
    --err-bg: #fbe3e3;
    --info: #1f3a5f;
    --info-bg: #e7eef7;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--navy); }

.site-header {
    background: var(--navy);
    color: #fff;
    padding: 0.7rem 1rem;
    padding-top: calc(0.7rem + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.site-header h1 { margin: 0; font-size: 1.2rem; font-weight: 600; }
.site-header h1 a { color: inherit; text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.site-nav a { color: #fff; text-decoration: none; font-size: 0.95rem; padding: 0.3rem 0; }
.site-nav a.nav-primary { background: var(--accent); padding: 0.35rem 0.8rem; border-radius: 4px; font-weight: 600; }
.nav-logout { margin: 0; }
.nav-logout button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.5); padding: 0.3rem 0.7rem; border-radius: 3px; cursor: pointer; font-size: 0.9rem; }

.site-main { padding: 1rem; max-width: 1100px; margin: 0 auto; }
@media (min-width: 700px) { .site-main { padding: 1.5rem; } }

h2 { margin: 0.5rem 0 0.8rem; font-size: 1.4rem; }
h3 { margin: 1rem 0 0.5rem; font-size: 1.1rem; }
small { color: var(--muted); }
.pre { white-space: pre-line; }

/* Flashes and alerts */
.flashes { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.flash, .alert { padding: 0.6rem 0.85rem; border-radius: 4px; font-size: 0.95rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #b6e0c4; }
.flash-error, .alert-error { background: var(--err-bg); color: var(--err); border-color: #ecbdbd; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f2d59a; }
.alert-info, .flash-info { background: var(--info-bg); color: var(--info); border-color: #c5d3e6; }
.alert h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert a { color: inherit; font-weight: 600; }
.alerts { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }

/* Buttons and forms */
.btn {
    display: inline-block; background: var(--navy); color: #fff; border: 0; border-radius: 6px;
    padding: 0.7rem 1.1rem; font-size: 1rem; text-decoration: none; cursor: pointer; min-height: 44px;
    line-height: 1.2;
}
.btn:hover { background: #2c4f7c; }
.btn-big { font-size: 1.15rem; padding: 1rem 1.4rem; width: 100%; text-align: center; }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.9rem; min-height: 32px; }
.btn-secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.btn-secondary:hover { background: #eef3fa; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #d2582a; }
.btn-danger { background: #b23a3a; }
.btn[disabled] { opacity: 0.5; cursor: default; }

.form { display: flex; flex-direction: column; gap: 0.8rem; max-width: 520px; }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }
.form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.95rem; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=number],
.form input[type=date], .form select, .form textarea, .field input, .field select, .field textarea {
    font: inherit; padding: 0.6rem; border: 1px solid #bbb; border-radius: 6px; min-height: 44px; width: 100%;
    background: #fff;
}
.form.inline label { flex: 1 1 160px; }
form.inline { display: inline; }
form.inline input[type=password] { width: 10em; min-height: 32px; padding: 0.3rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.row-retired td { color: var(--muted); }

.tag { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.45rem; border-radius: 10px; background: #e5e9ef; color: #333; margin-left: 0.2rem; white-space: nowrap; }
.tag-active { background: var(--ok-bg); color: var(--ok); }
.tag-quarantined, .tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-retired { background: #e5e5e5; color: #555; }
.tag-error { background: var(--err-bg); color: var(--err); }

.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.filters a { padding: 0.3rem 0.6rem; border-radius: 4px; text-decoration: none; }
.filters a.on { background: var(--navy); color: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.hero { margin-bottom: 1rem; }
.counts { display: flex; gap: 1rem; flex-wrap: wrap; }
.counts a { text-decoration: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0.5rem 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.rope-head h2 { margin-bottom: 0.2rem; }
.rope-desc { margin: 0 0 0.6rem; }
.admin-box { background: var(--info-bg); border-radius: 8px; padding: 0.6rem 1rem; margin: 0.5rem 0 1rem; }
.admin-box summary { cursor: pointer; font-weight: 600; }
.photos img { height: 80px; margin: 0.2rem 0.2rem 0 0; border-radius: 4px; }

/* ---------------------------------------------------------------------------
   Logging PWA
   --------------------------------------------------------------------------- */
.log-status { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.6rem; min-height: 1.4em; }
.log-status .pending { color: var(--warn); font-weight: 600; }
.log-status .offline { color: var(--err); font-weight: 600; }
.step { display: none; }
.step.on { display: block; }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; font-size: 0.95rem; }
.field > span { font-weight: 600; }
.choices { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.choice {
    flex: 1 1 30%; min-height: 48px; border: 2px solid #bbb; border-radius: 8px; background: #fff;
    font: inherit; font-size: 1rem; cursor: pointer; padding: 0.5rem 0.6rem; text-align: center;
}
.choice.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.choice.small { flex: 0 1 auto; min-height: 40px; font-size: 0.92rem; }
.chips { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.chip { border: 1.5px solid #999; background: #fff; border-radius: 20px; padding: 0.5rem 0.9rem; font: inherit; font-size: 0.95rem; min-height: 40px; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.8rem; }
.actions .btn { flex: 1 1 auto; text-align: center; }
.rope-cards { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.rope-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; }
.rope-card .id { font-size: 1.15rem; font-weight: 700; }
.rope-card .sub { color: var(--muted); font-size: 0.88rem; }
.rope-card button { background: none; border: 1px solid #bbb; border-radius: 6px; padding: 0.4rem 0.6rem; font: inherit; min-height: 40px; cursor: pointer; }
.confirm-card { background: #fff; border: 2px solid var(--navy); border-radius: 10px; padding: 1rem; text-align: center; }
.confirm-card .id { font-size: 2.2rem; font-weight: 800; letter-spacing: 0.02em; }
.confirm-card .desc { font-size: 1.15rem; margin: 0.3rem 0; }
.confirm-card .meta { color: var(--muted); font-size: 0.9rem; }
.confirm-card .alert { text-align: left; margin-top: 0.6rem; }

/* Scanner */
.scanner { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 70vh; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame {
    position: absolute; left: 8%; right: 8%; top: 40%; height: 18%;
    border: 3px solid #fff; border-radius: 6px; box-shadow: 0 0 0 2000px rgba(0,0,0,0.45);
}
.scanner .frame.hit { border-color: #4ade80; }
.scanner .readout {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 0.6rem; color: #fff;
    background: rgba(0,0,0,0.55); font-size: 0.95rem; text-align: center;
}
.pick-list { list-style: none; padding: 0; margin: 0.5rem 0; display: flex; flex-direction: column; gap: 0.4rem; max-height: 50vh; overflow-y: auto; }
.pick-list button { width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; font: inherit; cursor: pointer; min-height: 48px; }
.pick-list button strong { font-size: 1.05rem; }
.pick-list button.dim { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0; }
.review-block { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem; margin-bottom: 0.7rem; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------------------
   Stats
   --------------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem; }
.tile .n { font-size: 1.8rem; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 0.85rem; }
.chart { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem; margin-bottom: 1rem; }
.chart h3 { margin: 0 0 0.5rem; }
.chart .scroll { overflow-x: auto; }
.chart svg { display: block; }
.chart text { font-size: 11px; fill: #52514e; }
.chart .axis { stroke: #e4e4e0; stroke-width: 1; }
.chart .legend { display: flex; gap: 1rem; font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -1px; margin-right: 0.3rem; }
.chart details { margin-top: 0.4rem; font-size: 0.85rem; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 3em; align-items: center; gap: 0.5rem; font-size: 0.9rem; margin: 0.25rem 0; }
.hbar-row .bar { height: 14px; background: #2a78d6; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-row .v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1fr 1fr; } }
