:root {
  --bg: #f3f5f8;
  --card: #fff;
  --text: #1d2733;
  --muted: #6b7785;
  --accent: #1f6fd1;
  --border: #dde3ea;
  --happy: #3aa565;
  --okay: #e8b33a;
  --sad: #d9534f;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); line-height: 1.45; }

/* ---------- Survey ---------- */
.card { max-width: 560px; margin: 48px auto; background: var(--card); border-radius: 12px;
        padding: 32px; box-shadow: 0 2px 12px rgba(0,0,0,.06); text-align: center; }
.card.narrow { max-width: 380px; }
.card h1 { margin: 0 0 8px; font-size: 1.6rem; }
.sub { color: var(--muted); margin: 0 0 4px; }
.summary { color: var(--muted); font-style: italic; margin: 0 0 16px; }

.ratings { border: 0; padding: 0; margin: 24px 0; display: flex; justify-content: center; gap: 24px; }
.ratings legend { width: 100%; margin-bottom: 16px; font-weight: 600; }
.ratings input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ratings label { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
                 border-radius: 10px; padding: 8px; transition: transform .12s; }
.ratings label img { width: 72px; height: 72px; }
.ratings label span { font-size: .9rem; color: var(--muted); }
.ratings label .on { display: none; }
/* Highlight on hover, keyboard focus, or selection */
.ratings label:hover .off,
.ratings input:focus-visible + label .off,
.ratings input:checked + label .off { display: none; }
.ratings label:hover .on,
.ratings input:focus-visible + label .on,
.ratings input:checked + label .on { display: inline; }
.ratings input:checked + label { transform: scale(1.08); }
.ratings input:checked + label span { color: var(--text); font-weight: 600; }
.ratings input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

.comments-label { display: block; text-align: left; margin-bottom: 6px; font-weight: 600; }
.comments-label em { font-weight: 400; color: var(--muted); }
textarea, input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
textarea { width: 100%; resize: vertical; }
button { margin-top: 16px; background: var(--accent); color: #fff; border: 0; border-radius: 6px;
         padding: 10px 22px; font: inherit; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }

.msg { padding: 12px 14px; border-radius: 6px; background: #eef2f6; }
.msg.ok { background: #e6f5ec; color: #1f6b3f; }
.msg.err { background: #fbeaea; color: #8a2a27; }

.login { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }

/* ---------- Results ---------- */
body.admin { padding: 0 24px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 20px 0; }
.topbar h1 { margin: 0; font-size: 1.5rem; }
.topbar a, .admin a { color: var(--accent); text-decoration: none; }
.admin h2 { font-size: 1.1rem; margin: 28px 0 10px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--card);
           padding: 16px; border-radius: 10px; border: 1px solid var(--border); }
.filters label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: 4px; }
.filters button { margin: 0; }
.filters .reset { align-self: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
        display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .85rem; }
.stat img { width: 32px; height: 32px; }
.stat .num { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat.happy { border-top: 4px solid var(--happy); }
.stat.okay  { border-top: 4px solid var(--okay); }
.stat.sad   { border-top: 4px solid var(--sad); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.r1 td:first-child { border-left: 4px solid var(--sad); }
tr.r2 td:first-child { border-left: 4px solid var(--okay); }
tr.r3 td:first-child { border-left: 4px solid var(--happy); }
.rating-cell img { width: 28px; height: 28px; }
.comments { max-width: 420px; white-space: normal; }
.muted { color: var(--muted); font-size: .82rem; }
.nowrap { white-space: nowrap; }

.bar { display: flex; height: 12px; width: 220px; max-width: 100%; border-radius: 6px; overflow: hidden; background: #eef1f4; }
.bar span { display: block; height: 100%; }
.b-happy { background: var(--happy); } .b-okay { background: var(--okay); } .b-sad { background: var(--sad); }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 16px; }

@media (max-width: 600px) {
  .card { margin: 16px; padding: 22px; }
  .ratings { gap: 10px; }
  .ratings label img { width: 56px; height: 56px; }
  body.admin { padding: 0 16px 32px; }
}
