/* Aevapor -- customer-facing styles.
   Layout follows ~/Projects/_shared/docs/FRONTEND_PATTERNS.md (banner-on-top +
   background-beneath pattern). Banner is opaque so we don't get visual mud
   under it; content lives in a centered column. */

:root {
  --ink:         #13161c;
  --bg:          #f4f5f7;
  --brand:       #3870d8;
  --brand-dark:  #2956a9;
  --text:        #1f2329;
  --muted:       #5e6a76;
  --border:      #d3d8e0;
  --card:        #ffffff;
  --danger:      #c83232;
  --danger-dark: #8a2222;
  --success:     #2da462;
  --warn-bg:     #fdecec;
  --warn-border: #f2b8b8;

  --banner-h-mobile:  56px;
  --banner-h-desktop: 64px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { background-color: var(--ink); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  padding-top: calc(var(--banner-h-mobile) + var(--safe-top));
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  top: calc(var(--banner-h-mobile) + var(--safe-top));
  left: 0; right: 0; bottom: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bg);
}

@media (min-width: 768px) {
  body         { padding-top: calc(var(--banner-h-desktop) + var(--safe-top)); }
  body::before { top:         calc(var(--banner-h-desktop) + var(--safe-top)); }
}

/* ----------------------------------------------------------------------- */
/* Banner                                                                  */
/* ----------------------------------------------------------------------- */
.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  padding-top: var(--safe-top);
  background: rgba(19, 22, 28, 0.94);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--banner-h-mobile);
  gap: 16px;
}
@media (min-width: 768px) {
  .banner-inner { height: var(--banner-h-desktop); }
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-mark {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), #6ea7ff);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
}
.banner-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.banner-nav a {
  color: #d6dbe2;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.banner-nav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.banner-nav .cta {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
}
.banner-nav .cta:hover { background: #4a7fde; }
.banner-user { color: #8a96a3; font-size: 13px; }
@media (max-width: 540px) { .banner-user { display: none; } }
.logout-form { display: inline; margin: 0; }
.link-button {
  background: none;
  border: 0;
  color: #d6dbe2;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
}
.link-button:hover { color: #fff; background: rgba(255,255,255,0.06); }

/* ----------------------------------------------------------------------- */
/* Layout                                                                  */
/* ----------------------------------------------------------------------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 calc(20px + var(--safe-left)) 0 calc(20px + var(--safe-right));
}
main.container { padding-top: 24px; padding-bottom: 48px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 16px;
}
.page-head h1 { margin: 0; font-size: 24px; }
.page-head-actions { display: flex; gap: 8px; }

.breadcrumb {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 13px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }

.muted { color: var(--muted); }
.center { text-align: center; }
.top-gap { margin-top: 20px; }

.footer {
  padding-top: 24px;
  padding-bottom: calc(20px + var(--safe-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.footer a { color: var(--muted); }

/* ----------------------------------------------------------------------- */
/* Cards                                                                   */
/* ----------------------------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 14px rgba(0,0,0,0.04);
  margin-bottom: 18px;
}
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card.empty { text-align: center; padding: 36px 24px; }
.card h1 { margin: 0 0 6px; font-size: 22px; }
.card-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.card-head { margin: -4px 0 16px; }
.card-head h2 { margin: 0; font-size: 16px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }

/* ----------------------------------------------------------------------- */
/* Forms                                                                   */
/* ----------------------------------------------------------------------- */
.field {
  display: block;
  margin: 14px 0;
}
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #3a4452;
}
.field-help {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 540px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(56, 112, 216, 0.18);
}

/* iOS Safari autofill yellow fix (per FRONTEND_PATTERNS.md) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:active,
input:autofill {
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
          box-shadow: 0 0 0 1000px #fff inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

.form-errors {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--danger-dark);
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.form-errors-heading { margin: 0 0 4px; font-weight: 600; }
.form-errors p { margin: 4px 0; font-size: 14px; }

/* ----------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ----------------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}
.btn.primary {
  background: var(--brand);
  color: #fff;
}
.btn.primary:hover { background: #4a7fde; }
.btn.primary:active { background: var(--brand-dark); }
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn.ghost:hover { background: rgba(0,0,0,0.04); }
.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.danger:hover { background: #b02a2a; }
.btn.ghost.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn.ghost.danger:hover { background: rgba(200, 50, 50, 0.06); }
.btn.block { width: 100%; margin-top: 18px; }
.button-row { display: flex; gap: 10px; margin-top: 18px; }

.link-small { font-size: 13px; color: var(--brand); text-decoration: none; }
.link-small:hover { text-decoration: underline; }

/* ----------------------------------------------------------------------- */
/* Messages                                                                */
/* ----------------------------------------------------------------------- */
.messages { margin: 0 0 16px; }
.message {
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.message-success { background: #e7f6ec; border: 1px solid #b6d7c2; color: #1e6e3d; }
.message-info    { background: #e7eef8; border: 1px solid #b6c6e0; color: #1e4380; }
.message-error   { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--danger-dark); }
.message-warning { background: #fcf3e1; border: 1px solid #ecd8a3; color: #7c5816; }

/* ----------------------------------------------------------------------- */
/* Hero (landing page)                                                     */
/* ----------------------------------------------------------------------- */
.hero {
  background: var(--card);
  border-radius: 12px;
  padding: 56px 32px;
  text-align: center;
  margin: 8px 0 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 14px rgba(0,0,0,0.04);
}
.hero h1 { margin: 0 0 12px; font-size: 32px; letter-spacing: -0.02em; }
.hero-sub { max-width: 540px; margin: 0 auto 24px; color: var(--muted); font-size: 17px; }
.hero-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 720px) { .features { grid-template-columns: 1fr; } }
.feature {
  background: var(--card);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.feature h3 { margin: 0 0 8px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }

/* ----------------------------------------------------------------------- */
/* Dashboard / device list                                                 */
/* ----------------------------------------------------------------------- */
.org-card { padding: 20px 22px; }
.org-card-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.org-card-head h2 { margin: 0; font-size: 18px; }
.role-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 6px;
  background: #eef2f8;
  color: #4a5868;
}
.role-tag.role-owner { background: #e7eef8; color: #1e4380; }

.device-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }

/* A device row + its owner-only Unpair button sit side by side; the card stays
   the clickable part (Unpair is a separate sibling, not nested in the anchor). */
.device-row-outer { display: flex; align-items: stretch; gap: 8px; }
.device-row-outer .device-row { flex: 1 1 auto; min-width: 0; }
.device-unpair {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: var(--danger);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.device-unpair:hover { background: rgba(200, 50, 50, 0.08); }

/* Whole row is one tappable card -- the device name alone was too easy to miss
   (no underline + hover-only color = looks inert on touch). */
.device-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease, transform .04s ease;
}
.device-row:hover {
  border-color: var(--brand);
  background: #f1f6fd;
  box-shadow: 0 1px 5px rgba(56, 112, 216, 0.13);
}
.device-row:active { transform: scale(0.995); background: #e9f0fb; }
.device-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.device-status {
  width: 10px; height: 10px; border-radius: 50%;
  flex: 0 0 auto;
}
.device-status.status-online  { background: var(--success); box-shadow: 0 0 0 3px rgba(45, 164, 98, 0.18); }
.device-status.status-offline { background: #b7c0cc;        box-shadow: 0 0 0 3px rgba(183, 192, 204, 0.20); }

.device-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.device-name {
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.device-meta { color: var(--muted); font-size: 13px; }
.device-state { font-weight: 600; }
.device-state.is-online  { color: var(--success); }
.device-state.is-offline { color: var(--muted); }

.device-chevron {
  flex: 0 0 auto;
  color: #aab3bf;
  font-size: 24px;
  line-height: 1;
  transition: color .12s ease, transform .12s ease;
}
.device-row:hover .device-chevron { color: var(--brand); transform: translateX(2px); }

.org-picker { list-style: none; padding: 0; margin: 12px 0; }
.org-picker li { margin: 8px 0; }

/* Invite -- staff permission checkboxes */
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 14px; margin: 16px 0; }
.perm-group legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.perm-check { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0; font-size: 14px; cursor: pointer; }
.perm-check input[type="checkbox"] { margin-top: 3px; flex: 0 0 auto; width: auto; }
.perm-check .muted { font-size: 13px; }
.perm-sub { margin-left: 26px; }
.fine-print { font-size: 12px; margin-top: -6px; }
.staff-member { padding: 14px 0; border-top: 1px solid var(--border, #e6e6e6); }
.staff-member:first-of-type { border-top: 0; }
.staff-member-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.staff-perm-form { margin: 0; }
.invite-list { list-style: none; margin: 0; padding: 0; }
.invite-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border, #e6e6e6); flex-wrap: wrap; }
.invite-list li:first-child { border-top: 0; }
.link-small.danger { color: #b3261e; }

/* ----------------------------------------------------------------------- */
/* Cycle table                                                             */
/* ----------------------------------------------------------------------- */
.cycle-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.cycle-table th, .cycle-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.cycle-table th {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cycle-table td a { color: var(--brand); text-decoration: none; font-weight: 500; }
.cycle-table td a:hover { text-decoration: underline; }

.status {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  background: #eef2f8;
  color: #4a5868;
  letter-spacing: 0.02em;
}
.status.large { padding: 4px 12px; font-size: 14px; }
.status-completed { background: #e7f6ec; color: #1e6e3d; }
.status-aborted   { background: var(--warn-bg); color: var(--danger-dark); }
.status-incomplete{ background: #fcf3e1; color: #7c5816; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 14px;
}
.pagination a { color: var(--brand); text-decoration: none; }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0;
}
.kv dt { font-weight: 500; color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: #eef2f8;
  padding: 2px 6px;
  border-radius: 4px;
  color: #4a5868;
}

/* ----------------------------------------------------------------------- */
/* Theme toggle (banner) + dark mode                                        */
/* ----------------------------------------------------------------------- */
.theme-toggle {
  background: none;
  border: 0;
  cursor: pointer;
  color: #d6dbe2;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.theme-toggle:hover { color: #fff; background: rgba(255,255,255,0.06); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
/* Show the moon in light mode (tap to go dark); the sun in dark mode. */
.theme-toggle .sun  { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun  { display: block; }

[data-theme="dark"] {
  --ink:         #0b0d11;
  --bg:          #0e1116;
  --brand:       #5b8ce6;
  --brand-dark:  #3f6fc4;
  --text:        #e6e9ee;
  --muted:       #98a3b0;
  --border:      #2a313b;
  --card:        #181c23;
  --danger:      #e06464;
  --danger-dark: #f0a6a6;
  --success:     #43c98a;
  --warn-bg:     rgba(200, 50, 50, 0.13);
  --warn-border: rgba(224, 100, 100, 0.32);
}

/* Surfaces that use hardcoded light colors need explicit dark values. */
[data-theme="dark"] .card,
[data-theme="dark"] .hero,
[data-theme="dark"] .feature {
  box-shadow: none;
  border: 1px solid var(--border);
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #11151b;
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:active,
[data-theme="dark"] input:autofill {
  -webkit-box-shadow: 0 0 0 1000px #11151b inset;
          box-shadow: 0 0 0 1000px #11151b inset;
  -webkit-text-fill-color: var(--text);
}
[data-theme="dark"] .field-label { color: #aeb8c4; }

[data-theme="dark"] .btn.ghost:hover { background: rgba(255,255,255,0.06); }

/* Device rows */
[data-theme="dark"] .device-row        { background: #171b22; }
[data-theme="dark"] .device-row:hover  { background: #1b2230; box-shadow: 0 1px 5px rgba(0,0,0,0.4); }
[data-theme="dark"] .device-row:active { background: #20283a; }
[data-theme="dark"] .device-status.status-offline { background: #4a5460; box-shadow: 0 0 0 3px rgba(74,84,96,0.25); }
[data-theme="dark"] .device-chevron    { color: #69727e; }

/* Chips / tags / inline code */
[data-theme="dark"] .role-tag,
[data-theme="dark"] .status,
[data-theme="dark"] code { background: #232a35; color: #aeb8c4; }
[data-theme="dark"] .role-tag.role-owner { background: #1e2b44; color: #9cc0f5; }

/* Status pills (cycles) -- translucent over the dark surface */
[data-theme="dark"] .status-completed  { background: rgba(45,164,98,0.18);  color: #5fd29b; }
[data-theme="dark"] .status-aborted    { background: rgba(200,50,50,0.20);  color: #f0a6a6; }
[data-theme="dark"] .status-incomplete { background: rgba(124,88,22,0.28);  color: #e3c178; }

/* Flash messages */
[data-theme="dark"] .message-success { background: rgba(45,164,98,0.15);  border-color: rgba(45,164,98,0.35);  color: #6dd6a2; }
[data-theme="dark"] .message-info    { background: rgba(56,112,216,0.15); border-color: rgba(56,112,216,0.38); color: #8fb4f2; }
[data-theme="dark"] .message-warning { background: rgba(124,88,22,0.22);  border-color: rgba(236,216,163,0.30); color: #e3c178; }
[data-theme="dark"] .message-error   { background: var(--warn-bg);        border-color: var(--warn-border);     color: var(--danger-dark); }

/* ----------------------------------------------------------------------- */
/* Export menu (single cycle) + export dialog (cycle list)                  */
/* ----------------------------------------------------------------------- */
.page-head-actions { align-items: center; }

.export-menu { position: relative; display: inline-block; }
.export-menu > summary {
  list-style: none;
  cursor: pointer;
}
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  padding: 6px;
  z-index: 40;
  display: flex;
  flex-direction: column;
}
.export-menu-list a {
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.export-menu-list a:hover { background: rgba(56,112,216,0.10); color: var(--brand); }

.export-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  max-width: 360px;
  width: calc(100% - 32px);
  color: var(--text);
  background: var(--card);
  box-shadow: 0 20px 60px rgba(0,0,0,0.30);
}
.export-dialog::backdrop { background: rgba(0,0,0,0.45); }
.export-dialog-inner { padding: 18px 18px 14px; margin: 0; }
.export-dialog h2 { margin: 0 0 5px; font-size: 16px; }
.export-dialog .muted { font-size: 12.5px; line-height: 1.45; }
.export-group {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}
.export-group h3 { margin: 0 0 2px; font-size: 13.5px; }
.export-group-sub { margin: 0 0 9px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.export-formats { display: flex; gap: 6px; flex-wrap: wrap; }
.export-formats .btn { flex: 1 1 auto; min-width: 70px; padding: 7px 8px; font-size: 13px; }
.export-dialog .button-row { margin-top: 14px; }
.export-dialog .button-row .btn { padding: 7px 14px; font-size: 13px; }
.export-note { margin: 14px 0 0; text-align: center; font-size: 12px; }
.export-dismiss-hint { margin: 6px 0 0; text-align: center; font-size: 11.5px; opacity: 0.85; }

.suggest-dialog { max-width: 420px; }
.suggest-dialog textarea { resize: vertical; min-height: 96px; }
.suggest-dialog .button-row { justify-content: flex-end; }

/* Banner "Suggest a feature" trigger. */
.suggest-trigger { display: inline-flex; align-items: center; gap: 6px; }
.suggest-trigger .suggest-icon { width: 16px; height: 16px; display: block; }

/* Wide tables scroll inside their card instead of spilling past the card edge
   on narrow screens (the cycle list overflows on mobile otherwise). */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ----------------------------------------------------------------------- */
/* Mobile nav -- collapse the banner items behind a hamburger menu          */
/* ----------------------------------------------------------------------- */
.banner-inner { position: relative; }
.nav-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  color: #d6dbe2;
  padding: 6px;
  border-radius: 6px;
  line-height: 0;
}
.nav-toggle:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-toggle svg { width: 24px; height: 24px; display: block; }
.theme-toggle .toggle-label { display: none; }

@media (max-width: 640px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .banner-nav {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 192px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px;
    background: rgba(19, 22, 28, 0.99);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  }
  .banner-nav.open { display: flex; }

  .banner-nav a,
  .banner-nav .link-button,
  .banner-nav .theme-toggle,
  .banner-nav .suggest-trigger {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    line-height: 1.3;
  }
  .banner-nav .theme-toggle { gap: 10px; }
  .banner-nav .theme-toggle .toggle-label { display: inline; font-size: 14px; }
  .banner-nav .suggest-trigger .suggest-label { display: inline; }

  .logout-form { display: block; width: 100%; }

  .banner-nav .banner-user {
    display: block;
    padding: 9px 12px 5px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 2px;
  }
}

[data-theme="dark"] .export-menu-list a:hover { background: rgba(91,140,230,0.16); color: var(--brand); }

/* ----------------------------------------------------------------------- */
/* Signup device/manual radio + manual-logging records                      */
/* ----------------------------------------------------------------------- */
.radio-group { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.radio-opt { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.radio-opt input[type="radio"] { margin-top: 3px; flex: 0 0 auto; width: auto; }

.search-bar { display: flex; gap: 8px; margin: 0 0 16px; }
.search-bar input[type="search"] {
  flex: 1 1 auto; width: 100%;
  font-size: 16px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
[data-theme="dark"] .search-bar input[type="search"] { background: #11151b; }

.record-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.record-card {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; text-decoration: none; color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.record-card:hover { border-color: var(--brand); box-shadow: 0 1px 6px rgba(56,112,216,.13); }
.record-thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; background: #e9edf3; aspect-ratio: 16 / 10; }
.record-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.record-thumbs img:only-child { grid-column: 1 / -1; }
.record-nothumb { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
[data-theme="dark"] .record-thumbs { background: #232a35; }
.record-body { padding: 10px 12px; }
.record-date { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.record-field { font-size: 13px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-field .rf-label { font-weight: 600; }

.field-pair { display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px; }
.fp-inputs { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
@media (max-width: 540px) { .fp-inputs { grid-template-columns: 1fr; } }
.detail-remove {
  flex: 0 0 auto;
  width: 38px;
  border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1;
}
.detail-remove:hover { color: var(--danger); border-color: var(--danger); }
#add-field { margin-top: 4px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.photo-grid img { width: 100%; border-radius: 8px; display: block; border: 1px solid var(--border); }

/* Add-record photo previews (accumulated thumbnails) */
.photo-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-preview { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* Add-record: photo blocks with per-photo details (Option B) */
.btn-sm { padding: 6px 12px; font-size: 13px; }
.photo-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.photo-block-head { position: relative; width: 110px; margin-bottom: 10px; }
.photo-block-head img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--border); }
.photo-block-head .photo-remove { top: 4px; right: 4px; width: 24px; height: 24px; }
.photo-details { margin-bottom: 6px; }

/* Record detail: photo + its details side by side */
.photo-entry { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.photo-entry-img { flex: 0 0 auto; }
.photo-entry-img img { width: 200px; max-width: 100%; border-radius: 8px; display: block; border: 1px solid var(--border); }
.photo-entry-details { flex: 1 1 220px; min-width: 200px; }
@media (max-width: 540px) { .photo-entry-img img { width: 100%; } }

/* Consent forms */
.consent-qr { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: #fff; }
.consent-actions { margin-top: 12px; }
.button-row form { margin: 0; }

/* Consent task badge (banner) + pending-tasks dashboard section */
.brand { margin-right: auto; }
.task-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
  text-decoration: none; line-height: 1; flex: 0 0 auto;
}
.task-badge.hidden { display: none; }

.pending-consents { border: 1px solid var(--brand); }
.pending-list { display: flex; flex-direction: column; gap: 8px; }
.pending-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap;
}
.pending-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pending-name { font-weight: 600; }
.pending-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }

.assign-form { margin: 0; display: flex; gap: 6px; align-items: center; }
.assign-form select { min-width: 140px; }

/* Consent list per-row actions (delete) */
.consent-actions-cell { white-space: nowrap; }
.inline-delete { display: inline; margin: 0; }
.link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* Consent cycle-linking (C3) */
.link-device-select { min-width: 160px; }
.consent-attached { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.consent-attached li { padding: 8px 0; border-top: 1px solid var(--border); }
.consent-attached li:first-child { border-top: 0; }

/* Tabs (consent forms Pending / Assigned) */
.tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; margin-bottom: -1px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel.hidden { display: none; }

/* Notifications bell + dropdown (banner) */
.notif { position: relative; flex: 0 0 auto; }
.notif-btn { background: none; border: 0; cursor: pointer; color: #d6dbe2; padding: 6px; border-radius: 6px; position: relative; line-height: 0; display: inline-flex; align-items: center; }
.notif-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }
.notif-btn svg { width: 20px; height: 20px; display: block; }
.notif-count { position: absolute; top: -1px; right: -1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.notif-count.hidden { display: none; }
.notif-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 300px; max-width: 80vw; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 34px rgba(0,0,0,0.30); z-index: 60; overflow: hidden; }
.notif-dropdown.hidden { display: none; }
.notif-head { padding: 10px 14px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-empty { padding: 16px 14px; color: var(--muted); font-size: 14px; text-align: center; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: rgba(56,112,216,0.06); }
.notif-item.unread { background: rgba(56,112,216,0.08); }
.notif-msg { font-size: 14px; }
.notif-when { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Account -- SMS notification settings */
.checkbox-field { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; cursor: pointer; }
.checkbox-field input[type="checkbox"],
.checkbox-field input[type="radio"] { width: auto; flex: 0 0 auto; margin: 0; }
.shuttle { display: flex; align-items: stretch; gap: 12px; margin-top: 6px; }
.shuttle-col { display: flex; flex-direction: column; gap: 4px; flex: 1 1 0; min-width: 0; }
.shuttle-cap { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.shuttle-controls { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.shuttle-btn { padding: 6px 12px; min-width: 44px; font-size: 16px; }
.device-scope-list { margin: 8px 0 4px 24px; padding-left: 12px; border-left: 2px solid var(--border); }

/* Clickable list boxes (action shuttle). Sized to show ~4 rows, then scroll. */
.listbox {
  list-style: none; margin: 0; padding: 4px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  height: 168px; overflow-y: auto; width: 100%;
}
.listbox-item {
  padding: 9px 11px; border-radius: 6px; font-size: 14px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.listbox-item + .listbox-item { margin-top: 2px; }
.listbox-item:hover { background: rgba(56, 112, 216, 0.08); }
.listbox-item.selected { background: var(--brand); color: #fff; }
.listbox-item.selected:hover { background: var(--brand); }

/* Small inline tag (e.g. an "admin" marker in the sign-in history). */
.pill {
  display: inline-block; font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 7px; border-radius: 999px; vertical-align: middle;
  background: var(--brand); color: #fff; text-transform: uppercase; letter-spacing: 0.03em;
}
