
@font-face {
    font-family: "Inter";
    src: url("./fonts/InterVariable.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --paper: #fff;
    --white: #fff;
    --ink: #403b39;
    --muted: #746e68;
    --accent: #b99c52;
    --accent-dark: #b99c52;
    --button: #b99c52;
    --button-hover: #a88b43;
    --line: #e7dfd7;
}

/* Global */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 16px/1.65 "Inter", sans-serif;
}

a {
    color: inherit;
}

[hidden] {
    display: none !important;
}

/* Header */

.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.site-header .header-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 19px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.site-header .brand {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    line-height: 1.1;
}

.site-header .brand-name {
    font-family: Georgia, serif;
    font-size: 30px;
    letter-spacing: -1.4px;
    color: var(--ink);
    font-weight: 400;
}

.site-header .brand-name span {
    font-style: italic;
    color: var(--accent);
}

.site-header .brand-subtitle {
    font-family: "Inter", sans-serif;
    font-size: 10px;
    letter-spacing: 2.3px;
    text-transform: uppercase;
    margin-top: 7px;
    color: var(--muted);
}

.site-header .site-link {
    font-family: "Inter", sans-serif;
    font-size: 13px;
    text-decoration: none;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 4px;
    color: var(--ink);
    white-space: nowrap;
}

/* Main */

main {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

.intro {
    text-align: center;
    padding: 86px 22px 48px;
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2.6px;
    color: var(--accent-dark);
    margin: 0 0 15px;
}

/* Typography */

h1,
h2 {
    font-family: "Inter", sans-serif;
    font-weight: 500;
    line-height: 1.15;
    color: var(--accent-dark);
}

h1 {
    font-size: clamp(39px, 6vw, 64px);
    letter-spacing: -1.5px;
    margin: 0 0 18px;
}

h1 em {
    font-weight: 500;
    font-style: normal;
    color: var(--accent-dark);
}

.lead {
    font-family: Georgia, serif;
    font-size: 22px;
    margin: 0 0 19px;
}

.description {
    max-width: 590px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 15px;
}

/* Homepage selection */

.selection {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px;
}

.selection .choice {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 300px;
    padding: 35px 32px;
    border: 1px solid var(--line);
    background: #fff;
    text-decoration: none;
    box-shadow: 0 16px 50px rgba(55, 39, 23, 0.045);
    transition:
        border-color 0.2s,
        background 0.2s,
        transform 0.2s;
}

.selection .choice:hover {
    border-color: var(--accent);
    background: #fdfbf9;
    transform: translateY(-2px);
}

.selection .choice:focus-visible,
.brand:focus-visible {
    outline: 3px solid #c2a58c;
    outline-offset: 3px;
}

.choice-number {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--muted);
}

.selection .choice h2 {
    font-size: 33px;
    margin: 27px 0 14px;
}

.selection .choice p {
    margin: 0 0 28px;
    color: var(--muted);
    font-size: 15px;
}

.selection .choice-action {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 13px 18px;
    min-height: 52px;
    background: var(--button);
    color: #fff;
    font-size: 15px;
    letter-spacing: 0.04em;
}

.selection .choice:hover .choice-action {
    background: var(--button-hover);
}

.choice-action span {
    font-size: 23px;
    line-height: 1;
}

/* Disclaimer and footer */

.disclaimer {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
    margin: 30px 0 0;
    text-align: center;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    max-width: 1080px;
    margin: auto;
    padding: 24px 28px 38px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

/* Questionnaire */

.form-page main {
    max-width: 920px;
    padding-top: 35px;
}

.form-intro {
    padding: 24px 0 26px;
}

.form-intro h1 {
    font-size: clamp(32px, 5vw, 48px);
}

.form-intro p {
    color: var(--muted);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
    padding: 22px;
    border: 1px solid var(--line);
    background: #fdfbf9;
}

.toolbar label {
    display: flex;
    flex: 1 1 210px;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
}

/* Form inputs */

select,
input[type="text"],
input[type="date"],
input[type="time"],
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #fff;
    color: var(--ink);
    padding: 10px;
    font: inherit;
}

/* Questionnaire sections */

