/* ==========================================================================
   JTA ReferenceSafe — design system. Premium JTA Residential Care green
   branding, strong hierarchy, no emoji, purpose-built print/PDF layouts.
   ========================================================================== */

:root {
  --brand:        #14532d;
  --brand-mid:    #15803d;
  --brand-light:  #e9f7ee;
  --brand-tint:   #f3faf5;
  --mint:         #22c55e;

  --ink:      #10181f;
  --ink-soft: #334155;
  --muted:    #64748b;
  --border:   #e2e8f0;
  --border-strong: #cbd5e1;
  --bg:       #f5f8f6;
  --card:     #ffffff;

  --green:     #15803d;
  --green-bg:  #f0fdf4;
  --amber:     #b45309;
  --amber-bg:  #fffbeb;
  --red:       #b91c1c;
  --red-bg:    #fef2f2;
  --info:      #1d4ed8;
  --info-bg:   #eff6ff;
  --neutral-bg:#f1f5f9;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 8px 28px rgba(15, 61, 33, .14);

  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
a { color: var(--brand-mid); }
[hidden] { display: none !important; }

#app { max-width: 1180px; margin: 0 auto; padding: 20px 20px 56px; }
#app.narrow { max-width: 620px; }
#app.landing { max-width: none; padding: 0; }

.ethos-strip {
  background: var(--brand); color: #fff; text-align: center;
  font-size: 12.5px; letter-spacing: .02em; padding: 5px 10px; font-weight: 600;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 18px; flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--brand); }
.topbar .brand img { height: 32px; display: block; }
.topbar-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar-nav a {
  text-decoration: none; color: var(--ink-soft); font-weight: 600; font-size: 13.5px;
  padding: 8px 12px; border-radius: 8px;
}
.topbar-nav a:hover { background: var(--brand-tint); }
.topbar-nav a.active { background: var(--brand); color: #fff; }
.topbar-meta { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-soft); }

/* -------------------------------------------------------------------- btn */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--border-strong); background: #fff; color: var(--ink);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .15s ease;
}
.btn:hover { border-color: var(--brand-mid); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow); }
.btn.primary:hover { background: var(--brand-mid); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.xs { padding: 6px 10px; font-size: 12.5px; }
.btn.lg { padding: 15px 26px; font-size: 15.5px; }
.btn.block { width: 100%; }

/* ------------------------------------------------------------------- card */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.tight { padding: 14px 16px; }
.card h2 { margin: 0 0 4px; font-size: 17px; color: var(--brand); }
.card h3 { margin: 0 0 8px; font-size: 14.5px; color: var(--ink); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.section-title { font-size: 12.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin: 26px 0 12px; }

/* --------------------------------------------------------------- metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.metric { background: linear-gradient(160deg, #fff, var(--brand-tint)); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: left; box-shadow: var(--shadow); }
.metric .num { font-size: 30px; font-weight: 800; color: var(--brand); line-height: 1; }
.metric .lbl { font-size: 12.5px; color: var(--muted); margin-top: 6px; font-weight: 600; }
.metric.warn .num { color: var(--amber); }
.metric.alert .num { color: var(--red); }

/* --------------------------------------------------------------- status */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.green, .badge.cleared { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: var(--neutral-bg); color: var(--ink-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); } .dot.amber { background: var(--amber); } .dot.red { background: var(--red); } .dot.info { background: var(--info); } .dot.neutral { background: var(--muted); }

/* ------------------------------------------------------------------ table */
table.list { width: 100%; border-collapse: collapse; font-size: 13.8px; }
table.list th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); padding: 8px 10px; }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:hover td { background: var(--brand-tint); }
table.list tr.clickable { cursor: pointer; }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------------ forms */
label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 14.5px; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-mid); outline-offset: 1px; border-color: var(--brand-mid); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

.radio-group { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.radio-option {
  display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer; font-size: 14.5px; font-weight: 600;
}
.radio-option:hover { border-color: var(--brand-mid); }
.radio-option.selected { border-color: var(--brand); background: var(--brand-tint); color: var(--brand); }
.radio-option input { margin: 0; }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--ink-soft); padding: 10px 0; }
.checkbox-row input { margin-top: 3px; }

/* ---------------------------------------------------------------- modal */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h2 { margin-top: 0; color: var(--brand); }

/* ---------------------------------------------------------------- toast */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; transition: all .2s ease; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; z-index: 100; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.show.error { background: var(--red); }

/* ------------------------------------------------------------- timeline */
.timeline { border-left: 2px solid var(--border); margin-left: 8px; padding-left: 20px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ""; position: absolute; left: -25.5px; top: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand-mid); }
.timeline-item .ts { font-size: 12px; color: var(--muted); font-weight: 700; }
.timeline-item .desc { font-size: 14px; margin-top: 2px; }

/* ---------------------------------------------------------------- empty */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .icon-wrap { color: var(--border-strong); margin-bottom: 10px; }

/* =========================================================================
   Landing page
   ========================================================================= */
