/* Бағалау парағы — ортақ стиль. Ақ фон, бір ғана ашық тақырып. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f6f8fa;
  --line: #e4e8ee;
  --ink: #141a23;
  --muted: #5d6776;
  --accent: #0a7ea4;
  --accent-soft: #e6f4f9;
  --g1: #0a7ea4;
  --g1-soft: #e6f4f9;
  --g2: #a86a0c;
  --g2-soft: #fdf3e2;
  --grade5: #18804a;  --grade5-soft: #e5f5ec;
  --grade4: #0a7ea4;  --grade4-soft: #e6f4f9;
  --grade3: #b06d00;  --grade3-soft: #fdf1dc;
  --grade2: #c0392b;  --grade2-soft: #fce9e7;
  --danger: #c0392b;
  --danger-soft: #fce9e7;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 8px;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--ink); }
body { font-family: var(--font-body); font-size: 15px; line-height: 1.55; margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Жоғарғы жолақ */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1080px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); display: grid; place-items: center; }
.mark svg { width: 16px; height: 16px; }
.page-label { font-weight: 600; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 500; font-size: 13px; cursor: pointer; text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 16px; padding-block: 28px 64px; }
.banner { padding: 12px 16px; border-radius: var(--r-sm); background: var(--grade3-soft); color: #6b4300; font-size: 14px; }

/* Бет басы */
.view { display: grid; gap: 20px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.view-head > div:first-child { min-width: 0; }
h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 3.4vw, 30px); letter-spacing: -.02em; line-height: 1.2; margin: 6px 0; text-wrap: balance; }
.lede { color: var(--muted); margin: 0; max-width: 62ch; }

/* Батырмалар */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2a3442; }
.btn-ghost { background: var(--bg); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: #c9d0da; background: var(--surface); }
.btn-danger-ghost { background: var(--bg); border-color: #f1c9c4; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a32f23; }
.btn svg { width: 16px; height: 16px; flex: none; }

.confirm {
  border: 1px solid #f1c9c4; background: var(--danger-soft); border-radius: var(--r);
  padding: 16px 18px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.confirm p { margin: 0; color: #7a2219; max-width: 60ch; }
.confirm div { display: flex; gap: 8px; }

/* Кіру формасы */
.login { max-width: 380px; margin: 48px auto; border: 1px solid var(--line); border-radius: var(--r); padding: 28px; display: grid; gap: 16px; }
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0; color: var(--muted); }

/* Статистика */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-family: var(--font-display); font-weight: 500; font-size: 28px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 4px; }
.stat .v small { font-family: var(--font-body); font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }

.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gcard { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 10px; min-width: 0; }
.gcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.gcard .who { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.gcard .nums { display: flex; gap: 20px; font-size: 14px; color: var(--muted); }
.gcard .nums b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.linkrow { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; min-width: 0; }
.linkrow code { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 6px; padding: 6px 8px; overflow-x: auto; white-space: nowrap; user-select: all; }
.linkrow .btn { padding: 6px 10px; font-size: 13px; flex: none; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.tag.g1 { background: var(--g1-soft); color: var(--g1); }
.tag.g2 { background: var(--g2-soft); color: var(--g2); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #c3cad4; }
.state.sent { color: var(--grade5); }
.state.sent::before { background: var(--grade5); }
.state.dirty { color: var(--grade3); }
.state.dirty::before { background: var(--grade3); }

/* Бағалардың бөлінуі */
.dist { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 12px; }
.dist-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.dist-head b { font-weight: 600; }
.dist-head span { color: var(--muted); }
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface); }
.bar i { display: block; height: 100%; transition: width .3s; }
.bar i + i { border-left: 2px solid var(--bg); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Мониторинг кестесі */
.table-card { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface); padding: 10px 14px; white-space: nowrap; }
td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:first-child td { border-top: 0; }
td.n, th.n { width: 48px; color: var(--muted); font-variant-numeric: tabular-nums; }
td.name { font-weight: 500; overflow-wrap: anywhere; min-width: 160px; }
td.score, th.score { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; width: 90px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill b { font-family: var(--font-display); font-weight: 600; }
.pill.p5 { background: var(--grade5-soft); color: var(--grade5); }
.pill.p4 { background: var(--grade4-soft); color: var(--grade4); }
.pill.p3 { background: var(--grade3-soft); color: var(--grade3); }
.pill.p2 { background: var(--grade2-soft); color: var(--grade2); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty b { color: var(--ink); font-weight: 600; font-size: 16px; }
.empty p { margin: 0; max-width: 52ch; }

/* Топ парағы */
.field { display: grid; gap: 6px; max-width: 420px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input { font-weight: 500; }
input[type="text"], input[type="number"], input[type="password"] {
  width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--bg);
  border-radius: 10px; padding: 10px 12px; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
input:hover { border-color: #cdd4dd; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.bad { border-color: var(--danger); background: #fffafa; box-shadow: 0 0 0 3px var(--danger-soft); }
input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
input::placeholder { color: #a0a8b4; font-weight: 400; }

.sheet { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.sheet-head, .row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 120px 40px; gap: 10px; align-items: center; padding: 8px 12px; }
.sheet-head { background: var(--surface); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-block: 10px; }
.sheet-head span:nth-child(3) { text-align: right; }
.row + .row { border-top: 1px solid var(--line); }
.row .num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; font-size: 14px; }
.del { width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: #98a1ad; cursor: pointer; display: grid; place-items: center; }
.del:hover { color: var(--danger); background: var(--danger-soft); }
.del svg { width: 16px; height: 16px; }
.rows-empty { padding: 26px 16px; text-align: center; color: var(--muted); }
.add-row {
  width: 100%; border: 0; border-top: 1px dashed var(--line); background: var(--bg); padding: 14px;
  font-weight: 600; color: var(--accent); cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px;
}
.add-row:hover { background: var(--accent-soft); }
.add-row svg { width: 16px; height: 16px; }

.savebar {
  position: sticky; bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: 0 8px 28px rgba(20, 26, 35, .08);
}
.savemeta { display: flex; gap: 6px 18px; flex-wrap: wrap; align-items: center; font-size: 14px; color: var(--muted); }
.savemeta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.msg { font-size: 14px; flex-basis: 100%; order: 3; margin: 0; }
.msg:empty { display: none; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--grade5); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat .k { font-size: 12px; }
  .stat .v { font-size: 22px; }
  .two { grid-template-columns: 1fr; }
  .top-in { padding-block: 10px; }
  .sheet-head, .row { grid-template-columns: 28px minmax(0, 1fr) 84px 34px; gap: 8px; padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
