@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap");

:root {
  --bg: #f6f8f3;
  --surface: #ffffff;
  --border: #dfe7d4;
  --text: #0e2410;
  --text-dim: #516159;
  --text-faint: #82927f;
  --accent: #2a7a38;
  --accent-strong: #1f5c2a;
  --accent-contrast: #ffffff;
  --danger: #cc3b3b;
  --tile-projects: #2a7a38;
  --tile-sales: #2f6fed;
  --tile-ppa: #b07507;
  --tile-onsite: #2f5fc4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(14, 36, 16, 0.08);
  --shadow-lift: 0 8px 24px rgba(14, 36, 16, 0.14);
  color-scheme: light dark;
}
/* Day/Night: the toggle in the top bar sets data-theme on <html> (remembered on this device); with nothing chosen it
   follows the computer's own setting. */
:root[data-theme="dark"] {
  --bg: #16181a;
  --surface: #1f2224;
  --border: #2f3533;
  --text: #e8eee6;
  --text-dim: #a6b3a8;
  --text-faint: #75817a;
  --accent: #4caf5e;
  --accent-strong: #6cc47b;
  --accent-contrast: #0e2410;
  --shadow: none;
  --shadow-lift: 0 8px 24px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181a;
    --surface: #1f2224;
    --border: #2f3533;
    --text: #e8eee6;
    --text-dim: #a6b3a8;
    --text-faint: #75817a;
    --accent: #4caf5e;
    --accent-strong: #6cc47b;
    --accent-contrast: #0e2410;
    --shadow: none;
    --shadow-lift: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .logo-dark { display: none !important; } }
:root[data-theme="dark"] .logo-light, :root[data-theme="light"] .logo-dark { display: none !important; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Poppins", system-ui, sans-serif; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 500; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.link { border: 0; background: none; color: var(--text-dim); padding: 6px 8px; white-space: nowrap; }
.btn.link:hover { color: var(--text); }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.top img.logo { height: 30px; display: block; }
/* Top of the bar: Day/Night and the profile sit exactly where they do in every Generations app (14px down, 24px in). */
.who { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; align-self: flex-start; }
/* Day/Night and the profile: the same two round buttons, in the same order, as every Generations app. */
.round-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); display: grid; place-items: center; cursor: pointer; padding: 0; }
.round-btn:hover { color: var(--text); background: var(--bg); }
.profile { position: relative; }
.profile-btn { background: var(--bg); color: var(--text); font-weight: 600; font-size: 14px; }
.profile-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.profile-btn:has(img) { overflow: hidden; }
.profile-menu { position: absolute; right: 0; top: 42px; z-index: 40; min-width: 210px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lift); }
.profile-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.profile-email { font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.profile-menu hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.profile-menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 6px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--danger); }
.profile-menu button:hover { background: var(--bg); }
/* Notifications on this device (common.js): a plain line in the menu, and a short note when there's something to say. */
.profile-menu .push-btn { color: var(--text); }
.profile-menu .push-btn:disabled { opacity: .5; cursor: default; }
.profile-menu .push-note { margin: 2px 6px 6px; font-size: 12px; line-height: 1.45; color: var(--text-dim); max-width: 240px; }
.profile-menu .push-note[hidden] { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--border); display: grid; place-items: center; font-weight: 600; color: var(--text-dim); flex: none; }

main.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 600; margin: 0; }
.sub { color: var(--text-dim); margin: 0 0 24px; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 22px; min-height: 150px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--tile-color, var(--accent)); }
.tile .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--tile-color, var(--accent)); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 18px; margin-bottom: 8px; }
.tile .name { font-size: 18px; font-weight: 600; }
.tile .desc { color: var(--text-dim); font-size: 14px; flex: 1; }
.tile[data-app="projects"] { --tile-color: var(--tile-projects); }
.tile[data-app="sales"] { --tile-color: var(--tile-sales); }
.tile[data-app="ppa"] { --tile-color: var(--tile-ppa); }
.tile[data-app="onsite"] { --tile-color: var(--tile-onsite); }

.role { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-strong); text-transform: capitalize; }
.role.viewer { background: color-mix(in srgb, var(--text-faint) 20%, transparent); color: var(--text-dim); }
.role.owner { background: color-mix(in srgb, var(--tile-ppa) 18%, transparent); color: var(--tile-ppa); }
.role.off { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.empty { padding: 32px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-dim); text-align: center; }

