/* Ecolec engineer job sheet — screen styles.
   Print styles are in print.css and are loaded only by print.html.

   Three constraints drive every value below, and none of them is taste:

   1. Gloves. Nothing tappable is under 56px tall. Buttons are separated by
      real gaps rather than borders, so a near miss lands on nothing rather
      than on the wrong control.
   2. Sunlight. Pure white paper, near-black ink, and no grey text below
      #4A4A4A anywhere. Secondary text is dark and small, never light and
      large. Borders are 2px and black-ish, because a 1px #DDD rule is
      invisible on a phone in a car park in July.
   3. Ecolec's identity is green on black and the tagline is
      "Design • Install • Maintain". Black bars, green marks, nothing else.
      No gradients, no shadows, no rounded-everything. */

:root {
  --ink: #0B0B0B;
  --ink-2: #3A3A3A;      /* the lightest text allowed anywhere */
  --paper: #FFFFFF;
  --panel: #F2F3F1;
  --rule: #0B0B0B;
  --rule-soft: #B9BCB6;
  --green: #00843D;      /* Ecolec green */
  --green-dark: #006630;  /* for text on white: passes contrast */
  --green-ink: #FFFFFF;
  --amber: #8A5300;
  --red: #A31414;
  --tap: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 132, 61, 0.25); }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- masthead */

.ej-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #000;
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ej-mark {
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 19px;
  color: var(--green);
}

.ej-tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #D6D6D6;
  text-transform: uppercase;
}

