/* ==========================================================================
   JW · Sta. Fe Congregation — Field Service Reports
   Minimalist, professional design system
   ========================================================================== */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --surface-2: #fafbfc;
  --ink:       #1b2130;
  --ink-soft:  #4b5568;
  --muted:     #8a93a3;
  --line:      #e6e9ef;
  --line-2:    #eef1f5;
  --primary:   #3b5bdb;
  --primary-ink:#ffffff;
  --primary-soft:#eef1fe;
  --accent:    #0ca678;
  --danger:    #e03131;
  --warn:      #f08c00;
  --shadow:    0 1px 2px rgba(18,28,53,.04), 0 6px 20px rgba(18,28,53,.06);
  --shadow-lg: 0 10px 40px rgba(18,28,53,.16);
  --radius:    14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg:        #0f1218;
  --surface:   #171b23;
  --surface-2: #1c212b;
  --ink:       #e8ebf1;
  --ink-soft:  #b6bdca;
  --muted:     #7d8595;
  --line:      #262c38;
  --line-2:    #212734;
  --primary:   #5b78ef;
  --primary-soft:#1c2440;
  --accent:    #21c997;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: var(--radius-sm); transition: .15s;
}
.btn:hover { border-color: #cfd5e0; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn {
  background: none; border: 0; color: var(--primary); cursor: pointer;
  font: inherit; font-size: 13px; padding: 4px; text-decoration: none;
}
.linkbtn:hover { text-decoration: underline; }
.icon-btn {
  background: transparent; border: 0; cursor: pointer; font-size: 18px;
  color: var(--ink-soft); border-radius: 8px; width: 34px; height: 34px;
}
.icon-btn:hover { background: var(--line-2); }
.row { display: flex; }
.gap { gap: 10px; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
input, select, .search {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; width: 100%; transition: .15s;
}
input:focus, select:focus, .search:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.select { appearance: none; background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238a93a3' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 14px; }
.check input { width: auto; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; min-height: 1em; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; }

/* ---------- Fullscreen auth / setup ---------- */
.fullscreen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--bg), var(--surface-2)); padding: 20px; z-index: 50;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 400px;
}
.auth-card.wide { max-width: 560px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand.center { flex-direction: column; text-align: center; gap: 8px; margin-bottom: 26px; }
.brand h1 { font-size: 19px; }
.brand .sub, .sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }
.brand-mark { font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center;
  background: var(--primary-soft); border-radius: 12px; }
