:root {
  --bg: #F5F7F4;
  --surface: #FFFFFF;
  --ink: #0F1F19;
  --muted: #4B5B54;
  --muted2: #56665F;
  --line: #DCE3DE;
  --line2: #E8EDEA;
  --field: #B9C6BF;
  --green: #0B6B45;
  --green-d: #08553A;
  --green-t: #E3F1E9;
  --amber: #7A4E00;
  --amber-t: #FFF1D6;
  --blue: #1E4E8C;
  --blue-t: #E6EEF8;
  --red: #A3330C;
  --red-t: #FBE9E2;
  --radius: 14px;
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --head: 'Readex Pro', 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.7; }
a { color: var(--green); }
a:hover { color: var(--green-d); }
:focus-visible { outline: 3px solid #1E6FD9; outline-offset: 2px; }
main:focus { outline: none; }

.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -80px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 20; }
.skip:focus { top: 12px; color: #fff; }
.num { unicode-bidi: isolate; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(245, 247, 244, 0.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--head); font-weight: 700; font-size: 22px; min-height: 44px; }
.brand:hover { color: var(--ink); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; transition: background-color .15s ease; }
.nav a:hover { background: #E7ECE8; color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--green); color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.badge[hidden] { display: none; }
.nav a[aria-current="page"] .badge { background: #fff; color: var(--ink); }

/* type */
h1, h2, h3 { font-family: var(--head); line-height: 1.35; margin: 0; }
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-weight: 600; font-size: 14px; }
.lead { margin: 12px 0 0; color: var(--muted); font-size: 17px; max-width: 760px; }
.muted { color: var(--muted2); }
.small { font-size: 14px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* feed */
.page-head { padding: 36px 0 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.fchip { font: inherit; font-weight: 500; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; gap: 8px; align-items: center; transition: background-color .15s ease, border-color .15s ease; }
.fchip:hover { border-color: var(--field); }
.fchip span { color: var(--muted2); font-size: 13px; }
.fchip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.fchip.on span { color: #C9D3CE; }

.grid, .tlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; padding-block: 24px; }
.tlist { padding-bottom: 48px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.pcard { display: flex; flex-direction: column; gap: 14px; text-decoration: none; color: var(--ink); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.pcard:hover { transform: translateY(-2px); border-color: #C5D1CA; box-shadow: 0 10px 24px rgba(15, 31, 25, 0.08); color: var(--ink); }
.pc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.score { color: var(--muted2); font-size: 14px; }
.score b { font-family: var(--head); font-size: 28px; color: var(--ink); margin-inline-end: 2px; }
.pc-name { font-size: 18px; font-weight: 600; line-height: 1.5; }
.chip, .vtag { display: inline-flex; align-items: center; padding: 3px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.v-test { background: var(--green-t); color: var(--green); }
.v-cond { background: var(--amber-t); color: var(--amber); }
.v-res { background: var(--blue-t); color: var(--blue); }
.v-avoid { background: #EEF1EF; color: var(--muted); }

.mini { display: flex; flex-direction: column; gap: 6px; }
.mrow { display: grid; grid-template-columns: 96px 1fr 24px; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.mrow b { color: var(--ink); text-align: left; }
.track { display: block; height: 6px; background: var(--line2); border-radius: 999px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.track.lg { height: 10px; }

.sig { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.sig div { background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.sig dt { font-size: 12.5px; color: var(--muted2); line-height: 1.4; }
.sig dd { margin: 2px 0 0; font-weight: 700; font-size: 15px; }
.sig.wide { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-top: 12px; }
.pc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line2); padding-top: 12px; font-size: 14px; flex-wrap: wrap; margin-top: auto; }
.go { color: var(--green); font-weight: 600; }
.note { color: var(--muted2); font-size: 14px; padding-bottom: 32px; }

/* product */
.crumbs { padding-top: 16px; }
.crumbs a { font-weight: 500; display: inline-flex; min-height: 44px; align-items: center; }
.phead { display: flex; gap: 24px; align-items: flex-start; justify-content: space-between; padding-block: 4px 24px; flex-wrap: wrap; }
.phead-main { flex: 1 1 520px; min-width: 0; }
.phead-main h1 { margin-top: 12px; }
.bigscore { flex: none; width: 120px; height: 120px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.bigscore b { font-family: var(--head); font-size: 44px; line-height: 1; color: var(--green); }
.bigscore span { font-size: 13px; color: var(--muted2); margin-top: 6px; }
.exists { margin: 12px 0 0; background: var(--green-t); padding: 10px 14px; border-radius: 10px; font-size: 15px; }
.pgrid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; padding-bottom: 48px; align-items: start; }
.axes { display: flex; flex-direction: column; gap: 16px; margin: 16px 0 24px; }
.axis-top { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; margin-bottom: 6px; }
.axis p { margin: 6px 0 0; font-size: 14px; color: var(--muted2); }

/* forms */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field input { font: inherit; font-size: 17px; min-height: 48px; padding: 0 14px; border: 1px solid var(--field); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
.field input:focus { border-color: var(--green); outline: 3px solid rgba(11, 107, 69, 0.22); outline-offset: 0; }
.field small { color: var(--muted2); font-weight: 400; font-size: 12.5px; line-height: 1.5; }
.hint { margin: 12px 0 0; background: var(--amber-t); color: #5C3B00; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.calc-empty { margin: 0 0 16px; }
.form-err { color: var(--red); font-size: 14px; margin: 0 0 8px; }
.form-err:empty { display: none; }

.result { background: var(--green-t); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.result.bad { background: var(--red-t); }
.r-big { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.r-big span { font-weight: 600; }
.r-big b { font-family: var(--head); font-size: 34px; line-height: 1.1; color: var(--green); }
.result.bad .r-big b { color: var(--red); }
.result.bad p:last-child { margin: 0; color: #5E2109; }
.rgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.rgrid div { background: rgba(255, 255, 255, 0.75); border-radius: 10px; padding: 10px 12px; }
.rgrid dt { font-size: 12.5px; color: #2F4A3E; line-height: 1.4; }
.rgrid dd { margin: 2px 0 0; font-weight: 700; font-size: 17px; }
.r-note { margin: 12px 0 0; color: #2F4A3E; }

.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 22px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: transform .12s ease, background-color .12s ease, border-color .12s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-d); color: #fff; }
.btn.primary:disabled { background: #9FB3A9; cursor: not-allowed; transform: none; }
.btn.ghost { background: #fff; border-color: var(--field); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: #fff; border-color: #E3B5A3; color: var(--red); }
.btn.block { width: 100%; }
.linkbtn { font: inherit; background: none; border: none; color: var(--red); cursor: pointer; min-height: 44px; padding: 0 8px; text-decoration: underline; text-underline-offset: 4px; }

/* test */
.thead { padding-block: 4px 16px; }
.verdict { border-radius: 14px; padding: 18px 20px; border: 1px solid; }
.verdict b { font-family: var(--head); font-size: 22px; display: block; }
.verdict p { margin: 4px 0 0; }
.vk-scale { background: var(--green); border-color: var(--green); color: #fff; }
.vk-go { background: var(--green-t); border-color: #BFDCCB; color: #0B3D27; }
.vk-start, .vk-wait { background: var(--blue-t); border-color: #C6D6EC; color: #14355F; }
.vk-risk { background: var(--amber-t); border-color: #F0D49A; color: #4D3100; }
.vk-stop { background: var(--red-t); border-color: #EDC3B3; color: #5E2109; }
.vtag.vk-scale, .vtag.vk-go, .vtag.vk-start, .vtag.vk-wait, .vtag.vk-risk, .vtag.vk-stop { border: none; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding-block: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.kpi > span { font-size: 13px; color: var(--muted2); }
.kpi b { display: block; font-family: var(--head); font-size: 24px; margin-top: 2px; }
.kpi small { display: block; color: var(--muted2); font-size: 12.5px; margin-top: 4px; line-height: 1.5; }
.bar { height: 6px; background: var(--line2); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); }
.delivery-note { margin-top: -4px; }

.twocol { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; padding-bottom: 16px; align-items: start; }
.chart { width: 100%; height: auto; display: block; margin-top: 12px; font-family: var(--font); direction: ltr; }
.chart .grid-lines line { stroke: var(--line2); stroke-width: 1; }
.chart .grid-lines text, .chart .x-labels text { fill: var(--muted2); font-size: 12px; }
.chart .ref-target { stroke: var(--green); stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart .ref-max { stroke: var(--ink); stroke-width: 1.5; }
.chart .ref-stop { stroke: var(--red); stroke-width: 1.5; stroke-dasharray: 3 4; }
.chart .ref-label { font-size: 12px; font-weight: 600; }
.chart .ref-target-t { fill: var(--green); }
.chart .ref-max-t { fill: var(--ink); }
.chart .ref-stop-t { fill: var(--red); }
.chart .cpa-line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .cpa-dot { fill: #fff; stroke: var(--blue); stroke-width: 2.5; }
.chart-empty { margin-top: 12px; border: 1px dashed var(--line); border-radius: 12px; padding: 48px 16px; text-align: center; color: var(--muted2); }
.chart-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 8px 0 0; font-size: 13px; color: var(--muted2); }
.k { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid; margin-inline-end: -8px; vertical-align: middle; }
.k-line { border-color: var(--blue); }
.k-target { border-color: var(--green); border-top-style: dashed; }
.k-max { border-color: var(--ink); }
.k-stop { border-color: var(--red); border-top-style: dotted; }

.tablebox { overflow-x: auto; margin-top: 12px; position: relative; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--line2); }
th { font-size: 13px; color: var(--muted2); font-weight: 600; }
.settings-wrap { padding-block: 16px 48px; }
.settings summary { font-family: var(--head); font-weight: 600; font-size: 18px; cursor: pointer; min-height: 32px; }
.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line2); }

/* empty, how */
.empty { text-align: center; padding: 48px 20px; margin-block: 24px 48px; }
.empty p { max-width: 460px; margin: 12px auto 20px; }
.how { display: flex; flex-direction: column; gap: 16px; padding-block: 24px 48px; }
.how p { margin: 12px 0 0; }
.rules { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 12px; }
.rules li { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }

/* footer */
.site-foot { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted2); font-size: 13.5px; }
.site-foot p { margin: 0; max-width: 760px; }

@media (max-width: 880px) {
  .pgrid, .twocol { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .fields, .rgrid { grid-template-columns: minmax(0, 1fr); }
  .bigscore { width: 96px; height: 96px; }
  .bigscore b { font-size: 36px; }
  .nav a { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
