/* ============================================================
   JagTrace — shared mobile-first styles
   ============================================================ */
:root {
  --primary: #1a56ff;
  --primary-press: #1144cc;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #14171f;
  --muted: #687087;
  --border: #e6e8ec;
  --ok: #0a7d28;
  --err: #c0241c;
  --radius: 14px;
  --maxw: 560px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* App bar -------------------------------------------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0b0b0d;
  border-bottom: 1px solid #1c1c20;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
}
.appbar .brand { font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; }
.appbar .brand-logo { display: block; height: 28px; width: auto; margin-bottom: 3px; }
.appbar .brand small { display: block; font-weight: 500; font-size: 0.72rem; color: #9aa0ad; }
.appbar .back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-left: -6px;
  border-radius: 10px; color: #e8e8ea; text-decoration: none; font-size: 1.3rem;
}
.appbar .back:active { background: #1c1c20; }

/* Layout --------------------------------------------------- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 32px);
}
h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
a { color: var(--primary); }

/* Cards ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* Navigation cards (home) ---------------------------------- */
.navcard {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--text);
}
.navcard:active { background: #fbfbfd; }
.navcard .ic {
  flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: #eaf0ff; font-size: 1.4rem;
}
.navcard .tx { flex: 1; }
.navcard .tx strong { display: block; font-size: 1.02rem; }
.navcard .tx span { font-size: 0.86rem; color: var(--muted); }
.navcard .chev { color: var(--muted); font-size: 1.3rem; }

/* Buttons -------------------------------------------------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 52px;
  font-size: 1.05rem; font-weight: 600;
  border: 0; border-radius: 12px;
  background: var(--primary); color: #fff;
  cursor: pointer; text-decoration: none;
  margin-top: 14px;
  padding: 0 16px;
  -webkit-tap-highlight-color: transparent;
}
button:active, .btn:active { background: var(--primary-press); }
button:disabled { background: #9bb3ff; cursor: default; }
button.secondary, .btn.secondary { background: #eef0f4; color: var(--text); }
button.secondary:active { background: #e3e6ec; }

/* Inputs --------------------------------------------------- */
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }
input[type="text"], input[type="url"] {
  width: 100%; min-height: 48px;
  font-size: 1rem; padding: 0 12px;
  border: 1px solid #ccd1da; border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fff;
}

/* Result / detail rows ------------------------------------- */
.row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f1f4; }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); }
.row .v { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; word-break: break-all; }

/* Receipt (recipient confirmation) ------------------------- */
.receipt { text-align: center; margin-top: 18px; }
.receipt .row { text-align: left; }
.receipt-check {
  width: 60px; height: 60px; margin: 2px auto 14px;
  border-radius: 50%; background: #e6f6ec; color: var(--ok);
  display: grid; place-items: center; font-size: 1.9rem; font-weight: 700;
}
.receipt-title { margin: 0 0 4px; font-size: 1.25rem; }
.receipt-sub { margin: 0 0 16px; }

/* Status / output ------------------------------------------ */
.status { margin-top: 14px; min-height: 1.3em; }
.ok { color: var(--ok); }
.err { color: var(--err); }
.out {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem;
  white-space: pre-wrap; word-break: break-all;
  background: #f5f6f8; border-radius: 10px; padding: 12px; margin-top: 12px; min-height: 1.3em;
}
.url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; background: #eef3ff; padding: 10px 12px; border-radius: 10px; margin-top: 10px; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 20px; }
.banner { background: #fff7e6; border: 1px solid #ffe0a3; color: #7a5b00; padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 16px; }
canvas { display: block; margin: 14px auto 0; max-width: 100%; }
.tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #eef0f4; padding: 2px 7px; border-radius: 5px; }

/* Table (confirmations) ------------------------------------ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #f0f1f4; font-size: 0.88rem; white-space: nowrap; }
th { background: #f6f7f9; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
tr:last-child td { border-bottom: 0; }

/* JagTrace Interoffice additions -------------------------- */
textarea {
  width: 100%; font-size: 1rem; padding: 10px 12px;
  border: 1px solid #ccd1da; border-radius: 10px; background: #fff;
  font-family: inherit; resize: vertical; min-height: 44px;
}
label.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.95rem; color: var(--text); margin: 14px 0 4px;
}
label.check input { width: auto; min-height: 0; margin: 0; }

/* Status badges (trip / folder state) */
.badge {
  display: inline-block; font-size: 0.74rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: #eef0f4; color: var(--muted);
  white-space: nowrap;
}
.badge-transit  { background: #fff2d9; color: #8a5a00; }
.badge-delivered{ background: #e6f6ec; color: var(--ok); }
.badge-archived { background: #eef0f4; color: var(--muted); }
.badge-deleted  { background: #fdecec; color: var(--err); }

/* Stacked big action buttons in the tap flow keep the shared button style;
   secondary buttons already defined. Give a little breathing room. */
#view-active button, #view-idle button { margin-top: 12px; }

/* Shared owner banner + delivery list (tap flow) --------- */
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.owner-banner {
  background: linear-gradient(180deg,#0b0b0d,#1c2230);
  color: #fff; border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.owner-banner .owner-label { font-size: 1.15rem; font-weight: 700; }
.owner-banner .owner-tagid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; color: #9aa0ad; }

.delivery { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.delivery-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.delivery-item { font-weight: 600; }
.delivery-meta { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; color: var(--muted); margin: 4px 0 10px; word-break: break-word; }
.delivery-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Small inline row buttons (shared by tap flow + admin) --- */
.rowbtn {
  display: inline-block; font-size: 0.82rem; font-weight: 500;
  padding: 6px 12px; border-radius: 8px; background: #eef0f4; color: var(--text);
  border: 0; cursor: pointer; width: auto; min-height: 0; margin: 0; text-decoration: none;
}
.rowbtn:hover, .rowbtn:active { background: #e3e6ec; }
.rowbtn.danger { background: #fdecec; color: var(--err); }
