/* BWU Field Visit Tracker — shared styles */
:root {
  --navy: #0b3a6e;
  --navy-2: #0f4c8f;
  --ink: #1c2530;
  --muted: #5d6b7a;
  --line: #d9e0e8;
  --paper: #f3f6f9;
  --white: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e5f4ec;
  --warn: #9a5b00;
  --warn-bg: #fff2d9;
  --bad: #b3261e;
  --bad-bg: #fde8e6;
  --radius: 6px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--paper); font-size: 15px; line-height: 1.5; }
a { color: var(--navy-2); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #f2b705; outline-offset: 1px;
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 600; }
small, .muted { color: var(--muted); }

/* ---------- Admin shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #dce7f5; padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { padding: 0 18px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 10px; }
.side .brand img { width: 150px; display: block; }
.side .brand span { display: block; font-size: .85rem; margin-top: 8px; color: #b8cbe3; }
.side nav a { display: block; padding: 9px 18px; color: #dce7f5; text-decoration: none; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.07); }
.side nav a.on { background: rgba(255,255,255,.12); border-left-color: #f2b705; color: #fff; }
.side nav .sep { margin: 12px 18px 4px; font-size: .78rem; color: #8fa9c9; }
.side .who { padding: 14px 18px; margin-top: 12px; border-top: 1px solid rgba(255,255,255,.12); font-size: .88rem; }
.side .who a { color: #fff; }
.main { padding: 24px 28px 60px; min-width: 0; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.btn.menu-btn { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 1000; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; margin-bottom: 12px; }
  .main { padding: 16px; }
}

/* ---------- Components ---------- */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.7rem; font-weight: 600; line-height: 1.1; color: var(--navy); }
.stat span { font-size: .88rem; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--navy); background: var(--navy); color: #fff;
  padding: 8px 14px; border-radius: var(--radius); font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--navy-2); }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.ghost:hover { background: #eef3f9; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.sm { padding: 4px 10px; font-size: .84rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

label { display: block; font-size: .88rem; font-weight: 500; margin: 0 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #b9c4d0; border-radius: var(--radius); font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { min-width: 150px; flex: 1; }
.filters .actions { flex: 0 0 auto; display: flex; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid #e8edf2; vertical-align: top; }
thead th { background: #eaf0f7; color: #26384d; font-weight: 600; position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: #e5484d; color: #fff; font-size: .75rem; font-weight: 600; text-align: center; line-height: 18px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: .78rem; font-weight: 500; background: #e9eef4; color: #34465a; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.alert.ok { background: var(--ok-bg); border-color: #b6dcc6; color: #14553a; }
.alert.bad { background: var(--bad-bg); border-color: #f2c1bc; color: #8c1d17; }
.alert.warn { background: var(--warn-bg); border-color: #f0d49a; color: #6b4000; }

.map { height: 460px; border-radius: var(--radius); border: 1px solid var(--line); }
.map.sm { height: 300px; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: #000; }
.gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.gallery img, .gallery video { max-width: 320px; max-height: 260px; border-radius: var(--radius); border: 1px solid var(--line); background: #000; }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix thead th { white-space: normal; font-size: .82rem; min-width: 84px; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; }
.pager { display: flex; gap: 6px; margin-top: 12px; align-items: center; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .box { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.auth .box header { background: var(--navy); padding: 16px 20px; }
.auth .box header img { width: 150px; display: block; }
.auth .box .body { padding: 22px 20px; }
.auth .box .body > * + * { margin-top: 12px; }
.auth .btn { width: 100%; justify-content: center; padding: 11px; }

@media print {
  .side, .menu-btn, .no-print, .filters, .btn { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; font-size: 11px; }
  .panel, .table-wrap { border: none; }
  thead th { position: static; }
  .map { height: 360px; page-break-inside: avoid; }
}

/* Icon buttons (table row actions) */
.ico { flex: 0 0 auto; display: block; }
.icon-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.icon-actions form { margin: 0; display: inline-flex; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--navy); cursor: pointer; text-decoration: none; position: relative; }
.icon-btn:hover { background: #eef3f9; border-color: var(--navy); }
.icon-btn.warn { color: var(--warn); }
.icon-btn.warn:hover { background: var(--warn-bg); border-color: var(--warn); }
.icon-btn.ok { color: var(--ok); }
.icon-btn.ok:hover { background: var(--ok-bg); border-color: var(--ok); }
.icon-btn.bad { color: var(--bad); }
.icon-btn.bad:hover { background: var(--bad-bg); border-color: var(--bad); }
.icon-btn[data-tip]:hover::after, .icon-btn[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--ink); color: #fff; font-size: .75rem; line-height: 1.3; padding: 4px 8px; border-radius: 4px;
  white-space: nowrap; pointer-events: none; z-index: 20; }

/* Report type tiles */
.report-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.report-tile { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.report-tile .ico { color: var(--navy); }
.report-tile b { font-size: .92rem; font-weight: 600; line-height: 1.3; }
.report-tile small { font-size: .78rem; line-height: 1.35; }
.report-tile:hover { border-color: var(--navy); box-shadow: 0 2px 8px rgba(11,58,110,.10); }
.report-tile.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.report-tile.active .ico, .report-tile.active small { color: #dbe6f3; }
@media print { .report-tiles, .icon-actions { display: none !important; } }