.ej-top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.ej-who { font-size: 13px; color: #E8E8E8; }

.ej-linkbtn {
  background: transparent;
  border: 2px solid #4A4A4A;
  color: #fff;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
}

/* The connection strip. Always present, never a popup: an engineer needs to
   know where their work is without asking, and a toast that has faded is the
   same as no answer. */
.ej-net {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid var(--rule);
}
.ej-net[data-state='online'] { background: #E4F2E9; color: #00461F; }
.ej-net[data-state='offline'] { background: #FFF0CC; color: #4A3200; }
.ej-net[data-state='syncing'] { background: #E2ECF7; color: #10375C; }

/* -------------------------------------------------------------------- views */

.ej-view { padding: 14px 14px 96px; max-width: 44rem; margin: 0 auto; }

h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; }

.ej-sub { color: var(--ink-2); font-size: 14px; margin: 0 0 14px; }

/* --------------------------------------------------------------- sign in */

.ej-signin { max-width: 26rem; margin: 32px auto; }

.ej-field { display: block; margin: 0 0 16px; }
.ej-field > span {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.ej-input, .ej-select, .ej-textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 2px solid var(--rule);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
.ej-textarea { min-height: 120px; resize: vertical; }
.ej-input:focus, .ej-select:focus, .ej-textarea:focus, .ej-btn:focus-visible {
  outline: 4px solid var(--green);
  outline-offset: 1px;
}

/* Passcode is typed on a phone, so it can be revealed. The engineer reads it
   off a card the office gave them. */
.ej-reveal-row { display: flex; gap: 8px; }
.ej-reveal-row .ej-input { flex: 1; }

/* ------------------------------------------------------------------ buttons */

.ej-btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 14px 18px;
  border: 2px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.ej-btn + .ej-btn { margin-top: 10px; }
.ej-btn--primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.ej-btn--dark { background: #000; border-color: #000; color: #fff; }
.ej-btn--danger { border-color: var(--red); color: var(--red); }
.ej-btn:disabled { opacity: 0.45; cursor: default; }
.ej-btn--small { min-height: 48px; font-size: 15px; padding: 10px 12px; width: auto; }

.ej-btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ej-btn-row .ej-btn { flex: 1; min-width: 44%; margin-top: 0; }

/* -------------------------------------------------------------- day tabs */

.ej-tabs { display: flex; gap: 8px; margin: 0 0 14px; }
.ej-tab {
  flex: 1;
  min-height: 52px;
  border: 2px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.ej-tab[aria-selected='true'] { background: #000; color: #fff; }

/* -------------------------------------------------------------- day cards */

.ej-card {
  border: 2px solid var(--rule);
  margin: 0 0 16px;
  background: var(--paper);
}
.ej-card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px;
  background: #000;
  color: #fff;
}
.ej-card-time { font-size: 22px; font-weight: 800; color: var(--green); }
.ej-card-num { font-size: 14px; font-weight: 700; letter-spacing: 0.04em; }
.ej-card-body { padding: 12px 14px; }
.ej-card-site { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.ej-card-addr { font-size: 15px; color: var(--ink-2); margin: 0 0 8px; }
.ej-card-desc {
  font-size: 15px;
  margin: 0 0 12px;
  /* One line only. The whole point of the checklist below is that this blob is
     not where the work is recorded. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ej-card-foot { padding: 0 14px 14px; }

.ej-chiprow { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.ej-chip {
  display: inline-block;
  padding: 5px 10px;
  border: 2px solid var(--rule);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ej-chip--status { background: #000; color: #fff; border-color: #000; }
.ej-chip--done { background: var(--green); color: #fff; border-color: var(--green); }
.ej-chip--warn { background: #FFE08A; color: #4A3200; border-color: #4A3200; }
.ej-chip--sync-device { background: #FFF0CC; color: #4A3200; border-color: #4A3200; }
.ej-chip--sync-going { background: #E2ECF7; color: #10375C; border-color: #10375C; }
.ej-chip--sync-office { background: #E4F2E9; color: #00461F; border-color: #00461F; }

.ej-empty { border: 2px dashed var(--rule-soft); padding: 24px 16px; text-align: center; color: var(--ink-2); }

/* ------------------------------------------------------------- job sheet */

.ej-section { border: 2px solid var(--rule); margin: 0 0 16px; }
.ej-section > h3 {
  margin: 0;
  padding: 10px 14px;
  background: #000;
  color: #fff;
  font-size: 14px;
}
.ej-section-body { padding: 14px; }

/* The access block. Given its own colour and a heavy left edge because on the
   JobLogic sheet "Collect Keys from Intercounty Saffron Walden" is buried as
   line one of a five-job paragraph, which is how an engineer ends up standing
   outside a locked flat. */
.ej-access {
  border-left: 10px solid var(--green);
  background: #EAF4EE;
  padding: 12px 14px;
  margin: 0 0 12px;
}
.ej-access h4 { margin: 0 0 6px; font-size: 15px; }
.ej-access dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.ej-access dt { font-weight: 700; }
.ej-access dd { margin: 0; }

.ej-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; margin: 0; }
.ej-kv dt { font-weight: 700; color: var(--ink-2); }
.ej-kv dd { margin: 0; }

/* Tap targets that happen to be links: a phone number and an address are the
   two things an engineer needs in one press while holding a torch. */
.ej-tapline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 2px solid var(--rule);
  margin: 0 0 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}
.ej-tapline small { display: block; font-weight: 400; color: var(--ink-2); font-size: 13px; }
.ej-tapline .ej-tapline-go { margin-left: auto; color: var(--green-dark); font-weight: 800; }

/* -------------------------------------------------------------- checklist */

.ej-tasks { list-style: none; margin: 0; padding: 0; }
.ej-task { border-bottom: 2px solid var(--rule-soft); padding: 6px 0; }
.ej-task:last-child { border-bottom: 0; }

.ej-task-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: var(--tap);
  padding: 8px 0;
  cursor: pointer;
}
/* A 32px box, not a 16px one. This is the control that gets pressed most and
   it is pressed with a glove. */
.ej-task-box {
  flex: none;
  width: 32px;
  height: 32px;
  margin-top: 2px;
  accent-color: var(--green);
}
.ej-task-title { font-size: 16px; font-weight: 600; }
.ej-task--done .ej-task-title { color: var(--ink-2); text-decoration: line-through; }
.ej-task-origin { font-size: 12px; font-weight: 700; color: var(--green-dark); text-transform: uppercase; }
.ej-task-note { width: 100%; margin: 0 0 8px; }

/* ------------------------------------------------------------------ times */

.ej-times { display: grid; gap: 10px; }
.ej-time-row { display: flex; align-items: center; gap: 10px; border: 2px solid var(--rule); padding: 8px 10px; }
.ej-time-label { font-weight: 700; min-width: 7.5rem; }
.ej-time-value { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 800; min-width: 4.5rem; }
.ej-time-value[data-empty='1'] { color: var(--ink-2); font-weight: 400; font-size: 16px; }
.ej-time-row .ej-btn { width: auto; margin: 0 0 0 auto; }

/* ------------------------------------------------------------------ parts */

.ej-part { border: 2px solid var(--rule); padding: 10px 12px; margin: 0 0 10px; }
.ej-part-desc { font-weight: 700; }
.ej-part--missing { border-color: var(--red); background: #FCEDED; }

.ej-row { display: flex; gap: 10px; }
.ej-row .ej-input { flex: 1; }
.ej-row .ej-qty { flex: none; width: 5.5rem; }

/* ----------------------------------------------------------------- photos */

.ej-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.ej-photo { border: 2px solid var(--rule); }
.ej-photo img { display: block; width: 100%; height: 110px; object-fit: cover; }
.ej-photo input { width: 100%; border: 0; border-top: 2px solid var(--rule); padding: 8px; font: inherit; font-size: 13px; }

/* ------------------------------------------------------------- signature */

.ej-sigpad {
  width: 100%;
  height: 190px;
  border: 2px solid var(--rule);
  background: #fff;
  touch-action: none; /* or the browser scrolls the page instead of drawing */
  display: block;
}
.ej-sig-done { border: 2px solid var(--green); padding: 8px; }
.ej-sig-done img { display: block; width: 100%; height: 120px; object-fit: contain; background: #fff; }

/* ------------------------------------------------------------- yes and no */

.ej-yesno { display: flex; gap: 10px; }
.ej-yesno .ej-btn { margin-top: 0; }
.ej-yesno .ej-btn[aria-pressed='true'] { background: var(--green); border-color: var(--green); color: #fff; }
.ej-yesno .ej-btn--no[aria-pressed='true'] { background: var(--red); border-color: var(--red); }

/* ----------------------------------------------------------- sticky action */

.ej-sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 3px solid var(--rule);
}
.ej-sticky .ej-btn { margin: 0; }

.ej-note { font-size: 14px; color: var(--ink-2); margin: 8px 0 0; }
.ej-warn { border: 2px solid var(--red); background: #FCEDED; color: #5A0B0B; padding: 10px 12px; font-weight: 700; margin: 0 0 12px; }
.ej-ok { border: 2px solid var(--green); background: #EAF4EE; color: #00461F; padding: 10px 12px; font-weight: 700; margin: 0 0 12px; }

.ej-history { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.ej-history li { border-bottom: 1px solid var(--rule-soft); padding: 8px 0; }

@media (min-width: 40rem) {
  .ej-view { padding-bottom: 120px; }
}
