:root {
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f8fafc;
    --surface: #ffffff;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --sidebar: #0f172a;
    --sidebar-muted: #94a3b8;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
}

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

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
}

.req { color: #dc2626; }

.card { border: 1px solid var(--line); border-radius: var(--radius); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 18px; }

.public-body { background: var(--surface); }
.public-container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.public-narrow { max-width: 760px; }

.public-header {
    position: sticky; top: 0; z-index: 1030;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--line);
}
.public-header__inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.public-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.public-brand:hover { text-decoration: none; }
.public-brand__mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: #fff; font-weight: 700; }
.public-header__nav { display: flex; align-items: center; gap: 8px; }
.public-header__link { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.public-header__link:hover { color: var(--ink); text-decoration: none; background: var(--bg); }
.public-header__link--solid { background: var(--ink); color: #fff; }
.public-header__link--solid:hover { background: #1e293b; color: #fff; }

.hero {
    background: linear-gradient(135deg, var(--hero-from, #0f172a) 0%, var(--hero-to, #334155) 100%);
    color: #fff; padding: 76px 0;
}
.hero__inner { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center; }
.hero__badge { display: inline-block; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); color: #e2e8f0; padding: 6px 14px; border-radius: 999px; font-size: .82rem; font-weight: 600; margin-bottom: 18px; }
.hero__title { font-size: 2.6rem; font-weight: 800; line-height: 1.12; margin: 0 0 16px; }
.hero__lead { font-size: 1.1rem; color: #cbd5e1; margin-bottom: 26px; max-width: 40em; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }

.counter-card { background: #fff; color: var(--ink); border-radius: 16px; padding: 28px; box-shadow: 0 30px 60px -34px rgba(0,0,0,.55); }
.counter-card__label { display: block; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.counter-card__value { display: block; font-size: 3rem; font-weight: 800; line-height: 1.1; color: var(--primary); }
.counter-card__progress { height: 10px; background: #eff6ff; border-radius: 999px; overflow: hidden; margin: 14px 0 8px; }
.counter-card__bar { height: 100%; background: linear-gradient(90deg, var(--primary), #0ea5e9); }
.counter-card__meta { display: block; color: var(--muted); font-size: .85rem; }

.section { padding: 64px 0; }
.section--muted { background: var(--bg); border-top: 1px solid var(--line); }
.section__title { font-size: 1.7rem; font-weight: 800; margin-bottom: 16px; }

.sign-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 32px; align-items: start; }
.sign-form-wrap { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: 0 24px 48px -38px rgba(15,23,42,.3); }
.sign-form .form-label { font-weight: 600; }
.field-error { color: #dc2626; font-size: .85rem; margin-top: 4px; }
.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.choice-item:hover { border-color: var(--primary); }

.rating-group { display: flex; flex-wrap: wrap; gap: 8px; }
.rating-option input { display: none; }
.rating-option span { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; transition: all .15s ease; }
.rating-option input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); transform: translateY(-2px); }

.ai-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ai-recorder__status { font-size: .85rem; color: var(--muted); flex-basis: 100%; }
.ai-tools.is-recording .ai-recorder__toggle { background: #dc2626; border-color: #dc2626; color: #fff; }
.ai-tools.is-busy .btn { opacity: .6; pointer-events: none; }

.ai-output { white-space: normal; line-height: 1.7; color: #334155; }
.report-insights { line-height: 1.7; color: #334155; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 18px; }

.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-state__icon { font-size: 2.4rem; display: block; margin-bottom: 12px; color: var(--primary); opacity: .7; }

img.brand-logo { background: #fff; object-fit: contain; padding: 3px; }
.logo-preview { display: inline-flex; align-items: center; justify-content: center; height: 56px; min-width: 56px; padding: 6px 10px; background: var(--secondary); border-radius: 10px; }
.logo-preview img { max-height: 44px; max-width: 180px; object-fit: contain; }
.logo-preview__initial { color: #fff; font-weight: 800; font-size: 1.4rem; }

.poll-block { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }

.sign-aside { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 20px; }
.supporters-card, .results-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.supporters-card__title, .results-card__title { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }
.supporters-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.supporter { display: flex; align-items: center; gap: 12px; }
.supporter__avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: #eff6ff; color: var(--primary); font-weight: 800; }
.supporter__name { font-weight: 600; }

.poll-result { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.poll-result:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.poll-result__q { font-weight: 600; margin-bottom: 8px; }
.poll-result__total { color: var(--muted); font-size: .8rem; margin: 6px 0 0; }

.info-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.record-list { list-style: none; margin: 0; padding: 0; }
.record-list__item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.record-list__item:last-child { border-bottom: 0; }
.record-list__ref { font-weight: 700; letter-spacing: 1px; }
.record-list__date { color: var(--muted); margin-left: 12px; }
.record-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.record-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; }
.answer-block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.answer-block:last-child { border-bottom: 0; }
.answer-block__q { font-weight: 600; margin-bottom: 4px; }
.answer-block__a { margin: 0; color: #334155; }

.thanks-card { max-width: 620px; margin: 0 auto; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 46px 36px; box-shadow: 0 24px 48px -38px rgba(15,23,42,.3); }
.thanks-card__icon { width: 68px; height: 68px; margin: 0 auto 18px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #ecfdf5; color: #047857; font-size: 2rem; }
.thanks-card__title { font-size: 1.7rem; font-weight: 800; }
.thanks-card__lead { color: #334155; font-size: 1.05rem; }
.thanks-card__buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.public-footer { background: var(--ink); color: var(--sidebar-muted); padding: 24px 0; }
.public-footer__inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.public-footer .fw-semibold { color: #fff; }

.app-body { background: var(--bg); }
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: 248px; background: var(--sidebar); color: #e2e8f0; display: flex; flex-direction: column; padding: 20px 14px; position: fixed; inset: 0 auto 0 0; z-index: 1040; }
.app-sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.app-sidebar__mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; background: var(--primary); color: #fff; font-weight: 700; }
.app-sidebar__name { font-weight: 700; color: #fff; }
.app-nav { display: flex; flex-direction: column; gap: 4px; }
.app-nav__link { display: flex; align-items: center; padding: 10px 12px; border-radius: 9px; color: var(--sidebar-muted); font-weight: 500; }
.app-nav__link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.app-nav__link.is-active { background: var(--primary); color: #fff; }
.app-nav__icon { display: inline-block; width: 22px; text-align: center; margin-right: 8px; }
.app-sidebar__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }

.app-main { flex: 1; margin-left: 248px; display: flex; flex-direction: column; min-width: 0; }
.app-topbar { display: flex; align-items: center; gap: 16px; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 28px; position: sticky; top: 0; z-index: 1030; }
.app-topbar__title { font-weight: 700; }
.app-content { padding: 28px; max-width: 1180px; width: 100%; }

.role-pill { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; background: #e2e8f0; color: #334155; }
.role-pill--owner { background: #ede9fe; color: #6d28d9; }
.role-pill--admin { background: #dbeafe; color: #1d4ed8; }
.role-pill--editor { background: #dcfce7; color: #15803d; }
.role-pill--viewer { background: #f1f5f9; color: #475569; }

.page-header { margin-bottom: 22px; }
.page-title { font-size: 1.55rem; font-weight: 800; margin: 0; }
.page-subtitle { margin: 4px 0 0; }

.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-card__label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat-card__value { font-size: 1.8rem; font-weight: 800; }
.mini-progress { height: 7px; background: #eff6ff; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.mini-progress__bar { height: 100%; background: linear-gradient(90deg, var(--primary), #0ea5e9); }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; }
.bar-chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar-chart__bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--primary), #60a5fa); border-radius: 6px 6px 0 0; min-height: 4px; }
.bar-chart__label { font-size: .68rem; color: var(--muted); }
.bar-chart__count { font-size: .7rem; font-weight: 700; }

.rating-summary { display: flex; align-items: baseline; gap: 6px; margin-bottom: 14px; }
.rating-summary__avg { font-size: 2.2rem; font-weight: 800; color: var(--primary); }
.rating-summary__max { color: var(--muted); font-weight: 600; }
.rating-summary__count { margin-left: auto; color: var(--muted); font-size: .82rem; }

.dist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dist-row__key { width: 40px; font-weight: 600; font-size: .88rem; flex-shrink: 0; }
.dist-row__key--wide { width: 160px; font-weight: 500; }
.dist-row__track { flex: 1; height: 11px; background: #eff6ff; border-radius: 999px; overflow: hidden; }
.dist-row__fill { height: 100%; background: linear-gradient(90deg, var(--primary), #0ea5e9); border-radius: 999px; }
.dist-row__val { width: 96px; text-align: right; color: var(--muted); font-size: .8rem; flex-shrink: 0; }

.breakdown { margin-bottom: 20px; }
.breakdown:last-child { margin-bottom: 0; }
.breakdown__title { font-weight: 600; margin-bottom: 10px; }

.question-list { list-style: none; margin: 0; padding: 0; }
.question-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.question-item:last-child { border-bottom: 0; }
.question-item.is-inactive { background: #f8fafc; opacity: .75; }
.question-item__order { display: flex; flex-direction: column; line-height: 1; }
.question-item__body { flex: 1; min-width: 0; }
.question-item__label { font-weight: 600; margin: 0 0 2px; }
.question-item__meta { margin: 0; color: var(--muted); font-size: .8rem; }
.question-item__actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.question-item__actions form { display: inline; margin: 0; }

.settings-tabs .nav-link { color: var(--muted); font-weight: 600; }
.settings-tabs .nav-link.active { background: var(--primary); }
.settings-card { max-width: 760px; }

.module-toggle { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; cursor: pointer; }
.module-toggle:hover { border-color: var(--primary); }
.module-toggle input { margin-top: 3px; }
.module-toggle__body { display: flex; flex-direction: column; }
.module-toggle__title { font-weight: 700; }
.module-toggle__desc { color: var(--muted); font-size: .86rem; }

.setup-body { background: var(--bg); min-height: 100vh; }
.setup-header { background: #fff; border-bottom: 1px solid var(--line); }
.setup-container { width: 100%; max-width: 840px; margin: 0 auto; padding: 0 20px; }
.setup-header__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.setup-brand { font-weight: 800; }
.setup-main { padding: 40px 0 64px; }
.setup-intro h1 { font-size: 1.8rem; font-weight: 800; }
.setup-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 24px 0; }
.setup-steps__item { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; font-weight: 600; }
.setup-steps__item.is-active { border-color: var(--primary); color: var(--primary); }
.setup-steps__item.is-done { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.setup-steps__num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: currentColor; color: #fff; font-size: .75rem; }
.setup-steps__item .setup-steps__num { color: #fff; }
.setup-steps__item.is-active .setup-steps__num { background: var(--primary); }
.setup-steps__item.is-done .setup-steps__num { background: #047857; }
.setup-steps__label { color: inherit; }
.setup-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: 0 24px 48px -40px rgba(15,23,42,.3); }
.setup-card__title { font-size: 1.3rem; font-weight: 800; margin-bottom: 18px; }
.setup-card__actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }
.setup-finish { text-align: center; }
.setup-finish .setup-card__actions { justify-content: center; }

.mail-block { display: none; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.mail-block.is-visible { display: block; }

.auth-body { background: linear-gradient(155deg, var(--hero-from, #0f172a) 0%, var(--hero-to, #334155) 100%); min-height: 100vh; }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; }
.auth-card { width: 100%; max-width: 460px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 36px; box-shadow: 0 40px 80px -40px rgba(0,0,0,.55); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand__mark { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 800; font-size: 1.2rem; flex-shrink: 0; }
.auth-brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.auth-brand__name { font-weight: 800; font-size: 1.1rem; }
.auth-brand__tagline { color: var(--muted); font-size: .85rem; }
.auth-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { color: var(--muted); margin-bottom: 24px; }
.auth-footer { margin-top: 22px; color: rgba(255,255,255,.75); }

.rating-group { gap: 10px; }
.rating-option span { position: relative; border-width: 2px; }
.rating-option--1 span { color: #b91c1c; }
.rating-option--2 span { color: #c2410c; }
.rating-option--3 span { color: #a16207; }
.rating-option--4 span { color: #15803d; }
.rating-option--5 span { color: #047857; }
.rating-option--1 input:checked + span { background: #ef4444; border-color: #ef4444; color: #fff; }
.rating-option--2 input:checked + span { background: #f97316; border-color: #f97316; color: #fff; }
.rating-option--3 input:checked + span { background: #eab308; border-color: #eab308; color: #fff; }
.rating-option--4 input:checked + span { background: #22c55e; border-color: #22c55e; color: #fff; }
.rating-option--5 input:checked + span { background: #16a34a; border-color: #16a34a; color: #fff; }
.rating-option span:hover { border-color: currentColor; }

.scale-meter { display: flex; gap: 6px; flex-wrap: wrap; }

.public-footer__meta { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--sidebar-muted); font-size: .85rem; }
.public-footer__link { color: #fff; }

.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type="color"] { width: 52px; height: 42px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.color-field__hex { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; color: var(--muted); }

.app-nav__icon i, .public-header__nav i { font-size: .95rem; }

.account-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
.account-side { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.account-side__head { padding: 24px; text-align: center; border-bottom: 1px solid var(--line); }
.account-side__name { font-weight: 700; margin-top: 12px; }
.account-side__role { margin-top: 6px; }
.account-tabs { display: flex; flex-direction: column; padding: 10px; }
.account-tabs__link { padding: 10px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.account-tabs__link:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.account-tabs__link.is-active { background: var(--primary-soft); color: var(--primary-dark); }

.account-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; object-fit: cover; background: var(--primary-soft); color: var(--primary-dark); font-weight: 800; overflow: hidden; }
.account-avatar--xs { width: 28px; height: 28px; font-size: .8rem; }
.account-avatar--md { width: 72px; height: 72px; font-size: 1.6rem; }
.account-avatar--lg { width: 92px; height: 92px; font-size: 2rem; }
img.account-avatar { display: block; }

.avatar-edit { display: flex; align-items: center; gap: 18px; }
.avatar-edit__controls { flex: 1; min-width: 0; }

.password-field { position: relative; }
.password-field--enhanced .form-control { padding-right: 44px; }
.pw-toggle { position: absolute; top: 0; right: 0; height: 100%; width: 42px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--ink); }
.pw-strength { margin-top: 8px; display: flex; align-items: center; gap: 10px; }
.pw-strength__bar { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.pw-strength__bar span { display: block; height: 100%; width: 0; transition: width .2s ease, background .2s ease; background: #ef4444; }
.pw-strength__label { font-size: .8rem; color: var(--muted); min-width: 84px; }
.pw-strength--0 .pw-strength__bar span, .pw-strength--1 .pw-strength__bar span { background: #ef4444; }
.pw-strength--2 .pw-strength__bar span { background: #f59e0b; }
.pw-strength--3 .pw-strength__bar span { background: #22c55e; }
.pw-strength--4 .pw-strength__bar span { background: #16a34a; }

.profile-toggle { display: inline-flex; align-items: center; gap: 8px; }
.profile-menu { min-width: 240px; padding: 0; overflow: hidden; }
.profile-menu__head { padding: 14px 16px; background: var(--bg); }
.profile-menu__name { font-weight: 700; }
.profile-menu__email { color: var(--muted); font-size: .85rem; word-break: break-all; }
.profile-menu .dropdown-item { padding: 10px 16px; }

.question-item__handle { cursor: grab; color: #cbd5e1; font-size: 1.1rem; padding: 0 4px; }
.question-item__handle:active { cursor: grabbing; }
.question-item.sortable-ghost { opacity: .4; }
.question-item.sortable-chosen { background: var(--primary-soft); }

@media (max-width: 767.98px) {
    .account-layout { grid-template-columns: 1fr; }
}

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .hero__inner, .sign-layout { grid-template-columns: 1fr; }
    .hero { padding: 48px 0; }
    .hero__title { font-size: 2rem; }
    .sign-aside { position: static; }
}
