/* FDS Logbook (rebuild) — base styles.
   Clean, dependency-free. Light base ("light is serious"); dark is the
   opt-in theme via the Profile toggle. */

:root, [data-theme="light"] {
  --bg: #f4f4f6;
  --card: #ffffff;
  --line: #e3e3e9;
  --text: #1b1b22;
  --muted: #6b6b78;
  --accent: #33334b;
  --accent-hover: #DD1122;
  --error: #c0271a;
  --input-bg: #ffffff;
  --focus: #9a9ab0;
  --row-hover: #f1f1f5;
  --chip-bg: #f1f1f5;
  --radius: 12px;
  --band: #cccccc;       /* header/footer bar (old design: light = #ccc) */
  --text-logo: #33334b;  /* "Logbook" wordmark (old design) */
  --content-max: 1040px; /* signed-in content column width (dial this) */
}
[data-theme="dark"] {
  --band: #000000;
  --text-logo: #dddddd;
  --bg: #0d0d12;
  --card: #15151c;
  --line: #26262f;
  --text: #e9e9ee;
  --muted: #9a9aa6;
  --accent: #33334b;
  --accent-hover: #DD1122;
  --error: #ff6b6b;
  --input-bg: #0f0f15;
  --focus: #44445f;
  --row-hover: #1b1b24;
  --chip-bg: #1b1b24;
}

/* Brand display font — reserved for product names (here: the "Logbook" wordmark). */
@font-face {
  font-family: FDSFontOne;
  src: url("../font/FDSFontOne.woff") format("woff");
  font-display: swap;
}

* { box-sizing: border-box; }

/* Make the `hidden` attribute always win over display rules below. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}
/* Sticky footer: header / content / footer as a full-height column. */
body { min-height: 100vh; display: flex; flex-direction: column; }

