/* Arrive Service — handheld first, Android 6 Chrome compatible */
:root {
  --purple: #5F016F;
  --purple-dark: #43004F;
  --lilac: #F3ECF6;
  --line: #D9C9DF;
  --ink: #1C1C1C;
  --ink-soft: #5A5460;
  --paper: #FFFFFF;
  --danger: #B3261E;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--lilac); color: var(--ink);
  font-family: Roboto, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.4; }
body { -webkit-text-size-adjust: 100%; }

.app { max-width: 600px; margin: 0 auto; min-height: 100vh; background: var(--paper); display: flex; flex-direction: column; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 10px;
  border-bottom: 3px solid var(--purple); background: var(--paper); position: -webkit-sticky; position: sticky; top: 0; z-index: 5; }
.top img { height: 34px; display: block; }
.top .who { font-size: 13px; color: var(--ink-soft); text-align: right; line-height: 1.25; }
.top .who b { color: var(--ink); font-weight: 600; display: block; }

.screen { display: none; padding: 16px 16px 32px; flex: 1; }
.screen.active { display: block; }

h1 { font-size: 22px; font-weight: 600; margin: 4px 0 14px; color: var(--purple); letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 22px 0 8px; color: var(--purple); padding-bottom: 4px; border-bottom: 1px solid var(--line); }
p { margin: 0 0 12px; }
.hint { font-size: 13px; color: var(--ink-soft); margin: 4px 0 10px; }
.err { color: var(--danger); font-size: 14px; margin: 8px 0; min-height: 1em; }

/* Buttons */
.btn { display: block; width: 100%; border: 2px solid var(--purple); background: var(--purple); color: #fff;
  font: inherit; font-weight: 600; font-size: 17px; padding: 14px 16px; border-radius: 8px; text-align: center;
  cursor: pointer; margin: 0 0 10px; text-decoration: none; }
.btn:active { background: var(--purple-dark); border-color: var(--purple-dark); }
.btn.ghost { background: var(--paper); color: var(--purple); }
.btn.ghost:active { background: var(--lilac); }
.btn.small { font-size: 15px; padding: 10px 12px; width: auto; display: inline-block; margin: 0 6px 6px 0; }
.btn.big { padding: 22px 16px; font-size: 19px; }
.btn[disabled] { opacity: .5; }
.btn:focus, input:focus, select:focus, textarea:focus { outline: 3px solid #B98CC6; outline-offset: 2px; }
.row { display: flex; }
.row .btn { margin-right: 8px; }
.row .btn:last-child { margin-right: 0; }

/* Fields */
.field { margin: 0 0 12px; }
.field label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; font: inherit; font-size: 17px; padding: 12px;
  border: 1.5px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); -webkit-appearance: none; appearance: none; }