.section {
    background: #fff;
    margin: 18px 0;
    border: 1px solid var(--line);
    padding: 24px;
}

.section h2 {
    margin: 0 0 6px;
    font-size: 25px;
}

.page-reference {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.question {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.question:last-child {
    border-bottom: 0;
}

.repeat-entries {
    display: grid;
    gap: 20px;
    margin: 16px 0;
}

.repeat-entry {
    padding: 20px;
    border: 1px solid var(--line);
    background: #fdfbf9;
}

.repeat-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.repeat-entry-header h3 {
    margin: 0;
}

.repeat-group-heading {
    margin: 24px 0 4px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--accent);
    font-size: 1.1rem;
}

.repeat-remove,
.repeat-add {
    min-height: 44px;
}

@media (max-width: 600px) {
    .repeat-entry {
        padding: 14px;
    }
}

.question-label {
    margin-bottom: 10px;
    font-weight: 600;
}

.required {
    color: #ad523f;
}

.question.question-invalid {
    border-left: 4px solid #ad523f;
    padding-left: 16px;
    background: #fff5f2;
}

.question [aria-invalid="true"] {
    outline: 2px solid #ad523f;
    outline-offset: 2px;
}

.question-error {
    margin: 8px 0 0;
    color: #ad523f;
    font-size: 14px;
}

.choices {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 22px;
}

.choices .choice {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
}

.choices input {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
}

/* Buttons */

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
}

.form-action-row {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    margin: 22px 0;
}

.form-top-action {
    display: flex;
    margin-left: auto;
}

.form-top-action button {
    min-height: 44px;
}

button {
    border: 0;
    border-radius: 2px;
    background: var(--button);
    color: #fff;
    font: inherit;
    padding: 12px 18px;
    cursor: pointer;
}

button:hover {
    background: var(--button-hover);
}

button:disabled {
    opacity: 0.55;
    cursor: wait;
}

button.secondary {
    background: #746e68;
}

/* Questionnaire results */

.answer-chart {
    margin: 18px 0;
    padding: 24px;
    border: 1px solid var(--line);
    background: #fff;
}

.value-correction {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: min(440px, calc(100vw - 32px));
    padding: 16px 20px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 8px 30px #0003;
    text-align: center;
}

.answer-chart h2 {
    margin: 0 0 12px;
}

.answer-chart-scroll {
    max-width: 100%;
    overflow-x: auto;
}

.answer-chart-svg {
    display: block;
    max-width: none;
    height: 300px;
    font-family: inherit;
}

.chart-grid {
    stroke: var(--line);
}

.chart-axis {
    fill: var(--muted);
    font-size: 12px;
}

.chart-line {
    fill: none;
    stroke: #80611c;
    stroke-width: 2.5;
    stroke-linejoin: round;
}

.chart-point {
    fill: #80611c;
    stroke: #fff;
    stroke-width: 2;
}

.chart-hint {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 600px) {
    .answer-chart {
        padding: 16px;
    }
}

#results:not(:empty) {
    padding: 20px;
    border: 1px solid var(--line);
    background: #fdfbf9;
}

.result-list {
    columns: 2;
}

.result-list p {
    break-inside: avoid;
}

#status {
    color: var(--muted);
    font-size: 14px;
}

.form-back {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--accent);
}

/* User menu */

.user-menu {
    position: relative;
    margin-left: auto;
}

.user-bubble {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #77716d;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
}

#userBubble {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    text-align: center;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: 56px;
    min-width: 180px;
    padding: 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 4px 16px #0002;
    z-index: 1000;
}

.user-dropdown strong {
    display: block;
    margin-bottom: 12px;
}

#userDropdown button {
    display: block;
    width: 100%;
    padding: 9px 12px;
    margin: 2px 0;
    background: #fff;
    color: #111;
    border: none;
    border-radius: 4px;
    box-shadow: none;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
}

#userDropdown button:hover {
    background: #f5f5f5;
    color: #111;
}

#userDropdown button:focus-visible {
    outline: 2px solid #777;
    outline-offset: 2px;
}

/* Admin layout */

.admin-page {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 30px 40px 80px;
}

.admin-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    column-gap: 100px;
    align-items: start;
    margin-top: 30px;
}

