:root {
    --ink: #23313d;
    --muted: #667582;
    --line: #dfe6eb;
    --paper: #ffffff;
    --wash: #f4f7f8;
    --green: #236b57;
    --green-dark: #174c3f;
    --red: #a33d3d;
    --amber: #8a5d13;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; color: var(--ink); background: var(--wash); font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif; line-height: 1.6; overflow-x: hidden; }
a { color: var(--green-dark); }
.topbar { background: var(--green-dark); color: #fff; }
.topbar-inner, .container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .04em; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav a, .nav button { color: #fff; background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; }
.nav form { margin: 0; }
.mobile-menu { display: none; }
.container { padding: 32px 0 56px; }
h1, h2, h3 { line-height: 1.3; margin-top: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 22px; box-shadow: 0 2px 8px rgba(35,49,61,.04); }
.filters { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 180px)) auto; gap: 10px; align-items: end; margin-bottom: 18px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
input, select, textarea { width: 100%; border: 1px solid #c7d2d9; border-radius: 7px; background: #fff; color: var(--ink); padding: 9px 11px; font: inherit; }
textarea { min-height: 150px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(35,107,87,.14); border-color: var(--green); }
.form-row { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 22px; }
.button { display: inline-block; border: 1px solid var(--green); border-radius: 7px; padding: 8px 15px; background: var(--green); color: #fff; font: inherit; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--green-dark); }
.button.secondary { color: var(--green-dark); background: #fff; }
.button.danger { background: var(--red); border-color: var(--red); }
.button.small { padding: 5px 10px; font-size: .88rem; }
.inline { display: inline; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox input { width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; padding: 12px 9px; }
th { white-space: nowrap; font-size: .85rem; color: var(--muted); }
td .sub { color: var(--muted); font-size: .82rem; }
.question-cell { min-width: 260px; }
.answer-preview { max-width: 380px; white-space: pre-wrap; color: #40515c; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .78rem; background: #e8eef0; color: #40515c; white-space: nowrap; }
.badge.green { background: #dff1e8; color: #216448; }
.badge.amber { background: #fff0cf; color: var(--amber); }
.badge.red { background: #f9dfdf; color: var(--red); }
.alert { border-radius: 8px; padding: 12px 15px; margin-bottom: 18px; }
.alert.success { background: #e0f2e8; color: #1e6044; }
.alert.error { background: #fbe4e4; color: #8f3030; }
.alert.warning { background: #fff1d2; color: #7e5711; }
.errors { margin: 0; padding-left: 20px; }
.detail-grid { display: grid; grid-template-columns: 150px 1fr; gap: 0; }
.detail-grid dt, .detail-grid dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); font-size: .9rem; }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .88rem; }
.pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 18px 0 0; }
.pagination a, .pagination span { display: block; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; }
.pagination .active span { background: var(--green); color: #fff; border-color: var(--green); }
nav[role="navigation"] { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; color: var(--muted); font-size: .88rem; }
nav[role="navigation"] > div:first-child { display: none; }
nav[role="navigation"] > div:last-child { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }
nav[role="navigation"] > div:last-child > div { display: flex; align-items: center; }
nav[role="navigation"] p { margin: 0; }
nav[role="navigation"] a,
nav[role="navigation"] span[aria-disabled="true"],
nav[role="navigation"] span[aria-current="page"] { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 34px; padding: 5px 10px; border: 1px solid var(--line); background: var(--paper); color: var(--green-dark); text-decoration: none; }
nav[role="navigation"] a:first-child,
nav[role="navigation"] span[aria-disabled="true"]:first-child { border-radius: 6px 0 0 6px; }
nav[role="navigation"] a:last-child,
nav[role="navigation"] span[aria-disabled="true"]:last-child { border-radius: 0 6px 6px 0; }
nav[role="navigation"] a:hover { background: var(--wash); }
nav[role="navigation"] span[aria-current="page"] { background: var(--green); border-color: var(--green); color: #fff; }
nav[role="navigation"] span[aria-disabled="true"] { color: #aab6bd; }
nav[role="navigation"] svg { display: inline-block; width: 1rem; height: 1rem; max-width: 1rem; max-height: 1rem; }
nav[role="navigation"] a > span,
nav[role="navigation"] span[aria-disabled="true"] > span { display: inline-flex; align-items: center; justify-content: center; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(430px, 100%); }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 16px; }
@media (max-width: 850px) { .filters, .form-grid { grid-template-columns: 1fr 1fr; } .filters > :first-child { grid-column: 1 / -1; } }
@media (max-width: 560px) {
    .topbar { padding: 10px 0; }
    .topbar-inner { align-items: center; flex-direction: row; }
    .page-head { align-items: stretch; flex-direction: column; }
    .topbar-inner, .container { width: min(100% - 24px, 1180px); }
    .container { padding: 22px 0 40px; }
    .brand { max-width: calc(100% - 84px); overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
    .desktop-nav { display: none; }
    .mobile-menu { display: block; position: relative; margin-left: auto; z-index: 20; }
    .mobile-menu-button { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 76px; min-height: 42px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.32); border-radius: 7px; color: #fff; cursor: pointer; font-size: .86rem; list-style: none; }
    .mobile-menu-button::-webkit-details-marker { display: none; }
    .mobile-menu-button span:first-child { font-size: 1.3rem; line-height: 1; }
    .mobile-menu[open] .mobile-menu-button { background: rgba(255,255,255,.14); }
    .mobile-menu-panel { position: absolute; top: calc(100% + 8px); right: 0; width: min(260px, calc(100vw - 24px)); overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); box-shadow: 0 10px 24px rgba(35,49,61,.18); }
    .mobile-menu-panel a, .mobile-menu-panel button { display: block; width: 100%; padding: 12px 15px; border: 0; border-bottom: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; text-align: left; text-decoration: none; }
    .mobile-menu-panel a:hover, .mobile-menu-panel button:hover { background: var(--wash); }
    .mobile-menu-panel form { margin: 0; }
    .mobile-menu-panel form button { color: var(--red); cursor: pointer; }
    .mobile-menu-user { display: block; padding: 10px 15px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .84rem; }
    .page-head { gap: 12px; margin-bottom: 16px; }
    h1 { font-size: 1.45rem; }
    .page-head > .button, .page-head > .actions { width: 100%; }
    .page-head > .button { text-align: center; }
    .page-head > .actions { margin-top: 0; }
    .page-head > .actions > *, .page-head > .actions form { flex: 1 1 100%; width: 100%; }
    .page-head > .actions .button { width: 100%; text-align: center; }
    .card { padding: 16px; border-radius: 9px; }
    .filters, .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .filters > :first-child { grid-column: auto; }
    .filters > .button { width: 100%; }
    .table-wrap { margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap table { min-width: 640px; font-size: .88rem; }
    th, td { padding: 10px 8px; }
    .question-cell { min-width: 220px; }
    .answer-preview { display: -webkit-box; width: 400px; min-width: 320px; max-width: 400px; overflow: hidden; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
    .detail-grid dt { border-bottom: 0; padding-bottom: 0; }
    .detail-grid dd { padding-top: 3px; overflow-wrap: anywhere; }
    nav[role="navigation"] { align-items: stretch; flex-direction: column; gap: 10px; }
    nav[role="navigation"] > div:last-child { align-items: stretch; flex-direction: column; gap: 10px; }
    nav[role="navigation"] > div:last-child > div:last-child { justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
}
