:root {
  /* Olive / sage glass theme with lime accent — inspired by the wellness
     reference design. Keep firmware/room_panel/src/ui.cpp's palette in
     sync if you tweak these. */
  --bg: #6B7864;            /* dark sage olive */
  --panel: #4F5B4A;         /* darker olive — cards / buttons */
  --panel-2: #3D4738;       /* borders / hover */
  --text: #F1F5F9;          /* off-white */
  --muted: #B8C0AA;         /* muted olive — secondary text */
  --accent: #C6E54E;        /* bright lime */
  --on-accent: #0F172A;     /* dark text on lime */
  --ok: #C6E54E;            /* lime — same accent for consistency */
  --warn: #f59e0b;
  --err: #ef4444;           /* red — danger / stop */
  --pending: #f59e0b;
  --calling: #ef4444;
  --acked: #C6E54E;
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body { min-height: 100vh; padding: 16px; }

h1, h2, h3 { margin: 0 0 12px 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; color: var(--muted); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.topbar .right { display: flex; gap: 8px; align-items: center; }
.connection {
  font-size: 0.85rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.connection .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--err);
}
.connection.online .dot { background: var(--ok); }

.section { margin-bottom: 20px; }
.section .label {
  color: var(--muted); font-size: 0.95rem; margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--text);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: 1.1rem; font-weight: 600;
  cursor: pointer;
  min-height: 80px;
  transition: transform 80ms ease, background-color 120ms ease, border-color 120ms ease;
}
.btn.selected {
  border-color: var(--accent);
  background: var(--panel-2);
  box-shadow: 0 0 0 3px var(--accent);
  transform: scale(1.02);
}
/* Single-select coloured buttons (e.g. Funktion). The button has its own
   bg colour, so a single outer accent ring blends in for many palettes —
   layer an inset readable-colour ring + a thin white separator + the
   accent halo for guaranteed contrast on any --fn-fg / bg combination. */
.btn.fn-btn.selected {
  box-shadow:
    inset 0 0 0 4px var(--fn-fg, #fff),
    0 0 0 3px #fff,
    0 0 0 6px var(--accent);
  font-weight: 800;
  transform: scale(1.03);
}
/* Dim siblings once a single-select pick has been made. */
.btn.dim { opacity: 0.4; filter: saturate(0.7); }
/* Tap feedback must win over selection-scale while the finger is down. */
.btn:active { transform: scale(0.96); }
.btn.disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.btn-grid.fixed-3 { grid-template-columns: repeat(3, 1fr); }

.cta {
  width: 100%;
  padding: 28px 16px;
  font-size: 1.6rem;
  background: var(--accent);
  color: var(--on-accent);
}
.cta.danger { background: var(--err); color: #fff; }
.cta.ok     { background: var(--ok); color: var(--on-accent); }

.banner {
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
}
.banner.calling {
  background: var(--calling); color: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}
.banner.acked { background: var(--acked); color: var(--on-accent); }
.banner.moment { background: var(--warn); color: var(--on-accent); }
.banner.declined-all { background: #475569; color: var(--text); }
.banner .recipients {
  margin-top: 16px;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.tag.pending  { background: rgba(0,0,0,0.25); color: #fff; }
.tag.accepted { background: var(--ok); color: var(--on-accent); }
.tag.declined { background: rgba(255,255,255,0.15); color: #fff; text-decoration: line-through; opacity: 0.7; }
.banner h2 { color: inherit; opacity: 0.85; }
.banner .big { font-size: 2.4rem; font-weight: 800; margin: 8px 0; }
.banner .sub { font-size: 1.2rem; opacity: 0.9; }

/* New, cleaner hierarchy for the call banner: the WHO (recipient names)
   and the WHY (call reason) are the two big lines you should grasp at a
   glance. Everything else (caller room, state, time, accepter) collapses
   into a single small context line below. */
.banner .hero-who {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 6px 0 0 0;
  word-break: break-word;
}
.banner .hero-why {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 8px 0 14px 0;
  opacity: 0.95;
}
.banner .context-line {
  font-size: 1rem;
  opacity: 0.8;
  margin: 0 0 12px 0;
}

/* "From -> To" header at the top of every active-call banner. Names get
   the same prominence as the call reason (.big); the connecting verb
   stays smaller and slightly muted so the names pop. */
.banner .from-to {
  display: flex; flex-wrap: wrap;
  align-items: baseline; justify-content: center;
  gap: 10px;
  font-size: 1.6rem; font-weight: 800;
  margin-bottom: 6px;
}
.banner .from-to .verb {
  font-size: 1.05rem; font-weight: 500;
  opacity: 0.75;
}
.banner .from-to .name { white-space: nowrap; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.78; }
}

.calls-list { display: grid; gap: 12px; }
.call-card {
  background: var(--panel);
  border-left: 6px solid var(--pending);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px; align-items: center;
}
.call-card .meta { display: flex; flex-direction: column; gap: 4px; }
.call-card .room { font-size: 1.4rem; font-weight: 700; }
.call-card .func { font-size: 1.1rem; color: var(--muted); }
.call-card .age  { font-size: 0.9rem; color: var(--muted); }
.call-card.fresh { border-left-color: var(--err); }
.call-card .ack-btn {
  padding: 18px 28px; font-size: 1.2rem;
  background: var(--ok); color: var(--on-accent);
  border: none; border-radius: var(--radius); cursor: pointer; font-weight: 700;
}
.call-card .actions { display: flex; gap: 8px; }
.call-card .actions button {
  padding: 18px 22px; font-size: 1.1rem; font-weight: 700;
  border: none; border-radius: var(--radius); cursor: pointer;
}
.call-card .actions .accept { background: var(--ok); color: var(--on-accent); }
.call-card .actions .moment { background: var(--warn); color: var(--on-accent); }
.call-card .actions .decline { background: var(--err); color: #fff; }
.tag.momentarily { background: var(--warn); color: var(--on-accent); }
.call-card .recipients-mini {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.call-card .recipients-mini .tag { font-size: 0.78rem; padding: 2px 8px; }
.tag.pending-light { background: var(--panel-2); color: var(--text); }

.empty {
  text-align: center; padding: 40px;
  color: var(--muted); font-size: 1.2rem;
}

.role-card {
  display: block;
  padding: 28px;
  background: var(--panel); border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 1.2rem;
}
.role-card .h { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; color: var(--accent); }
.role-card .d { color: var(--muted); }

select, input[type="text"], input[type="number"] {
  background: var(--panel); color: var(--text);
  border: 2px solid var(--panel-2); border-radius: 10px;
  padding: 14px; font-size: 1rem; width: 100%;
}

table { width: 100%; border-collapse: collapse; }
table th, table td {
  padding: 10px; border-bottom: 1px solid var(--panel-2);
  text-align: left;
}
table th { color: var(--muted); font-weight: 600; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: 0; }

.btn-sm {
  padding: 8px 14px; min-height: 0;
  font-size: 0.95rem;
}

.toast {
  position: fixed; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2); padding: 14px 22px;
  border-radius: var(--radius);
  font-size: 1rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 200ms ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.tag {
  display: inline-block;
  padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); color: var(--text);
  font-size: 0.85rem;
}