.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 240px;
    margin-top: 0;
}

.admin-sidebar button {
    width: 100%;
    padding: 14px 18px;
    text-align: left;
    font-size: 15px;
    background: var(--button);
    color: white;
}

.admin-sidebar button:hover,
.admin-sidebar button.active {
    background: var(--button-hover);
}

.admin-content {
    min-width: 0;
    padding-top: 0;
    overflow-x: auto;
}

.admin-content #content {
    margin-top: 0;
    padding-top: 0;
}

.admin-content #content > h2:first-child {
    margin-top: 0;
    padding-top: 0;
    line-height: 1.15;
}

.admin-content #error:empty {
    display: none;
}

/* Login */

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 460px;
    margin-top: 30px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 16px;
    font-weight: 500;
}

.login-field input {
    display: block;
    width: 100%;
    height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: white;
    color: var(--ink);
    font: inherit;
}

.login-form button {
    align-self: flex-start;
    min-width: 160px;
    padding: 12px 24px;
}

.login-form #msg {
    margin: 0;
    color: #ad523f;
}

/* User management */

.user-actions {
    margin-top: 30px;
}

#createUserPanel {
    max-width: 500px;
    margin-top: 25px;
    padding: 25px;
    border: 1px solid var(--line);
    background: #fdfbf9;
}

#createUserPanel h3 {
    margin: 0 0 25px;
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.user-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-form-field label {
    font-size: 15px;
    font-weight: 600;
}

.user-form-field input {
    width: 100%;
    height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: white;
    color: var(--ink);
    font: inherit;
}

.user-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

/* Template management */

.template-item {
    display: grid;
    grid-template-columns: 40px 200px minmax(0, 1fr) 120px;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
}

.template-order {
    white-space: nowrap;
    color: var(--muted);
}

.template-caption {
    font-weight: 600;
    white-space: nowrap;
}

.template-description {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

.template-actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 5px;
}

.template-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--ink);
}

.template-actions button:hover {
    color: var(--accent);
    background: #fdfbf9;
}

.template-actions svg {
    width: 18px;
    height: 18px;
}

/* User management tables */

.user-table {
    width: 100%;
    border-collapse: collapse;
}

.user-table th,
.user-table td {
    padding: 16px 22px;
    vertical-align: middle;
    white-space: nowrap;
}

.user-table th:first-child,
.user-table td:first-child {
    padding-left: 8px;
}

.user-table th:last-child,
.user-table td:last-child {
    padding-right: 8px;
}

.user-table thead {
    border-bottom: 1px solid var(--line);
}

.user-table tbody tr {
    border-bottom: 1px solid var(--line);
}

.user-table .template-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

/* Settings */

.settings-page {
    width: min(100% - 40px, 900px);
    margin: 48px auto 80px;
}

.settings-page h1 {
    margin-bottom: 32px;
}

