/* ============================================================================
   Сервис-деск ОТО «Софт Эксперт» — оформление интерфейса
   Палитра взята с sfx-tula.ru: синий #486DAA, зелёный #72BE37
   ========================================================================== */
:root {
  --blue: #486DAA;
  --blue-dark: #375784;
  --blue-soft: #eef2fa;
  --green: #72BE37;
  --green-dark: #5aa028;
  --green-soft: #f0f8e9;
  --ink: #1d2734;
  --ink-2: #4a5a6d;
  --muted: #7b899b;
  --line: #e3e9f2;
  --bg: #f3f6fb;
  --card: #ffffff;
  --red: #d64545;
  --amber: #c98a11;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 43, 77, .06), 0 8px 24px -12px rgba(23, 43, 77, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- каркас */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: 1160px; margin: 0 auto; padding: 10px 18px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 36px; width: auto; display: block; }
.brand__sep { width: 1px; height: 26px; background: var(--line); }
.brand__dept { font-size: 12.5px; line-height: 1.15; color: var(--ink-2); font-weight: 600; }
.brand__dept small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.topbar__spacer { flex: 1 1 auto; }

.userbox { display: flex; align-items: center; gap: 10px; position: relative; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(140deg, var(--blue), #6d8fc9);
  color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center; flex: 0 0 auto;
}
.avatar--eng { background: linear-gradient(140deg, var(--green-dark), var(--green)); }
.avatar--adm { background: linear-gradient(140deg, #2f3b4d, #5b6a80); }
.avatar, .comment__av { overflow: hidden; }
.avatar img, .comment__av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-pick .chip { font-size: 17px; line-height: 1; padding: 7px 9px; }

.bell {
  position: relative; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-2);
}
.bell:hover { background: var(--blue-soft); color: var(--blue); }
.bell__badge {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff;
}

.nav {
  max-width: 1160px; margin: 0 auto; padding: 0 12px 8px;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); border: 1px solid transparent;
}
.nav a:hover { background: #fff; border-color: var(--line); }
.nav a.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.main { flex: 1 0 auto; width: 100%; max-width: 1160px; margin: 0 auto; padding: 20px 16px 96px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 16px calc(18px + var(--safe-b)); }

.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------- карточки */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 14px; }
.card__title { font-size: 15px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card__title .muted { font-weight: 500; }

.grid { display: grid; gap: 14px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat__num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat__lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-top: 2px; }
.stat--new .stat__num { color: var(--blue); }
.stat--work .stat__num { color: var(--amber); }
.stat--done .stat__num { color: var(--green-dark); }

/* ---------------------------------------------------------------- заявки */
.ticket {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; position: relative;
  transition: border-color .15s, transform .15s;
  border-left: 3px solid transparent;
}
.ticket:hover { border-color: #c9d6ea; transform: translateY(-1px); }
.ticket--critical { border-left-color: var(--red); }
.ticket--high { border-left-color: #e8a33d; }
.ticket--low { border-left-color: #c3ccd8; }
.ticket + .ticket { margin-top: 10px; }
.ticket__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ticket__num { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.ticket__title { font-weight: 650; font-size: 15.5px; margin: 0 0 4px; }
.ticket__meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.ticket__meta span { display: inline-flex; align-items: center; gap: 4px; }
.ticket__right { position: absolute; top: 14px; right: 16px; text-align: right; font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap;
}
.pill--new { background: #e8eefb; color: #2f5696; }
.pill--in_progress { background: #fff4e0; color: #8a5c00; }
.pill--closed { background: #eaf7e8; color: #3f7a2e; }
.pill--prio-low { background: #eef1f5; color: #5b6a7c; }
.pill--prio-normal { background: #eef2fa; color: #3b5b8e; }
.pill--prio-high { background: #fdeee0; color: #9a5a12; }
.pill--prio-critical { background: #fdeaea; color: #b03030; }
.pill--role-client { background: #eef2fa; color: #3b5b8e; }
.pill--role-engineer { background: #eaf7e8; color: #3f7a2e; }
.pill--role-admin { background: #eceff3; color: #43536a; }

.empty {
  text-align: center; padding: 44px 20px; color: var(--muted);
  background: #fff; border: 1px dashed #cfd9e8; border-radius: var(--radius);
}
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; }

/* ---------------------------------------------------------------- формы */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; border: 1px solid #d5dfec; border-radius: 10px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; font-size: 15px;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(72, 109, 170, .14); }
textarea.input { min-height: 110px; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237b899b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) {
  .row { grid-template-columns: 1fr; }
  .grid--stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 11px 10px; }
  .stat__num { font-size: 21px; }
  .stat__lbl { font-size: 10.5px; letter-spacing: .03em; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font-weight: 650; font-size: 14.5px; background: var(--blue); color: #fff;
  transition: background .15s, transform .05s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--green { background: var(--green); }
.btn--green:hover { background: var(--green-dark); }
.btn--ghost { background: #fff; color: var(--ink); border-color: #d5dfec; }
.btn--ghost:hover { background: var(--blue-soft); border-color: #bccde6; }
.btn--danger { background: #fff; color: var(--red); border-color: #f0cccc; }
.btn--danger:hover { background: #fdeaea; }
.btn--sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn--block { width: 100%; }
.btn--icon { padding: 8px 10px; }

/* -------------------------------------------------------------- чипы */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 13px; border-radius: 10px; border: 1px solid #d5dfec; background: #fff;
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); display: inline-flex; gap: 8px; align-items: center;
}
.chip:hover { border-color: #b9cae2; background: #fafcff; }
.chip.is-on { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); box-shadow: 0 0 0 2px rgba(72, 109, 170, .12) inset; }

/* ------------------------------------------------------------ фото-плитки */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.photo {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eef2f7;
  border: 1px solid var(--line); cursor: zoom-in;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(12, 20, 30, .65); color: #fff; cursor: pointer; font-size: 13px; line-height: 1;
}
.drop {
  border: 1.5px dashed #c7d4e6; border-radius: 12px; padding: 18px; text-align: center;
  color: var(--ink-2); background: #fafcff; cursor: pointer;
}
.drop:hover { border-color: var(--blue); background: #f4f8ff; }
.drop b { display: block; margin-bottom: 3px; }
.drop small { color: var(--muted); }

/* --------------------------------------------------------------- заявка */
.ticket-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.ticket-head h1 { font-size: 21px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; margin: 4px 0 0; }
.meta-grid div { min-width: 0; }
.meta-grid dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.meta-grid dd { margin: 3px 0 0; font-size: 14px; word-break: break-word; }

.desc { white-space: pre-wrap; line-height: 1.6; font-size: 14.5px; }

.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: 4px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: #fff; border: 2px solid var(--blue);
}
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--green); border-color: var(--green); }
.timeline b { display: block; font-size: 13.5px; }
.timeline small { color: var(--muted); font-size: 12px; }

.comments { display: grid; gap: 12px; }
.comment { display: flex; gap: 10px; }
.comment__av {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--blue-soft); color: var(--blue); font-weight: 700; font-size: 12px;
}
.comment--staff .comment__av { background: var(--green-soft); color: var(--green-dark); }
.comment__body { background: #f7f9fd; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 14px; white-space: pre-wrap; }
.comment--internal .comment__body { background: #fff8e8; border-color: #f3e0b8; }
.comment__meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.comment__meta b { color: var(--ink-2); }

.actionbar {
  position: sticky; bottom: 0; z-index: 20; margin: 14px -16px -16px; padding: 12px 16px calc(12px + var(--safe-b));
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ------------------------------------------------------------ таблицы */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 10px 12px; background: #f8fafd; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid #eef2f8; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fafcff; }
.tbl .num { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--muted); }
.tbl__actions { display: flex; gap: 6px; justify-content: flex-end; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.tabs button.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* --------------------------------------------------------------- прочее */
.toasts { position: fixed; right: 16px; top: 74px; z-index: 90; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast {
  background: #1f2937; color: #fff; border-radius: 12px; padding: 11px 14px; font-size: 13.5px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4); animation: slidein .22s ease-out; display: flex; gap: 9px;
}
.toast--ok { background: #2f7d32; }
.toast--err { background: #b33434; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .5); z-index: 80;
  display: grid; place-items: center; padding: 16px; animation: fadein .15s;
}
@keyframes fadein { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .35);
}
.modal__head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal__head h3 { font-size: 16.5px; flex: 1 0 auto; }
.modal__body { padding: 18px 20px; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.lightbox {
  position: fixed; inset: 0; background: rgba(8, 12, 18, .94); z-index: 95; display: grid; place-items: center;
  padding: 20px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox__close { position: absolute; top: 14px; right: 16px; color: #fff; background: none; border: 0; font-size: 30px; cursor: pointer; }

/* ------------------------------------------------------------- страницы входа */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: #fff;
}
.auth__side {
  background: radial-gradient(1200px 500px at -10% -20%, #5b81bd 0%, #486DAA 45%, #33527f 100%);
  color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth__side::after {
  content: ""; position: absolute; right: -90px; bottom: -120px; width: 340px; height: 340px;
  border-radius: 50%; background: rgba(114, 190, 55, .28); filter: blur(10px);
}
.auth__side h2 { font-size: 27px; max-width: 420px; margin-bottom: 14px; }
.auth__side p { color: rgba(255, 255, 255, .82); max-width: 430px; font-size: 14.5px; }
.auth__logo { height: 41px; width: auto; filter: brightness(0) invert(1); }
.auth__feats { display: grid; gap: 12px; position: relative; z-index: 1; margin-top: 26px; }
.auth__feats div { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: rgba(255,255,255,.92); }
.auth__feats svg { flex: 0 0 auto; margin-top: 2px; opacity: .9; }
.auth__form { padding: 40px clamp(20px, 6vw, 64px); display: flex; flex-direction: column; justify-content: center; }
.auth__form .brand img { height: 36px; }
.auth__form h1 { font-size: 24px; margin: 22px 0 6px; }
.auth__form > p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.auth__switch { margin-top: 16px; font-size: 13.5px; color: var(--muted); text-align: center; }
.auth__switch button { background: none; border: 0; color: var(--blue); font-weight: 650; cursor: pointer; padding: 0 4px; }
.auth__box { width: min(420px, 100%); margin: 0 auto; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; }

/* ------------------------------------------------------------- адаптив */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth__side { display: none; }
  .auth__form { padding: 26px 18px 40px; min-height: 100vh; }
  .brand__sep, .brand__dept { display: none; }
  .main { padding: 16px 12px calc(84px + var(--safe-b)); }
  .topbar__inner { padding: 9px 12px; }
  .card { padding: 15px; border-radius: 12px; }
  .ticket__right { position: static; text-align: left; margin-top: 6px; }
  .ticket__top { padding-right: 0; }
  .tbl th, .tbl td { padding: 9px 10px; }
  .hide-sm { display: none !important; }
  .nav { padding: 0 10px 8px; }
  .toasts { top: auto; bottom: calc(70px + var(--safe-b)); left: 12px; right: 12px; max-width: none; }
  .btn { padding: 11px 15px; }
  .page-head h1 { font-size: 19px; }
  .actionbar { margin: 12px -12px -12px; padding: 10px 12px calc(10px + var(--safe-b)); }
  .actionbar .btn { flex: 1 1 auto; }
}
@media (min-width: 861px) {
  .nav { padding: 0 18px 8px; }
}
