:root {
  --blue: #164a7b;
  --blue-2: #1f6097;
  --bg: #f2f5f8;
  --line: #b9c7d4;
  --text: #1e2c38;
  --muted: #5c6f7d;
  --white: #fff;
  --danger: #9b2c2c;
  --ok: #23723a;
  --warning-bg: #fff8e6;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--blue); }
button, .button { appearance: none; border: 0; border-radius: 5px; padding: 9px 13px; background: var(--blue); color: white; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:hover, .button:hover { background: var(--blue-2); }
button.secondary, .button.secondary { background: #e7eef5; color: var(--blue); border: 1px solid #b8c8d8; }
button.secondary:hover, .button.secondary:hover { background: #dce8f2; }
button:disabled { opacity: .55; cursor: not-allowed; }
.app-header { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 12px 24px; background: white; border-bottom: 1px solid #d8e0e8; position: sticky; top: 0; z-index: 30; }
.brand { color: #153e63; font-size: 24px; font-weight: 800; text-decoration: none; }
.subtitle { color: #35566f; margin-left: 16px; font-size: 13px; }
.top-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top-nav a { text-decoration: none; font-weight: 600; }
.user-chip, .active-badge { background: #eaf2f8; color: #244c68; border-radius: 999px; padding: 6px 10px; font-weight: 700; }
.inline-form { display: inline; }
.link-button { background: transparent; color: var(--blue); padding: 0; }
.page-shell { padding: 16px; max-width: 2200px; margin: 0 auto; }
.panel, .resident-card, .login-card { background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(20, 45, 65, .05); }
.panel { padding: 12px; }
h1, h2, h3 { color: #173f60; margin-top: 0; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; color: #2d485c; }
input[type="text"], input[type="password"], input[type="number"], select, textarea { width: 100%; background: white; border: 1px solid #c6d0da; border-radius: 4px; padding: 7px 8px; font: inherit; color: var(--text); }
select { min-height: 36px; }
textarea { min-height: 82px; resize: vertical; line-height: 1.38; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--blue); flex: 0 0 auto; }
fieldset { border: 1px solid #c8d4df; border-radius: 7px; margin: 0 0 12px; padding: 12px; min-width: 0; }
legend { font-weight: 800; color: #254b68; padding: 0 5px; }
.messages { max-width: 1200px; margin: 10px auto 0; padding: 0 16px; }
.message { padding: 10px 12px; border-radius: 5px; background: #e7f3e9; border: 1px solid #9cc5a4; }
.dashboard-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.resident-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.resident-card { padding: 14px; }
.resident-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 18px; }
.project-list { margin-top: 12px; display: grid; gap: 7px; }
.project-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid #d4dee7; border-radius: 5px; text-decoration: none; }
.project-row:hover { background: #f5f9fc; }
.project-row small { color: var(--muted); white-space: nowrap; }
.muted { color: var(--muted); }
.login-card { max-width: 420px; padding: 28px; margin: 8vh auto 0; }
.login-card form { display: grid; gap: 16px; }
.editor-toolbar { margin-bottom: 12px; }
.toolbar-row { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar-row:last-child { margin-bottom: 0; }
.toolbar-row label { min-width: 160px; }
.toolbar-row .grow { flex: 1 1 260px; }
.save-status { font-weight: 800; padding: 7px 10px; border-radius: 5px; }
.save-status.saved { color: var(--ok); background: #eaf6ed; }
.save-status.dirty { color: #925f00; background: #fff1cf; }
.editor-grid { display: grid; grid-template-columns: minmax(520px, 5fr) minmax(300px, 3fr) minmax(500px, 5fr); gap: 12px; align-items: stretch; }
.input-panel, .assessment-panel, .output-panel { min-height: calc(100vh - 210px); }
.scroll-region { max-height: calc(100vh - 305px); overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.tab-bar { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; border-bottom: 1px solid #d4dee7; padding-bottom: 5px; }
.tab-button { padding: 7px 9px; background: #eef3f7; color: #254b68; border: 1px solid #cad6e0; font-size: 13px; }
.tab-button.active { background: var(--blue); color: white; border-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 14px; }
.check-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-grid label { flex-direction: row; align-items: flex-start; font-weight: 500; line-height: 1.3; }
.rating-table { display: grid; grid-template-columns: minmax(200px, 1.4fr) minmax(190px, 1fr); gap: 8px 10px; align-items: center; }
.rating-table > div { overflow-wrap: anywhere; }
.rating-head { font-weight: 800; color: #244c68; }
.assessment-row { display: grid; grid-template-columns: 1fr minmax(145px, 1fr); gap: 8px; align-items: center; margin-bottom: 8px; }
.output-main textarea, .output-panel .tab-panel textarea { min-height: calc(100vh - 405px); }
.output-main { min-height: calc(100vh - 360px); }
.sub-tabs { margin-top: 2px; }
.output-actions { display: flex; gap: 7px; flex-wrap: wrap; margin: 10px 0; }
.validation-box { min-height: 95px; max-height: 145px; overflow: auto; border: 1px solid #c6d0da; border-radius: 5px; padding: 9px; background: #fbfcfd; white-space: pre-wrap; line-height: 1.35; }
.validation-box.warning { background: var(--warning-bg); border-color: #d8b65c; }
.blocks-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.blocks-table th, .blocks-table td { border: 1px solid #ccd7e0; padding: 6px; text-align: left; vertical-align: top; }
.blocks-table th { background: #edf3f7; }
.table-wrap { overflow: auto; max-height: calc(100vh - 390px); }
.footer-note { color: #7a2e00; font-weight: 700; margin: 12px 4px 2px; }
.hidden { display: none !important; }
.modal { position: fixed; inset: 0; background: rgba(15, 30, 45, .48); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal-card { width: min(700px, 95vw); max-height: 80vh; overflow: auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 16px 60px rgba(0,0,0,.25); }
.modal-card ul { padding-left: 22px; }
.admin-card { max-width: 900px; margin: 0 auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { border-bottom: 1px solid #d6e0e8; padding: 9px; text-align: left; }
.form-card { max-width: 600px; margin: 0 auto; }
.form-card form { display: grid; gap: 14px; }
.errorlist { color: var(--danger); margin: 4px 0; }

@media (max-width: 1450px) {
  .editor-grid { grid-template-columns: minmax(480px, 1.25fr) minmax(290px, .75fr); }
  .output-panel { grid-column: 1 / -1; min-height: 720px; }
  .output-main textarea, .output-panel .tab-panel textarea { min-height: 480px; }
}
@media (max-width: 900px) {
  .app-header { position: static; align-items: flex-start; flex-direction: column; }
  .subtitle { display: block; margin: 3px 0 0; }
  .editor-grid { display: block; }
  .panel { margin-bottom: 12px; }
  .scroll-region { max-height: none; }
  .input-panel, .assessment-panel, .output-panel { min-height: auto; }
  .check-grid, .check-grid.compact { grid-template-columns: 1fr; }
  .rating-table { grid-template-columns: 1fr; }
  .rating-head { display: none; }
  .assessment-row { grid-template-columns: 1fr; }
}