.settings-card {
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.settings-card h2 {
    margin: 0 0 24px;
}

.account-details {
    margin: 0;
}

.account-details > div {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 24px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.account-details > div:first-child {
    border-top: 1px solid var(--line);
}

.account-details dt {
    font-weight: 600;
}

.account-details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

#edit-account {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}

#edit-account label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

#edit-account input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin: 0;
    font-family: inherit;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

#edit-account .settings-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

/* Saved data */

.file-preview-dialog {
    width: min(1100px, 96vw);
    height: min(850px, 92vh);
    padding: 16px;
    border: 1px solid #e8e0da;
    border-radius: 8px;
}

.file-preview-dialog::backdrop {
    background: rgb(0 0 0 / 65%);
}

.file-preview-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.file-preview-header strong {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.file-preview-header button {
    width: auto;
}

.file-preview-content {
    display: block;
    width: 100%;
    height: calc(100% - 72px);
    object-fit: contain;
    border: 0;
}

.user-upload-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 24px 0 12px;
}

.user-upload-form input[type="file"] {
    max-width: 100%;
}

.user-upload-form button {
    width: auto;
}

.saved-data .saved-data-table th {
    padding: 14px 10px;
    text-align: left;
    border-bottom: 1px solid #e8e0da;
}

.saved-data {
    margin-top: 0;
    margin-bottom: 64px;
}

.saved-data .saved-data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    margin: 0;
}

.saved-data .saved-data-table tr {
    border-bottom: 1px solid #e8e0da;
}

.saved-data .saved-data-table td {
    padding: 14px 10px;
    border: 0;
    font-size: 15px;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

.saved-data .saved-data-number {
    width: 40px;
    color: #777;
}

.saved-data .saved-data-name {
    width: 210px;
    font-weight: 600;
    color: #404040;
}

.saved-data .saved-data-description {
    color: #817b76;
    white-space: normal;
}

.saved-data .saved-data-table td.saved-data-actions {
    width: 120px;
    padding: 8px 0;
    text-align: right;
    white-space: nowrap;
}

.saved-data .saved-data-table button.saved-data-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    height: 32px;
    min-height: 32px;
    margin: 0 2px;
    padding: 6px;
    background: transparent;
    color: #444;
    border: none;
    border-radius: 4px;
    box-shadow: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}

.saved-data .saved-data-table button.saved-data-icon:hover {
    background: #f4f0ed;
    color: #222;
}

.saved-data .saved-data-table button.saved-data-icon svg {
    display: block;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Save confirmation toast */

.save-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translate(-50%, 15px);
    z-index: 9999;
    padding: 12px 24px;
    border-radius: 10px;
    background: #263b32;
    color: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition:
        opacity 0.25s ease,
        transform 0.25s ease;
}

.save-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Read-only questionnaire */

/* Draw radio buttons explicitly to avoid browser
   disabled-state fading and filter issues. */

#questionnaire input[type="radio"]:disabled {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    margin: 0;
    border: 2px solid #aaa;
    border-radius: 50%;
    background: #fff;
    opacity: 1;
    filter: none;
    position: relative;
    flex-shrink: 0;
}

#questionnaire input[type="radio"]:disabled:checked {
    border-color: #000;
    background: #fff;
}

#questionnaire input[type="radio"]:disabled:checked::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: #000;
}

/* Read-only checkboxes */

#questionnaire input[type="checkbox"]:disabled {
    opacity: 1;
    accent-color: #000;
}

/* Read-only text, date, and textarea fields */

#questionnaire input[type="text"]:disabled,
#questionnaire input[type="date"]:disabled,
#questionnaire input[type="time"]:disabled,
#questionnaire textarea:disabled,
#measurement-select:disabled {
    opacity: 1;
    color: var(--ink);
    -webkit-text-fill-color: var(--ink);
    background: #fff;
}

/* Keep saved answer text at normal weight */

#questionnaire .choices .choice {
    font-weight: 400;
}

#questionnaire .choices .choice:has(input:disabled) {
    cursor: default;
}

/* Responsive layout */

@media (max-width: 700px) {
    .admin-page {
        padding: 20px;
    }

    .admin-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .admin-sidebar {
        width: 100%;
    }

    .admin-content {
        width: 100%;
    }

    .selection {
        grid-template-columns: 1fr;
    }

    #items {
        overflow-x: auto;
    }

    .template-item {
        min-width: 650px;
    }

    .saved-data .saved-data-name {
        width: auto;
    }

    .saved-data .saved-data-description {
        display: none;
    }

    .saved-data .saved-data-table td.saved-data-actions {
        width: 110px;
    }
}