/* Members */
.members { margin-top: 48px; }
.members-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.members-head .hint { margin: 0; }
.members-head input[type=search] { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 220px; }
.table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 2fr) repeat(var(--apps, 3), minmax(90px, 1fr)); align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row.head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); background: color-mix(in srgb, var(--bg) 60%, var(--surface)); }
button.row { width: 100%; text-align: left; border: 0; border-top: 1px solid var(--border); background: none; cursor: pointer; }
button.row:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.row.inactive { opacity: .55; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .text { min-width: 0; }
.person .nm, .person .em { display: block; }
.person .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .em { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash { color: var(--text-faint); }

/* Member dialog */
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lift); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog form { padding: 24px; display: grid; gap: 16px; }
label.field, div.photo-field { display: grid; gap: 4px; font-size: 14px; color: var(--text-dim); }
label.field input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0; display: grid; gap: 10px; }
legend { padding: 0 6px; font-size: 14px; color: var(--text-dim); }
.app-access { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-access select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); min-width: 140px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.actions .right { display: flex; gap: 8px; margin-left: auto; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; margin: 0; }
.hint { color: var(--text-faint); font-size: 13px; margin: 0; }

/* Login and plain pages */
body.plain { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.plain-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 36px 32px; text-align: center; box-shadow: var(--shadow-lift); }
.plain-logo { height: 36px; margin-bottom: 20px; }
#gsi { display: flex; justify-content: center; margin: 20px 0 8px; min-height: 44px; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  main.wrap { padding: 24px 16px 48px; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .row.head { display: none; }
  .row .cell::before { content: attr(data-app) ": "; color: var(--text-faint); font-size: 13px; }
}

/* Top bar nav and the Admin page */
.top-left { display: flex; align-items: center; gap: 28px; min-width: 0; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--text-dim); text-decoration: none; font-weight: 500; font-size: 14px; padding: 6px 12px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.nav a.on { color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { margin-bottom: 20px; }
.banner { margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; font-size: 14px; color: var(--text-dim); background: color-mix(in srgb, var(--tile-ppa) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tile-ppa) 30%, var(--border)); }
.btn.small { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.row.admin-row { grid-template-columns: minmax(0, 2fr) repeat(var(--apps, 3), minmax(80px, 1fr)) minmax(110px, 1.1fr) 104px; }
.row.member { cursor: pointer; }
.row.member:hover, .row.member:focus-visible { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); outline: none; }
.status { display: grid; font-size: 14px; }
.status small { color: var(--text-faint); font-size: 12px; }
.status.dim { color: var(--text-faint); }
.invite-body { padding: 24px; display: grid; gap: 14px; }
.invite-body .sub { margin: 0; }
label.field textarea { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: 13px/1.5 ui-monospace, "SF Mono", monospace; resize: vertical; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
@media (max-width: 640px) {
  .top-left { gap: 12px; }
  .top-left .logo { height: 22px; }
  .row.admin-row { grid-template-columns: 1fr; }
  .actions .right { flex-wrap: wrap; }
}
.person .nm:has(.nm-text) { display: flex; align-items: center; gap: 6px; min-width: 0; }
.person .nm-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.person .nm .role { flex: none; }

/* App cards on the home page: the Sales login card's look, one colour per app */
.app-card[data-app="sales"] { --app-from: #b3e577; --app-to: #3faa47; --app-ink: #10230a; }
.app-card[data-app="projects"] { --app-from: #9be8dc; --app-to: #1f9a8a; --app-ink: #062a25; }
.app-card[data-app="ppa"] { --app-from: #ffe08a; --app-to: #f0932b; --app-ink: #2e1a03; }
.app-card[data-app="onsite"] { --app-from: #a9c8ff; --app-to: #3b6fe0; --app-ink: #0a1a3a; }
.tiles:has(.app-card) { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.app-card {
  --app-from: #b3e577; --app-to: #3faa47; --app-ink: #10230a;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 34px 30px 26px; border-radius: 22px;
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--app-to) 14%, transparent), transparent 70%), var(--surface);
  border: 1px solid var(--border); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.app-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--app-from), var(--app-to)); }
.app-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--app-to) 55%, var(--border)); box-shadow: 0 28px 70px rgba(0, 0, 0, 0.26); }
.app-wordmark { height: 18px; width: auto; margin-bottom: 22px; }
.app-card h2 { font-size: 22px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.app-card p { margin: 0 0 24px; color: var(--text-dim); font-size: 14px; flex: 1; }
.app-open {
  display: block; width: 100%; padding: 13px 16px; border-radius: 999px;
  background: linear-gradient(135deg, var(--app-from), var(--app-to)); color: var(--app-ink);
  font-weight: 600; text-decoration: none; transition: filter .15s;
}
.app-open:hover { filter: brightness(1.06); }
.app-open:focus-visible { outline: 3px solid color-mix(in srgb, var(--app-to) 50%, transparent); outline-offset: 3px; }
.app-access { margin-top: 14px; font-size: 12px; color: var(--text-faint); }
.greeting { text-align: center; }
.greeting .hq-name { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); margin: 0 0 6px; }
@media (max-width: 640px) {
  .top img.logo { height: 16px; }
  .top-left { gap: 8px; }
  .nav a { padding: 6px 8px; }
}
/* Taller cards, green wordmark in the top bar */
.app-card { padding: 48px 32px 34px; min-height: 340px; }
.app-wordmark { margin-bottom: 30px; }
.app-card p { margin-bottom: 32px; font-weight: 300; font-size: 13.5px; color: var(--text-faint); }
.top img.logo { height: 24px; }
@media (max-width: 640px) { .top img.logo { height: 16px; } }
/* Admin dialog: block / delete, and the result notice */
.actions .left { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.warn { color: var(--tile-ppa); border-color: color-mix(in srgb, var(--tile-ppa) 45%, var(--border)); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: var(--danger); }
.banner.ok { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); color: var(--text); }
.role.superuser { background: color-mix(in srgb, var(--tile-ppa) 18%, transparent); color: var(--tile-ppa); }
.role.adminlevel { background: color-mix(in srgb, var(--tile-projects) 18%, transparent); color: var(--tile-projects); }
.row.member.locked { cursor: default; }
label.field select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }

