/* frifle - shared styles. Mobile-first; admin pages widen on desktop. */

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #64748b;
  --accent: #1d6f42;        /* forest green, field shooting vibe */
  --accent-dark: #14532d;
  --danger: #b91c1c;
  --border: #d7dde3;
  --inner: #c2410c;         /* inner-hit orange */
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  background: var(--accent-dark);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
header.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
header.topbar h1 a { color: #fff; }
header.topbar .who { font-size: .85rem; opacity: .85; }
header.topbar button { background: rgba(255,255,255,.15); color: #fff; border: none; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
main.narrow { max-width: 520px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.card h3 { margin: 16px 0 8px; font-size: .95rem; }

label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}
input[type="number"].mini { width: 64px; padding: 6px; text-align: center; }

button {
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: .95rem;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: #e2e8f0; color: var(--text); }
button.danger { background: var(--danger); }
button.small { padding: 5px 10px; font-size: .82rem; }
button:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: center; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 140px; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.pill {
  display: inline-block;
  background: #e7f0ea;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .8rem;
  margin: 1px;
}
.pill.inner { background: #fdebd9; color: var(--inner); }

.muted { color: var(--muted); font-size: .88rem; }
.error { color: var(--danger); font-size: .9rem; margin-top: 8px; min-height: 1.2em; }
.ok { color: var(--accent-dark); }

/* account / 2FA */
.qr { display: block; width: 220px; max-width: 100%; margin: 8px 0; image-rendering: pixelated; }
.secret { font-size: .95rem; letter-spacing: .04em; word-break: break-all; }
.codes {
  background: #f1f5f9; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; font-size: 1.05rem; line-height: 1.7; columns: 2;
}
.setup-link {
  background: #e7f0ea; border: 1px solid var(--accent); border-radius: 8px;
  padding: 12px; margin-top: 12px; word-break: break-all;
}
.setup-link code { font-size: .85rem; }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px;
  background: #e2e8f0; color: var(--muted); }
.badge.ok { background: #e7f0ea; color: var(--accent-dark); }
.badge.warn { background: #fdebd9; color: var(--inner); }

.logo-sm { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; }

.score { font-variant-numeric: tabular-nums; font-weight: 600; }
.score .inner-part { color: var(--inner); }

/* results entry matrix */
.result-cell { white-space: nowrap; }
.result-cell input { width: 46px; padding: 5px 2px; text-align: center; border: 1px solid var(--border); border-radius: 6px; }
.result-cell .sep { color: var(--muted); padding: 0 2px; }
.result-cell.saved input { border-color: var(--accent); }

/* station editor */
.station {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  background: #fafcfb;
}
.station-head { display: flex; align-items: center; gap: 10px; }
.station-head strong { flex: 1; }
.fig-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.times-grid { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.times-grid .time-item { text-align: center; }
.times-grid .time-item label { margin: 0 0 2px; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: #e2e8f0; color: var(--text); }
.tabs button.active { background: var(--accent); color: #fff; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 10px;
}
.modal {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  max-width: 860px; width: 100%; max-height: 95vh; overflow: auto;
}
.hidden { display: none !important; }

/* target analysis canvas */
.canvas-wrap { position: relative; width: 100%; touch-action: none; }
.canvas-wrap canvas { width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }
.analyze-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.analyze-toolbar input[type="range"] { flex: 1; min-width: 120px; }

/* live (shooter) view */
.live-main { max-width: 560px; }
.live-station {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); margin-bottom: 8px;
}
.live-station .st-no {
  width: 40px; height: 40px; border-radius: 50%;
  background: #e7f0ea; color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.live-station .st-info { flex: 1; }
.live-station .st-score { font-size: 1.3rem; }
.live-station.waiting .st-score { color: var(--muted); font-size: .9rem; }
.live-station.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0% { background: #d2f1dd; }
  100% { background: var(--card); }
}
.live-total {
  text-align: center; padding: 18px; border-radius: var(--radius);
  background: var(--accent-dark); color: #fff; margin-bottom: 14px;
}
.live-total .big { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.live-total .place { font-size: .95rem; opacity: .9; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--accent-dark); color: #fff; padding: 12px 18px;
  border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  font-size: .95rem; z-index: 99; max-width: 92vw;
}

@media (max-width: 640px) {
  main { padding: 10px; }
  th, td { padding: 6px; }
  .hide-mobile { display: none; }
}

header.topbar a.toplink { color: #fff; font-size: .85rem; opacity: .9; }