@media (max-width: 600px) {
    .site-header .header-inner {
        padding: 15px 20px;
    }

    .site-header .brand-name {
        font-size: 25px;
    }

    .site-header .site-link {
        font-size: 12px;
    }

    main {
        padding: 0 12px 48px;
    }

    .intro {
        padding: 52px 10px 38px;
    }

    .lead {
        font-size: 19px;
    }

    .selection {
        gap: 16px;
    }

    .selection .choice {
        min-height: 250px;
        padding: 25px 23px;
    }

    .selection .choice h2 {
        font-size: 29px;
    }

    .site-footer {
        padding: 20px;
        flex-direction: column;
    }

    .result-list {
        columns: 1;
    }

    .section {
        padding: 15px;
    }

    .toolbar {
        padding: 15px;
    }

    .settings-card {
        padding: 20px;
    }

    .account-details > div {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    * {
        transition: none !important;
    }
}


/* Admin saved-data table */

.admin-data-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-data-table th,
.admin-data-table td {
    padding: 14px 12px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
}

.admin-data-table th {
    font-weight: 600;
}

.admin-data-table td:nth-child(3) {
    white-space: nowrap;
}

.admin-data-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.admin-data-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.admin-data-icon:hover {
    background: #f4f0ed;
    color: var(--accent);
}

.admin-data-icon svg {
    width: 18px;
    height: 18px;
}

.admin-data-delete:hover {
    color: #b33b32;
}

.admin-data-icon:disabled {
    opacity: 0.4;
    cursor: wait;
}


/* Password change page */

.password-change-page {
    max-width: 460px;
    margin: 8vh auto;
    padding: 0 20px 40px;
}

.password-change-intro {
    margin: 0 0 28px;
    line-height: 1.6;
}

.password-change-form .login-field {
    margin-bottom: 20px;
}

.password-change-form .login-field label {
    display: block;
    margin-bottom: 8px;
}

.password-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.password-input-row input {
    flex: 1;
    min-width: 0;
}

.password-input-row .password-toggle {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
    margin: 0;
    min-width: 0;
}

/* Strength indicator */

.password-strength {
    margin: 8px 0 18px;
}

.password-strength-track {
    width: 100%;
    height: 8px;
    background: #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

#strengthBar {
    width: 0;
    height: 100%;
    border-radius: 6px;
    transition:
        width 0.2s ease,
        background-color 0.2s ease;
}

#strengthText {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Password requirements */

.password-requirements {
    margin: 12px 0 20px;
}

.password-requirements p {
    margin: 7px 0;
    color: #a33a32;
    font-size: 0.9rem;
}

.password-requirements p::before {
    content: "✗ ";
    font-weight: 700;
}

.password-requirements p.valid {
    color: #237a46;
}

.password-requirements p.valid::before {
    content: "✓ ";
}

/* Generator */

.password-generate {
    width: 100%;
    margin: 0 0 24px;
}

/* Tablet: keep the existing tabs and actions, but give content the full width. */
@media (max-width: 1024px) {
    .admin-page {
        padding: 24px clamp(16px, 4vw, 32px) 64px;
    }

    .admin-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
    }

    .admin-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
    }

    .admin-sidebar button {
        flex: 1 1 180px;
        min-height: 44px;
        text-align: center;
    }

    .admin-content {
        width: 100%;
        min-width: 0;
    }

    .template-item {
        grid-template-columns: 36px minmax(0, 1fr) auto;
        min-width: 0;
    }

    .template-caption,
    .template-description {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .template-description {
        grid-column: 2 / -1;
    }

    .template-actions button,
    .admin-data-icon,
    .saved-data .saved-data-table button.saved-data-icon {
        flex-basis: 44px;
        width: 44px;
        min-width: 44px;
        max-width: 44px;
        height: 44px;
        min-height: 44px;
    }

    .user-table .template-actions {
        gap: 4px;
    }

    .user-table th,
    .user-table td {
        padding: 12px;
    }

    .user-upload-form select {
        min-height: 44px;
    }

    .question input[type="number"] {
        width: 100%;
        min-height: 44px;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 3px;
        background: #fff;
        color: var(--ink);
        font: inherit;
    }
}

