:root {
  --ink: #152033;
  --muted: #667085;
  --line: #e5e9f0;
  --paper: #ffffff;
  --canvas: #f4f7fb;
  --brand: #1769e0;
  --brand-dark: #0e4fae;
  --green: #087a55;
  --amber: #a15c00;
  --red: #b42318;
  --shadow: 0 12px 35px rgba(23, 38, 66, .08);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }

.topbar {
  min-height: 68px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 28px;
  color: #fff;
  background: #12213a;
  box-shadow: 0 5px 24px rgba(10, 25, 50, .18);
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: linear-gradient(135deg, #3292ff, #1769e0);
  font-size: 21px; font-weight: 800;
}
.brand strong, .brand small, .account strong, .account small { display: block; }
.brand small, .account small { margin-top: 2px; color: #aebbd0; font-size: 11px; }
.nav { display: flex; align-items: stretch; gap: 4px; flex: 1; }
.nav a { padding: 24px 8px; color: #cfd8e7; border-bottom: 3px solid transparent; font-size: 13px; }
.nav a:hover { color: #fff; border-bottom-color: #4c9aff; }
.account { display: flex; align-items: center; gap: 16px; text-align: right; }
.nav-toggle { display: none; margin-left: auto; color: #fff; background: transparent; border: 0; font-size: 25px; }

.container { width: min(1480px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 60px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 3vw, 40px); letter-spacing: -.035em; }
h2 { margin-bottom: 16px; font-size: 19px; }
h3 { font-size: 15px; }
.eyebrow { margin-bottom: 6px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.counter { color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.breadcrumbs { display: flex; gap: 8px; margin-bottom: 16px; color: var(--muted); font-size: 14px; }

.panel { padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading h2 { margin-bottom: 0; }
.grid { display: grid; gap: 24px; }
.grid.two { grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); }
.ticket-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stack { display: flex; flex-direction: column; }
.gap { gap: 24px; }

.metrics { display: grid; grid-template-columns: repeat(6, minmax(125px, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric { position: relative; overflow: hidden; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 15px; }
.metric::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #a9b3c3; }
.metric span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.metric strong { font-size: 30px; }
.metric.new::after { background: #2585f3; }
.metric.work::after { background: #7a5af8; }
.metric.paused::after { background: #f79009; }
.metric.danger::after { background: #d92d20; }
.metric.done::after { background: #12b76a; }

.ticket-list { margin: 18px -8px -8px; }
.ticket-row { display: grid; grid-template-columns: 58px 100px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 13px 8px; color: var(--ink); border-top: 1px solid var(--line); }
.ticket-row:hover { color: var(--ink); background: #f8faff; }
.ticket-id { color: var(--brand); font-weight: 800; }
.ticket-main strong, .ticket-main small { display: block; }
.ticket-main small { margin-top: 4px; color: var(--muted); }
.ticket-row time { color: var(--muted); font-size: 13px; white-space: nowrap; }

.department-list { margin-top: 16px; }
.department-list > div { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.department-list small { grid-column: 1 / -1; color: var(--muted); }
.resolution { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding: 16px; background: #eef5ff; border-radius: 12px; }
.resolution strong { color: var(--brand-dark); font-size: 22px; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.queue-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 16px; }
.queue-tab { padding: 9px 13px; color: #344054; background: #fff; border: 1px solid #cfd6e1; border-radius: 999px; font-size: 13px; font-weight: 750; }
.queue-tab:hover { color: var(--brand-dark); border-color: #91b9ed; }
.queue-tab.active { color: #fff; background: var(--brand); border-color: var(--brand); }
label { display: flex; flex-direction: column; gap: 7px; color: #39475d; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #cfd6e1; border-radius: 9px; outline: none; }
textarea { min-height: 82px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23, 105, 224, .12); }
.filter-actions { display: flex; align-items: end; gap: 10px; }

.button { display: inline-flex; min-height: 40px; padding: 9px 16px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 750; }
.button.primary { color: #fff; background: var(--brand); }
.button.primary:hover { color: #fff; background: var(--brand-dark); }
.button.secondary { color: var(--brand-dark); background: #e9f2ff; border-color: #c7ddfb; }
.button.ghost { color: #39475d; background: transparent; border-color: #cbd3df; }
.topbar .button.ghost { color: #e6edf7; border-color: #5a6980; }
.button.danger { color: #fff; background: var(--red); }
.button.danger-outline { color: var(--red); background: #fff; border-color: #e8aaa5; }
.button.danger-outline:hover { color: #fff; background: var(--red); }
.button.small { min-height: 33px; padding: 6px 11px; font-size: 12px; }
.button.wide { width: 100%; }
.button-group { display: flex; flex-wrap: wrap; gap: 9px; }

.alert { margin-bottom: 20px; padding: 13px 16px; border-radius: 10px; font-weight: 650; }
.alert.success { color: #05603f; background: #e9f9f1; border: 1px solid #a9e2c5; }
.alert.warning { color: #7a4300; background: #fff6e5; border: 1px solid #e9c77f; }
.alert.danger { color: #8a1c13; background: #fff0ee; border: 1px solid #f1b7b1; }

.bulk-toolbar { display: grid; grid-template-columns: minmax(170px, 1fr) 180px auto auto; align-items: end; gap: 12px; margin-bottom: 16px; padding: 16px 20px; }
.bulk-toolbar > div { align-self: center; }
.bulk-toolbar > div strong, .bulk-toolbar > div small { display: block; }
.bulk-toolbar > div small { margin-top: 4px; color: var(--muted); }

.table-wrap { padding: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 13px 14px; color: #56657a; background: #f7f9fc; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
td small { display: block; margin-top: 4px; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f6f9fe; }
tr.planned-today td { background: #f4fbf7; }
tr.planned-today:hover td { background: #ebf8f0; }
tr.overdue td:first-child { border-left: 4px solid var(--red); }
.strong-link { font-weight: 800; }
.problem { min-width: 230px; max-width: 420px; }
.select-column { width: 42px; padding-left: 12px; padding-right: 8px; text-align: center; }
.select-column input { width: auto; margin: 0; }
.plan-date { display: inline-flex; padding: 4px 7px; border-radius: 7px; background: #eef1f5; font-size: 12px; font-weight: 800; white-space: nowrap; }
.plan-date.today { color: #05603f; background: #ddf5e8; }
.quick-action-cell { min-width: 140px; }
.quick-status { width: 260px; }
.quick-status:not([open]) { width: auto; }
.quick-status summary { width: fit-content; list-style: none; }
.quick-status summary::-webkit-details-marker { display: none; }
.quick-status-form { gap: 10px; margin-top: 10px; padding: 12px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; }
.quick-status-form textarea { min-height: 60px; }
.empty-cell { padding: 42px; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; color: var(--muted); }

.status { display: inline-flex; width: fit-content; padding: 5px 9px; color: #344054; background: #f1f3f6; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status.large { padding: 8px 13px; font-size: 14px; }
.status-новая { color: #075aa9; background: #e7f2ff; }
.status-в-работе { color: #5535bc; background: #eeeaff; }
.status-отложена { color: #8b4f00; background: #fff2dd; }
.status-выполнена, .status-закрыта { color: #06724d; background: #e4f8ee; }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.detail-grid span, .problem-box > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.detail-grid strong, .detail-grid small { display: block; }
.detail-grid small { margin-top: 3px; color: var(--muted); }
.problem-box { margin-top: 24px; padding: 18px; background: #f6f8fb; border-radius: 12px; }
.problem-box p { margin-bottom: 0; white-space: pre-wrap; line-height: 1.55; }
.attachments { margin-top: 24px; }
.file-link { display: inline-flex; margin: 0 8px 8px 0; padding: 9px 12px; background: #f3f6fa; border-radius: 8px; }
.file-link small { margin-left: 6px; color: var(--muted); }
.timeline { position: relative; margin-top: 18px; padding-left: 22px; border-left: 2px solid #d9e1ec; }
.timeline article { position: relative; padding: 0 0 20px 10px; }
.timeline article::before { content: ""; position: absolute; left: -18px; top: 4px; width: 9px; height: 9px; border: 3px solid #fff; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px #b9c8db; }
.timeline time, .comments time { float: right; color: var(--muted); font-size: 12px; }
.timeline p { margin: 5px 0; line-height: 1.45; }
.timeline small { color: var(--muted); }
.comments article { padding: 14px 0; border-bottom: 1px solid var(--line); }
.comments article p { margin: 7px 0 0; white-space: pre-wrap; }
.inline-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; margin-top: 18px; }
.action-card { position: sticky; top: 20px; }
.quick-comments { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-comments button { padding: 6px 8px; color: #42526a; background: #f2f4f7; border: 1px solid #d9dee7; border-radius: 7px; cursor: pointer; font-size: 11px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #e7f1ff, var(--canvas) 45%); }
.login-shell { min-height: calc(100vh - 130px); display: grid; place-items: center; }
.login-card { width: min(440px, 100%); padding: 34px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.login-card h1 { margin: 8px 0 10px; }
.login-card > p { color: var(--muted); }
.login-card form { margin-top: 24px; }
.login-brand { margin-bottom: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-full { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline { display: flex; align-items: center; gap: 7px; }
.inline select { min-width: 145px; }
.rule-form { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; align-items: end; gap: 14px; }
.form-panel { margin-bottom: 20px; }
.report-metrics { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.pill { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.pill.active { color: #05603f; background: #e7f8ef; }
.pill.blocked { color: #8a1c13; background: #fff0ee; }
.pill.notification-pending, .pill.notification-sending { color: #8b4f00; background: #fff2dd; }
.pill.notification-sent { color: #06724d; background: #e4f8ee; }
.pill.notification-failed { color: #8a1c13; background: #fff0ee; }
.notification-metrics { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.notification-metrics .metric { color: var(--ink); }
tr.inactive { opacity: .62; }
.details-json { min-width: 260px; max-width: 520px; word-break: break-word; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: #eef1f5; font-size: 11px; font-weight: 800; }
.badge.active { color: #05603f; background: #e7f8ef; }
.badge.inactive { color: #8a1c13; background: #fff0ee; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.section-gap { margin-top: 24px; }
.table-heading { padding: 20px 22px 8px; }
.table-heading h2 { margin: 0; }
.assignment-box { margin-top: 22px; }
.assignment-box > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; padding: 7px 10px; color: #17443e; background: #e9f6f3; border: 1px solid #bcded6; border-radius: 999px; font-size: 12px; font-weight: 750; }
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0; }
.small-text { font-size: 12px; line-height: 1.45; }
fieldset { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.check-list { display: grid; gap: 7px; max-height: 240px; overflow: auto; }
.check-list.horizontal { display: flex; flex-wrap: wrap; max-height: none; overflow: visible; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 6px 8px; color: var(--ink); background: #f7f9fc; border-radius: 7px; font-size: 12px; font-weight: 650; }
label.check input { width: auto; margin: 0; }
label.check.whole { padding: 10px; background: #e9f2ff; border: 1px solid #c7ddfb; }
label.check.warning-choice { background: #fff4df; border-color: #e8c477; }
.assignment-form { gap: 13px; }
.plain-list { margin: 0; padding-left: 20px; color: #39475d; line-height: 1.65; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.project-card { display: block; color: var(--ink); }
.project-card:hover { color: var(--ink); border-color: #a7c8f4; transform: translateY(-1px); }
.project-card p { color: var(--muted); }
.project-card > small { display: block; margin-top: 16px; color: var(--muted); }
.project-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.project-stats span { padding: 10px; background: #f5f7fa; border-radius: 9px; color: var(--muted); font-size: 11px; }
.project-stats strong { display: block; color: var(--ink); font-size: 22px; }
.project-strip { margin-top: 24px; }
.project-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 18px; }
.project-cards a { padding: 14px; color: var(--ink); background: #f6f9fe; border: 1px solid #e0e8f4; border-radius: 11px; }
.project-cards strong, .project-cards span, .project-cards small { display: block; }
.project-cards span, .project-cards small { margin-top: 5px; color: var(--muted); font-size: 12px; }
.danger-text { color: var(--red); font-weight: 800; }
.access-card h2 { margin: 0; }
.role-guide { margin-bottom: 0; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 18px; }
.role-grid > div { padding: 12px; background: #f6f9fe; border: 1px solid #e0e8f4; border-radius: 10px; }
.role-grid strong, .role-grid small { display: block; }
.role-grid small { margin-top: 5px; color: var(--muted); line-height: 1.4; }
.section-note { margin: 14px 4px 0; font-size: 12px; }
.compact-details { margin-top: 18px; }
.access-actions { display: grid; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.scope-form { display: grid; grid-template-columns: minmax(180px, .5fr) minmax(300px, 1fr) auto; align-items: end; gap: 10px; }
.analytics-filters { grid-template-columns: repeat(4, minmax(170px, 1fr)); }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .ticket-layout, .grid.two { grid-template-columns: 1fr; }
  .action-card { position: static; }
  .bulk-toolbar { grid-template-columns: 1fr 180px auto; }
  .bulk-toolbar > div { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .topbar { padding: 12px 18px; flex-wrap: wrap; gap: 12px; }
  .nav-toggle { display: block; }
  .nav { display: none; order: 3; flex-basis: 100%; flex-direction: column; }
  .nav.open { display: flex; }
  .nav a { padding: 10px 8px; border: 0; }
  .account { margin-left: auto; }
  .account > span { display: none; }
  .container { width: min(100% - 28px, 1480px); padding-top: 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .filters, .form-grid, .detail-grid, .rule-form { grid-template-columns: 1fr; }
  .scope-form, .analytics-filters { grid-template-columns: 1fr; }
  .bulk-toolbar { grid-template-columns: 1fr; }
  .bulk-toolbar > div { grid-column: auto; }
  .ticket-row { grid-template-columns: 52px 1fr; }
  .ticket-row .ticket-main { grid-column: 1 / -1; }
  .ticket-row time { display: none; }
  .inline-form { grid-template-columns: 1fr; }
  .panel { padding: 18px; border-radius: 13px; }
  .table-wrap { padding: 0; }
}
