/* Team Training — styled after the GCE Field App (patterns copied). */
:root {
  --green-dark: #0d1f12;
  --green: #1a4d2e;
  --green-mid: #2d6a4f;
  --green-light: #40916c;
  --gold: #d4a017;
  --gold-bright: #f0c040;
  --gold-dim: #b8860b;
  --black: #0a0a0a;
  --white: #fafafa;
  --off-white: #f5f5f0;
  --gray: #6b7280;
  --gray-light: #e5e7eb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --ok: #15803d;
  --radius: 12px;
  --touch: 48px;
  --shadow: 0 2px 8px rgba(0,0,0,.18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--black);
  background: var(--off-white);
  min-height: 100%;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

img { max-width: 100%; height: auto; display: block; }

/* ---- App chrome ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--green-dark);
  color: var(--white);
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.app-header .logo {
  width: 72px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px 5px;
  flex-shrink: 0;
}

.app-header .titles { flex: 1; min-width: 0; }
.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .sub {
  font-size: 0.75rem;
  opacity: .85;
  color: var(--gray-light);
}

.btn-icon {
  min-width: var(--touch);
  min-height: var(--touch);
  border: none;
  background: transparent;
  color: var(--gold-bright);
  font-size: 1.4rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:active { background: rgba(255,255,255,.1); }

main {
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}


/* ---- Home ---- */
.home-hero {
  text-align: center;
  padding: 8px 0 20px;
}
.home-hero img {
  width: 100%;
  max-width: 300px;
  margin: 0 auto 14px;
  background: #fff;
  border-radius: 14px;
  padding: 14px 18px;
  border: 1px solid var(--gray-light);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.home-hero p {
  margin: 0;
  color: var(--gray);
  font-size: 0.95rem;
}

.nav-grid {
  display: grid;
  gap: 12px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 14px 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--green);
  color: var(--white);
  font-weight: 600;
  font-size: 1.1rem;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}
.nav-btn:active { transform: scale(.98); background: var(--green-mid); }
.nav-btn .icon {
  font-size: 1.6rem;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}
.nav-btn.secondary {
  background: var(--white);
  color: var(--green-dark);
  border: 2px solid var(--green);
}
.nav-btn.gold {
  background: var(--gold);
  color: var(--black);
}
.nav-btn.muted {
  background: var(--gray-light);
  color: var(--black);
  box-shadow: none;
}

.offline-banner {
  background: var(--gold);
  color: var(--black);
  text-align: center;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  display: none;
}
.offline-banner.show { display: block; }

/* ---- Forms ---- */
.page-title {
  margin: 0 0 16px;
  font-size: 1.35rem;
  color: var(--green-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-light);
}

.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--green);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 6px;
}

.field {
  margin-bottom: 14px;
}
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--green-dark);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 2px solid var(--gray-light);
  border-radius: 8px;
  background: var(--white);
  appearance: none;
  -webkit-appearance: none;
}
.field textarea {
  min-height: 88px;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(45,106,79,.2);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field-row.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--touch);
}
.toggle-row label { margin: 0; font-weight: 600; }
.toggle {
  position: relative;
  width: 56px;
  height: 32px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle span {
  position: absolute;
  inset: 0;
  background: var(--gray-light);
  border-radius: 999px;
  cursor: pointer;
  transition: .2s;
}
.toggle span::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle input:checked + span { background: var(--green-mid); }
.toggle input:checked + span::after { transform: translateX(24px); }

/* ---- Line items ---- */
.line-items { display: flex; flex-direction: column; gap: 10px; }

.line-item {
  border: 2px solid var(--gray-light);
  border-radius: 10px;
  padding: 12px;
  background: #fafcf9;
  position: relative;
}

.line-item .remove-line {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 40px;
  min-height: 40px;
  border: none;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
}

.suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chip {
  min-height: 40px;
  padding: 8px 12px;
  border: 2px solid var(--green);
  background: var(--white);
  color: var(--green);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:active { background: var(--green); color: white; }

/* ---- Totals ---- */
.totals {
  background: var(--green-dark);
  color: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}
.totals .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 1rem;
}
.totals .row.grand {
  border-top: 2px solid var(--gold);
  margin-top: 8px;
  padding-top: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-bright);
}

