/* ==========================================================================
   PvPCult Tickets — панель администрирования
   Тёмная тема по умолчанию, светлая через [data-theme="light"].
   ========================================================================== */

:root {
  --bg:            #0b0d12;
  --bg-grad:       radial-gradient(1200px 600px at 12% -10%, #1a2138 0%, transparent 60%),
                   radial-gradient(900px 500px at 100% 0%, #17203a 0%, transparent 55%);
  --surface:       #12161f;
  --surface-2:     #171d29;
  --surface-3:     #1d2432;
  --border:        #242c3c;
  --border-strong: #323c52;

  --text:          #e8ecf5;
  --text-dim:      #98a2b8;
  --text-mute:     #6b7488;

  --accent:        #5865f2;
  --accent-soft:   rgba(88, 101, 242, .14);
  --accent-hover:  #6b76f5;

  --yellow:        #f0b232;
  --green:         #23a55a;
  --blue:          #5865f2;
  --red:           #f23f43;

  --yellow-soft:   rgba(240, 178, 50, .14);
  --green-soft:    rgba(35, 165, 90, .14);
  --blue-soft:     rgba(88, 101, 242, .14);
  --red-soft:      rgba(242, 63, 67, .14);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow:    0 8px 24px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .85);

  --sidebar-w: 256px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg:            #f4f6fb;
  --bg-grad:       radial-gradient(1100px 520px at 10% -10%, #e2e8fb 0%, transparent 60%),
                   radial-gradient(900px 460px at 100% 0%, #e6ecfb 0%, transparent 55%);
  --surface:       #ffffff;
  --surface-2:     #f7f9fd;
  --surface-3:     #eef2f9;
  --border:        #dfe5ef;
  --border-strong: #c6cfdf;

  --text:          #131722;
  --text-dim:      #56607a;
  --text-mute:     #808aa3;

  --accent-soft:   rgba(88, 101, 242, .1);
  --yellow-soft:   rgba(240, 178, 50, .16);
  --green-soft:    rgba(35, 165, 90, .14);
  --blue-soft:     rgba(88, 101, 242, .12);
  --red-soft:      rgba(242, 63, 67, .12);

  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .08);
  --shadow:    0 8px 24px -14px rgba(20, 30, 60, .3);
  --shadow-lg: 0 24px 60px -28px rgba(20, 30, 60, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .6em; }
::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); background-clip: content-box; }

/* ============================== Каркас ================================== */

.app { display: block; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 18px;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  color: #fff;
  box-shadow: 0 6px 18px -6px var(--accent);
}
.brand__mark svg { width: 21px; height: 21px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 15px; letter-spacing: -.02em; }
.brand__text small { color: var(--text-mute); font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 520;
  transition: background .15s, color .15s;
}
.nav__item svg { width: 18px; height: 18px; flex: none; }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar__foot { display: flex; flex-direction: column; gap: 10px; }

.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font: inherit; font-size: 13px;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle svg { width: 17px; height: 17px; }
[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon { display: none; }

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.user-card__avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--surface-3); }
.user-card__info { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.user-card__info strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card__info small { color: var(--text-mute); font-size: 11px; }

.content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 26px 32px 18px;
  background: linear-gradient(to bottom, var(--bg) 45%, transparent);
}
.topbar__title h1 { font-size: 23px; }
.topbar__title p { color: var(--text-dim); margin: 3px 0 0; font-size: 13px; }
.topbar__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.content__body { padding: 4px 32px 48px; flex: 1; }

