:root {
  --ink: #17243e;
  --muted: #667085;
  --line: #dfe4ea;
  --paper: #ffffff;
  --canvas: #f4f6f8;
  --accent: #0b7a75;
  --accent-dark: #075e5a;
  --navy: #1d3455;
  --soft-teal: #e9f5f3;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--navy); border-radius: 9px; font-weight: 850; }
.help-menu { position: relative; flex: 0 0 auto; }
.help-menu summary { list-style: none; min-height: 38px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--navy); background: #fff; border: 1px solid #cbd4de; border-radius: 9px; font-size: .82rem; font-weight: 760; cursor: pointer; user-select: none; transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease; }
.help-menu summary::-webkit-details-marker { display: none; }
.help-menu summary::before { content: "?"; width: 20px; height: 20px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 50%; font-size: .72rem; font-weight: 850; }
.help-menu summary:hover, .help-menu[open] summary { background: var(--soft-teal); border-color: #9dcfc9; }
.help-menu summary:focus-visible { outline: 3px solid rgba(11,122,117,.18); outline-offset: 2px; }
.help-panel { position: absolute; top: calc(100% + 12px); right: 0; width: min(470px, calc(100vw - 32px)); max-height: calc(100vh - 92px); overflow-y: auto; padding: 24px; color: var(--ink); background: #fff; border: 1px solid #ccd5df; border-radius: 14px; box-shadow: 0 22px 55px rgba(22,36,62,.18); }
.help-heading { padding-bottom: 16px; border-bottom: 1px solid #e8edf1; }
.help-heading h2 { margin: 6px 0 0; font-size: 1.2rem; letter-spacing: -.025em; }
.help-steps { margin: 18px 0; padding-left: 22px; color: #475467; font-size: .82rem; line-height: 1.55; }
.help-steps li + li { margin-top: 9px; }
.help-steps strong { color: #2d3b50; }
.help-warning { display: grid; gap: 5px; padding: 13px 14px; color: #704a1d; background: #fcf5e7; border: 1px solid #ead7b4; border-radius: 9px; font-size: .78rem; line-height: 1.5; }
.help-note { margin: 13px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 72px; }

.hero { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(360px,.95fr); gap: 28px; align-items: center; margin-bottom: 24px; }
.eyebrow { margin: 0; color: var(--accent-dark); font-size: .77rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.hero h1 { max-width: 650px; margin: 9px 0 0; font-size: clamp(2.15rem, 4.2vw, 3.45rem); line-height: 1.02; letter-spacing: -.05em; }
.hero h1 span { display: block; }
.title-types { color: var(--accent-dark); }
.objective-card { padding: 20px 22px; background: linear-gradient(135deg,#fff 0%,#f5faf9 100%); border: 1px solid #d4e4e2; border-radius: 14px; box-shadow: 0 10px 28px rgba(22,36,62,.045); }
.objective-label { display: inline-flex; margin-bottom: 8px; color: var(--accent-dark); font-size: .73rem; font-weight: 820; letter-spacing: .075em; text-transform: uppercase; }
.objective-card p { margin: 0; color: #526074; font-size: .88rem; line-height: 1.55; }
.objective-card p + p { margin-top: 8px; }

.workspace { display: grid; grid-template-columns: minmax(0,.92fr) minmax(0,1.08fr); gap: 20px; align-items: stretch; margin-top: 20px; }
.form-card, .report-card { background: var(--paper); border: 1px solid var(--line); box-shadow: 0 12px 35px rgba(22,36,62,.055); }
.form-card { padding: 28px; border-radius: 16px; }
.card-heading { display: flex; align-items: flex-start; gap: 13px; padding-bottom: 24px; margin-bottom: 23px; border-bottom: 1px solid #edf0f3; }
.step-number { width: 28px; height: 28px; border-radius: 50%; background: var(--soft-teal); color: var(--accent-dark); display: grid; flex: 0 0 auto; place-items: center; font-weight: 850; font-size: .82rem; }
.card-heading h2, .results-heading h2, .rules-intro h2 { margin: 0; letter-spacing: -.025em; }
.card-heading h2 { font-size: 1.12rem; }
.card-heading p, .results-heading p, .rules-intro p, .report-topline p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }

label { display: block; margin: 18px 0 8px; color: #344054; font-size: .83rem; font-weight: 700; }
textarea, select { width: 100%; color: var(--ink); background: #fbfcfd; border: 1px solid #cfd6de; border-radius: 10px; outline: none; transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease; }
textarea { padding: 13px 14px; resize: vertical; line-height: 1.55; font-size: .9rem; }
textarea::placeholder { color: #98a2b3; }
textarea:focus, select:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(11,122,117,.12); }
select { height: 45px; padding: 0 38px 0 13px; }
select:disabled { color: #98a2b3; background-color: #f3f5f7; cursor: not-allowed; }
.compact-textarea { min-height: 92px; }
.author-textarea { min-height: 108px; }
.references-textarea { min-height: 316px; }
.field-hint { color: #7b8493; margin: 7px 0 0; font-size: .76rem; line-height: 1.5; }
.author-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; max-height: 132px; overflow-y: auto; padding-right: 4px; }
.author-preview span { background: #eef2f6; color: #41516a; padding: 5px 9px; border-radius: 6px; font-size: .76rem; font-weight: 650; }
.input-meta { display: flex; justify-content: space-between; gap: 14px; margin-top: 9px; color: #7b8493; font-size: .75rem; }
.error-message { margin-top: 16px; border-left: 3px solid #c24a4a; background: #fff2f1; padding: 11px 13px; color: #9d3131; border-radius: 5px; font-size: .82rem; }

.actions { display: flex; align-items: center; gap: 9px; margin-top: 22px; }
.primary-button, .secondary-button, .icon-button, .text-button { border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 720; transition: all 150ms ease; }
.primary-button { min-height: 44px; padding: 0 19px; border-radius: 9px; color: #fff; background: var(--accent); box-shadow: 0 5px 14px rgba(11,122,117,.2); }
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.secondary-button { min-height: 42px; padding: 0 15px; border-radius: 9px; color: #344054; background: #fff; border: 1px solid #ccd3dc; }
.secondary-button:hover { background: #f7f9fa; border-color: #aeb8c5; }
.icon-button { width: 42px; height: 42px; border-radius: 9px; color: #667085; background: #fff; border: 1px solid #ccd3dc; font-size: 1.25rem; }
.icon-button:hover { color: #9d3131; background: #fff7f6; border-color: #e8b8b4; }
.text-button { background: transparent; color: var(--accent-dark); padding: 8px; font-size: .8rem; }
.text-button:hover { color: var(--accent); background: var(--soft-teal); border-radius: 7px; }

.results-section { padding-top: 72px; scroll-margin-top: 48px; }
.results-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.results-heading h2 { font-size: clamp(1.65rem,3vw,2.3rem); margin-top: 9px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.metric { min-height: 148px; padding: 20px; border-radius: 13px; border: 1px solid; display: flex; flex-direction: column; }
.metric-label { font-size: .78rem; font-weight: 780; text-transform: uppercase; letter-spacing: .045em; }
.metric strong { margin: auto 0 6px; font-size: 2.55rem; line-height: 1; letter-spacing: -.05em; }
.metric > span:last-child { font-size: .76rem; opacity: .76; }
.metric-a { color: #205b4f; background: #ecf7f3; border-color: #c5e6dc; }
.metric-b { color: #2b537b; background: #eef5fb; border-color: #cbddeb; }
.metric-c { color: #895b23; background: #fbf5e9; border-color: #ead8b7; }
.metric-total { color: #3c4760; background: #f2f3f7; border-color: #d9dce5; }

.report-card { border-radius: 15px; overflow: hidden; }
.report-topline { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.report-topline h3 { margin: 0; font-size: 1rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { background: #f7f8fa; color: #667085; text-transform: uppercase; letter-spacing: .055em; font-size: .69rem; text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
td { padding: 15px 14px; border-bottom: 1px solid #edf0f3; vertical-align: top; color: #475467; line-height: 1.5; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }
.row-number { color: #98a2b3; width: 48px; font-variant-numeric: tabular-nums; }
.reference-cell { min-width: 400px; max-width: 650px; color: #2e3b4f; }
.muted { color: #98a2b3; }
.classification-control { width: 150px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.classification-select { height: 36px; min-width: 142px; padding: 0 10px; border-radius: 8px; font-size: .74rem; font-weight: 750; cursor: pointer; }
.select-a { color: #236356; background-color: #e6f4ef; border-color: #b9ddcf; }
.select-b { color: #28567f; background-color: #e9f2fa; border-color: #c2d8e9; }
.select-self { color: #8c5d24; background-color: #faf0dd; border-color: #e7d1a8; }
.restore-button { display: inline-flex; align-items: center; padding: 2px 4px; color: #687387; background: transparent; border: 0; font-size: .67rem; font-weight: 650; }
.restore-button:hover { color: var(--accent-dark); text-decoration: underline; }
.results-pagination { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 22px; color: #667085; background: #fafbfc; border-top: 1px solid var(--line); font-size: .76rem; }
.results-pagination > div { display: flex; align-items: center; gap: 8px; }
.results-pagination .secondary-button { min-height: 36px; }

.rules-section { padding: 20px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 10px 28px rgba(22,36,62,.04); }
.rules-intro { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 16px; }
.section-icon { width: 42px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; color: var(--accent-dark); background: var(--soft-teal); border-radius: 9px; font-size: .67rem; font-weight: 850; letter-spacing: -.03em; }
.rules-intro h2 { font-size: 1.2rem; }
.rules-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.rules-grid article { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 17px 18px 17px 62px; }
.rules-grid h3 { margin: 0 0 6px; font-size: .92rem; }
.rules-grid p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.rule-tag { position: absolute; top: 16px; left: 16px; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-weight: 850; }
.tag-a { color: #236356; background: #e6f4ef; }
.tag-b { color: #28567f; background: #e9f2fa; }
.tag-c { color: #8c5d24; background: #faf0dd; }

footer { min-height: 112px; display: flex; align-items: center; color: #667085; border-top: 1px solid var(--line); background: #edf0f3; font-size: .76rem; }
.footer-inner { width: min(1180px,calc(100% - 40px)); margin: 0 auto; padding: 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.footer-content { display: grid; gap: 8px; min-width: 0; }
.footer-inner p { max-width: 1000px; margin: 0; line-height: 1.5; }
.footer-inner strong { color: #4b586d; }
.license-line { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; font-size: .72rem; }
.license-line a { color: var(--accent-dark); font-weight: 680; text-underline-offset: 2px; }
.license-line a:hover { color: var(--accent); }
.cc-icons { display: inline-flex; align-items: center; gap: 3px; margin-left: 2px; }
.cc-icons img { width: 18px; height: 18px; display: block; }
.visit-counter { flex: 0 0 auto; color: #7b8493; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .objective-card { max-width: 760px; }
  .workspace { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2,1fr); }
  .rules-grid { grid-template-columns: 1fr; }
  .references-textarea { min-height: 260px; }
}

@media (max-width: 600px) {
  .topbar { min-height: 60px; gap: 8px; padding: 0 18px; }
  .brand { gap: 8px; font-size: .8rem; }
  .brand-mark { width: 31px; height: 31px; }
  .help-menu summary { padding: 0 9px; font-size: .76rem; }
  .help-menu summary::before { display: none; }
  .help-panel { position: fixed; top: 70px; right: 13px; left: 13px; width: auto; max-height: calc(100vh - 84px); padding: 20px; }
  .page-shell { width: min(100% - 26px,1180px); padding-top: 26px; }
  .hero { margin-bottom: 18px; }
  .hero h1 { font-size: 2.25rem; }
  .objective-card, .rules-section { padding: 17px; }
  .form-card { padding: 20px; border-radius: 13px; }
  textarea, select { font-size: 16px; }
  .actions { flex-wrap: wrap; }
  .primary-button { flex: 1 1 100%; }
  .secondary-button { flex: 1; }
  .input-meta { align-items: flex-start; flex-direction: column; }
  .results-section { margin-top: 54px; padding-top: 0; }
  .results-heading { align-items: flex-start; flex-direction: column; }
  .results-heading .secondary-button { width: 100%; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { min-height: 130px; padding: 16px; }
  .metric strong { font-size: 2.2rem; }
  .report-topline, .results-pagination { align-items: flex-start; flex-direction: column; padding: 19px; }
  .results-pagination > div { width: 100%; }
  .results-pagination .secondary-button { flex: 1; }
  .footer-inner { width: min(100% - 30px,1180px); align-items: flex-start; flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