/* ---- Action bars ---- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--off-white) 20%);
  padding: 16px 0 calc(12px + env(safe-area-inset-bottom));
  z-index: 20;
}

.btn {
  flex: 1 1 calc(50% - 10px);
  min-height: var(--touch);
  min-width: 120px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--green);
  color: white;
}
.btn-gold {
  background: var(--gold);
  color: var(--black);
}
.btn-outline {
  background: white;
  color: var(--green-dark);
  border: 2px solid var(--green);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-full { flex: 1 1 100%; }

/* ---- Lists ---- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--gray);
}

.list-item {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--gray-light);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: block;
  text-align: left;
  width: 100%;
}
.list-item:active { background: #f0f7f3; }
.list-item .li-title {
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 4px;
}
.list-item .li-meta {
  font-size: 0.85rem;
  color: var(--gray);
}
.list-item .li-total {
  margin-top: 8px;
  font-weight: 700;
  color: var(--gold-dim);
}

/* ---- Signature ---- */

/* ---- Team Training mappings ---- */
.app-header .logo { width: 56px; height: 40px; background: transparent; padding: 0; }
.home-hero img { background: var(--green-dark); max-width: 240px; }
.nav-btn { width: 100%; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0 0 14px; color: var(--green-dark); }
label input, label select, label textarea, #u_q {
  display: block; width: 100%; min-height: var(--touch); padding: 10px 12px; margin-top: 6px;
  border: 2px solid var(--gray-light); border-radius: 8px; background: var(--white); font-weight: 400; }
label select[multiple] { min-height: 150px; }
label textarea { min-height: 88px; resize: vertical; }
label input:focus, label select:focus, label textarea:focus, #u_q:focus { outline: none; border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(45,106,79,.2); }
label input[type=checkbox] { display: inline; width: auto; min-height: 0; margin-right: 8px; }
#u_q { margin: 0 0 12px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; margin: 6px 6px 0 0; background: var(--gold); color: var(--black); flex: 0 1 auto; }
.btn.alt { background: white; color: var(--green-dark); border: 2px solid var(--green); }
.btn.red { background: var(--danger); color: white; min-width: 48px; }
.card .card { box-shadow: none; background: var(--off-white); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: white; }
td, th { border: 1px solid var(--gray-light); padding: 8px; text-align: left; vertical-align: top; }
th { background: var(--green); color: var(--white); }
td select, td input { width: 100%; min-height: 40px; padding: 6px 8px; border: 2px solid var(--gray-light); border-radius: 8px; background: white; }
tr.unit { cursor: pointer; }
tr.unit:active, tr.unit:hover { background: #f0f7f3; }
tr.unit td:first-child { font-weight: 700; color: var(--green-dark); white-space: nowrap; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #fff; background: var(--gray); }
.tag.ok { background: var(--ok); } .tag.warn { background: var(--gold-dim); } .tag.bad { background: var(--danger); }
.draft { background: #fff8e1; border-left: 4px solid var(--gold); padding: 10px 12px; border-radius: 8px; font-size: .88rem; margin: 8px 0; }
canvas.sig { display: block; width: 100%; height: 120px; border: 2px dashed var(--green-mid); border-radius: 8px; background: #fff; touch-action: none; margin-bottom: 4px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.thumbs img { height: 80px; border-radius: 8px; }
a { color: var(--green-mid); overflow-wrap: anywhere; }
footer { font-size: .78rem; text-align: center; padding: 16px; color: var(--gray); }
@media print { .app-header, footer, .noprint, .btn { display: none !important; } .card { box-shadow: none; border: 0; } body { background: #fff; } }
