:root {
  --ink: #0f272d;
  --ink-soft: #263b41;
  --sky: #4f9aa8;
  --sky-dark: #2f6b78;
  --bg: #f4f4f4;
  --surface: #ffffff;
  --line: #e1e6e7;
  --muted: #5d6e73;
  --danger: #c2362b;
  --radius: 10px;
  --p-critical: #c2362b;
  --p-high: #e08a2c;
  --p-medium: #4f9aa8;
  --p-low: #a9bcc1;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

/* бренд  */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }

/* страница входа  */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }

.auth-side {
  display: none;
  background: var(--ink);
  color: #fff;
  padding: 48px 56px;
  flex-direction: column;
  justify-content: space-between;
}
.auth-side .brand { color: #fff; }
.auth-title {
  font-size: clamp(34px, 3.6vw, 52px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  max-width: 14ch;
}
.auth-note { margin: 18px 0 0; color: #a9bcc1; max-width: 34ch; font-size: 16px; }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.auth-form { width: 100%; max-width: 360px; }
.auth-form .brand { margin-bottom: 40px; }
.auth-form h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; margin: 0 0 8px; }
.auth-form .sub { margin: 0 0 32px; color: var(--muted); }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.input-wrap { position: relative; }
input {
  width: 100%; height: 48px; padding: 0 14px;
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
input:hover { border-color: #c5cfd1; }
input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(79, 154, 168, .22); }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(194, 54, 43, .15); }
input.has-toggle { padding-right: 84px; }

.toggle {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  height: 32px; padding: 0 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.toggle:hover { color: var(--ink); background: var(--bg); }

.btn {
  width: 100%; height: 48px; margin-top: 8px;
  border: 0; border-radius: var(--radius);
  background: var(--ink); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--ink-soft); }
.btn:disabled { opacity: .55; cursor: default; }

.error { margin: 14px 0 0; min-height: 22px; font-size: 14px; font-weight: 600; color: var(--danger); }

@media (min-width: 880px) {
  .auth { grid-template-columns: minmax(380px, 5fr) 6fr; }
  .auth-side { display: flex; }
  .auth-form .brand { display: none; }
}

/*  панель после входа  */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 28px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.who { font-size: 14px; color: var(--muted); }

.btn-quiet {
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-quiet:hover { background: var(--bg); border-color: #c5cfd1; }

.page { max-width: 1240px; margin: 0 auto; padding: 40px 28px; }
.page h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin: 0 0 6px; }
.page .sub { margin: 0; color: var(--muted); }

.empty {
  margin-top: 32px; padding: 40px 28px;
  border: 1px dashed #c5cfd1; border-radius: var(--radius);
  color: var(--muted);
}
.empty b { color: var(--ink); }

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

/*  список заявок  */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 28px 0 18px;
}
.filters input[type="search"] { flex: 1 1 220px; width: auto; height: 44px; }
.filters select {
  height: 44px; padding: 0 12px;
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
.filters select:hover { border-color: #c5cfd1; }
.filters select:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(79, 154, 168, .22); }
.filters .btn-quiet { height: 44px; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto;
}
table.tickets { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tickets th {
  text-align: left; padding: 12px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--muted); background: var(--bg);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tickets td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tickets tr:last-child td { border-bottom: 0; }
table.tickets tbody tr:hover { background: #f8f9f9; }
table.tickets a { color: var(--ink); font-weight: 700; text-decoration: none; white-space: nowrap; }
table.tickets a:hover { color: var(--sky-dark); text-decoration: underline; }
td.desc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
td.nowrap { white-space: nowrap; color: var(--muted); }

.sort {
  border: 0; background: transparent; padding: 0;
  font: inherit; font-size: 13px; font-weight: 700;
  color: var(--ink); cursor: pointer;
}

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  background: var(--bg); color: var(--muted);
}
.badge-critical { background: #fbe3e0; color: #a52a20; }
.badge-high { background: #fdebd6; color: #9a4f08; }
.badge-medium { background: #e4eff1; color: #2f6b78; }
.badge-low { background: #e9eeef; color: #5d6e73; }
.badge-new { background: #e4eff1; color: #2f6b78; }
.badge-in-progress { background: #fdf3d3; color: #7a5a06; }
.badge-resolved { background: #e0f3e6; color: #1e6b36; }


/*  страница заявки  */
.back { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.back:hover { color: var(--ink); }

.detail { display: grid; gap: 20px; margin-top: 28px; }
@media (min-width: 900px) { .detail { grid-template-columns: 3fr 2fr; align-items: start; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px;
}
.card h2 { font-size: 16px; font-weight: 800; margin: 24px 0 10px; }
.card h2:first-child { margin-top: 0; }

.fields { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; margin: 0 0 8px; font-size: 14px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; font-weight: 600; word-break: break-word; }

.description { margin: 0; max-width: 68ch; font-size: 16px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }

.status-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.status-actions .btn-quiet:disabled { opacity: .55; cursor: default; }

.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
/* история как линия времени */
.history li { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 0 0 18px 24px; }
.history li::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: -4px; width: 2px; background: var(--line); }
.history li::after {
  content: ""; position: absolute; left: 0; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--sky);
}
.history li:last-child { padding-bottom: 0; }
.history li:last-child::before { display: none; }
.history li span { color: var(--muted); font-size: 13px; }

/*  меню и обзор  */
.topbar-left { display: flex; align-items: center; gap: 32px; }
.nav { display: flex; gap: 6px; }
.nav a {
  padding: 6px 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none;
}
.nav a:hover { color: var(--ink); background: var(--bg); }
.nav a.active { color: var(--ink); background: var(--bg); }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin: 28px 0 20px; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
/* линии справа и снизу у каждой ячейки, крайние обрезаются контейнером */
.stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 22px;
  color: var(--ink); text-decoration: none;
  box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
  transition: background .15s;
}
.stat:hover { background: #f8f9f9; }
.stat span { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }

.bars-card h2 { margin-bottom: 16px; }
.bar-row {
  display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 14px;
  padding: 8px 0; color: var(--ink); text-decoration: none;
}
.bar-row:hover .bar-name { text-decoration: underline; }
.bar-name { font-size: 14px; font-weight: 600; }
.bar-track { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; min-width: 0; }
.bar-critical { background: #c2362b; }
.bar-high { background: #e08a2c; }
.bar-medium { background: var(--sky); }
.bar-low { background: #a9bcc1; }
.bar-count { text-align: right; font-weight: 800; font-size: 14px; }

.fields .btn-quiet { margin-left: 12px; height: 30px; font-size: 13px; }


/*  форма заявки для сотрудников  */
.page.form-page { max-width: 640px; }
.form-page form { margin-top: 28px; }

a.btn-quiet { display: inline-flex; align-items: center; text-decoration: none; }

select, textarea {
  width: 100%; padding: 0 14px;
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
select { height: 48px; cursor: pointer; }
textarea { padding: 12px 14px; resize: vertical; min-height: 140px; }
select:hover, textarea:hover { border-color: #c5cfd1; }
select:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(79, 154, 168, .22); }

.options { display: grid; gap: 10px; }
.field .option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; font-weight: 400; font-size: 16px;
  margin-bottom: 0;
  transition: border-color .15s, box-shadow .15s;
}
.option:hover { border-color: #c5cfd1; }
.option:has(input:checked) { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(79, 154, 168, .22); }
.option input { width: auto; height: auto; margin-top: 5px; accent-color: var(--sky); }
.option b { display: block; font-weight: 700; }
.option span span { display: block; font-size: 14px; color: var(--muted); }

.field-error { margin: 6px 0 0; min-height: 0; font-size: 14px; font-weight: 600; color: var(--danger); }

/* поле ловушка для спам ботов за пределами экрана */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.ticket-number { margin: 20px 0 8px; font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }

.filters select { width: auto; }


/*  форма заявки, две колонки  */
.auth-main { position: relative; }
.auth-corner { position: absolute; top: 24px; right: 24px; }
.auth-form.wide { max-width: 540px; padding: 48px 0; }


.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.counter { margin: 6px 0 0; font-size: 13px; color: var(--muted); text-align: right; }
.counter.near { color: var(--danger); font-weight: 600; }


/* левая панель всегда на высоту окна, прокручивается только правая часть */
@media (min-width: 880px) {
  .auth-side {
    position: sticky; top: 0;
    height: 100vh; align-self: start;
    overflow-y: auto;
  }
}

/*пошаговая форма  */
.wizard-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 10px; }
.wizard-progress .seg { height: 4px; border-radius: 999px; background: var(--line); transition: background .3s; }
.wizard-progress .seg.on { background: var(--sky); }
.wizard-label { margin: 0 0 22px; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--muted); }

.step:not([hidden]) { animation: step-in .35s ease both; }
@keyframes step-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field .cat {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 0;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; font-weight: 400;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cat:hover { border-color: #c5cfd1; transform: translateY(-1px); }
.cat:has(input:checked) { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(79, 154, 168, .22); }
.cat input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cat:has(input:focus-visible) { outline: 2px solid var(--sky); outline-offset: 2px; }
.cat-ico { font-size: 22px; line-height: 1; flex: none; }
.cat b { display: block; font-size: 14px; font-weight: 700; }
.cat small { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
@media (max-width: 520px) { .cats { grid-template-columns: 1fr; } }

.recap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.recap span { padding: 4px 12px; border-radius: 999px; background: #e4eff1; color: #2f6b78; font-size: 13px; font-weight: 700; }

.wizard-nav { display: flex; gap: 10px; margin-top: 8px; }
.wizard-nav .btn { margin-top: 0; flex: 1; }
.wizard-nav .btn-quiet { height: 48px; padding: 0 20px; }
.wizard-nav [hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .step:not([hidden]) { animation: none; }
}


/*  экран успеха \ */
.check { width: 72px; height: 72px; margin-bottom: 8px; }
.check-circle { stroke: var(--sky); stroke-width: 2.5; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .6s ease forwards; }
.check-mark { stroke: var(--sky); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw .4s .5s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
#successView:not([hidden]) h1 { animation: step-in .4s .8s ease both; }
.ticket-number { min-height: 1.2em; }
.success-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (prefers-reduced-motion: reduce) {
  .check-circle, .check-mark { animation: none; stroke-dashoffset: 0; }
  #successView:not([hidden]) h1 { animation: none; }
}

/*  фирменный цвет задаётся переменной  */
.brand { gap: 12px; }
.brand-logo { font-size: 20px; font-weight: 800; letter-spacing: .08em; padding-right: 12px; border-right: 1px solid currentColor; line-height: 1; }
.brand-sub { font-size: 14px; font-weight: 500; opacity: .75; }

/* левая панель спокойнее, меньше заголовок, без декоративных линий */
.auth-title { font-size: clamp(28px, 2.6vw, 40px); letter-spacing: -0.025em; max-width: 18ch; }
.side-foot { margin: 0; color: #8fa6ab; font-size: 14px; max-width: 40ch; }
.side-foot b { color: #fff; font-weight: 700; }

/* иконки категорий */
.cat-ico {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 10px; font-size: 0;
  background: color-mix(in srgb, var(--sky) 12%, transparent);
  color: var(--sky-dark);
  transition: background .15s, color .15s;
}
.cat:has(input:checked) .cat-ico { background: var(--sky); color: #fff; }


/*  ввод кода подтверждения  */
.code-input { text-align: center; font-size: 28px; font-weight: 700; letter-spacing: .5em; padding-left: .5em; font-variant-numeric: tabular-nums; }
.verify-links { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; color: var(--muted); font-size: 14px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--sky-dark); cursor: pointer; }
.linkbtn:hover:not(:disabled) { text-decoration: underline; }
.linkbtn:disabled { color: var(--muted); cursor: default; font-weight: 500; }


/*  левая панель формы, сроки ответа  */
/* цвет полосы совпадает с цветом приоритета на обзоре */
.sla { display: grid; gap: 22px; margin: 36px 0 0; max-width: 40ch; }
.sla-row { padding-left: 16px; border-left: 3px solid var(--ink-soft); }
.sla-row dt { font-size: 16px; font-weight: 700; color: #fff; }
.sla-row dd { margin: 2px 0 0; font-size: 15px; color: #a9bcc1; }
.sla-high { border-left-color: #e08a2c; }
.sla-medium { border-left-color: var(--sky); }
.sla-low { border-left-color: #a9bcc1; }

/*  вход для специалистов, тут без боковой панели  */
.login { min-height: 100vh; display: flex; flex-direction: column; }
.login .topbar { flex: none; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 24px 64px; }
.login-main .auth-form h1 { font-size: 28px; }
.login-main .back { margin: 24px 0 0; }


/*  цвет приоритета задаётся переменной --prio  */
.prio-critical { --prio: var(--p-critical); }
.prio-high { --prio: var(--p-high); }
.prio-medium { --prio: var(--p-medium); }
.prio-low { --prio: var(--p-low); }
.done { --prio: #d3dadc; } /* решённые заявки без цвета срочности */

.dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--prio); }
td.prio, td.cat { white-space: nowrap; }
td.cat { color: var(--muted); }
table.tickets tbody td:first-child { padding-left: 17px; box-shadow: inset 3px 0 0 var(--prio); }

/*  обзор  */
.overview { display: grid; gap: 20px; }
@media (min-width: 960px) { .overview { grid-template-columns: 3fr 2fr; align-items: start; } }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.more { font-size: 14px; font-weight: 600; color: var(--sky-dark); text-decoration: none; white-space: nowrap; }
.more:hover { text-decoration: underline; }

.attn { list-style: none; margin: 0; padding: 0; }
.attn li { border-bottom: 1px solid var(--line); }
.attn li:last-child { border-bottom: 0; }
.attn-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px;
  padding: 12px 8px 12px 16px;
  color: var(--ink); text-decoration: none;
  box-shadow: inset 3px 0 0 var(--prio);
  transition: background .15s;
}
.attn-item:hover { background: #f8f9f9; }
.attn-main { display: flex; gap: 12px; min-width: 0; font-size: 14px; }
.attn-main b { flex: none; }
.attn-desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.attn-time { font-size: 13px; color: var(--muted); white-space: nowrap; }
.attn-meta { grid-column: 1 / -1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn-empty { margin: 8px 0 0; color: var(--muted); font-size: 14px; }


/*  страница заявки  */
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; }
.title-row h1 { margin: 0; }
.title-row .badge { padding: 3px 12px; font-size: 13px; }

.detail-col { display: grid; gap: 20px; align-content: start; min-width: 0; }
.from { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 0 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.from b { overflow-wrap: anywhere; }

.card .error { min-height: 0; margin: 10px 0 0; }
.card .error:empty { display: none; }
.card .hint { margin: 10px 0 0; }
.detail-col .fields { grid-template-columns: 110px 1fr; margin: 0; }

.btn-sm {
  height: 36px; padding: 0 14px;
  border: 0; border-radius: 8px;
  background: var(--ink); color: #fff;
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background .15s;
}
.btn-sm:hover { background: var(--ink-soft); }
.btn-sm:disabled { opacity: .55; cursor: default; }

/* выбранный приоритет подсвечен рамкой его цвета */
.btn-quiet .dot { margin-right: 8px; }
.btn-quiet[aria-pressed="true"] { border-color: var(--prio); box-shadow: inset 0 0 0 1px var(--prio); cursor: default; }

/* шаги на левой панели формы */
.steps {
  list-style: none; margin: 32px 0 0; padding: 0;
  display: grid; gap: 20px; max-width: 40ch;
  counter-reset: step;
}
.steps li { position: relative; padding-left: 46px; color: #a9bcc1; font-size: 15px; counter-increment: step; }
.steps li b { display: block; color: #fff; font-size: 16px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--sky); color: var(--sky);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}

.auth-side > div { margin: auto 0; }