:root {
  --bg: #f4f5f9;
  --panel: #ffffff;
  --line: #e8eaef;
  --line-soft: #f1f2f6;
  --text: #16181d;
  --muted: #767e8b;
  --accent: #5b46d6;
  --accent-dark: #4a37bd;
  --accent-soft: #efecfd;
  --ok: #16794a;
  --ok-soft: #e6f4ec;
  --go: #17924f;
  --err: #b3261e;
  --err-soft: #fbeceb;
  --warn: #8a5b00;
  --warn-soft: #fdf3df;
  --shadow: 0 1px 2px rgba(22, 24, 29, .04), 0 8px 24px rgba(22, 24, 29, .05);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.icon-defs { display: none; }

/* --- каркас --- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo { display: flex; align-items: center; gap: 11px; padding: 0 6px 22px; }
.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #8b5ce0);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .3px;
  flex: none;
}
.logo-text b { display: block; font-size: 14px; line-height: 1.2; }
.logo-text i { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: #454b57;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
}
.sidebar nav a svg {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .8;
}
.sidebar nav a span { flex: 1; }
.sidebar nav a:hover { background: #f6f6fa; color: var(--text); }
.sidebar nav a.on {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(91, 70, 214, .28);
}
.sidebar nav a.on svg { opacity: 1; }

.nav-group {
  font-size: 10.5px;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: #a6adb9;
  padding: 18px 11px 6px;
  font-weight: 600;
}

.pill {
  background: #eceefa;
  color: var(--accent);
  border-radius: 9px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.sidebar nav a.on .pill { background: rgba(255, 255, 255, .24); color: #fff; }
.pill.soft { background: #f0f1f4; color: #7b828f; }

.side-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--line);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex: none;
}
.side-user-name { flex: 1; min-width: 0; }
.side-user-name b { display: block; font-size: 13px; }
.side-user-name i { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }
.leave { color: var(--muted); text-decoration: none; font-size: 18px; padding: 0 4px; }
.leave:hover { color: var(--err); }

.content { flex: 1; min-width: 0; }
main { max-width: 1240px; margin: 0 auto; padding: 26px 30px 70px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { display: none; }
  .side-user { margin-top: 12px; }
  main { padding: 18px 16px 50px; }
}

/* --- типографика --- */

h1 { font-size: 25px; margin: 0; letter-spacing: -.3px; }
h2 { font-size: 15px; margin: 0 0 4px; }

.eyebrow {
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #a0a7b3;
  font-weight: 600;
  margin-bottom: 3px;
}

.muted { color: var(--muted); font-size: 12.5px; }
.warn { color: var(--warn); font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.link { color: var(--accent); text-decoration: none; border-bottom: 1px solid #cfc7f5; }
.link:hover { border-bottom-color: var(--accent); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head.compact { margin-bottom: 12px; align-items: center; }

.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.actions.spaced { margin-top: 18px; }
.actions form { margin: 0; }

/* --- кнопки --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { border-color: #d5d8e0; box-shadow: 0 1px 3px rgba(0, 0, 0, .05); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(91, 70, 214, .25);
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.go {
  background: var(--go);
  border-color: var(--go);
  color: #fff;
  box-shadow: 0 4px 14px rgba(23, 146, 79, .24);
}
.btn.go:hover { background: #128044; border-color: #128044; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f1f2f5; box-shadow: none; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: default; box-shadow: none; }

/* --- сообщения --- */

.flash {
  padding: 12px 16px;
  border-radius: 11px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  font-size: 13.5px;
}
.flash.ok { background: var(--ok-soft); border-color: #c6e6d4; color: var(--ok); }
.flash.err { background: var(--err-soft); border-color: #f2ccc9; color: var(--err); }

/* --- панели и плитки --- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: #dfe2e8;
}
.tile-label { font-size: 12.5px; color: var(--muted); }
.tile-value { font-size: 36px; font-weight: 600; line-height: 1.15; margin: 4px 0 2px; }
.tile-note { font-size: 12px; color: #97a0ad; }
.tile.blue::after { background: #3b6fd4; }
.tile.violet::after { background: var(--accent); }
.tile.green::after { background: var(--go); }
.tile.red::after { background: var(--err); }
.tile.red .tile-value { color: var(--err); }

.cards { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-width: 148px;
  color: var(--muted);
  font-size: 12px;
  box-shadow: var(--shadow);
}
.card span { display: block; font-size: 24px; color: var(--text); font-weight: 600; line-height: 1.3; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

.calm {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fafbfc;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 15px;
  margin-top: 12px;
}
.calm .tick {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex: none;
}
.calm.warn-box { background: var(--warn-soft); border-color: #f2e2bd; }
.calm.warn-box .tick { background: #f9e5bb; color: var(--warn); }

/* --- быстрые действия --- */

.quick { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.quick-item { margin: 0; display: block; text-decoration: none; }
.quick-item > button, a.quick-item {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  font: inherit;
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.quick-item > button:hover, a.quick-item:hover { border-color: #d3d6de; background: #fafafc; }
.quick-item b { display: block; font-weight: 600; font-size: 13.5px; }
.quick-item i { display: block; font-style: normal; font-size: 12px; color: var(--muted); }
.q-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 15px;
}

/* --- фильтры --- */

.filters { display: flex; gap: 7px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.chip:hover { border-color: #d5d8e0; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- таблицы --- */

.bulkbar {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 13px 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.bulkbar + table.grid { border-radius: 0 0 var(--radius) var(--radius); }
table.grid th {
  text-align: left;
  font-size: 11.5px;
  color: #8a919d;
  font-weight: 600;
  letter-spacing: .3px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfd;
  white-space: nowrap;
}
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #fcfcfe; }
table.grid.compact td, table.grid.compact th { padding: 8px 12px; }
table.grid tr.st-cancelled { opacity: .5; }

th.right, td.right { text-align: right; }
th.tiny, td.tiny { width: 30px; }
.empty { text-align: center; color: var(--muted); padding: 34px 14px; }

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #f0f1f4;
  color: #5d646f;
  white-space: nowrap;
}
.status.s-matched { background: var(--accent-soft); color: var(--accent); }
.status.s-printed, .status.s-used, .status.s-free { background: var(--ok-soft); color: var(--ok); }
.status.s-blocked, .status.s-cancelled { background: var(--err-soft); color: var(--err); }
.status.s-reserved { background: var(--warn-soft); color: var(--warn); }

.count { font-weight: 600; }
.count.zero { color: var(--err); }

/* --- формы --- */

.inline { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.inline-form { display: inline-flex; gap: 7px; align-items: center; margin: 0; }
.row-form { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.row-form input { min-width: 150px; }
.upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

input[type=search], input[type=text], input[type=password], input[type=number],
input[type=file], select {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 13.5px;
  background: #fff;
  max-width: 100%;
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: #b7abee;
  box-shadow: 0 0 0 3px rgba(91, 70, 214, .12);
}
select { max-width: 280px; }
input[type=file] { padding: 6px 9px; font-size: 12.5px; }

.hint { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; line-height: 1.55; }
.ok-line { color: var(--ok); }

.form .field { display: block; margin-bottom: 14px; }
.form .field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.form .field input { width: 100%; max-width: 420px; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.grid-fields .field input { max-width: 100%; }
.checks { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }

.pager { display: flex; gap: 14px; align-items: center; justify-content: center; padding: 16px; }

/* --- модальное окно --- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 28, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
  max-width: 450px;
  width: 100%;
  box-shadow: 0 20px 56px rgba(0, 0, 0, .26);
}
.modal-card p { margin: 0 0 14px; font-size: 15px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* --- вход и первый запуск --- */

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  width: 100%;
  max-width: 390px;
  box-shadow: var(--shadow);
}
.brand.big {
  font-size: 21px;
  font-weight: 700;
  color: var(--accent);
  padding: 0;
  letter-spacing: -.2px;
}
.brand span { color: var(--muted); margin: 0 3px; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.btn.wide { width: 100%; justify-content: center; margin-top: 8px; }

.auth-brand { display: flex; align-items: center; gap: 11px; }
.auth-card .auth-sub { margin: 14px 0 22px; }
.status.s-shipped { background: #eef0f4; color: #5d646f; }
.pill.hot { background: #fbe3e1; color: var(--err); }
.sidebar nav a.on .pill.hot { background: rgba(255,255,255,.3); color: #fff; }
