/* ============ Tasker — тёмная фиолетовая тема ============ */
:root {
  --bg: #0b0a16;
  --bg-2: #110f22;
  --surface: #17152e;
  --surface-2: #1d1b38;
  --surface-3: #25224a;
  --border: #2c2950;
  --border-soft: #211f3e;

  --text: #ece9ff;
  --muted: #9893c0;
  --faint: #6f6a99;

  --accent: #7c5cff;
  --accent-2: #a78bff;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #5b8cff 100%);
  --accent-glow: rgba(124, 92, 255, 0.45);

  --green: #3ad29f;
  --yellow: #f7c948;
  --orange: #ff9f45;
  --red: #ff5d73;
  --blue: #5b8cff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(91, 140, 255, 0.12), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ---------- App layout ---------- */
body.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand__mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent-grad);
  color: #fff; font-size: 16px;
  box-shadow: 0 8px 20px -6px var(--accent-glow);
}
.brand__name { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav__link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600; font-size: 14.5px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
  width: 100%;
  background: none;
  font-family: inherit;
  text-align: left;
}
.nav__link:hover { color: var(--text); background: var(--surface); }
.nav__link.is-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(91, 140, 255, 0.12));
  border-color: var(--border);
}
.nav__ico { font-size: 15px; width: 18px; text-align: center; }
.nav__link--logout { color: var(--faint); }
.nav__link--logout:hover { color: var(--red); }

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.hint {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}
.hint__title { margin: 0 0 4px; font-weight: 700; font-size: 14px; }
.hint__text { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 10, 22, 0.6);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.topbar__actions { display: flex; align-items: center; gap: 16px; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip__meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip__name { font-weight: 700; font-size: 13.5px; }
.user-chip__role { font-size: 12px; color: var(--muted); }

.avatar {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.avatar--sm { width: 30px; height: 30px; font-size: 12px; }

.content { padding: 28px 32px 48px; flex: 1; }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 26px;
}
.kpi {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi--accent {
  background: linear-gradient(140deg, rgba(124, 92, 255, 0.28), rgba(91, 140, 255, 0.1)), var(--surface);
  border-color: var(--border);
}
.kpi--danger { border-color: rgba(255, 93, 115, 0.4); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi__ico { font-size: 16px; opacity: 0.8; }
.kpi__value { font-size: 38px; font-weight: 800; letter-spacing: -0.03em; margin: 8px 0 2px; }
.kpi__hint { font-size: 12.5px; color: var(--faint); }
.kpi--danger .kpi__value { color: var(--red); }

/* ---------- Panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 20px; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.panel__title { margin: 0; font-size: 16px; font-weight: 700; }
.count {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px; font-weight: 700;
  margin-left: 6px;
}
.link { color: var(--accent-2); font-weight: 600; font-size: 13.5px; }
.link:hover { color: #fff; }

/* ---------- Ticket rows ---------- */
.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.ticket:hover { border-color: var(--border); transform: translateY(-1px); background: var(--surface-3); }
.ticket__prio {
  width: 8px; height: 38px; border-radius: 5px; flex-shrink: 0;
}
.ticket__prio--lg { height: 46px; width: 10px; }
.prio--low { background: var(--blue); }
.prio--medium { background: var(--yellow); }
.prio--high { background: var(--orange); }
.prio--critical { background: var(--red); box-shadow: 0 0 14px -2px var(--red); }

.ticket__main { flex: 1; min-width: 0; }
.ticket__title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.ticket__id { color: var(--faint); font-weight: 700; font-size: 13px; }
.ticket__meta { display: flex; align-items: center; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
.ticket__assignee { font-size: 12.5px; color: var(--muted); }
.ticket__assignee--none { color: var(--faint); font-style: italic; }
.ticket__side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 11px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
  border: 1px solid transparent;
}
.status--new { background: rgba(91, 140, 255, 0.16); color: #9db8ff; border-color: rgba(91, 140, 255, 0.3); }
.status--in_progress { background: rgba(247, 201, 72, 0.16); color: #ffd86b; border-color: rgba(247, 201, 72, 0.3); }
.status--resolved { background: rgba(58, 210, 159, 0.16); color: #5fe3bb; border-color: rgba(58, 210, 159, 0.3); }
.status--closed { background: rgba(150, 145, 190, 0.16); color: #b9b4dd; border-color: rgba(150, 145, 190, 0.28); }
.status--rejected { background: rgba(255, 93, 115, 0.16); color: #ff8a9b; border-color: rgba(255, 93, 115, 0.3); }

.chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--border-soft);
}
.chip--soft { background: rgba(124, 92, 255, 0.1); color: var(--accent-2); border-color: rgba(124, 92, 255, 0.2); }

.deadline { font-size: 12px; font-weight: 600; color: var(--muted); }
.deadline--overdue { color: var(--red); }
.deadline--soon { color: var(--orange); }
.deadline--ok { color: var(--muted); }
.deadline--done { color: var(--green); }
.deadline--none { color: var(--faint); }

/* ---------- Tabs / filters ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  padding: 9px 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px; color: var(--muted);
  border: 1px solid transparent;
}
.tab:hover { color: var(--text); background: var(--surface); }
.tab.is-active { color: #fff; background: var(--surface-2); border-color: var(--border); }

.filters {
  display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap;
}
.filters__search { flex: 1; min-width: 200px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field__opt { color: var(--faint); font-weight: 500; }
.form__actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; }

.input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}
.input::placeholder { color: var(--faint); }
.input--sm { padding: 7px 10px; font-size: 13px; }
.textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
select.input { appearance: none; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-weight: 700; font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn--primary {
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 10px 24px -10px var(--accent-glow);
}
.btn--primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn--ghost {
  background: var(--surface-2); color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface-3); }
.btn--block { width: 100%; }
.btn--sm { padding: 7px 12px; font-size: 12.5px; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert--error { background: rgba(255, 93, 115, 0.12); color: #ff8a9b; border-color: rgba(255, 93, 115, 0.3); }
.alert--ok { background: rgba(58, 210, 159, 0.12); color: #5fe3bb; border-color: rgba(58, 210, 159, 0.3); }

/* ---------- Detail page ---------- */
.detail { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.detail__head { display: flex; gap: 16px; margin-bottom: 18px; }
.detail__title { margin: 0 0 10px; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.detail__badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail__desc {
  white-space: pre-wrap;
  color: #d6d2f5;
  font-size: 15px; line-height: 1.65;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.detail__side { display: flex; flex-direction: column; gap: 20px; }
.side__title { margin: 0 0 16px; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.meta { margin: 0; display: grid; grid-template-columns: 1fr; gap: 14px; }
.meta dt { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.meta dd { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }

.action-block { margin-bottom: 16px; }
.action-block .field__label { display: block; margin-bottom: 7px; }
.action-row { display: flex; gap: 8px; }
.action-row .input { flex: 1; }

/* ---------- Comments ---------- */
.comments { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.comment { display: flex; gap: 12px; }
.comment__body { flex: 1; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.comment__head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.comment__author { font-weight: 700; font-size: 13.5px; }
.comment__role { font-size: 11.5px; color: var(--accent-2); background: rgba(124,92,255,0.12); padding: 1px 7px; border-radius: 6px; }
.comment__time { font-size: 12px; color: var(--faint); margin-left: auto; }
.comment__text { margin: 0; font-size: 14px; color: #d6d2f5; white-space: pre-wrap; }
.comment-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.comment-form .textarea { width: 100%; }

/* ---------- Tables / users ---------- */
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); padding: 0 12px 12px; font-weight: 700; }
.table td { padding: 12px; border-top: 1px solid var(--border-soft); font-size: 14px; vertical-align: middle; }
.table .td--right { text-align: right; }
.row--off { opacity: 0.55; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user__name { font-weight: 700; font-size: 14px; }
.inline-form { margin: 0; }

/* ---------- Empty / misc ---------- */
.muted { color: var(--muted); }
.empty { text-align: center; padding: 40px 20px; }
.empty__title { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.empty__text { color: var(--muted); margin: 0 0 18px; }
.form-page { max-width: 760px; }

/* ---------- Auth ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-shell { width: 100%; max-width: 440px; }
.auth-card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}
.auth-card__brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.auth-card__title { margin: 0 0 4px; font-size: 26px; font-weight: 800; text-align: center; letter-spacing: -0.02em; }
.auth-card__sub { margin: 0 0 24px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-card__foot { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.auth-card__foot a { color: var(--accent-2); font-weight: 700; }
.auth-card .form__row { grid-template-columns: 1fr 1fr; }

/* ---------- Error ---------- */
.error-box { text-align: center; max-width: 460px; margin: 60px auto; padding: 40px; }
.error-box__code {
  width: 64px; height: 64px; margin: 0 auto 18px;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(255, 93, 115, 0.14); color: var(--red);
  font-size: 30px; font-weight: 800;
}
.error-box__title { font-size: 24px; font-weight: 800; margin: 0 0 8px; }
.error-box__text { color: var(--muted); margin: 0 0 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .detail, .two-col { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  body.app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar__foot { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .topbar { padding: 16px; }
  .content { padding: 18px 16px 40px; }
  .form__row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
