/* Non-critical styles — app still usable if this file fails to load */

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.app-header .brand {
  display: flex; align-items: center; gap: 10px; font-weight: 800;
}
.app-header .brand .mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(145deg, #1a2a44, #0f172a);
  border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--accent); font-size: 13px;
}
.app-header .meta { color: var(--muted); font-size: 12px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: var(--panel2);
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
}
.status-pill.offline .dot { background: var(--warn); }
.status-pill.offline { color: #ffe7a3; border-color: #6b5420; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 1.1fr 1fr; min-height: calc(100vh - 56px); }
}

.panel {
  padding: 14px 16px 24px;
  border-bottom: 1px solid var(--border);
}
@media (min-width: 900px) {
  .panel { border-bottom: 0; border-right: 1px solid var(--border); }
  .panel + .panel { border-right: 0; }
}

.panel h2 {
  margin: 0 0 10px; font-size: 1rem; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.panel h2 span.count {
  color: var(--muted); font-weight: 600; font-size: 12px;
}

/* Site rail under map */
.site-rail {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.site-card {
  flex: 0 0 auto; min-width: 148px; max-width: 180px;
  display: flex; gap: 8px; align-items: flex-start; text-align: left;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px; cursor: pointer; color: var(--text);
  font: inherit;
}
.site-card.active {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px rgba(245,185,66,.35);
}
.site-card .swatch, .swatch {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: 0 0 auto;
}
.swatch.lg { width: 14px; height: 14px; margin-top: 2px; }
.site-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.site-card-name {
  font-weight: 800; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-card-meta {
  font-size: 10px; color: var(--muted); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.site-selected-head { display: flex; gap: 10px; align-items: flex-start; }
.site-selected .sub { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.35; }
.key-contact { margin-top: 8px; font-size: 13px; }
.site-roster { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.site-roster-title { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.site-roster-row {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid rgba(36,48,73,.6); font-size: 13px;
}
.site-roster-row:last-child { border-bottom: 0; }
.site-roster-row .muted, .muted { color: var(--muted); font-weight: 500; }
.tiny { font-size: 11px; }
.mini-actions { display: flex; gap: 6px; }
.mini {
  text-decoration: none; font-size: 11px; font-weight: 800;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; color: var(--text);
  background: #0f172a;
}
.mini.call { color: #86efac; border-color: rgba(74,222,128,.35); }
.mini.wa { color: var(--accent); border-color: rgba(61,214,198,.35); }
.site-selected-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.sort-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px;
}
.sort-label { font-size: 11px; color: var(--muted); font-weight: 700; margin-right: 2px; }
.active-filter {
  display: none; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(245,185,66,.08); border: 1px solid rgba(245,185,66,.25);
  border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 12px;
}
.active-filter.show { display: flex; }

.list-section {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px 4px; margin-top: 4px;
  font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  position: sticky; top: 0; background: linear-gradient(var(--bg), rgba(11,18,32,.92));
  z-index: 2;
}
.list-section .count { font-weight: 700; }

.card.roster { border-color: rgba(245,185,66,.28); }
.name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-roster {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  color: #04201c; background: var(--accent2); border-radius: 999px; padding: 2px 7px;
}
.phone-line { margin-top: 6px; font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.phone-line.missing { color: var(--muted); font-weight: 600; font-size: 12px; }
.site-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.site-badge {
  font-size: 11px; font-weight: 700; color: var(--text);
  background: #0f172a; border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 8px; cursor: pointer;
}
.site-badge.active { background: rgba(245,185,66,.12); color: #ffe7a3; }
.copy-btn {
  background: #0f172a !important; color: var(--muted) !important;
  border: 1px solid var(--border) !important; border-radius: 10px !important;
  padding: 10px 12px !important; font-weight: 700 !important; font-size: 13px !important;
  min-height: 40px; cursor: pointer;
}
.more-btn {
  width: 100%; margin-top: 4px; padding: 14px !important;
  background: var(--panel2) !important;
}

.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input {
  flex: 1; background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; /* 16px avoids iOS zoom */
  outline: none;
}
.search-row input:focus { border-color: var(--accent); }
.search-row button, .chip, .btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-weight: 700; cursor: pointer; font-size: 13px;
}
.btn.primary { background: var(--accent); color: #04201c; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: #3b1515; color: #ffb4b4; border-color: #5c2424; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip.active { background: rgba(61,214,198,.15); border-color: var(--accent); color: var(--accent); }

.map-wrap {
  background: #0a101c; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  position: relative; min-height: 280px;
}
.map-wrap svg { width: 100%; height: 320px; display: block; touch-action: manipulation; }
.map-legend {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(10,16,28,.85); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 11px; color: var(--muted);
  max-width: 70%;
}
.map-tip {
  margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.4;
}
.site-selected {
  margin-top: 10px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
}
.site-selected strong { color: var(--accent2); }

.list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: min(60vh, 640px); overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
}
.card {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px;
}
.card .top {
  display: flex; justify-content: space-between; gap: 8px; align-items: flex-start;
}
.card .name { font-weight: 800; font-size: 15px; }
.card .score {
  font-size: 11px; font-weight: 800; color: var(--accent);
  background: rgba(61,214,198,.1); border: 1px solid rgba(61,214,198,.25);
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.35; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.card .tag {
  font-size: 10px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 7px; text-transform: lowercase;
}
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.card .actions a, .card .actions button {
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  background: #0f172a; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-weight: 700; font-size: 13px;
  min-height: 40px; /* fat touch targets for gloves/field */
}
.card .actions a.call { border-color: rgba(74,222,128,.35); color: #86efac; }
.card .actions a.wa { border-color: rgba(61,214,198,.35); color: var(--accent); }

.empty {
  color: var(--muted); text-align: center; padding: 28px 12px;
  border: 1px dashed var(--border); border-radius: 12px;
}

/* Login */
.login-wrap {
  min-height: calc(100vh - 40px); display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(100%, 400px); background: var(--panel);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 1.35rem; }
.login-card .lead { color: var(--muted); margin: 0 0 18px; font-size: 14px; line-height: 1.4; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 700; }
.login-card input {
  width: 100%; background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; margin-bottom: 12px;
}
.login-card .err {
  display: none; background: #3b1515; color: #ffb4b4;
  border: 1px solid #5c2424; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 13px;
}
.login-card .err.show { display: block; }
.login-card .hint {
  margin-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.4;
}
.login-card .offline-note {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: #1a2a14; border: 1px solid #2f4a28; color: #b7f0c4; font-size: 12px;
}

.footer-bar {
  padding: 10px 16px 20px; color: var(--muted); font-size: 11px; text-align: center;
}

/* Pin pulse */
@keyframes pulse {
  0% { r: 5; opacity: 1; }
  100% { r: 16; opacity: 0; }
}
.pin-pulse { fill: var(--accent2); animation: pulse 1.4s ease-out infinite; }


/* Mobile chrome — phone in one hand (Africa/Harare) */
html, body { overflow-x: hidden; }
.app-header {
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app-header .brand { min-width: 0; }
.app-header .brand > div { min-width: 0; }
.app-header .meta,
#hdr-user {
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#logout-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 12px;
}

.ri-tabbar {
  display: none;
}
.ri-tabbar .ri-tab {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
  color: var(--muted, #93a0b8);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .02em;
}
.ri-tabbar .ri-tab.active { color: var(--accent, #3dd6c6); }

@media (max-width: 720px) {
  .hdr-actions a.btn,
  .app-header a.btn { display: none; }
  .ri-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    background: var(--panel, #121a2b);
    border-top: 1px solid var(--border, #243049);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    min-height: calc(44px + env(safe-area-inset-bottom, 0px));
  }
  #app.ready,
  .ri-dash,
  .fleet-wrap,
  .ri-fc-page,
  .pb-body,
  .field-body,
  .map-layout,
  .layout {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}