/* Admin tabs and the App rules grid */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 20px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 500; color: var(--text-dim); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.app-switch { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.app-switch button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 16px; font-weight: 500; cursor: pointer; color: var(--text-dim); }
.app-switch button.on { color: var(--app-ink, #10230a); border-color: transparent; background: linear-gradient(135deg, var(--app-from), var(--app-to)); }
.app-switch [data-app="projects"] { --app-from: #9be8dc; --app-to: #1f9a8a; --app-ink: #062a25; }
.app-switch [data-app="sales"] { --app-from: #b3e577; --app-to: #3faa47; --app-ink: #10230a; }
.app-switch [data-app="ppa"] { --app-from: #ffe08a; --app-to: #f0932b; --app-ink: #2e1a03; }
.app-switch [data-app="onsite"] { --app-from: #a9c8ff; --app-to: #3b6fe0; --app-ink: #0a1a3a; }
.row.rules-row { grid-template-columns: minmax(0, 1fr) repeat(3, 90px); }
.row.rules-row > span:not(.perm), .rules-row .tick { text-align: center; justify-self: center; }
.rules-row .perm { font-size: 14px; }
.tick { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 30px; cursor: pointer; }
.tick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.tick .changed { position: absolute; top: -2px; right: 2px; color: var(--tile-ppa); font-size: 18px; line-height: 1; }
.rules-actions { margin-top: 16px; }
.rules-actions .right { align-items: center; }
@media (max-width: 640px) {
  .row.rules-row { grid-template-columns: minmax(0, 1fr) repeat(3, 52px); }
  .row.rules-row.head span:not(:first-child) { font-size: 10px; }
  .rules-row .tick::before { content: none; }
}
@media (max-width: 640px) { .row.rules-row.head { display: grid; } }
.row.rules-row.head > span:first-child { text-align: left; justify-self: start; }

/* User types grid: any number of type columns */
.rules-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.row.rules-row { grid-template-columns: minmax(180px, 1fr) repeat(var(--types, 3), minmax(84px, 110px)); }
.rules-table { overflow-x: auto; }
.type-head { border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border)); background: none; color: var(--text); border-radius: 6px; padding: 3px 8px; font: inherit; font-size: 12px; text-transform: none; letter-spacing: 0; cursor: pointer; justify-self: center; }
.type-head:hover { border-style: solid; border-color: var(--accent); }
@media (max-width: 640px) { .row.rules-row { grid-template-columns: minmax(140px, 1fr) repeat(var(--types, 3), 60px); } }

/* Activity log */
.activity-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.activity-filters select, .activity-filters input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.activity-filters input { flex: 1; min-width: 180px; }
.row.activity-row { grid-template-columns: 70px minmax(140px, 1.1fr) 110px minmax(0, 2.4fr); align-items: start; font-size: 14px; }
.row.activity-day { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); background: color-mix(in srgb, var(--bg) 60%, var(--surface)); padding: 8px 16px; }
.activity-row small { display: block; color: var(--text-faint); font-size: 12px; }
.a-time { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.a-who { overflow-wrap: anywhere; }
.app-chip { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--text-faint) 18%, transparent); color: var(--text-dim); }
.app-chip[data-app="projects"] { background: color-mix(in srgb, #1f9a8a 18%, transparent); color: #1f9a8a; }
.app-chip[data-app="sales"] { background: color-mix(in srgb, #3faa47 18%, transparent); color: #3faa47; }
.app-chip[data-app="ppa"] { background: color-mix(in srgb, #f0932b 18%, transparent); color: #d97a0f; }
.activity-more { text-align: center; margin-top: 12px; }
@media (max-width: 640px) {
  .row.activity-row { grid-template-columns: 60px 1fr; }
  .row.activity-row .a-app, .row.activity-row .a-what { grid-column: 2; }
}
/* Four app cards line up as one row of four on wide screens, two by two on medium, stacked on phones (never 3 + 1). */
.tiles:has(> .app-slot:nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1240px) {
  main.wrap:has(> .tiles > .app-slot:nth-child(4):last-child) { max-width: 1240px; }
  .tiles:has(> .app-slot:nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles:has(> .app-slot:nth-child(4):last-child) .app-card { padding-left: 26px; padding-right: 26px; }
}
@media (max-width: 640px) {
  .tiles:has(> .app-slot:nth-child(4):last-child) { grid-template-columns: minmax(0, 1fr); }
}

/* Home page: the tiles sit in the middle of the page, and the greeting in the middle of the space above them. */
body.home { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body.home > main.wrap { flex: 1; width: 100%; display: flex; flex-direction: column; padding-top: 24px; padding-bottom: 40px; }
body.home .greeting { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 16px 0 32px; }
body.home > main.wrap::after { content: ''; flex: 1; }

/* Each tile with its "Live … Dashboard" link underneath (empty space kept so cards line up). */
.app-slot { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.app-slot[data-app="sales"] { --app-from: #b3e577; --app-to: #3faa47; }
.app-slot[data-app="projects"] { --app-from: #9be8dc; --app-to: #1f9a8a; }
.app-slot[data-app="ppa"] { --app-from: #ffe08a; --app-to: #f0932b; }
.app-slot[data-app="onsite"] { --app-from: #a9c8ff; --app-to: #3b6fe0; }
.app-slot > .app-card { flex: 1; }
.app-live { min-height: 40px; display: flex; justify-content: center; align-items: center; }
.app-live a { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text-faint); transition: color .15s; }
.app-live a:hover { color: var(--text); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #e5484d; animation: live-pulse 2s infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .55); } 70% { box-shadow: 0 0 0 7px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* TV screens page */
.tv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tv-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.tv-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tv-card-head h2 { margin: 0; font-size: 18px; }
.tv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tv-chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-strong); }
.tv-address { border: 1px dashed var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; background: color-mix(in srgb, var(--bg) 50%, var(--surface)); }
.tv-type { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.tv-address code { font: 600 20px/1.3 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; overflow-wrap: anywhere; }
.tv-actions { display: flex; flex-wrap: wrap; gap: 8px; } /* wraps onto a second line rather than running off the card */
.tv-panel-picks { display: grid; gap: 8px; }
.tv-group { display: grid; gap: 8px; padding: 10px 12px; border-radius: 10px; border-left: 3px solid var(--tv-colour, var(--accent)); background: color-mix(in srgb, var(--tv-colour, var(--accent)) 6%, transparent); }
.tv-group[data-app="projects"] { --tv-colour: #1f9a8a; }
.tv-group[data-app="sales"] { --tv-colour: #3faa47; }
.tv-group[data-app="ppa"] { --tv-colour: #f0932b; }
.tv-group-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }

/* TV screens: room under Add a TV, the live preview beside the choices, Remove on each card */
#tv-notice { margin-top: 16px; }
.tv-list { margin-top: 16px; }
.tv-dialog { width: min(980px, calc(100vw - 32px)); }
.tv-form { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px 24px; align-items: start; }
.tv-form-main { display: grid; gap: 16px; }
.tv-form-foot { grid-column: 1 / -1; display: grid; gap: 12px; }
.tv-preview { display: grid; gap: 8px; position: sticky; top: 0; }
.tv-preview-screen { position: relative; width: 420px; height: 236px; overflow: hidden; border-radius: 10px; border: 1px solid var(--border); background: #0c1310; }
.tv-preview-screen iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; transform: scale(0.21875); transform-origin: 0 0; pointer-events: none; }
.tv-preview .hint { margin: 0; }
@media (max-width: 860px) {
  .tv-form { grid-template-columns: 1fr; }
  .tv-preview { display: none; }
}
.tv-preview-wait { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; color: var(--text-dim); background: #0c1310; }


/* Home page: Ava's briefing for today and what needs your attention, under the tiles. */
.ava-today { width: 100%; max-width: 760px; margin: 28px auto 0; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.ava-today[hidden] { display: none; }
.ava-today-head { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; border-radius: 10px; }
.ava-today-head::-webkit-details-marker { display: none; }
.ava-today-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.ava-today[open] .ava-today-head { margin-bottom: 10px; }
.ava-today-count { margin-left: auto; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #b45309; background: color-mix(in srgb, #e0a020 18%, transparent); }
.ava-today-count[hidden] { display: none; }
/* Open, the big number in the card says it: the pill is for when it's folded away. */
.ava-today[open] .ava-today-count { display: none; }
.ava-today-chev { flex: 0 0 auto; width: 9px; height: 9px; margin: 0 4px 3px auto; border-right: 2px solid var(--text-dim); border-bottom: 2px solid var(--text-dim); transform: rotate(45deg); transition: transform .2s; }
.ava-today-count:not([hidden]) + .ava-today-chev { margin-left: 8px; }
.ava-today[open] .ava-today-chev { transform: rotate(225deg); margin-bottom: -3px; }
.ava-today-head img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: 50% 18%; border: 2px solid var(--accent); }
.ava-today-head strong { display: block; font-size: 15px; }
.ava-today-head span { font-size: 12.5px; color: var(--text-dim); }
.ava-today-text { margin: 0 0 14px; line-height: 1.55; color: var(--text-dim); font-size: 14px; }
.ava-today-text[hidden] { display: none; }
/* At a glance: a big number, what it means, and the urgent count as a chip. */
.ava-sum { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin: 4px 0 8px; }
.ava-sum[hidden] { display: none; }
.ava-sum-n { font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.ava-sum-label { font-size: 15px; color: var(--text-dim); }
.ava-sum-chips { display: inline-flex; gap: 6px; margin-left: auto; }
.ava-sum .chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--text-dim); background: color-mix(in srgb, var(--text-faint) 16%, transparent); }
.ava-sum .chip.urgent { color: #e5605b; background: color-mix(in srgb, #d9534f 16%, transparent); }
.ava-sum .chip.attention { color: #d99a1e; background: color-mix(in srgb, #e0a020 16%, transparent); }
.ava-alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ava-alerts li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; }
.ava-alerts b { font-weight: 500; }
.ava-alerts li.none { color: var(--text-dim); justify-content: center; }
.ava-alerts .dot { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: #7f8e8c; }
.ava-alerts .sev-urgent .dot { background: #d9534f; }
.ava-alerts .sev-attention .dot { background: #e0a020; }
.ava-alerts a { flex: 1; min-width: 0; color: var(--text); text-decoration: none; }
.ava-alerts a:hover b { text-decoration: underline; }
.ava-alerts a span { display: block; color: var(--text-faint); font-size: 12.5px; margin-top: 3px; }
.ava-alerts em { flex: 0 0 auto; font-style: normal; font-size: 11px; letter-spacing: .4px; text-transform: uppercase; color: var(--text-faint); margin-top: 3px; }
.ava-alert-done { flex: 0 0 auto; width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 50%; background: none; color: var(--text-dim); cursor: pointer; }
.ava-alert-done:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Admin: a member's photo, with Upload / Change and Remove. */
.photo-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.photo-preview .avatar { width: 44px; height: 44px; font-size: 17px; }

/* TV screens: Ava ticked on a TV. */
.tv-ava-pick { margin-top: 14px; font-weight: 600; }
.tv-chip.tv-chip-ava { background: color-mix(in srgb, #e8841a 18%, transparent); color: #e8841a; }
.tv-ava-btn.on { border-color: #e8841a; color: #e8841a; }
.tv-ava-btn.on:hover { background: color-mix(in srgb, #e8841a 14%, transparent); }

/* Today's quote under "Kia ora" on the home page. */
.greeting .quote { max-width: 620px; margin: 22px auto 0; font-size: 17px; line-height: 1.5; font-style: italic; color: var(--text); }
.greeting .quote .q::before { content: "\201C"; }
.greeting .quote .q::after { content: "\201D"; }

/* The profile menu, tidied: who you are at the top, then each thing on its own roomy line with an icon. Comes last so it
   wins over the plainer rules above. */
.profile-menu { width: 268px; min-width: 0; padding: 6px; border-radius: 16px; background: var(--surface); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border); border: none; }
.profile-menu .profile-name { padding: 10px 12px 0; font-size: 15px; }
.profile-menu .profile-email { padding: 2px 12px 10px; font-size: 13px; }
.profile-menu hr { margin: 0 6px 4px; }
.profile-menu button { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 14.5px; font-weight: 500; }
.profile-menu button::before { content: ""; flex: 0 0 auto; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.profile-menu .push-btn { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9'/%3E%3Cpath d='M10.3 21a1.94 1.94 0 0 0 3.4 0'/%3E%3C/svg%3E"); }
#signout { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='M16 17l5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E"); }
.profile-menu .push-note { margin: 0 12px 8px 42px; max-width: none; font-size: 12.5px; }
.ava-today-count { white-space: nowrap; }

/* On a phone the header shows just the Generations knot, not the full wordmark, so there's room for the rest. */
.top img.logo-knot { display: none; }
@media (max-width: 640px) {
  .top img.logo { display: none !important; }
  .top img.logo-knot { display: block; width: 30px; height: 30px; }
}

/* Your access, in the profile menu: one line per app. */
.profile-access { margin: 0 6px 6px; padding: 8px 6px 4px; border-top: 1px solid var(--border); }
.profile-access-label { padding: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--text-faint); }
.profile-access-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 13.5px; color: var(--text); }
.profile-access-row b { font-weight: 500; color: var(--text-dim); }

/* Each tile's own coloured Generations knot, centred above its name (no wordmark). On a computer the small corner knot
   (alive.js) isn't needed as well; on a phone that one becomes the row's icon instead. */
.app-mark { display: block; width: 48px; height: 48px; margin: 0 auto 18px; object-fit: contain; transition: transform 1.2s cubic-bezier(.2, .8, .2, 1); }
/* It turns when you point at the tile, as the corner knot used to. */
.app-card:hover .app-mark { transform: rotate(180deg) scale(1.08); }
@media (prefers-reduced-motion: reduce) { .app-card:hover .app-mark { transform: none; } }
@media (min-width: 641px) { .app-knot { display: none; } }

/* Each tile's name in its app's colour (Projects teal, Sales green, PPA amber, On-site blue): a solid colour by day,
   the same gradient as its Open button by night. */
.app-card h2 { color: var(--app-to); }
:root[data-theme="dark"] .app-card h2 {
  background: linear-gradient(135deg, var(--app-from), var(--app-to)); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-card h2 {
    background: linear-gradient(135deg, var(--app-from), var(--app-to)); -webkit-background-clip: text; background-clip: text; color: transparent; }
}

/* "Opening Projects…": the app's own knot, turning while the app opens. */
.launch-knot { display: block; width: 72px; height: 72px; margin: 4px auto 18px; animation: launch-spin 1.4s cubic-bezier(.5, .1, .5, .9) infinite; }
@keyframes launch-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .launch-knot { animation-duration: 4s; } }