/* Phone: visible tab grid and readable, touch-friendly data cards. */
@media (max-width: 600px) {
    .site-header .header-inner {
        flex-wrap: wrap;
        gap: 8px 12px;
    }

    .site-header .brand,
    .site-header .header-inner > .brand-name {
        flex: 1 1 auto;
        min-width: 0;
    }

    .site-header .site-link {
        order: 3;
        margin-left: auto;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .site-header .user-menu {
        margin-left: 0;
    }

    .admin-page {
        padding: 20px 16px 48px;
    }

    .admin-layout {
        gap: 18px;
        margin-top: 18px;
    }

    .admin-sidebar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        overflow: visible;
    }

    .admin-sidebar button {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 10px 8px;
        font-size: 13px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .admin-sidebar button:nth-child(3):last-child {
        grid-column: 1 / -1;
    }

    .admin-content,
    .user-table-wrap,
    #saved-data-list {
        min-width: 0;
        max-width: 100%;
    }

    .admin-content {
        overflow-x: hidden;
    }

    .intro {
        padding: 32px 0;
    }

    .selection .choice {
        min-height: 0;
    }

    .user-table,
    .admin-data-table,
    .saved-data .saved-data-table {
        display: block;
        width: 100%;
    }

    .user-table thead,
    .admin-data-table thead,
    .saved-data .saved-data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .user-table tbody,
    .admin-data-table tbody,
    .saved-data .saved-data-table tbody {
        display: grid;
        gap: 12px;
    }

    .user-table tbody tr,
    .admin-data-table tbody tr,
    .saved-data .saved-data-table tbody tr {
        display: grid;
        min-width: 0;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
    }

    .user-table td,
    .admin-data-table td,
    .saved-data .saved-data-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        min-width: 0;
        padding: 6px 0;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: right;
        border: 0;
    }

    .user-table td::before,
    .admin-data-table td::before,
    .saved-data .saved-data-table td::before {
        flex: 0 0 80px;
        font-weight: 600;
        text-align: left;
        color: var(--muted);
    }

    .user-table td:nth-child(1)::before,
    .admin-data-table td:nth-child(1)::before,
    .saved-data .saved-data-table td:nth-child(1)::before { content: 'Name'; }
    .user-table td:nth-child(2)::before { content: 'Person'; }
    .user-table td:nth-child(1)::before { content: 'Benutzer'; }
    .user-table td:nth-child(3)::before { content: 'E-Mail'; }
    .user-table td:nth-child(4)::before { content: 'Admin'; }
    .admin-data-table td:nth-child(2)::before { content: 'Benutzer'; }
    .admin-data-table td:nth-child(3)::before { content: 'Zeitpunkt'; }
    .saved-data .saved-data-table td:nth-child(2)::before { content: 'Typ'; }
    .saved-data .saved-data-table td:nth-child(3)::before { content: 'Zeitpunkt'; }
    .user-table td:last-child::before,
    .admin-data-table td:last-child::before,
    .saved-data .saved-data-table td:last-child::before { content: 'Aktionen'; }

    .user-table th:first-child,
    .user-table td:first-child,
    .user-table th:last-child,
    .user-table td:last-child,
    .saved-data .saved-data-table td.saved-data-actions {
        width: auto;
        padding: 6px 0;
    }

    .user-table .template-actions,
    .admin-data-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .admin-data-table td:nth-child(3) {
        white-space: normal;
    }

    #items {
        overflow-x: visible;
    }

    .template-item {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 8px;
    }

    .template-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .user-upload-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .user-upload-form input[type="file"],
    .user-upload-form button,
    .user-upload-form select,
    .actions button,
    .login-form button {
        width: 100%;
        min-width: 0;
    }

    .form-action-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-action-row .actions,
    .form-action-row .form-top-action {
        display: contents;
    }

    .form-top-action button {
        grid-area: 1 / 2;
        width: 100%;
        min-width: 0;
    }

    .user-form-actions,
    .settings-actions {
        flex-wrap: wrap;
    }

    #createUserPanel,
    .settings-card {
        max-width: 100%;
        padding: 16px;
    }

    .file-preview-dialog {
        width: calc(100% - 16px);
        height: calc(100% - 32px);
        padding: 12px;
    }

    .file-preview-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .file-preview-header strong {
        flex-basis: 100%;
    }

    .file-preview-content {
        height: calc(100% - 100px);
    }

    input,
    textarea,
    select {
        font-size: 16px;
    }
}

@media (pointer: coarse) {
    .form-back,
    .password-toggle,
    #userDropdown button,
    .choices .choice {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .choices input {
        width: 24px;
        height: 24px;
        flex: 0 0 24px;
    }

    button:focus-visible,
    a:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible {
        outline: 3px solid var(--accent);
        outline-offset: 2px;
    }
}

/* Submit and error */

.password-error {
    color: #a33a32;
    margin: 12px 0;
}

.password-error:empty {
    display: none;
}

.password-submit {
    width: 100%;
}

.password-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

@media (max-width: 520px) {
    .password-change-page {
        margin-top: 5vh;
    }
}
