:root {
  --ink: #1d2433; --muted: #667085; --line: #e4e7ec; --bg: #f5f6f8; --card: #fff;
  --accent: #ff6a13; --accent-dark: #e05500; --nav: #1d2433;
  --ok-bg: #dcfae6; --ok: #05603a; --err-bg: #fee4e2; --err: #b42318;
  --info-bg: #eff4ff; --info: #1849a9; --warn-bg: #fef0c7; --warn: #93370d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: #175cd3; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 26px 0 10px; }
.card h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.topbar { background: var(--nav); color: #fff; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; min-height: 60px; display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.logo { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.logo-mark { display: block; width: 30px; height: 30px; }
nav { display: flex; gap: 4px; }
nav a { color: #c8cdd6; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; }
nav a.active, nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.signout { margin-left: auto; }
/* "Sign out" is a button styled exactly like the menu links (same size, same hover). */
.topbar button.link { background: none; border: 0; color: #c8cdd6; cursor: pointer; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: inherit; }
.topbar button.link:hover, .topbar button.link:focus-visible { color: #fff; background: rgba(255,255,255,.1); }
.topbar button.link:focus-visible, nav a:focus-visible { outline: 2px solid #ff6a13; outline-offset: 1px; }
.shell { max-width: 1240px; margin: 0 auto; padding: 28px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.crumb { margin: 0 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; overflow-x: auto; }
button, .button { display: inline-block; font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 8px; border: 1px solid #d0d5dd; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: #f9fafb; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); }
.big { padding: 11px 18px; font-size: 15px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.danger { color: var(--err); border-color: #fda29b; }
input, textarea { font: inherit; border: 1px solid #d0d5dd; border-radius: 8px; padding: 8px 10px; width: 100%; background: #fff; }
textarea { font: 13px/1.5 ui-monospace, monospace; }
label { display: block; font-weight: 600; font-size: 14px; }
label input, label textarea { margin-top: 4px; font-weight: 400; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.inline-form input[name=name] { max-width: 320px; }
.inline-form input[type=file] { max-width: 420px; }
.check { display: flex; gap: 6px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.actions { text-align: right; white-space: nowrap; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef2f6; color: #344054; }
.pill.subject { background: #fff1e6; color: var(--accent-dark); }
.pill.ready, .pill.run-done, .pill.welcome { background: var(--ok-bg); color: var(--ok); }
.pill.error, .pill.run-failed { background: var(--err-bg); color: var(--err); }
.pill.pending, .pill.processing, .pill.run-queued, .pill.run-extracting, .pill.run-scoring, .pill.run-rendering { background: var(--info-bg); color: var(--info); }
.pill.terms { background: #e0eaff; color: #3538cd; }
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.error-text { color: var(--err); max-width: 320px; }
.warn-text { color: var(--warn); }
.promo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.promo { padding: 0; overflow: hidden; }
.promo img { display: block; width: 100%; height: 170px; object-fit: cover; object-position: top; border-bottom: 1px solid var(--line); }
.noimg { height: 170px; display: grid; place-items: center; color: var(--muted); background: #f2f4f7; }
.promo-body { padding: 12px 14px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.files { list-style: none; margin: 6px 0; padding: 0; color: var(--muted); word-break: break-all; }
.kind { display: inline-block; min-width: 92px; font-weight: 600; color: #344054; }
.score { font-size: 20px; font-weight: 800; text-align: center; }
.s1 { color: #b42318; } .s2 { color: #c4320a; } .s3 { color: #b54708; } .s4, .s5 { color: #027a48; }
.subject-row td { background: #fff7f0; }
.log { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow-y: auto; }
.log li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.login { max-width: 380px; margin: 60px auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.confirm-delete details { position: relative; }
.confirm-delete summary { list-style: none; }
.confirm-delete summary::-webkit-details-marker { display: none; }
.confirm-box { position: absolute; right: 0; top: 44px; z-index: 5; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 10px 30px rgba(16,24,40,.15); display: grid; gap: 10px; font-size: 14px; }
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
  .inline-form input[name=name], .inline-form input[type=file] { max-width: 100%; }
}

/* Settings: formatted framework, editor with preview, rule list */
.card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.md { line-height: 1.6; }
.md h1 { font-size: 22px; margin: 4px 0 10px; }
.md h2 { font-size: 18px; margin: 20px 0 8px; }
.md h3 { font-size: 16px; margin: 16px 0 6px; }
.md p, .md ul, .md ol { margin: 0 0 10px; }
.md ul, .md ol { padding-left: 22px; }
.md table { border-collapse: collapse; margin: 8px 0 14px; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.md th { background: #f2f4f7; }
.framework-view { border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; background: #fcfcfd; max-height: 640px; overflow-y: auto; }
.framework-actions { display: grid; gap: 10px; margin-top: 14px; }
details.editor > summary { list-style: none; width: fit-content; }
details.editor > summary::-webkit-details-marker { display: none; }
details.editor[open] > summary { margin-bottom: 12px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.split textarea.md-source { font: 14px/1.55 ui-monospace, "SFMono-Regular", Menlo, monospace; min-height: 420px; }
.label-like { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.preview { border: 1px dashed #d0d5dd; border-radius: 8px; padding: 12px 16px; min-height: 420px; max-height: 760px; overflow-y: auto; }
.editor-form .row { margin-top: 12px; }
textarea.autogrow { resize: vertical; overflow: hidden; }
.rules { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.rule { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.rule textarea { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; border-color: transparent; background: #f9fafb; min-height: 40px; }
.rule textarea:focus { border-color: #d0d5dd; background: #fff; outline: 2px solid #ffd6b8; }
.rule-no { display: grid; place-items: center; width: 26px; height: 26px; margin-top: 6px; border-radius: 50%; background: #fff1e6; color: var(--accent-dark); font-weight: 700; font-size: 13px; }
.rule-tools { display: flex; gap: 4px; align-items: center; margin-top: 4px; }
button.icon { padding: 4px 9px; font-size: 13px; line-height: 1.2; }
.pill.custom { background: #f4ebff; color: #6941c6; }
.new-rule { border-style: dashed; }
.rules-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .preview, .split textarea.md-source { min-height: 240px; }
  .rule { grid-template-columns: 24px 1fr; }
  .rule-tools { grid-column: 2; }
}

.summary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.summary-list li { padding-left: 12px; border-left: 3px solid #ffd6b8; }

.reread { margin-top: 8px; justify-content: flex-end; color: var(--muted); }
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.pill.check { background: var(--warn-bg); color: var(--warn); }
.sources ul { margin: 4px 0 0 18px; padding: 0; }

.run-meta p { margin: 0 0 2px; }
.run-meta strong { font-weight: 700; color: inherit; }
.meta-label { display: inline-block; min-width: 108px; font-weight: 600; color: var(--ink); }

/* Improvement priority pills: deliberately soft tints, the label carries the meaning */
.pill.prio-high { background: #fef3f2; color: #b42318; }
.pill.prio-medium { background: #fffaeb; color: #b54708; }
.pill.prio-low { background: #f2f4f7; color: #475467; }
/* The reset confirmation sits at the bottom edge of a scrolling card: open it upwards so it is never clipped. */
.rules-actions .confirm-box { top: auto; bottom: 46px; }
[hidden] { display: none !important; }

.section-meta { margin: 0 0 14px; }
.section-meta p { margin: 0 0 2px; }

/* Collapsible "how to prepare a brand ZIP" box */
.rules-toggle { margin-top: 4px; padding: 5px 12px; font-size: 13px; }
.rules-toggle::after { content: " ▾"; }
.rules-toggle[aria-expanded="true"]::after { content: " ▴"; }
.info-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; background: #f3f6ff; border: 1px solid #dbe4ff; border-radius: 14px; padding: 20px; margin: 0 0 18px; }
.info-box h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 16px; color: #1849a9; }
.info-icon { flex: none; }
.info-main p { margin: 0 0 8px; }
.info-main ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.info-main code { background: #e3eaff; color: #1b3a8a; }
.info-tree { background: #fff; border: 1px solid #dbe4ff; border-radius: 12px; padding: 16px 18px; overflow-x: auto; }
.info-tree pre { margin: 0; font: 14px/1.7 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; color: #475467; }
.info-tree .f { color: #b54708; font-weight: 700; }
.info-tree .ext { color: #475467; }
.info-tree .tag-welcome { display: inline-block; background: #dcfae6; color: #05603a; font: 600 12px/1.4 system-ui, sans-serif; padding: 0 8px; border-radius: 999px; }
@media (max-width: 860px) { .info-box { grid-template-columns: 1fr; } }
.info-main code { white-space: nowrap; }

/* Performance scoring */
.score { font-size: 20px; font-weight: 800; }
.matrix td.cell { white-space: nowrap; }
.cell .sub { display: block; font-size: 12px; color: var(--muted); }
.cell.s1 { background: #fee4e2; } .cell.s2 { background: #fdeadb; } .cell.s3 { background: #fef0c7; }
.cell.s4 { background: #e3f7ea; } .cell.s5 { background: #cdf0da; }
.trend.improving { color: #027a48; } .trend.worsening { color: #b42318; } .trend.stable { color: var(--muted); }
.narrow { max-width: 520px; }
form.inline { display: inline; }
.pill.run-collecting { background: var(--info-bg); color: var(--info); }
h3 { font-size: 15px; margin: 18px 0 8px; }