.wrap {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 18px 16px 44px;
  flex: 1 0 auto;
}
/* Keep the auth cards compact; the signed-in view uses the full width. */
#view-signed-out .card,
#view-unverified .card,
#view-onboarding,
#view-loading { max-width: 440px; margin-left: auto; margin-right: auto; }
.onb-photo { display: flex; align-items: center; gap: 16px; margin: 18px 0; }
.onb-photo .avatar { width: 88px; height: 88px; font-size: 34px; }
.onb-photo button { margin: 0; }
.onb-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- app header / footer bands (follow the theme: light bar in light mode) --- */
.appheader { background: var(--band); }
.appheader-in,
.appfooter-in {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ah-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.ah-logo-link { display: inline-flex; align-items: center; }
.ah-logo-link:hover { opacity: 0.9; }
.ah-logo { height: 50px; width: auto; display: block; }
/* Logo artwork swaps with the theme, matching the old design's files. */
.ah-logo-dark { display: none; }
[data-theme="dark"] .ah-logo-light { display: none; }
[data-theme="dark"] .ah-logo-dark { display: block; }
.ah-word {
  font-family: FDSFontOne, "Trebuchet MS", Arial, sans-serif;
  font-size: 32px;
  line-height: 1;
  color: var(--text-logo);
  text-decoration: none;
  transition: color 0.18s ease;
}
.ah-word:hover { color: var(--accent-hover); }

/* Right side of the bar: who you're viewing + your avatar (= Profile) + log out. */
.ah-user { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.ah-avatar {
  margin: 0; padding: 0; border: 2px solid transparent;
  width: 50px; height: 50px; border-radius: 50%; flex: none; /* match the FDS logo height (50px) */
  background-color: var(--accent); background-size: cover; background-position: center;
  color: #fff; font-size: 20px; font-weight: bold; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.15s ease, opacity 0.15s ease;
}
.ah-avatar:hover { background-color: var(--accent); opacity: 0.9; }
.ah-avatar.has-photo,
.ah-avatar.has-photo:hover { background-color: transparent; }
.ah-avatar.active { border-color: var(--accent-hover); }
/* Cross-user indicator between the avatars: eye = viewing, pencil = editing. */
.ah-indicator {
  margin: 0; padding: 2px; border: none; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-logo); line-height: 0; transition: opacity 0.15s ease;
}
.ah-indicator:hover { background: none; opacity: 0.75; }
.ah-indicator svg { width: 34px; height: 34px; display: block; }
/* The person whose logbook you're viewing (click = their profile). */
.ah-viewing {
  margin: 0; padding: 0; border: none;
  width: 50px; height: 50px; border-radius: 50%; flex: none; /* match the header avatar (50px) */
  background-color: var(--accent); background-size: cover; background-position: center;
  color: #fff; font-size: 20px; font-weight: bold; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: opacity 0.15s ease;
}
.ah-viewing:hover { opacity: 0.9; background-color: var(--accent); }
.ah-viewing.has-photo,
.ah-viewing.has-photo:hover { background-color: transparent; }
.ah-logout { color: var(--text-logo); font-size: 15px; text-decoration: none; white-space: nowrap; }
.ah-logout::before { content: "|"; margin-right: 9px; opacity: 0.5; }
.ah-logout:hover { color: var(--accent-hover); }

.appfooter { background: var(--band); flex: none; }
.appfooter-in {
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.af-copy { white-space: nowrap; }
/* Icons are tight-cropped to their glyphs (viewBox = glyph bbox), so a uniform gap
   gives uniform *visible* spacing and a single height keeps them evenly sized. */
.af-social { display: inline-flex; align-items: center; gap: 22px; }
.af-social a { display: inline-flex; }
.af-social img {
  height: 22px; width: auto; display: block;
  opacity: 0.82; transition: opacity 0.15s ease;
}
.af-social a:hover img { opacity: 1; }
/* Social icons swap with the theme (colored on light, white on dark). */
.af-social .ic-dark { display: none; }
[data-theme="dark"] .af-social .ic-light { display: none; }
[data-theme="dark"] .af-social .ic-dark { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 24px 22px;
}
.card > h2:first-child { margin-top: 0; } /* heading flush to the top padding, matching the bottom */

h1 { font-size: 22px; margin: 0 0 16px; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 5px;
}

input {
  width: 100%;
  font-size: 16px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus { outline: none; border-color: var(--focus); }
/* Radios/checkboxes must not inherit the full-width text-input styling
   (Safari stretches them; Chrome quietly ignores it). */
input[type="radio"], input[type="checkbox"] {
  width: auto; padding: 0; font-size: inherit;
  background: none; border: none; border-radius: 0; vertical-align: middle;
}

button {
  margin-top: 18px;
  font-size: 16px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 24px;
  padding: 11px 26px;
  cursor: pointer;
  transition: background 0.18s ease;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
button.ghost:hover { background: transparent; border-color: var(--accent-hover); color: var(--text); }

.unverified-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.unverified-actions button { margin-top: 8px; }

.error { color: var(--error); font-size: 14px; min-height: 1.2em; margin: 10px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono  { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }

/* --- Entries table --- */
.entries-card { margin-top: 16px; }
.entries-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.entries-head h2 { font-size: 18px; margin: 0 0 12px; }
.dev-toggles .dev-csv { margin: 0 0 0 auto; }

.entries { overflow-x: auto; }
.er {
  display: grid;
  grid-template-columns: var(--er-cols, 3fr 5.5fr 8fr 6fr 3.5fr 4fr 4.5fr);
  gap: 0 10px;
  min-width: 660px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
.er span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.er-head { color: var(--muted); font-size: 13px; font-weight: bold; }
.er:last-child { border-bottom: none; }

/* --- Entries: filters, sort headers, pager --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 4px 0 14px;
}
.filters label { margin: 0; color: var(--text); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.filters select {
  width: 160px; font-size: 14px; color: var(--text); background: var(--input-bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
}
.f-range { display: inline-flex; align-items: center; gap: 8px; }
.rangein { width: 84px; font-size: 14px; padding: 7px 9px; }

button.mini {
  margin: 0; font-size: 14px; padding: 7px 14px; border-radius: 18px;
}
button.mini.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.mini.ghost:hover:not(:disabled) { border-color: var(--accent-hover); color: var(--text); background: transparent; }

/* clickable sort headers */
.er-head .th { cursor: pointer; user-select: none; }
.er-head .th:hover { color: var(--text); }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-top: 14px;
}
.pagesize label { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.pagebtns { display: inline-flex; align-items: center; gap: 8px; }
.pagebtns button { min-width: 40px; }
#pg-info { min-width: 64px; text-align: center; }

/* --- unassigned telemetry (devices) --- */
.dev-unassigned { color: var(--accent-hover); font-weight: bold; }
.dev-orphan-box {
  border: 1px solid var(--accent-hover); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 14px;
}
.dev-orphan-h { font-size: 14px; margin-bottom: 8px; }
.dev-orphan-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 14px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.dev-orphan-assign { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dev-orphan-assign .orphan-jn { width: 84px; font-size: 14px; padding: 6px 8px; }
.dev-orphan-assign .mini { margin: 0; }

/* --- Devices: level 1 device tiles + level 2 records header --- */
.dev-summary {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.5;
  margin: 2px 0 18px;
}
.dev-summary-num { color: var(--text); font-size: 19px; font-weight: bold; }
.dev-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.dev-tile {
  margin: 0;
  padding: 16px 16px 14px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, transform 0.05s ease;
}
.dev-tile:hover { background: var(--card); border-color: var(--accent-hover); }
.dev-tile:active { transform: translateY(1px); }
/* Product/device names wear the brand display font (FDSFontOne is product-only). */
.prodname { font-family: FDSFontOne, "Trebuchet MS", Arial, sans-serif; font-weight: normal; }
/* DigiAlti / MetaAlti prefix: the FDS signature rainbow gradient (clipped to text). */
.prod-grad {
  background: linear-gradient(to right, #C01718, #AE9B12, #107E35, #0071A9, #574C9B, #E4007D);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.dev-tile-name { font-size: 20px; }
.dev-tile-serial { color: var(--muted); font-size: 13px; }
.dev-tile-count { color: var(--accent-hover); font-size: 14px; font-weight: bold; margin-top: 6px; }
.dev-tile-orphan { border-style: dashed; }
.dev-tile-orphan .dev-tile-name { color: var(--accent-hover); }
.dev-tile-sub { color: var(--muted); font-size: 12px; }

.dev-records-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.dev-records-head h2 { font-size: 18px; margin: 0; }
.dev-records-head .mini { margin: 0; }

/* --- clickable rows + entry detail --- */
.er-row { cursor: pointer; }
.er-row:hover { background: var(--row-hover); }

.entry-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.entry-nav { display: flex; gap: 6px; }
.entry-nav .mini { margin: 0; min-width: 42px; font-size: 17px; line-height: 1; }
.entry-nav .mini:disabled { opacity: 0.4; cursor: default; }
.entry-hd { display: flex; align-items: baseline; gap: 12px; margin: 16px 0 4px; }
.entry-hd h2 { font-size: 24px; margin: 0; }
.entry-sect { margin-top: 18px; }
.entry-sect h3 {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.6px; margin: 0;
}
/* sect() sections (Signature/Tags/Media/Device): h3 is the section's rule line */
.entry-sect > h3 { margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
/* field sections: title + one Edit button, ruled under the whole row */
.sect-hd {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.sect-edit { margin: 0; }
.entry-sect .kv { grid-template-columns: minmax(150px, auto) 1fr; }
.kv-form { align-items: center; gap: 10px 16px; }
.kv-form dd { width: 100%; }
.kv-form .ef-field {
  width: 100%; min-width: 0; font-size: 15px;
  color: var(--text); background: var(--input-bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.kv-form .ef-field:focus { outline: none; border-color: var(--focus); }
.sect-body .ef-actions { margin-top: 12px; }
.sect-body > .desc-input { width: 100%; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-block; font-size: 13px; background: var(--chip-bg);
  border: 1px solid var(--line); border-radius: 14px; padding: 5px 12px;
}
.desc { white-space: pre-wrap; margin: 0; }

/* --- discipline tabs --- */
.disc-tabs { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.disc-tab {
  margin: 0; font-size: 15px; padding: 8px 18px; border-radius: 20px;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.disc-tab:hover { background: transparent; border-color: var(--accent-hover); color: var(--text); }
.disc-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.disc-tab.active:hover { background: var(--accent); color: #fff; }

/* --- subscription warning banner --- */
.sub-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; background: #8a5a00; color: #fff;
  border-radius: var(--radius); padding: 10px 16px; margin-bottom: 14px; font-size: 14px;
}
.sub-banner .mini { margin: 0; background: rgba(255,255,255,0.18); }
.sub-banner .mini:hover { background: rgba(255,255,255,0.32); }

/* --- app nav --- */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.appnav { display: flex; gap: 8px; }
.navbtn {
  margin: 0; font-size: 15px; padding: 8px 18px; border-radius: 20px;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.navbtn:hover { background: transparent; border-color: var(--accent-hover); color: var(--text); }
.navbtn.active, .navbtn.active:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.navbtn .nav-abbr { display: none; } /* short label (Stats/Admin), swapped in under 500px */

/* --- profile editing --- */
.prof-form .prof-in { width: auto; min-width: 180px; font-size: 15px; padding: 8px 10px; }
.prof-form dd { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.prof-chk { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: var(--muted); font-size: 13px; }
.prof-chk input { width: auto; margin: 0; }
.prof-ro { font-size: 15px; }
.prof-sports { gap: 14px; }
.prof-status { min-height: 1.1em; margin: 4px 0 0; opacity: 0; transition: opacity 0.15s ease; }
.prof-status.show { opacity: 1; color: var(--accent-hover); }
.email-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; margin-top: 8px; }
.email-form input { width: auto; min-width: 180px; font-size: 15px; padding: 8px 10px; }
.email-form .mini { margin: 0; }
.email-form #email-msg { flex-basis: 100%; }

/* --- profile --- */
.prof-top { display: flex; align-items: center; gap: 18px; margin-bottom: 6px; }
.avatar {
  width: 72px; height: 72px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff; font-size: 28px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}
.avatar.has-photo { background-color: transparent; background-size: cover; background-position: center; }

/* Associates statistics card — most active + month's records, per window */
.assoc-rank { list-style: none; margin: 4px 0 12px; padding: 0; }
.assoc-rank li { display: flex; align-items: center; gap: 9px; padding: 3px 0; }
.assoc-recs { margin: 4px 0 8px; }
.assoc-recs dt { color: var(--muted); font-size: 12px; margin-top: 9px; }
.assoc-recs dd { display: flex; align-items: center; gap: 9px; margin: 3px 0 0; }
.assoc-rank .assoc-name, .assoc-recs .assoc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assoc-rank .assoc-jumps, .assoc-recs .assoc-val { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.sa-av { width: 30px; height: 30px; font-size: 12px; cursor: pointer; }
.sa-av:hover { opacity: 0.85; }

/* Quiet text link next to the subscription-days count */
.prof-extend { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.prof-extend:hover { color: var(--text); }

/* --- toasts: non-blocking notifications (replace alert) --- */
.toast-host {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  align-items: center; width: max-content; max-width: 92vw; pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer; max-width: 460px;
  padding: 11px 16px; border-radius: 10px; color: #fff; font-size: 14px; line-height: 1.4;
  background: var(--accent); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: #c0312f; }
.toast-ok { background: #1f7a4d; }
#prof-avatar { width: 108px; height: 108px; font-size: 42px; } /* profile page: 50% larger than the base avatar */
#prof-avatar:hover { opacity: 0.88; }
#avatar-btn { margin-top: 8px; }
.prof-name { font-size: 22px; font-weight: bold; }
.prof-counts { color: var(--muted); font-size: 14px; margin-top: 4px; }
.tag { font-size: 11px; border-radius: 10px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.tag.pub { background: #16331c; color: #7fd99a; border: 1px solid #244a2c; }
.tag.priv { background: var(--chip-bg); color: var(--muted); border: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; background: var(--chip-bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px 10px; }

/* --- associates management --- */
.assoc-search { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 18px; }
.assoc-find strong { font-size: 14px; }
.assoc-find-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.assoc-find-row input { width: auto; flex: 1; min-width: 90px; font-size: 14px; padding: 7px 9px; }
.assoc-find-row .mini { margin: 0; }
.assoc-results { display: flex; flex-direction: column; gap: 4px; }
.assoc-grp { margin-bottom: 14px; }
.assoc-grp h4 {
  font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px;
  margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.assoc-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 0; font-size: 14px;
}
.assoc-who { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.assoc-av { width: 34px; height: 34px; font-size: 13px; flex: none; }
.assoc-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assoc-acts { display: inline-flex; gap: 6px; flex: none; }
.assoc-acts .mini { margin: 0; padding: 5px 12px; font-size: 13px; }

/* --- description editor (first write path) --- */
.desc-input {
  width: 100%; min-height: 90px; resize: vertical;
  font-family: inherit; font-size: 15px;
  color: var(--text); background: var(--input-bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.desc-input:focus { outline: none; border-color: var(--focus); }
.desc-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }

/* --- inline field editors (date / time) --- */
.efield { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ef-text { width: auto; min-width: 150px; font-size: 15px; padding: 8px 10px; }
/* Inline-edit affordance: faint pencil + clickable value (no loud button per row). */
.ef-pencil {
  margin: 0; padding: 0 4px; border: none; background: none;
  font-size: 14px; line-height: 1; color: var(--muted); cursor: pointer; opacity: 0.45;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.ef-pencil:hover { background: none; color: var(--accent-hover); opacity: 1; }
.ef-clickable { cursor: pointer; transition: color 0.12s ease; }
.ef-clickable:hover { color: var(--accent-hover); }
.ef-actions { display: flex; align-items: center; gap: 10px; }
#desc-area .ef-actions { margin-top: 10px; }

.ef-select {
  font-size: 15px; padding: 8px 10px; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--line); border-radius: 8px;
}

/* --- add entry --- */
#add-entry-btn { margin: 0 0 0 auto; }
#add-entry { margin: 0 0 14px; }
.add-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--input-bg);
}
.add-form label {
  display: flex; flex-direction: column; gap: 4px; margin: 0;
  color: var(--muted); font-size: 13px;
}
.add-form input { width: auto; font-size: 15px; padding: 8px 10px; }
.add-form #add-jn { width: 90px; }
.add-form .mini { margin: 0; }

/* --- statistics dashboard --- */
.stat-disc { margin-top: 16px; }
.stat-disc h2 { font-size: 20px; margin: 0 0 14px; }

/* activity heatmap — GitHub-style jumps/day for the past year (brand-red intensity) */
.hm-scroll { overflow-x: auto; padding-bottom: 4px; }
.hm-wrap { --hm: 12px; display: inline-block; min-width: 100%; }
.hm-months { display: grid; gap: 3px; height: 12px; margin-bottom: 5px; font-size: 10px; color: var(--muted); }
.hm-mon { grid-row: 1; white-space: nowrap; }
.hm-grid { display: grid; grid-template-rows: repeat(7, var(--hm)); grid-auto-flow: column; gap: 3px; }
.hm-cell { width: var(--hm, 12px); height: var(--hm, 12px); border-radius: 2px; background: var(--line); }
.hm-l1 { background: #f6b8c0; }
.hm-l2 { background: #ef8190; }
.hm-l3 { background: #e34c5e; }
.hm-l4 { background: #dd1122; }
.hm-lx { background: transparent; }
.hm-legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.hm-key { display: flex; align-items: center; gap: 5px; }

/* trend charts (cumulative line + per-month bars) */
.stat-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.chartbox { min-width: 0; }
.chartbox h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cwrap { position: relative; height: 220px; }
@media (max-width: 700px) { .stat-charts { grid-template-columns: 1fr; } }
.stat-cols {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 28px;
}
.stat-sub h4 {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.6px; margin: 8px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.stat-sub .kv { grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 14px; }
.rec-jump-link { color: var(--muted); cursor: pointer; text-decoration: none; font-size: 13px; white-space: nowrap; }
.rec-jump-link:hover { color: var(--accent-hover); text-decoration: underline; }

/* --- check statistics --- */
.check-out { margin-top: 10px; }
.check-out .check-list { list-style: none; margin: 8px 0 0; padding: 0; }
.check-out .check-list li {
  font-size: 14px; color: var(--text);
  padding: 7px 0; border-top: 1px solid var(--line);
}
.check-out .check-jump {
  color: var(--accent); cursor: pointer; text-decoration: none;
  font-weight: 600; white-space: nowrap;
}
.check-out .check-jump:hover { color: var(--accent-hover); text-decoration: underline; }
.check-out .check-recheck { color: var(--accent); cursor: pointer; text-decoration: underline; white-space: nowrap; }
.check-out .check-recheck:hover { color: var(--accent-hover); }

/* --- administration --- */
.ax-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin-bottom: 14px; }
.ax-controls label { display: flex; flex-direction: column; gap: 4px; margin: 0; color: var(--muted); font-size: 13px; }
.ax-controls input { width: 90px; font-size: 15px; padding: 8px 10px; }
.ax-controls .mini { margin: 0; }
.ax-hint { font-weight: bold; } /* admin validation hints — bold so they don't get missed */
.ax-grid-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.ax-grid { border-collapse: collapse; font-size: 13px; }
.ax-grid th, .ax-grid td { border: 1px solid var(--line); padding: 4px 6px; white-space: nowrap; }
.ax-grid thead th { background: var(--chip-bg); position: sticky; top: 0; vertical-align: top; }
.ax-h { display: flex; flex-direction: column; gap: 2px; }
.ax-copy { margin: 0; font-size: 10px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.ax-copy input { width: auto; margin: 0; }
.ax-in { width: 100%; font-size: 13px; padding: 5px 6px; min-width: 88px; }
.ax-in.ax-num { min-width: 76px; }
.ax-in.ax-text { min-width: 160px; }
.ax-flag-c { text-align: center; }
.ax-flag { width: auto !important; min-width: 0 !important; }
#ax-actions { margin-top: 14px; display: flex; align-items: center; gap: 12px; }
#ax-actions .mini { margin: 0; }

/* --- current settings --- */
.set-cols {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 28px;
}
.set-group h4 {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.6px; margin: 8px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.set-deflabel { margin: 0 0 8px; color: var(--text); font-size: 13px; }
.set-deflabel .ef-select { margin-left: 6px; max-width: 180px; }
.set-list { list-style: none; margin: 0 0 10px; padding: 0; }
.set-list li { padding: 3px 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.set-name { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.set-rename, .set-remove {
  width: 22px; height: 22px; padding: 0; line-height: 1; border-radius: 50%;
  font-size: 13px; background: var(--chip-bg); color: var(--muted);
  border: 1px solid var(--line); margin: 0;
}
.set-rename { margin-left: auto; }
.set-remove { margin-left: 0; }
.set-rename:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.set-remove:hover { background: var(--accent-hover); color: #fff; border-color: var(--accent-hover); }
.set-add { display: flex; gap: 8px; align-items: center; }
.set-add .ef-text { flex: 1; min-width: 0; }
.set-add .mini { margin: 0; }

/* --- media (embeds) --- */
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.media-item { position: relative; }
.media-embed iframe, .media-embed .instagram-media {
  width: 100% !important; border-radius: 8px;
}
.media-embed iframe { aspect-ratio: 16 / 9; height: auto; }
.media-remove {
  position: absolute; top: 6px; right: 6px; z-index: 2; margin: 0;
  width: 28px; height: 28px; padding: 0; line-height: 1; border-radius: 50%;
  font-size: 18px; background: rgba(0,0,0,0.6); color: #fff;
}
.media-remove:hover { background: var(--accent-hover); }
.media-add { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.media-add .ef-text { flex: 1; min-width: 240px; }
.media-add .mini { margin: 0; }

/* --- signature --- */
.sig-img { max-width: 280px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: block; }
.sig-lock { color: var(--accent-hover); font-size: 13px; margin: 0 0 10px; }
.sig-pad {
  border: 1px solid var(--focus); border-radius: 8px; background: #fff;
  touch-action: none; cursor: crosshair; max-width: 100%;
}

/* --- jumper tags + linked jumps --- */
.tag-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.tag-card:last-of-type { border-bottom: none; }
.tag-av {
  width: 44px; height: 44px; font-size: 16px; flex: none;
  background-size: cover; background-position: center;
}
.tag-av.has-photo { background-color: transparent; }
.tag-name { font-weight: bold; }
.tag-link { margin-left: auto; }
.tag-card .tag-remove { margin: 0; }
.tag-add { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.tag-add .ef-select { max-width: 240px; }
.tag-add .mini { margin: 0; }

/* --- device telemetry --- */
.dev-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; background: var(--input-bg);
}
.dev-card:last-child { margin-bottom: 0; }
.dev-hd { margin-bottom: 8px; }
.dev-jn { margin-bottom: 10px; }
.dev-jn .ef-val { font-weight: bold; }
.dev-toggles { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 2px; }
.dev-cb { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 13px; cursor: pointer; }
.dev-cb input { width: auto; margin: 0; cursor: pointer; }
.dev-chart-wrap { position: relative; height: 280px; margin-top: 8px; }
.dev-compare-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.dev-compare-row .dev-compare { flex: 1; min-width: 200px; }
.dev-compare-row .mini { margin: 0; }
.dev-compare-msg { flex-basis: 100%; }

/* --- flags editor --- */
#ef-flags .ef-actions { margin-top: 12px; }
.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 18px;
}
.flag-chk {
  display: flex; align-items: center; gap: 8px;
  margin: 0; color: var(--text); font-size: 14px; cursor: pointer;
}
.flag-chk input { width: auto; margin: 0; cursor: pointer; }

/* =========================================================================
   Responsive — phone/field sizing. Built out screen by screen.
   ========================================================================= */
@media (max-width: 500px) {
  /* nav row can't fit "Statistics"/"Administration" on a phone — use short labels */
  .navbtn .nav-full { display: none; }
  .navbtn .nav-abbr { display: inline; }
}

@media (max-width: 560px) {
  .appheader-in, .appfooter-in { padding-left: 12px; padding-right: 12px; }
  .wrap { padding-left: 12px; padding-right: 12px; }
  .ah-logo { height: 38px; }
  .ah-word { font-size: 25px; }
  .ah-user { gap: 8px; }
  .ah-avatar { width: 38px; height: 38px; font-size: 15px; } /* match the mobile logo height (38px) */
  .ah-viewing { width: 38px; height: 38px; font-size: 15px; } /* match the mobile header avatar */
  .ah-logout { font-size: 14px; }
  .ah-logout::before { margin-right: 7px; }
  .af-social { gap: 18px; }
  .entry-sect .kv { grid-template-columns: minmax(96px, 42%) 1fr; gap: 6px 10px; }
}

/* Entries: below 640px, drop the sidescrolling table for per-jump cards. */
@media (max-width: 640px) {
  .entries { overflow-x: visible; }
  .er-head { display: none; }
  .er.er-row {
    display: block;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    padding: 6px 12px;
    margin-bottom: 8px;
  }
  .er.er-row:last-child { margin-bottom: 0; }
  .er-row span {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    padding: 5px 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
  }
  .er-row span:last-child { border-bottom: none; }
  .er-row span::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    text-align: left;
  }
}