.field textarea { min-height: 96px; resize: vertical; }
.field select { background-image: none; padding-right: 12px; }
.field.found input { border-color: var(--purple); background: #FBF7FC; }
.field .sub { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.scanrow { display: flex; }
.scanrow input { flex: 1; border-radius: 8px 0 0 8px; }
.scanrow button { font: inherit; font-weight: 600; padding: 0 16px; border: 1.5px solid var(--purple); border-left: 0;
  background: var(--purple); color: #fff; border-radius: 0 8px 8px 0; cursor: pointer; }
.found-banner { background: var(--lilac); border-left: 4px solid var(--purple); padding: 8px 12px; border-radius: 0 8px 8px 0;
  font-size: 14px; margin: 0 0 12px; }
.found-banner.warn { border-left-color: #C77D00; background: #FFF6E8; }

/* Machine type switch */
.seg { display: flex; border: 2px solid var(--purple); border-radius: 8px; overflow: hidden; margin: 0 0 16px; }
.seg button { flex: 1; font: inherit; font-size: 15px; font-weight: 600; padding: 12px 6px; background: #fff; color: var(--purple);
  border: 0; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--purple); }
.seg button.on { background: var(--purple); color: #fff; }

/* Check rails — the paper PPM sheet, made tappable */
.rails { border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.rail { display: flex; align-items: center; width: 100%; border: 0; border-bottom: 1.5px solid var(--line);
  background: #fff; font: inherit; font-size: 17px; color: var(--ink); text-align: left; padding: 15px 14px; cursor: pointer; }
.rail:last-child { border-bottom: 0; }
.rail .mark { width: 28px; height: 28px; border: 2px solid var(--purple); border-radius: 6px; margin-right: 14px;
  flex: 0 0 28px; position: relative; background: #fff; }
.rail.on { background: var(--purple); color: #fff; }
.rail.on .mark { background: #fff; border-color: #fff; }
.rail.on .mark::after { content: ""; position: absolute; left: 8px; top: 3px; width: 7px; height: 13px;
  border: solid var(--purple); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.rail .lbl { flex: 1; }
.rail.sub { padding-left: 34px; font-size: 16px; }
.rails-actions { text-align: right; margin: 6px 0 0; }
.link { background: none; border: 0; color: var(--purple); font: inherit; font-size: 14px; text-decoration: underline; padding: 6px; cursor: pointer; }

/* Voltage */
.volt { display: flex; align-items: center; }
.volt input { width: 130px; margin-right: 8px; }
.volt span { color: var(--ink-soft); }

/* Signature */
.sigwrap { border: 1.5px solid var(--line); border-radius: 8px; background: #fff; position: relative; }
.sigwrap canvas { display: block; width: 100%; height: 170px; touch-action: none; border-radius: 8px; }
.sigwrap .sigline { position: absolute; left: 16px; right: 16px; bottom: 34px; border-bottom: 1px dashed var(--line); pointer-events: none; }
.sigwrap .x { position: absolute; left: 16px; bottom: 36px; color: var(--line); font-size: 18px; pointer-events: none; }

/* Home */
.home-grid .btn { margin-bottom: 12px; }
.stat { font-size: 13px; color: var(--ink-soft); margin-top: 20px; }

/* Lists */
.list { border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.item { display: block; width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1.5px solid var(--line);
  padding: 12px 14px; font: inherit; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item b { display: block; font-weight: 600; }
.item span { font-size: 13px; color: var(--ink-soft); }
.item .tag { float: right; font-size: 12px; color: var(--purple); border: 1px solid var(--purple); border-radius: 4px; padding: 1px 6px; }

/* Report preview */
.report { border: 1.5px solid var(--line); border-radius: 8px; padding: 16px; background: #fff; }
.report .rhead { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid var(--purple); padding-bottom: 8px; margin-bottom: 10px; }
.report .rhead img { height: 36px; }
.report .rhead .co { font-size: 12px; color: var(--ink-soft); text-align: right; white-space: pre-line; }
.report h3 { font-size: 18px; margin: 0; color: var(--purple); }
.report .rsub { color: var(--ink-soft); font-size: 14px; margin: 0 0 10px; }
.report table { border-collapse: collapse; width: 100%; }
.report .meta td { padding: 4px 4px; border-bottom: 1px solid #EEE7F1; font-size: 15px; vertical-align: top; }
.report .meta td.k { color: var(--ink-soft); width: 38%; }
.report h4 { font-size: 14px; margin: 14px 0 4px; color: var(--purple); border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.report .cl td { padding: 3px 4px; font-size: 15px; }
.report .cl td.t { width: 26px; }
.report .bx { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--purple); border-radius: 3px; position: relative; vertical-align: middle; }
.report .bx.on { background: var(--purple); }
.report .bx.on::after { content: ""; position: absolute; left: 4px; top: 0; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.report .notes { white-space: pre-wrap; border: 1px solid var(--line); border-radius: 6px; padding: 8px; min-height: 40px; font-size: 15px; }
.report .sig { max-height: 90px; max-width: 100%; border-bottom: 1px solid #999; }
.report .foot { margin-top: 14px; font-size: 12px; color: var(--ink-soft); border-top: 1px solid #EEE7F1; padding-top: 6px; }
.actions { margin: 16px 0; }

/* Modal */
.modal { display: none; position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: rgba(28,28,28,.55); z-index: 20; padding: 24px 16px; }
.modal.open { display: block; }
.modal .box { background: #fff; border-radius: 10px; padding: 18px; max-width: 480px; margin: 40px auto 0; }
.modal h3 { margin: 0 0 12px; color: var(--purple); font-size: 18px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 15px; z-index: 30; display: none; max-width: 90%; }
.toast.show { display: block; }

.build { text-align: center; font-size: 11px; color: #A69BAB; padding: 8px 0 16px; }

/* Busy overlay */
.busy { display: none; position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: rgba(255,255,255,.7); z-index: 25;
  align-items: center; justify-content: center; font-weight: 600; color: var(--purple); }
.busy.show { display: flex; }

/* Print (system print / desktop PDF): only the report */
@media print {
  body { background: #fff; }
  .app > *:not(#screen-report) { display: none !important; }
  #screen-report { display: block !important; padding: 0; }
  #screen-report .actions, #screen-report h1, #screen-report .build, #screen-report .hint { display: none !important; }
  .report { border: 0; padding: 0; }
  @page { margin: 12mm; }
}