.landing-shell {
  position: relative; min-height: calc(100vh - 34px); overflow: hidden;
  background: linear-gradient(135deg, var(--brand-tint) 0%, #eef7f1 45%, var(--brand-light) 100%);
  display: flex; flex-direction: column;
}
.landing-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 24px 32px; flex-wrap: wrap; gap: 12px; }
.landing-header .brand-block { display: flex; align-items: center; gap: 14px; }
.landing-header .brand-block img { height: 42px; display: block; }
.landing-header .brand-text .name { font-weight: 800; color: var(--brand); font-size: 16px; }
.landing-header .brand-text .ethos { font-size: 12px; color: var(--muted); }
.trust-bar { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 0 20px 6px; }
.trust-chip { font-size: 12px; font-weight: 700; color: var(--brand); background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; }
.landing-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 20px 48px; }
.hero-eyebrow { font-size: 12.5px; font-weight: 800; letter-spacing: .14em; color: var(--brand-mid); text-transform: uppercase; }
.hero-title { font-size: clamp(30px, 4.6vw, 48px); font-weight: 800; color: var(--brand); margin: 8px 0 6px; letter-spacing: -.01em; }
.hero-sub { font-size: 17px; color: var(--brand-mid); font-weight: 700; margin-bottom: 12px; }
.hero-desc { max-width: 600px; color: var(--ink-soft); font-size: 15.5px; line-height: 1.6; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-bottom: 34px; }
.hero-actions .btn { padding: 17px 30px; font-size: 15.5px; box-shadow: var(--shadow-lg); }
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.quick-links a { text-decoration: none; font-size: 13px; font-weight: 700; color: var(--brand); background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; }
.quick-links a:hover { border-color: var(--brand-mid); }
.landing-footer { text-align: center; font-size: 12.5px; color: var(--muted); padding: 18px; border-top: 1px solid var(--border); background: rgba(255,255,255,.6); }
.landing-footer .ln1 { font-weight: 700; color: var(--ink-soft); margin-bottom: 3px; }

/* =========================================================================
   App footer (corporate identity, brief §"corporate identity")
   ========================================================================= */
.app-footer { margin-top: 34px; padding: 20px 0 10px; border-top: 1px solid var(--border); text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.app-footer strong { color: var(--ink-soft); }

/* =========================================================================
   Referee portal (external, standalone page)
   ========================================================================= */
.portal-body { background: linear-gradient(160deg, var(--brand-tint), #eef7f1); min-height: 100vh; }
.portal-shell { max-width: 640px; margin: 0 auto; padding: 0 16px 56px; }
.portal-masthead { background: var(--brand); color: #fff; padding: 22px 20px; text-align: center; margin: 0 -16px 20px; }
.portal-masthead img { height: 38px; margin-bottom: 10px; }
.portal-masthead h1 { margin: 0; font-size: 19px; }
.portal-masthead .sub { font-size: 12.5px; opacity: .9; margin-top: 4px; }
.progress-track { display: flex; gap: 6px; margin: 4px 0 22px; }
.progress-track .seg { flex: 1; height: 6px; border-radius: 4px; background: var(--border); }
.progress-track .seg.done { background: var(--brand-mid); }
.step-label { font-size: 12.5px; color: var(--muted); font-weight: 700; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.prefill-box { background: var(--brand-tint); border: 1px solid var(--brand-light); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; font-size: 14px; }
.prefill-box .k { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 700; }
.prefill-box .v { font-weight: 700; color: var(--ink); margin-bottom: 8px; }

/* =========================================================================
   Premium print / PDF page (screen preview of the generated document —
   actual PDF is produced client-side via jsPDF using the same content).
   ========================================================================= */
.doc-page { background: #fff; max-width: 800px; margin: 0 auto 20px; box-shadow: var(--shadow-lg); border-radius: 4px; overflow: hidden; }
.doc-header { background: linear-gradient(120deg, var(--brand), #0f3d21); color: #fff; padding: 34px 40px 26px; }
.doc-header .top-row { display: flex; justify-content: space-between; align-items: flex-start; }
.doc-header img { height: 40px; }
.doc-header .classification { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; background: rgba(255,255,255,.15); padding: 4px 10px; border-radius: 999px; font-weight: 700; }
.doc-header h1 { font-size: 25px; margin: 18px 0 2px; letter-spacing: -.01em; }
.doc-header .sub { font-size: 13.5px; opacity: .92; }
.doc-header .ethos { font-size: 12.5px; font-style: italic; opacity: .85; margin-top: 10px; }
.doc-trust-strip { background: var(--brand-light); color: var(--brand); font-size: 11.5px; font-weight: 700; text-align: center; padding: 8px 16px; }
.doc-body { padding: 30px 40px; }
.doc-panel { background: var(--brand-tint); border-radius: var(--radius-sm); padding: 16px 20px; margin-bottom: 18px; }
.doc-panel .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.doc-panel .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.doc-panel .v { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.doc-section-h { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); border-bottom: 2px solid var(--brand-light); padding-bottom: 6px; margin: 24px 0 12px; }
.doc-body p { font-size: 14px; line-height: 1.65; color: var(--ink-soft); }
.doc-verify-box { border: 1.5px solid var(--brand-light); background: var(--brand-tint); border-radius: var(--radius-sm); padding: 16px 20px; margin-top: 22px; }
.doc-verify-box .t { font-weight: 800; color: var(--brand); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.doc-footer { padding: 18px 40px 26px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.7; }
.doc-footer strong { color: var(--ink-soft); }
.sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; }
.sig-box { border-top: 1.5px solid var(--border-strong); padding-top: 6px; font-size: 12.5px; color: var(--muted); }

@media print {
  .no-print { display: none !important; }
  body, .doc-page { box-shadow: none; }
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 720px) {
  #app { padding: 14px 12px 40px; }
  .doc-header, .doc-body, .doc-footer { padding-left: 20px; padding-right: 20px; }
}
