/* Shared UI theme v2 - "liquid glass": dark ambient gradient canvas with drifting glow,
   frosted glass panels, bold gradient headings. Inspired by the gradient arrow in Network
   Rail's own logo (orange -> red) rather than an arbitrary trend chase. Not official brand
   hex values - swap --brand/--brand-2 for exact ones if you have them.

   Deliberately NOT glassified: RAG badges/banners stay solid, high-contrast, standard
   traffic-light colours - those carry safety meaning per NR/GN/RMVP/0200 and must never
   be ambiguous, regardless of how bold the rest of the theme gets. Print output is a
   completely separate stylesheet (leaflet.css) and is untouched by any of this. */

:root {
  --brand: #E2001A;
  --brand-2: #FF7A1A;
  --ink: #1a1310;
  --muted: #6b5f66;
  --border: rgba(20, 10, 10, 0.14);
  --card: #ffffff;
  --green: #107C10;
  --amber: #D97706;
  --red: #D13438;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  margin: 0;
  padding: 0 0 40px 0;
  line-height: 1.45;
  min-height: 100vh;
  /* Photo background with a flat dark tint over it (not a visible gradient - just a uniform
     darken) so the masthead text and glass cards stay legible. Path is relative to this CSS
     file (calculator/), so it resolves the same from index.html/dev.html/view.html. */
  background-image:
    linear-gradient(rgba(10, 5, 8, 0.72), rgba(10, 5, 8, 0.72)),
    url("images/background.jpg");
  background-size: auto, cover;
  background-position: 0 0, center top;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}

.wrap { max-width: 920px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

/* --- Masthead: slim brand strip. The bold statement is the page's own <h1> below it. --- */
.masthead { padding: 18px 24px 0 24px; position: relative; z-index: 1; }
.masthead-org {
  display: inline-block;
  font-weight: 800; font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: #ffd7c2;
  padding-bottom: 10px;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--brand-2), var(--brand)) 1;
}
.masthead-product { font-size: 0.8rem; color: rgba(255, 255, 255, 0.6); margin-left: 10px; }

h1 {
  font-size: clamp(1.7rem, 3.2vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 18px 0 6px 0;
  color: #ffffff;
}
h2 { font-size: 1.1rem; }
.subtitle { color: rgba(255, 255, 255, 0.78); margin-top: 0; margin-bottom: 20px; font-size: 0.95rem; }
.back-link { font-size: 0.85rem; color: #fff; display: inline-block; margin-bottom: 10px; opacity: 0.85; }
.back-link:hover { opacity: 1; }

/* --- Top nav: same three links on every page, active one highlighted --- */
.top-nav { display: flex; gap: 10px; margin: 10px 0 22px 0; flex-wrap: wrap; position: relative; z-index: 1; }
.top-nav a {
  display: inline-block;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.top-nav a:hover { background: rgba(255, 255, 255, 0.22); }
.top-nav a.current { background: var(--brand); border-color: var(--brand); }

/* --- Panels: fully opaque, not translucent - semi-transparent backgrounds throw off
   ClearType/font antialiasing and made text look subtly soft even without backdrop-filter. --- */
.card {
  position: relative; z-index: 1;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 14px 40px rgba(20, 5, 10, 0.35);
}
.card h2 {
  font-size: 1.05rem;
  margin-top: 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  display: flex; justify-content: space-between; align-items: baseline;
}

label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #f4f4f5;
  color: var(--ink);
}
input[type=text]:focus, input[type=number]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(226, 0, 26, 0.15);
  background: white;
}
textarea { resize: vertical; min-height: 60px; }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
button.primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: white;
  border: none;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgba(226, 0, 26, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button.primary:hover { transform: translateY(-1px); box-shadow: 0 9px 26px rgba(226, 0, 26, 0.45); }
button.primary:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
button.secondary {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid rgba(20, 10, 10, 0.18);
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
button.secondary:hover { background: #f3f3f3; border-color: var(--brand); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid rgba(20, 10, 10, 0.08); }
th { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }

/* RAG badges - deliberately solid, no glass/gradient. Safety signal, must stay unambiguous. */
.badge {
  display: inline-block; padding: 3px 11px; border-radius: 20px;
  color: white; font-weight: 700; font-size: 0.75rem;
}
.badge.green { background: var(--green); }
.badge.amber { background: var(--amber); }
.badge.red { background: var(--red); }

.row-actions button {
  border: none; background: none; cursor: pointer; color: var(--brand);
  text-decoration: underline; font-size: 0.85rem; padding: 0 4px;
}

.empty-note { color: var(--muted); font-size: 0.88rem; }
.hint { font-size: 0.8rem; color: var(--muted); }
.dev-link { font-size: 0.78rem; font-weight: 600; color: var(--brand); border-bottom: 1px solid var(--brand); }

/* --- GitHub connection bar (index.html + dev.html) --- */
.gh-bar {
  position: relative; z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  background: #ffffff;
}
.gh-connected { display: flex; justify-content: space-between; align-items: center; }
.gh-change-btn, .gh-connect-btn {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: white; border: none; border-radius: 6px;
  padding: 6px 12px; cursor: pointer; font-size: 0.8rem;
}
.gh-setup-title { font-weight: 700; margin-bottom: 8px; }
.gh-setup-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px; margin-bottom: 10px;
}
.gh-setup-grid input {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
}
.gh-error { color: var(--red); font-size: 0.82rem; margin-top: 6px; min-height: 1em; }

/* --- Share modal (the "Driver link" QR popup) - used by index.html, history.html, status.html,
   all sharing the same #shareModal/.share-modal markup and showShareLink/closeShareModal JS. --- */
.share-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.share-modal {
  background: white;
  border-radius: 12px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
}
.share-modal h3 {
  margin: 0 0 6px 0;
  font-size: 1.1rem;
}
.share-modal input[type=text] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  margin-bottom: 10px;
  font-family: inherit;
}
.share-qr-wrap {
  text-align: center;
  margin-top: 14px;
}
.share-qr-wrap img {
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* --- Custom alert/confirm dialogs (shared.js customAlert/customConfirm) - replaces the native
   browser alert()/confirm() popups on every page so they match the rest of the app. --- */
.dlg-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 2000; padding: 20px;
}
.dlg-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.dlg-message {
  margin: 0 0 18px 0;
  font-size: 0.92rem;
  color: var(--ink);
  white-space: pre-wrap;
  line-height: 1.5;
}
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; }
.dlg-input { margin-bottom: 4px; }
