:root {
  --bg: #faf5ef;
  --panel: #ffffff;
  --line: #ead8c8;
  --ink: #2d2520;
  --muted: #75695f;
  --orange: #f47b20;
  --coral: #f36c5a;
  --sand: #f6e7d8;
  --success: #287a54;
  --danger: #a33a31;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: inherit; }
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 245, 239, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.top {
  max-width: 1440px;
  margin: auto;
  padding: 14px 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { width: 116px; height: auto; display: block; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 8px; }
.sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
main { max-width: 1440px; margin: auto; padding: 18px 22px 34px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-panel { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: 0 16px 42px rgba(28,40,36,.10); }
.field { display: grid; gap: 6px; margin-bottom: 12px; min-width: 0; }
label { font-size: 11px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
input, select, button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  min-height: 38px;
  padding: 0 10px;
  font: inherit;
  font-size: 14px;
  max-width: 100%;
}
select { width: 100%; min-width: 0; }
button { cursor: pointer; font-weight: 800; }
button:disabled { cursor: not-allowed; opacity: .55; }
.button-link { display: inline-grid; place-items: center; text-decoration: none; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; font-weight: 800; }
.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.ghost { background: transparent; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.notice { min-height: 20px; font-size: 13px; color: var(--danger); margin-top: 10px; }
.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: 1fr 1fr; }
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(28,40,36,.07);
  min-width: 0;
}
.card { display: grid; gap: 8px; }
.dashboard-card { min-height: 128px; grid-template-rows: 1fr auto; align-items: stretch; }
.dashboard-card-title { min-height: 40px; display: flex; align-items: flex-start; margin-bottom: 8px; }
.meta { font-size: 12px; color: var(--muted); line-height: 1.35; }
.question { font-size: 12px; color: var(--muted); line-height: 1.35; margin-bottom: 10px; }
.value { font-size: 28px; font-weight: 850; line-height: 1; }
.metric { background: var(--orange); color: #fff; border-color: var(--orange); min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; }
.metric .meta, .metric label { color: rgba(255,255,255,.88); }
.filters { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; align-items: end; }
.filters .field { margin-bottom: 0; }
.filters select { font-size: 12px; padding: 0 7px; }
.admin-form { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)) auto; gap: 12px; align-items: end; }
.admin-form .field { margin-bottom: 0; }
.compact-admin-form { grid-template-columns: minmax(130px, 180px) minmax(260px, 1fr) minmax(120px, 150px) auto auto; }
.dashboard-admin-form { grid-template-columns: repeat(7, minmax(120px, 1fr)); }
.dashboard-description { grid-column: span 3; }
.assignment-form { grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) repeat(4, minmax(110px, 150px)) auto; }
.user-actions { justify-content: flex-start; }
.question-controls { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(150px, 180px) minmax(130px, 160px); gap: 12px; align-items: end; margin: 14px 0 0; }
.question-controls .field { margin-bottom: 0; }
.wide { grid-template-columns: 1fr; }
.panel-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.chart { display: grid; gap: 8px; }
.summary-charts .panel { display: flex; flex-direction: column; }
.summary-charts .chart { height: 360px; align-content: center; overflow-y: auto; padding-right: 4px; }
.summary-charts #groupChart { overflow: visible; }
.summary-charts #countryChart { align-content: start; padding-top: 8px; }
.donut-wrap { display: flex; justify-content: center; align-items: center; min-height: 300px; }
.summary-charts .donut-wrap { min-height: 100%; height: 100%; }
.donut-svg { width: min(520px, 100%); height: auto; overflow: visible; }
.donut-label { font-size: 10px; font-weight: 850; fill: var(--ink); }
.donut-sub { font-size: 9px; font-weight: 700; fill: var(--muted); }
.donut-line { stroke: #7f8a86; stroke-width: 1.1; fill: none; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(120px, 2fr) 80px; gap: 10px; align-items: center; min-height: 28px; }
.bar-label { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: var(--sand); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; background: var(--orange); border-radius: 999px; }
.bar-value { text-align: right; font-size: 12px; font-weight: 800; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); background: #fafbf9; }
.sig-mark { display: block; color: var(--coral); font-size: 10px; font-weight: 850; line-height: 1.1; margin-top: 2px; }
.sig-cell { cursor: pointer; position: relative; }
.sig-cell:hover { background: #fff7e8; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tab { border-radius: 999px; min-height: 32px; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.banner th.group { background: #edf4f1; color: #26413d; text-align: center; }
.banner .base td { font-weight: 800; background: #fff; }
.banner .banner-letters td { font-weight: 800; color: var(--muted); background: #fafbf9; }
.banner .section td { background: #fafbf9; font-weight: 800; }
.foot { font-size: 11px; color: var(--muted); margin-top: 12px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,29,27,.42); z-index: 40; display: none; align-items: center; justify-content: center; padding: 18px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border: 1px solid var(--line); border-radius: 8px; max-width: 920px; width: min(920px,96vw); max-height: 82vh; overflow: auto; box-shadow: 0 24px 70px rgba(15,20,18,.26); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; margin: 0; }
.modal-body { padding: 16px; font-size: 13px; line-height: 1.45; }
.modal-body table { margin-top: 10px; min-width: 860px; }
.modal-close { min-width: 36px; padding: 0; }
.role-modal { max-width: 420px; }
.empty { text-align: center; border: 1px dashed var(--line); border-radius: 8px; padding: 24px; color: var(--muted); }
@media (max-width: 900px) {
  .top { grid-template-columns: 1fr; }
  .kpis, .two { grid-template-columns: 1fr; }
  main { padding: 14px; }
  .filters, .question-controls, .admin-form, .compact-admin-form, .dashboard-admin-form, .assignment-form { grid-template-columns: 1fr; }
  .dashboard-description { grid-column: auto; }
  .summary-charts .chart { height: 320px; }
  .bar-row { grid-template-columns: 1fr; gap: 5px; }
  .bar-value { text-align: left; }
}