/* ============================== Элементы ================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card__head h2 { font-size: 15px; }
.card__head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-mute); }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-mute); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; }

.icon-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--text-mute);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

input[type="text"], input[type="search"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="url"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808aa3' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 15px;
  padding-right: 30px;
}
input[type="color"] {
  width: 42px; height: 34px; padding: 2px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); cursor: pointer;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .field__label {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  letter-spacing: .01em;
}
.field__hint { font-size: 11.5px; color: var(--text-mute); line-height: 1.45; }
.field__error { font-size: 11.5px; color: var(--red); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }

.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ============================== Значки ================================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge--yellow { background: var(--yellow-soft); color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 30%, transparent); }
.badge--green  { background: var(--green-soft);  color: var(--green);  border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.badge--blue   { background: var(--blue-soft);   color: var(--blue);   border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.badge--red    { background: var(--red-soft);    color: var(--red);    border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.badge--muted  { background: var(--surface-3);   color: var(--text-dim); border-color: var(--border); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--yellow { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }
.dot--green  { background: var(--green);  box-shadow: 0 0 0 3px var(--green-soft); }
.dot--blue   { background: var(--blue);   box-shadow: 0 0 0 3px var(--blue-soft); }
.dot--red    { background: var(--red);    box-shadow: 0 0 0 3px var(--red-soft); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12.5px; font-weight: 550;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--text-mute); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip--yellow.is-active { background: var(--yellow-soft); border-color: var(--yellow); color: var(--yellow); }
.chip--green.is-active  { background: var(--green-soft);  border-color: var(--green);  color: var(--green); }
.chip--blue.is-active   { background: var(--blue-soft);   border-color: var(--blue);   color: var(--blue); }
.chip--red.is-active    { background: var(--red-soft);    border-color: var(--red);    color: var(--red); }

mark { background: color-mix(in srgb, var(--yellow) 40%, transparent); color: var(--text); border-radius: 3px; padding: 0 2px; }

.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }

/* ============================== Дашборд ================================= */

