:root {
    --blue: #0fb7ec;
    --blue-dark: #0588b4;
    --green: #7ac42c;
    --green-dark: #609a23;
    --ink: #26333a;
    --muted: #66747b;
    --line: #dce7eb;
    --canvas: #edf3f5;
    --white: #fff;
    --danger: #c73535;
    --warning: #8a5b00;
    --shadow: 0 22px 60px rgba(31, 58, 69, .14);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 16px; line-height: 1.5; }
a { color: var(--blue-dark); }
button, input, textarea, select { font: inherit; }
button, .button { min-height: 46px; }

.survey-page { min-height: 100vh; background: radial-gradient(circle at 15% 10%, rgba(15,183,236,.15), transparent 32rem), radial-gradient(circle at 90% 80%, rgba(122,196,44,.12), transparent 30rem), var(--canvas); }
.survey-page::before { content: ""; display: block; height: 8px; background: linear-gradient(90deg, var(--blue) 0 72%, var(--green) 72%); }
.survey-shell { width: min(100% - 32px, 720px); margin: 0 auto; padding: 48px 0 28px; }
.survey-card { background: var(--white); border: 1px solid rgba(15,183,236,.14); border-radius: 24px; padding: 38px; box-shadow: var(--shadow); }
.brand-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 28px; border-bottom: 1px solid var(--line); margin-bottom: 32px; }
.brand-header img { display: block; width: 190px; height: auto; }
.brand-header span { color: var(--muted); font-size: .9rem; font-weight: 700; }
.eyebrow { color: var(--blue-dark); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 8px; }
h1 { font-size: clamp(1.85rem, 4vw, 2.55rem); line-height: 1.12; margin: 0 0 14px; letter-spacing: -.035em; }
h2 { font-size: 1.18rem; line-height: 1.25; margin: 0 0 8px; }
.lead { color: var(--muted); font-size: 1.08rem; margin: 0 0 30px; }
.survey-form { display: grid; gap: 22px; }
.rating-fieldset { border: 0; padding: 0; margin: 0; }
.rating-fieldset legend, .field-label { display: block; font-weight: 750; margin-bottom: 9px; }
.rating-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.rating-option { position: relative; text-align: center; cursor: pointer; }
.rating-option input { position: absolute; opacity: 0; pointer-events: none; }
.rating-number { display: grid; place-items: center; aspect-ratio: 1; border: 2px solid var(--line); border-radius: 14px; color: #47565d; font-size: 1.35rem; font-weight: 800; transition: .18s ease; }
.rating-label { position: absolute; clip: rect(0 0 0 0); width: 1px; height: 1px; overflow: hidden; }
.rating-option:hover .rating-number { border-color: var(--blue); transform: translateY(-2px); }
.rating-option input:focus-visible + .rating-number { outline: 3px solid rgba(15,183,236,.28); outline-offset: 2px; }
.rating-option input:checked + .rating-number { color: #fff; background: var(--green); border-color: var(--green); box-shadow: 0 8px 20px rgba(122,196,44,.28); }
.rating-anchors { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 8px; }
textarea, input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="number"], select { width: 100%; border: 1px solid #cbd9de; border-radius: 10px; background: #fff; padding: 12px 14px; color: var(--ink); }
textarea { min-height: 120px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 3px solid rgba(15,183,236,.18); border-color: var(--blue); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 9px; padding: 11px 18px; font-weight: 800; text-decoration: none; cursor: pointer; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-primary { color: #fff; background: var(--green); box-shadow: 0 8px 18px rgba(122,196,44,.22); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--blue-dark); background: #e9f8fd; border: 1px solid #bde9f7; }
.button-danger { color: #fff; background: #b53b32; }
.button-danger:hover { background: #932c25; }
.button-wide { width: 100%; }
.privacy-note, .support-note { color: var(--muted); font-size: .86rem; margin: 26px 0 0; }
.survey-shell > footer { text-align: center; color: #76858b; font-size: .82rem; margin-top: 20px; }
.success-mark { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: rgba(122,196,44,.14); color: var(--green-dark); font-size: 2rem; font-weight: 900; margin-bottom: 24px; }
.text-link { font-weight: 750; }
.alert { border-radius: 10px; padding: 12px 14px; margin: 0 0 18px; font-weight: 650; }
.alert-error { color: #8f2020; background: #fff0f0; border: 1px solid #f0caca; }
.alert-success { color: #315d13; background: #eff9e5; border: 1px solid #cce9ae; }
.alert-warning { color: var(--warning); background: #fff8df; border: 1px solid #f0dfa1; }

.admin-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, rgba(15,183,236,.16), transparent 36rem), var(--canvas); }
.login-card { width: min(100%, 430px); background: #fff; border-radius: 20px; padding: 34px; box-shadow: var(--shadow); }
.login-card img { width: 190px; height: auto; margin-bottom: 34px; }
.login-card h1 { font-size: 1.8rem; }
.login-card p { color: var(--muted); margin-top: 0; }
.login-card form { display: grid; gap: 12px; }

.admin-header { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.admin-header-inner { width: min(100% - 32px, 1240px); min-height: 72px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.admin-header img { width: 190px; height: auto; }
.admin-header nav { display: flex; gap: 18px; overflow-x: auto; }
.admin-header nav a { color: #435158; text-decoration: none; font-weight: 700; font-size: .9rem; }
.admin-shell { width: min(100% - 32px, 1240px); margin: 0 auto; padding: 38px 0 60px; }
.page-title { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-title h1 { font-size: clamp(1.8rem, 3vw, 2.5rem); margin: 0; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-grid-wide { grid-template-columns: repeat(4, 1fr); }
.stat-card { min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; background: #fff; padding: 22px; border: 1px solid var(--line); border-radius: 15px; }
.stat-link { color: inherit; text-decoration: none; transition: transform .18s ease, box-shadow .18s ease; }
.stat-link:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(31,58,69,.09); }
.stat-card span { color: var(--muted); font-weight: 700; font-size: .9rem; }
.stat-card strong { font-size: 2.25rem; line-height: 1; }
.stat-card small { color: var(--muted); }
.stat-accent { background: linear-gradient(145deg, #09a8dc, #0fb7ec); color: #fff; border-color: transparent; }
.stat-accent span, .stat-accent small { color: rgba(255,255,255,.82); }
.stat-warning { background: #fff4f2; border-color: #f0cbc5; }
.stat-warning span, .stat-warning strong { color: #a12e24; }
.stat-repeat { background: #fff8df; border-color: #efdca0; }
.stat-repeat span, .stat-repeat strong { color: #805800; }
.dashboard-grid, .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 22px; margin-bottom: 18px; }
.panel > h2, .panel-heading { margin-bottom: 20px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.panel-heading p { color: var(--muted); margin: 4px 0 0; }
.bar-row { display: grid; grid-template-columns: 22px 1fr 30px; gap: 10px; align-items: center; margin: 10px 0; }
.bar-track { height: 10px; overflow: hidden; background: #e8f0f2; border-radius: 999px; }
.bar-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); border-radius: inherit; }
.technician-list { display: grid; }
.technician-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid #edf2f4; }
.technician-list > div:last-child { border: 0; }
.technician-list small { color: var(--muted); font-weight: 500; }
.empty-state { color: var(--muted); }
.import-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }
.import-grid-wave { grid-template-columns: 1fr 1fr 1fr auto; }
.file-field { display: grid; gap: 7px; color: #405058; font-weight: 700; font-size: .9rem; }
.file-field input { border: 1px dashed #b8cbd2; border-radius: 10px; padding: 10px; background: #f8fbfc; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { color: #64737a; text-align: left; font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; padding: 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 9px; border-bottom: 1px solid #edf2f4; vertical-align: top; }
.comment-cell { min-width: 190px; max-width: 320px; }
.results-panel { scroll-margin-top: 92px; }
.results-table { min-width: 1760px; }
.summary-table { min-width: 620px; }
.wave-table { min-width: 1250px; }
.customer-table { min-width: 1420px; }
.results-table td { vertical-align: middle; }
.cell-note { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; font-weight: 500; white-space: nowrap; }
.email-link { color: var(--ink); font-weight: 750; text-decoration-thickness: 1px; text-underline-offset: 2px; white-space: nowrap; }
.contact-link { display: inline-flex; padding: 6px 10px; border: 1px solid #bde9f7; border-radius: 7px; background: #e9f8fd; color: var(--blue-dark); font-weight: 800; text-decoration: none; white-space: nowrap; }
.rating-pill { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: .78rem; font-weight: 850; white-space: nowrap; }
.rating-good { color: #477b20; background: #eff9e5; }
.rating-bad { color: #9b2c24; background: #ffebe8; }
.attention-row { background: #fff8f7; }
.attention-row td:first-child { box-shadow: inset 4px 0 0 #d85247; }
.repeat-row { background: #fffaf0; }
.repeat-row td:first-child { box-shadow: inset 4px 0 0 #e1a127; }
.repeat-badge { display: inline-flex; border-radius: 999px; padding: 4px 8px; background: #fff0c2; color: #785100; font-size: .72rem; font-weight: 850; white-space: nowrap; }
.contact-warning { display: block; margin-top: 4px; color: #986100; font-size: .74rem; font-weight: 750; }
.empty-cell { text-align: center; color: var(--muted); padding: 34px; }
.status { display: inline-flex; border-radius: 999px; padding: 4px 9px; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.status-ready { background: #e9f8fd; color: #087da5; }
.status-sent { background: #fff6dc; color: #886000; }
.status-responded { background: #eff9e5; color: #477b20; }
.status-merged { background: #eef0f1; color: #58666c; }
.status-archived { background: #eef0f1; color: #58666c; }
.archived-row { opacity: .72; }
.table-actions { display: flex; justify-content: flex-end; padding-top: 16px; }
.compact-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; white-space: nowrap; }
.compact-actions form { margin: 0; }
.text-button { appearance: none; border: 0; padding: 0; min-height: auto; background: none; color: var(--blue-dark); font-weight: 700; cursor: pointer; text-decoration: underline; }
.filter-grid { display: grid; gap: 12px; align-items: end; margin-bottom: 18px; }
.filter-grid label, .rule-grid label { display: grid; gap: 6px; color: #405058; font-size: .82rem; font-weight: 750; }
.dashboard-filter { grid-template-columns: repeat(3, 1fr) auto; margin-bottom: 0; }
.result-filter { grid-template-columns: repeat(6, minmax(130px, 1fr)) auto; }
.filter-actions { display: flex; gap: 8px; }
.active-filter { margin: 0 0 14px; padding: 10px 12px; border-radius: 9px; background: #e9f8fd; color: #286075; }
.send-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-top: 16px; }
.bulk-selection-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid #bde9f7; border-radius: 10px; background: #f0fbfe; }
.bulk-selection-actions { display: flex; align-items: center; gap: 14px; }
.button-small { min-height: 38px; padding: 8px 13px; }
.bulk-selection-bar strong { color: var(--blue-dark); white-space: nowrap; }
.repeat-confirm { display: flex; align-items: flex-start; gap: 9px; max-width: 760px; color: var(--muted); font-size: .84rem; }
.repeat-confirm input { margin-top: 4px; }
.send-mode { margin: 10px 0 0; font-size: .8rem; font-weight: 750; }
.send-rule { margin: 9px 0 0; color: var(--muted); font-size: .8rem; }
.send-mode-test { color: #886000; }
.send-mode-live { color: #a12e24; }
.table-limit { color: var(--warning); font-size: .85rem; }
.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.danger-zone { border-color: #efc5c1; }
.danger-zone p { color: var(--muted); }
.settings-form { display: grid; align-content: start; gap: 8px; }
.settings-form h2 { margin-bottom: 12px; }
.settings-form .field-label { margin: 8px 0 0; }
.settings-form .button { justify-self: start; margin-top: 12px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 700; }
.content-form { scroll-margin-top: 92px; }
.content-settings-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; align-items: start; }
.content-side { display: grid; gap: 18px; }
.settings-group { min-width: 0; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: 12px; }
.settings-group legend { padding: 0 8px; color: var(--blue-dark); font-weight: 800; }
.settings-group .field-label { margin: 15px 0 7px; }
.settings-group input:not([type="hidden"]) { width: 100%; border: 1px solid #cbd9de; border-radius: 10px; background: #fff; padding: 12px 14px; color: var(--ink); }
.settings-group textarea { min-height: 0; }
.rating-label-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.rating-label-settings label { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.rating-label-settings label:nth-child(3) { grid-column: 1 / -1; }
.content-actions { display: flex; justify-content: flex-end; padding-top: 18px; }
.admin-footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 0 16px 30px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
    .content-settings-grid { grid-template-columns: 1fr; }
    .import-grid, .import-grid-wave { grid-template-columns: 1fr 1fr; }
    .import-grid .button { grid-column: 1 / -1; }
    .dashboard-filter { grid-template-columns: 1fr 1fr; }
    .result-filter { grid-template-columns: 1fr 1fr 1fr; }
    .result-filter .filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .survey-shell { width: min(100% - 20px, 720px); padding-top: 18px; }
    .survey-card { padding: 24px 20px; border-radius: 18px; }
    .brand-header { align-items: start; flex-direction: column; gap: 12px; padding-bottom: 22px; margin-bottom: 26px; }
    .brand-header img { width: 170px; }
    .rating-scale { gap: 6px; }
    .rating-number { border-radius: 10px; font-size: 1.15rem; }
    .rating-anchors { font-size: .72rem; }
    .admin-header-inner { align-items: flex-start; flex-direction: column; padding: 16px 0; }
    .admin-header nav { width: 100%; overflow-x: auto; gap: 16px; padding-bottom: 3px; }
    .page-title { align-items: flex-start; flex-direction: column; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { min-height: 112px; padding: 17px; }
    .stat-card strong { font-size: 1.85rem; }
    .import-grid { grid-template-columns: 1fr; }
    .import-grid .button { grid-column: auto; }
    .dashboard-filter, .result-filter, .rule-grid { grid-template-columns: 1fr; }
    .result-filter .filter-actions { grid-column: auto; }
    .send-toolbar { align-items: stretch; flex-direction: column; }
    .send-toolbar .button { width: 100%; }
    .bulk-selection-bar { align-items: flex-start; flex-direction: column; }
    .bulk-selection-actions { align-items: flex-start; flex-direction: column; }
    .rating-label-settings { grid-template-columns: 1fr; }
    .rating-label-settings label:nth-child(3) { grid-column: auto; }
    .panel { padding: 17px; }
}

/* Wave management */
.wave-action summary { cursor: pointer; list-style: none; }
.wave-action summary::-webkit-details-marker { display: none; }
.wave-action-form { min-width: 240px; max-width: 320px; white-space: normal; padding: 12px; margin-top: 8px; border: 1px solid #d9e4eb; border-radius: 8px; background: #fff; }
.wave-action-form label { display: block; margin-bottom: 10px; }
.wave-action-form input[type="text"] { width: 100%; box-sizing: border-box; margin-top: 6px; }
.wave-action-form p { font-size: 13px; line-height: 1.5; }
.wave-action-form .switch-row { display: flex; }
.compact-actions button:disabled { opacity: .55; cursor: not-allowed; }

/* v10: compact history and feedback resolution */
.panel-collapse > summary { cursor:pointer; font-size:1.05rem; font-weight:700; color:var(--navy, #163b4b); padding:14px 0; }
.panel-collapse[open] > summary { margin-bottom:16px; border-bottom:1px solid #dce8ee; }
.panel-collapse + .panel-collapse { border-top:1px solid #dce8ee; margin-top:12px; }
.feedback-tabs { margin-bottom:20px; }
.feedback-table { min-width:1000px; width:100%; }
.feedback-table .comment-cell { min-width:220px; max-width:420px; white-space:normal; }
.feedback-table button { white-space:normal; min-width:140px; }
.repeat-wave-filter { display:flex; align-items:end; flex-wrap:wrap; gap:14px; margin-bottom:14px; }
.repeat-wave-filter label { display:grid; gap:8px; min-width:230px; }