.brand-mark.big { font-size: 34px; width: 60px; height: 60px; }
.brand-mark.sm { font-size: 20px; width: 38px; height: 38px; border-radius: 10px; }
.steps { color: var(--ink-soft); font-size: 13.5px; padding-left: 20px; margin: 0 0 22px; }
.steps li { margin-bottom: 8px; }
.steps code { background: var(--line-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.titles { min-width: 0; }
/* Fluid sizes so the title & subtitle always stay on a single line, shrinking
   with the viewport rather than wrapping. */
.titles h1 { font-size: clamp(11.5px, 3.2vw, 15.5px); line-height: 1.15; white-space: nowrap; }
.titles p { margin: 0; font-size: clamp(9px, 2.4vw, 12px); color: var(--muted); white-space: nowrap; }
.topnav { display: flex; gap: 4px; margin-left: 10px; }
.nav-btn {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  background: transparent; border: 0; color: var(--ink-soft);
  padding: 8px 13px; border-radius: 9px;
  display: inline-flex; align-items: center; gap: 7px;
}
.nav-btn:hover { background: var(--line-2); color: var(--ink); }
.nav-btn.active { background: var(--primary-soft); color: var(--primary); }
.nav-btn.active .ico { color: var(--primary); }
.ico {
  width: 17px; height: 17px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-btn:hover .ico { color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }

/* ---------- Content / Views ---------- */
.content { max-width: 1080px; margin: 0 auto; padding: 26px 22px 60px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.view-head h2 { font-size: 22px; }
.dash-controls { display: flex; gap: 10px; align-items: center; }
.dash-controls .select { width: auto; min-width: 170px; }

/* inline add/edit publisher panel (replaces the old modal pop-up) */
.inline-panel {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
  animation: pop .16s ease-out;
}
.inline-panel .panel-title { font-weight: 650; font-size: 15px; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
.form-grid .field { margin: 0; }
.form-grid .check { margin: 0 0 6px; }
.panel-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* inline "change type" editor inside the reports table */
.inline-move { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.inline-move .move-sel { width: auto; min-width: 150px; padding: 5px 8px; }
.rowbtn.ok { color: var(--accent); border-color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card.attend { background: var(--surface-2); }
.card.attend .kpi-value { color: var(--accent); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.kpi { display: flex; flex-direction: column; gap: 6px; }
.card.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; position: relative; }
.card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.kpi-more { font-size: 11.5px; color: var(--muted); font-weight: 600; opacity: 0; transition: opacity .12s; }
.card.clickable:hover .kpi-more { opacity: 1; }
.card.accent.clickable:hover { border-color: #fff; }
.card.accent .kpi-more { color: rgba(255,255,255,.85); }
.foot-link { cursor: pointer; }
.foot-link:hover { color: var(--primary); text-decoration: underline; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.kpi-foot { font-size: 11.5px; color: var(--muted); }
.kpi.accent { background: var(--primary); border-color: var(--primary); }
.kpi.accent .kpi-label, .kpi.accent .kpi-foot { color: rgba(255,255,255,.8); }
.kpi.accent .kpi-value { color: #fff; }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.panel h3 { font-size: 16.8px; margin-bottom: 8px; } /* +20% */
table.mini { width: 100%; border-collapse: collapse; font-size: 16.2px; } /* +20% */
table.mini td { padding: 8px 0; border-bottom: 1px solid var(--line-2); color: var(--ink-soft); }
table.mini td.num { color: var(--ink); font-weight: 650; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini tr.strong td { color: var(--ink); font-weight: 700; border-top: 1.5px solid var(--line); }

.empty { text-align: center; color: var(--muted); padding: 40px; background: var(--surface);
  border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: 18px; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,20,32,.44);
  display: grid; place-items: center; padding: 20px; z-index: 40;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.modal.sm { max-width: 420px; }
.modal.lg { max-width: 720px; }
.modal.xl { max-width: 960px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar .search { width: 220px; }
.inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.inline .select, .inline input { width: auto; }
.inline .grow { min-width: 240px; }

/* ---------- Tables / grids ---------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: auto; }
.table-wrap.tall { max-height: 56vh; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: var(--surface-2); padding: 10px 12px;
  position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line);
}
table.grid th.num { text-align: right; }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid input, table.grid select { padding: 6px 8px; font-size: 13px; }
.reports .part-in { width: 64px; }
.reports .hrs-in { width: 84px; }
.reports .bs-in { width: 84px; }

.badge { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 9px; border-radius: 20px; }
.badge.pub  { background: #eef2ff; color: #3b5bdb; }
.badge.aux  { background: #fff4e6; color: #e8590c; }
.badge.reg  { background: #e6fcf5; color: #087f5b; }
.badge.unb  { background: #f3f0ff; color: #6741d9; }
.badge.on   { background: #ebfbee; color: #2b8a3e; }
.badge.off  { background: #fff0f0; color: #c92a2a; }
:root[data-theme="dark"] .badge { filter: brightness(.9) saturate(1.3); }

.rowbtn { background: none; border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px;
  font-size: 12px; cursor: pointer; color: var(--ink-soft); }
.rowbtn:hover { border-color: var(--primary); color: var(--primary); }
.rowbtn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab {
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  background: none; border: 0; color: var(--muted); padding: 9px 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Pioneer summary ---------- */
.small-cards { grid-template-columns: repeat(4, 1fr); margin: 4px 0 16px; }
.small-cards .card { padding: 14px; }
.small-cards .kpi-value { font-size: 24px; }
.target-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 16px; }
.target-input { display: flex; align-items: center; gap: 10px; }
.num-in { width: 120px; }
.target-out { margin-top: 12px; display: none; }
.target-out.show { display: block; }
.span-note { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 10px;
  padding: 6px 10px; background: var(--primary-soft); border-radius: 8px; display: inline-block; }
.target-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.target-cell { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.target-cell .t-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.target-cell .t-val { font-size: 20px; font-weight: 700; }
.pace { margin-top: 10px; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 8px; }
.pace.good { background: #ebfbee; color: #2b8a3e; }
.pace.behind { background: #fff4e6; color: #e8590c; }

.userform { display: grid; grid-template-columns: 1fr 1fr auto auto auto; gap: 12px; align-items: end; margin-bottom: 18px; }
.userform .field { margin: 0; }
.userform .field.short { }
.userform .btn { height: 40px; }
.userform .form-error { grid-column: 1 / -1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 60;
  animation: rise .2s ease-out;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok  { background: var(--accent); color: #fff; }
@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .cards, .small-cards { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  .target-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .topnav { display: none; }
  .userform { grid-template-columns: 1fr 1fr; }
  .content { padding-bottom: 80px; } /* room for bottom nav */
  /* Attendance spans the full row as an organized rectangle */
  .card.attend { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .card.attend .kpi-value { font-size: 30px; }
}
@media (max-width: 560px) {
  .content { padding: 18px 14px 80px; }
  .view-head { flex-direction: column; align-items: stretch; }
  .cards, .small-cards { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  /* Keep the title and the theme toggle from colliding on phones */
  .topbar { gap: 8px; padding: 10px 14px; }
  .topbar-brand { flex: 1 1 auto; min-width: 0; }
  .titles h1, .titles p { overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { flex: 0 0 auto; gap: 6px; }
  #who-name { display: none; } /* free up room; Sign out remains */
}

/* Mobile bottom nav fallback */
.mobilenav { display: none; }
@media (max-width: 860px) {
  .mobilenav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface);
    border-top: 1px solid var(--line); z-index: 20;
  }
  .mobilenav button { flex: 1; background: none; border: 0; padding: 9px 4px 8px; font: inherit;
    font-size: 11px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px; }
  .mobilenav button.active { color: var(--primary); }
  .mobilenav .ico { width: 20px; height: 20px; }
}