.stat {
  position: relative;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 2px;
  background: var(--accent); opacity: .8;
}
.stat--yellow::after { background: var(--yellow); }
.stat--green::after  { background: var(--green); }
.stat--blue::after   { background: var(--blue); }
.stat--red::after    { background: var(--red); }
.stat__label { font-size: 12px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat__value { font-size: 30px; font-weight: 680; letter-spacing: -.03em; margin-top: 6px; line-height: 1; }
.stat__meta { margin-top: 7px; font-size: 12px; color: var(--text-dim); }

.chart { display: flex; align-items: flex-end; gap: 5px; height: 170px; padding-top: 8px; }
.chart__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; position: relative; }
.chart__bar { border-radius: 4px 4px 0 0; min-height: 2px; transition: opacity .15s; }
.chart__bar--created { background: var(--accent); }
.chart__bar--closed { background: color-mix(in srgb, var(--green) 70%, transparent); }
.chart__col:hover .chart__bar { opacity: .75; }
.chart__label { font-size: 10px; color: var(--text-mute); text-align: center; margin-top: 6px; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-list__row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.bar-list__name { font-size: 13px; }
.bar-list__count { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.bar-list__track { grid-column: 1 / -1; height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-list__fill { height: 100%; background: linear-gradient(90deg, var(--accent), #8b5cf6); border-radius: 999px; }

/* ============================== Таблица ================================= */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  position: sticky; top: 0;
  text-align: left; font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-mute);
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { transition: background .12s; cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }

.cell-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-user img { width: 26px; height: 26px; border-radius: 50%; flex: none; background: var(--surface-3); }
.cell-user__name { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cell-user__name strong { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-user__name small { color: var(--text-mute); font-size: 11px; }

.cell-num { font-family: var(--mono); font-weight: 600; color: var(--text-dim); }
.snippet {
  margin-top: 6px; padding: 7px 10px;
  background: var(--surface-3); border-left: 2px solid var(--accent);
  border-radius: 0 6px 6px 0;
  font-size: 12px; color: var(--text-dim);
}
.snippet b { color: var(--text); font-weight: 600; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination__info { font-size: 12.5px; color: var(--text-mute); }
.pagination__pages { display: flex; gap: 5px; align-items: center; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-mute); }
.empty svg { width: 46px; height: 46px; opacity: .35; margin-bottom: 12px; }
.empty h3 { font-size: 15px; color: var(--text-dim); margin-bottom: 5px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ============================== Фильтры ================================= */

.filters { display: flex; flex-direction: column; gap: 14px; }
.filters__row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters__search { position: relative; flex: 1 1 320px; min-width: 240px; }
.filters__search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-mute); pointer-events: none; }
.filters__search input { padding-left: 34px; }
.filters__group { display: flex; gap: 6px; flex-wrap: wrap; }
.filters__advanced { display: none; padding-top: 14px; border-top: 1px dashed var(--border); }
.filters__advanced.is-open { display: block; }
.filters__count { font-size: 12px; color: var(--text-mute); }

/* ============================== Переписка =============================== */

.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.transcript { display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.transcript__scroll { overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }

.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 5px 8px; border-radius: 8px; }
.msg:hover { background: var(--surface-2); }
.msg--grouped { padding-top: 1px; padding-bottom: 1px; }
.msg--grouped .msg__avatar { visibility: hidden; height: 0; }
.msg--grouped .msg__head { display: none; }
.msg--deleted .msg__text { opacity: .55; text-decoration: line-through; }
.msg__avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); }
.msg__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg__author { font-weight: 620; font-size: 14px; }
.msg__author.is-staff { color: var(--accent); }
.msg__tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 4px; background: var(--accent); color: #fff; }
.msg__tag--bot { background: var(--text-mute); }
.msg__time { font-size: 11.5px; color: var(--text-mute); }
.msg__text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.msg__text code { font-family: var(--mono); font-size: .88em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.msg__text pre { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--border); padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 6px 0; }
.msg__text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg__reply { font-size: 12px; color: var(--text-mute); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.att-image { max-width: min(420px, 100%); border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; display: block; background: var(--surface-3); }
.att-video, .att-audio { max-width: min(460px, 100%); border-radius: 10px; border: 1px solid var(--border); }
.att-file {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; font-size: 13px;
}
.att-file svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.att-file__meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.att-file__meta strong { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.att-file__meta small { color: var(--text-mute); font-size: 11px; }
.att-broken { padding: 9px 13px; border: 1px dashed var(--border-strong); border-radius: 10px; font-size: 12.5px; color: var(--text-mute); }

.embed {
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  padding: 10px 13px;
  margin-top: 7px;
  max-width: 520px;
}
.embed__title { font-weight: 620; font-size: 13.5px; margin-bottom: 3px; }
.embed__desc { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; }
.embed__fields { display: grid; gap: 7px; margin-top: 8px; }
.embed__field strong { display: block; font-size: 12px; }
.embed__field span { font-size: 12.5px; color: var(--text-dim); white-space: pre-wrap; }
.embed__image { max-width: 100%; border-radius: 7px; margin-top: 8px; }

.side-card + .side-card { margin-top: 14px; }
.meta-list { display: flex; flex-direction: column; gap: 11px; }
.meta-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; align-items: baseline; }
.meta-row__key { color: var(--text-mute); font-size: 12px; flex: none; }
.meta-row__val { text-align: right; overflow-wrap: anywhere; }

.answer { padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.answer + .answer { margin-top: 9px; }
.answer__label { font-size: 11.5px; font-weight: 650; color: var(--text-mute); text-transform: uppercase; letter-spacing: .04em; }
.answer__value { font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline__item { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding-bottom: 14px; position: relative; }
.timeline__item::before { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item:last-child::before { display: none; }
.timeline__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin: 5px auto 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline__body { font-size: 13px; }
.timeline__body time { display: block; font-size: 11.5px; color: var(--text-mute); margin-top: 1px; }

/* ============================== Темы ==================================== */

.topic-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 15px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, transform .1s;
}
.topic-card:hover { border-color: var(--border-strong); }
.topic-card.is-disabled { opacity: .58; }
.topic-card__emoji { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--surface-3); font-size: 19px; }
.topic-card__title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.topic-card__title strong { font-size: 14.5px; }
.topic-card__meta { font-size: 12px; color: var(--text-mute); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.topic-card__actions { display: flex; gap: 5px; }
.topic-list { display: flex; flex-direction: column; gap: 10px; }

.field-builder { display: flex; flex-direction: column; gap: 10px; }
.field-row {
  padding: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.field-row__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.field-row__head strong { font-size: 12.5px; color: var(--text-dim); flex: 1; }
.field-row__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-row__grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ====================== Предпросмотр сообщения Discord ================== */

.dc-preview {
  padding: 14px;
  background: color-mix(in srgb, var(--surface-3) 70%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.dc-content { font-size: 14px; margin-bottom: 9px; white-space: pre-wrap; }
.dc-embed {
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  padding: 13px 15px;
  max-width: 480px;
}
.dc-embed__author { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.dc-embed__title { font-size: 15px; font-weight: 650; margin-bottom: 6px; }
.dc-embed__desc { font-size: 13.5px; color: var(--text-dim); white-space: pre-wrap; line-height: 1.5; }
.dc-embed__thumb { width: 68px; height: 68px; object-fit: cover; border-radius: 7px; float: right; margin: 0 0 8px 10px; }
.dc-embed__image { width: 100%; border-radius: 7px; margin-top: 10px; }
.dc-embed__footer { font-size: 11.5px; color: var(--text-mute); margin-top: 9px; clear: both; }

.dc-buttons { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.dc-buttons__row { display: flex; gap: 7px; flex-wrap: wrap; }
.dc-button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 7px;
  font-size: 13px; font-weight: 550;
  background: #4e5058; color: #fff;
}
.dc-button--1 { background: #5865f2; }
.dc-button--2 { background: #4e5058; }
.dc-button--3 { background: #248046; }
.dc-button--4 { background: #da373c; }

.dc-select {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 11px; padding: 9px 13px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 7px; font-size: 13.5px; color: var(--text-dim);
}
.dc-empty { margin-top: 11px; font-size: 12.5px; color: var(--text-mute); }

/* ============================== Модалка ================================= */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 6, 12, .72);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade .16s ease;
}
.modal {
  width: 100%; max-width: 620px;
  max-height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.1);
}
.modal--wide { max-width: 780px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: 16px; }
.modal__head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-mute); }
.modal__body { padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px; border-top: 1px solid var(--border); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

/* ============================== Тосты =================================== */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 15px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: slide-in .2s ease;
}
.toast--ok { border-left-color: var(--green); }
.toast--err { border-left-color: var(--red); }
.toast--warn { border-left-color: var(--yellow); }
.toast strong { display: block; margin-bottom: 2px; }
.toast span { color: var(--text-dim); }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } }

/* ============================== Лайтбокс =============================== */

.lightbox {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(2, 4, 10, .92);
  display: grid; place-items: center;
  padding: 40px;
  animation: fade .15s ease;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-lg); }
.lightbox__close {
  position: absolute; top: 18px; right: 22px;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .1); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.lightbox__close:hover { background: rgba(255, 255, 255, .2); }

/* ============================== Вход ==================================== */

.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
}
.auth__card {
  width: 100%; max-width: 420px;
  padding: 38px 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth__mark {
  width: 58px; height: 58px; margin: 0 auto 20px;
  display: grid; place-items: center;
  border-radius: 17px;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  color: #fff;
  box-shadow: 0 12px 30px -10px var(--accent);
}
.auth__mark svg { width: 30px; height: 30px; }
.auth__card h1 { font-size: 21px; margin-bottom: 8px; }
.auth__card p { color: var(--text-dim); font-size: 13.5px; }
.auth__btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; margin-top: 24px; padding: 12px;
  background: var(--accent); border: 0; border-radius: 11px;
  color: #fff; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.auth__btn:hover { background: var(--accent-hover); }
.auth__btn svg { width: 20px; height: 20px; }
.auth__note {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-mute); line-height: 1.6;
}
.auth__alert {
  margin-top: 18px; padding: 12px 14px;
  background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 32%, transparent);
  border-radius: var(--radius); color: var(--text);
  font-size: 13px; text-align: left;
}
.auth__alert--warn { background: var(--yellow-soft); border-color: color-mix(in srgb, var(--yellow) 32%, transparent); }

/* ============================== Адаптив ================================= */

@media (max-width: 1100px) {
  .ticket-layout { grid-template-columns: minmax(0, 1fr); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    inset: auto 0 0 0; width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 8px 10px; border-right: 0; border-top: 1px solid var(--border);
  }
  .sidebar__brand, .sidebar__foot .theme-toggle span, .user-card__info { display: none; }
  .sidebar__nav { flex-direction: row; justify-content: space-around; }
  .nav__item span { display: none; }
  .nav__item { padding: 9px 13px; }
  .content { margin-left: 0; padding-bottom: 64px; }
  .topbar { padding: 18px 16px 12px; }
  .content__body { padding: 4px 16px 32px; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .field-row__grid, .field-row__grid--3 { grid-template-columns: minmax(0, 1fr); }
}
