:root {
  color-scheme: dark;
  --bg: #071117;
  --panel: #0b1820;
  --panel-2: #10242d;
  --line: #213842;
  --text: #edf7fb;
  --muted: #91a6ae;
  --blue: #1d9bf0;
  --green: #3ed26f;
  --orange: #f5a524;
  --red: #ef4444;
  --violet: #a855f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #12313d 0, #071117 42%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 24, 32, 0.95);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(216, 237, 245, 0.32);
  border-radius: 8px;
  background: #f8fbfd;
  box-shadow: 0 0 0 1px rgba(29, 155, 240, 0.12), 0 10px 24px rgba(0, 0, 0, 0.22);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 3px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand strong {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 20px 0 6px;
  font-size: 28px;
  text-transform: uppercase;
}

.login-panel p,
.topbar p,
.sidebar-brand span {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: #c9d7dc;
}

.login-form input,
select,
.filter-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #09151c;
  color: var(--text);
}

.login-form button,
.primary-button,
.primary-link-button,
.danger-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: white;
  background: #12649b;
}

.primary-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 700;
}

.danger-button {
  background: #9d2424;
}

.error-text {
  min-height: 18px;
  color: #ff8d8d;
}

.app-shell {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(5, 16, 22, 0.96);
  padding: 16px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 18px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 10px;
  color: #d9e7eb;
  background: transparent;
  text-align: left;
}

.nav-button.active {
  border-color: #143b51;
  background: #0d2b3d;
  color: white;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #95b7c4;
}

.nav-icon.small {
  width: 22px;
  height: 22px;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button.active .nav-icon {
  color: var(--blue);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 23, 0.72);
}

.topbar h2 {
  margin: 0 0 4px;
  font-size: 24px;
  text-transform: uppercase;
}

.topbar p {
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.logout-button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #0b1820;
}

.logout-button {
  padding: 0 14px;
}

.page-content {
  padding: 18px 24px;
  overflow: auto;
}

.monitor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  gap: 16px;
}

.monitor-toolbar {
  min-height: 52px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(11, 24, 32, 0.82);
}

.monitor-toolbar b {
  display: block;
  margin-bottom: 3px;
}

.monitor-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.camera-grid.single-view {
  grid-template-columns: 1fr;
}

.camera-tile {
  min-height: 214px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(145deg, #20343c, #0c171d 52%, #162c25);
}

.single-view .camera-tile {
  min-height: min(68vh, 720px);
}

.camera-media {
  width: 100%;
  height: 100%;
  min-height: 214px;
  display: block;
  object-fit: cover;
}

.single-view .camera-media {
  min-height: min(68vh, 720px);
}

.camera-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(255,255,255,0.05) 18% 19%, transparent 19% 36%, rgba(255,255,255,0.04) 36% 37%, transparent 37%),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(255,255,255,0.035) 34px 35px),
    radial-gradient(circle at 68% 66%, rgba(62, 210, 111, 0.28), transparent 18%),
    radial-gradient(circle at 36% 74%, rgba(239, 68, 68, 0.24), transparent 16%);
  opacity: 0.95;
}

.camera-tile.has-media::before {
  display: none;
}

.camera-head,
.camera-live,
.camera-actions,
.vision-placeholder {
  position: absolute;
  z-index: 1;
}

.camera-head {
  inset: 0 0 auto;
  min-height: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.42);
  font-weight: 700;
  font-size: 13px;
}

.camera-live {
  right: 10px;
  top: 40px;
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
}

.camera-actions {
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.48);
}

.camera-actions button,
.camera-actions a {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 5px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.82);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.camera-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.vision-placeholder {
  inset: 32px 0 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(29, 155, 240, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(29, 155, 240, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 50% 46%, rgba(29, 155, 240, 0.16), transparent 30%),
    radial-gradient(circle at 50% 46%, rgba(34, 197, 94, 0.08), transparent 48%);
  background-size: 34px 34px, 34px 34px, 100% 100%, 100% 100%;
}

.vision-placeholder::before,
.vision-placeholder::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(29, 155, 240, 0.24);
  border-radius: 50%;
}

.vision-placeholder::before {
  width: 190px;
  height: 190px;
}

.vision-placeholder::after {
  width: 118px;
  height: 118px;
  border-color: rgba(34, 197, 94, 0.22);
}

.vision-eye {
  width: 126px;
  height: 64px;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(125, 211, 252, 0.72);
  border-radius: 999px 999px 999px 999px / 70% 70% 70% 70%;
  box-shadow: 0 0 28px rgba(29, 155, 240, 0.28), inset 0 0 18px rgba(29, 155, 240, 0.16);
}

.vision-eye span {
  width: 32px;
  height: 32px;
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(125, 211, 252, 0.9), rgba(29, 155, 240, 0.2) 44%, transparent 70%);
  box-shadow: 0 0 26px rgba(125, 211, 252, 0.58);
}

.vision-scan {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 44%;
  height: 1px;
  z-index: 2;
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.9), transparent);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.5);
}

.vision-status {
  position: absolute;
  left: 12px;
  bottom: 48px;
  z-index: 2;
  color: rgba(125, 211, 252, 0.88);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.side-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 24, 32, 0.92);
}

.side-panel {
  padding: 14px;
}

.camera-picker {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.camera-picker label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.side-panel h3,
.panel h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.ptz-pad {
  width: 168px;
  height: 168px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  margin: 10px auto 18px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #09151c;
}

.ptz-pad span,
.ptz-pad button {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: #132a35;
}

.ptz-pad button {
  font-weight: 800;
}

.ptz-pad button:active,
.control-row button:active {
  background: #17577a;
  color: white;
}

.control-row,
.filter-row {
  display: grid;
  grid-template-columns: 1fr 42px 42px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.control-row button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: white;
  background: #122630;
}

.camera-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(340px, 1.2fr);
  gap: 16px;
}

.settings-wide,
.system-wide {
  grid-column: 1 / -1;
}

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h3 {
  margin: 0;
}

.vpn-layout {
  min-height: calc(100vh - 190px);
}

.vpn-panel {
  height: calc(100vh - 190px);
  min-height: 560px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.vpn-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #071117;
}

.camera-form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #09151c;
}

.camera-form-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.compact-actions {
  margin: 8px 0 12px;
}

.camera-settings-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: 8px 0 12px;
}

.camera-settings-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.camera-settings-toolbar select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #071117;
  color: var(--text);
}

.camera-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.camera-form input,
.user-form input,
.user-form select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #071117;
  color: var(--text);
}

.user-form {
  display: grid;
  gap: 10px;
}

.user-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.user-access-list {
  display: grid;
  gap: 12px;
}

.user-access-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #09151c;
}

.user-access-head,
.user-access-controls {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(150px, 0.7fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: center;
}

.user-access-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.user-access-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.user-access-controls select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #071117;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 8px;
}

.access-check {
  min-height: 38px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 6px;
  background: rgba(7, 17, 23, 0.76);
}

.access-check input:disabled + .nav-icon,
.access-check input:disabled ~ b {
  opacity: 0.58;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px;
}

.toggle-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: 20px 28px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #09151c;
  color: var(--text);
}

.toggle-row input {
  width: 16px;
  height: 16px;
}

.camera-form .toggle-row {
  grid-template-columns: 20px 1fr;
}

.command-box {
  display: block;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #071117;
  color: #cdeaf7;
  overflow-x: auto;
}

.hint {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #09151c;
  color: var(--muted);
  line-height: 1.5;
}

.hint.compact {
  display: block;
  min-height: 38px;
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 24, 32, 0.92);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}


.fixation-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.fixation-card {
  min-height: 88px;
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 24, 32, 0.92);
}

.fixation-card span {
  font-weight: 700;
}

.fixation-card strong {
  font-size: 24px;
  line-height: 1.1;
}

.fixation-card small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}


.ptz-fixations {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.ptz-fixations .fixation-strip {
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 0;
}

.ptz-fixations .fixation-card {
  min-height: 74px;
  padding: 10px 12px;
}

.ptz-fixations .fixation-card strong {
  font-size: 18px;
}

.camera-picker input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #09151c;
  color: var(--text);
}

.system-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.system-metric {
  min-height: 104px;
}

.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  margin-top: 12px;
  background: #071117;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.ai-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.ai-status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.ai-status-grid .metric {
  min-height: 76px;
}

.ai-status-grid .metric strong {
  font-size: 18px;
}

.ai-event {
  grid-template-columns: 1fr 90px;
}

.two-col {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
}

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

.panel {
  padding: 16px;
}

.list {
  display: grid;
  gap: 8px;
}

.list-item,
.table-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid #18303a;
  border-radius: 6px;
  background: #09151c;
}

button.list-item {
  width: 100%;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.equipment-item.active {
  outline: 1px solid rgba(29, 155, 240, 0.42);
  background: rgba(29, 155, 240, 0.12);
}

.map-object.active {
  outline: 1px solid rgba(29, 155, 240, 0.55);
  background: rgba(29, 155, 240, 0.16);
}

.map-selected {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(29, 155, 240, 0.42);
  border-radius: 7px;
  background: rgba(29, 155, 240, 0.11);
}

.map-selected small {
  color: var(--muted);
}

.equipment-row b {
  justify-self: end;
  text-align: right;
}

.table {
  display: grid;
  gap: 6px;
}

.table-row.users {
  grid-template-columns: 1.1fr 1fr 0.8fr 92px;
}

.table-head {
  color: var(--muted);
  font-weight: 700;
}

.small-danger {
  min-height: 30px;
  border: 1px solid rgba(239, 68, 68, 0.36);
  border-radius: 6px;
  color: #ffd7d7;
  background: rgba(157, 36, 36, 0.78);
}

.small-danger:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.table-row.alarms {
  grid-template-columns: 150px 1fr 1fr 110px;
}

.table-row.events {
  grid-template-columns: 150px minmax(160px, 0.9fr) minmax(140px, 0.7fr) minmax(220px, 1fr) 100px;
}

.table-row.processes {
  grid-template-columns: 80px minmax(180px, 1fr) minmax(120px, 0.8fr) 70px 70px 100px;
}

.file-cell {
  min-width: 0;
}

.file-cell small {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.badge {
  color: var(--green);
  font-weight: 700;
}

.badge.red {
  color: var(--red);
}

.badge.orange {
  color: var(--orange);
}

.map-board {
  min-height: 520px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(30deg, transparent 0 46%, rgba(29,155,240,0.16) 46% 47%, transparent 47%),
    linear-gradient(125deg, transparent 0 54%, rgba(29,155,240,0.15) 54% 55%, transparent 55%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 48px),
    #07151d;
}

.pin {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px currentColor;
}

.live-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  min-height: 620px;
}

.yandex-map-shell {
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #051016;
  box-shadow: inset 0 0 0 1px rgba(29, 155, 240, 0.08);
}

.yandex-map-shell iframe {
  width: 100%;
  height: 100%;
  min-height: 620px;
  display: block;
  border: 0;
  filter: invert(0.9) hue-rotate(178deg) saturate(0.72) brightness(0.72) contrast(1.08);
}

.map-side {
  align-self: stretch;
  overflow: auto;
}

.pin.red {
  background: var(--red);
}

.pin.orange {
  background: var(--orange);
}

.statusbar {
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 8px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #061017;
}

.ok {
  color: var(--green);
}

.warn {
  color: var(--violet);
}

.danger {
  color: var(--red);
}

.alert {
  color: var(--orange);
}

.ops-monitor-shell {
  --ops-line: rgba(0, 157, 255, 0.32);
  --ops-fill: rgba(3, 18, 34, 0.9);
  width: 100%;
  min-height: calc(100vh - 142px);
  padding: 0;
  color: #f4fbff;
}

.ops-board {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: calc(100vh - 154px);
  margin: 0;
}

.ops-live-panel,
.ops-widget {
  border: 1px solid var(--ops-line);
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(2, 16, 31, 0.96), rgba(1, 9, 20, 0.96));
  box-shadow: inset 0 0 32px rgba(0, 122, 255, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.24);
}

.ops-live-panel {
  padding: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
}

.ops-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  margin-bottom: 6px;
}

.ops-panel-title h3,
.ops-widget h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.ops-panel-title small {
  color: #8fb5c7;
  font-size: 12px;
}

.ops-camera-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(220px, 1fr));
  gap: 8px;
  min-height: 0;
}

.ops-camera {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 145, 255, 0.32);
  border-radius: 7px;
  background: #061424;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.ops-camera.active {
  border-color: rgba(28, 198, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(0, 174, 255, 0.28), 0 0 28px rgba(0, 174, 255, 0.24);
}

.ops-camera.active::after {
  content: "Выбрана для PTZ";
  position: absolute;
  z-index: 2;
  right: 8px;
  top: 34px;
  padding: 3px 7px;
  border-radius: 5px;
  color: white;
  background: rgba(0, 116, 181, 0.88);
  font-size: 11px;
  font-weight: 700;
}

.ops-camera-media,
.ops-camera-fallback {
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: block;
  object-fit: cover;
}

.ops-camera-fallback {
  background:
    linear-gradient(0deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18)),
    linear-gradient(90deg, transparent 0 49%, rgba(235, 244, 255, 0.45) 49% 51%, transparent 51%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 38px),
    radial-gradient(circle at 18% 70%, #1b2c32 0 8%, transparent 9%),
    radial-gradient(circle at 70% 64%, #24323a 0 9%, transparent 10%),
    linear-gradient(160deg, #61707a 0 30%, #2e4b36 31% 54%, #1f2d35 55% 100%);
}

.ops-scene-2 {
  background:
    linear-gradient(0deg, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.14)),
    radial-gradient(circle at 44% 48%, rgba(30, 30, 32, 0.75) 0 1.2%, transparent 1.4%),
    radial-gradient(circle at 62% 52%, rgba(30, 30, 32, 0.75) 0 1.2%, transparent 1.4%),
    repeating-linear-gradient(90deg, transparent 0 70px, rgba(255, 255, 255, 0.16) 70px 72px),
    linear-gradient(145deg, #6b6d67 0 36%, #385232 37% 54%, #51616b 55% 100%);
}

.ops-scene-3 {
  background:
    linear-gradient(90deg, transparent 0 47%, rgba(240, 248, 255, 0.42) 47% 49%, transparent 49%),
    radial-gradient(ellipse at 12% 74%, #1f2529 0 13%, transparent 14%),
    radial-gradient(ellipse at 35% 70%, #22282c 0 12%, transparent 13%),
    radial-gradient(ellipse at 64% 68%, #20272c 0 12%, transparent 13%),
    linear-gradient(160deg, #567040 0 28%, #4b5558 29% 62%, #243036 63% 100%);
}

.ops-scene-4 {
  background:
    linear-gradient(85deg, transparent 0 45%, rgba(240, 248, 255, 0.38) 45% 47%, transparent 47%),
    radial-gradient(ellipse at 28% 72%, #1d252a 0 10%, transparent 11%),
    radial-gradient(ellipse at 54% 67%, #273039 0 11%, transparent 12%),
    radial-gradient(ellipse at 77% 61%, #2b333a 0 10%, transparent 11%),
    linear-gradient(155deg, #63766c 0 28%, #344c35 29% 48%, #46555f 49% 100%);
}

.ops-camera-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 35%, rgba(0, 0, 0, 0.56));
}

.ops-camera-meta,
.ops-camera strong,
.ops-camera-tools {
  position: absolute;
  z-index: 1;
}

.ops-camera-meta {
  top: 8px;
  left: 9px;
  right: 9px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 6px black;
}

.ops-camera strong {
  left: 9px;
  bottom: 8px;
  font-size: 14px;
  text-shadow: 0 1px 6px black;
}

.ops-camera-tools {
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 5px;
}

.ops-camera-tools button,
.ops-camera-tools a,
.ops-view-toolbar button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(130, 188, 220, 0.36);
  border-radius: 5px;
  color: #e8f8ff;
  background: rgba(4, 14, 25, 0.72);
  text-decoration: none;
}

.ops-camera-tools button:disabled {
  opacity: 0.45;
}

.ops-view-toolbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(0, 145, 255, 0.26);
  border-radius: 7px;
  background: rgba(3, 20, 38, 0.82);
}

.ops-view-toolbar span {
  flex: 1;
}

.ops-view-toolbar .active {
  color: white;
  background: #11689f;
}

.ops-camera-control {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) 108px minmax(190px, 0.9fr) minmax(180px, 0.8fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(0, 145, 255, 0.26);
  border-radius: 7px;
  background: rgba(2, 13, 26, 0.9);
}

.ops-camera-select,
.ops-preset-controls {
  display: grid;
  gap: 8px;
}

.ops-camera-select label {
  display: grid;
  gap: 5px;
  color: #9fc0ce;
  font-size: 12px;
}

.ops-camera-select select,
.ops-preset-controls select {
  min-height: 34px;
}

.ops-ptz-pad {
  width: 108px;
  height: 108px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  justify-self: center;
}

.ops-ptz-pad span,
.ops-ptz-pad button {
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 145, 255, 0.34);
  border-radius: 999px;
  color: #e7f8ff;
  background: rgba(12, 48, 78, 0.78);
  font-size: 12px;
  font-weight: 700;
}

.ops-ptz-pad button:active {
  background: #1476aa;
}

.ops-lens-controls {
  display: grid;
  gap: 6px;
}

.ops-lens-controls .control-row {
  margin: 0;
  grid-template-columns: 1fr 34px 34px;
}

.ops-preset-controls .danger-button {
  min-height: 34px;
}

.ops-right-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.ops-widget {
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}

.ops-widget a {
  display: inline-block;
  margin-top: 10px;
  color: #16c7ff;
  text-decoration: none;
}

.ops-map {
  width: 100%;
  height: calc(100% - 30px);
  min-height: 210px;
  margin-top: 9px;
  border: 0;
  border-radius: 6px;
  filter: invert(1) hue-rotate(180deg) saturate(0.85) brightness(0.68) contrast(1.24);
  background: #061424;
}

.ops-ai-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.ops-ai-tabs span {
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(21, 53, 83, 0.82);
  color: #d9f4ff;
  font-size: 12px;
}

.ops-face-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
}

.ops-face {
  width: 96px;
  aspect-ratio: 1;
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 37%, #f0c0a5 0 17%, transparent 18%),
    radial-gradient(ellipse at 50% 72%, #303640 0 29%, transparent 30%),
    radial-gradient(ellipse at 50% 45%, #cfa083 0 28%, transparent 29%),
    linear-gradient(140deg, #304f5f, #152230);
  box-shadow: inset 0 0 0 2px rgba(0, 190, 255, 0.18);
}

.ops-face-card p {
  display: grid;
  gap: 8px;
  margin: 0;
  font-size: 12px;
}

.ops-face-card span {
  color: #d4e8f1;
}

.ops-event-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ops-event-row {
  display: grid;
  grid-template-columns: 14px 48px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.ops-event-row small {
  grid-column: 3;
  color: #c6dce7;
}

.ops-recent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.ops-recent {
  min-height: 78px;
  position: relative;
  overflow: hidden;
  border-radius: 5px;
  background:
    radial-gradient(ellipse at 60% 64%, #26323b 0 16%, transparent 17%),
    linear-gradient(145deg, #546b58, #1f2d38);
}

.ops-recent:nth-child(2n) {
  background:
    radial-gradient(ellipse at 45% 60%, #1f252d 0 14%, transparent 15%),
    linear-gradient(145deg, #65716e, #26354a);
}

.ops-recent span {
  position: absolute;
  left: 6px;
  bottom: 5px;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .sidebar-brand div:last-child,
  .nav-button span:last-child {
    display: none;
  }

  .monitor-grid,
  .two-col,
  .content-grid,
  .live-map-layout,
  .system-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-wide,
  .system-wide {
    grid-column: auto;
  }
}

@media (max-width: 1500px) {
  .ops-board {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  }

  .ops-camera-control {
    grid-template-columns: minmax(220px, 1fr) 108px minmax(170px, 0.8fr);
  }

  .ops-preset-controls {
    grid-column: 1 / -1;
    grid-template-columns: minmax(180px, 1fr) auto minmax(160px, 0.7fr);
    align-items: center;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(5, 1fr);
  }

  .camera-grid,
  .camera-settings,
  .toggle-grid,
  .metric-grid,
  .fixation-strip {
    grid-template-columns: 1fr;
  }

  .monitor-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .system-metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .access-grid,
  .user-access-controls,
  .user-access-head {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-map-layout,
  .yandex-map-shell,
  .yandex-map-shell iframe {
    min-height: 460px;
  }

  .table-row.alarms,
  .table-row.events,
  .table-row.processes,
  .table-row.users {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    background: #071117;
  }

  button,
  .primary-button,
  .danger-button,
  .logout-button,
  input,
  select {
    min-height: 44px;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 20;
    height: 74px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: rgba(5, 16, 22, 0.98);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.34);
  }

  .sidebar-brand {
    display: none;
  }

  .nav-list {
    height: 100%;
    display: flex;
    grid-template-columns: none;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    width: 76px;
    min-width: 76px;
    min-height: 58px;
    grid-template-columns: 1fr;
    grid-template-rows: 24px 1fr;
    justify-items: center;
    align-content: center;
    gap: 3px;
    padding: 6px 5px;
    border-color: rgba(148, 163, 184, 0.12);
    background: #09151c;
    text-align: center;
  }

  .nav-button span:last-child {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: #cfe0e6;
    font-size: 10px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-button.active {
    background: #10354a;
    border-color: rgba(29, 155, 240, 0.58);
  }

  .nav-icon,
  .nav-icon.small {
    width: 24px;
    height: 24px;
  }

  .workspace {
    min-height: 100vh;
    display: block;
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 58px;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    gap: 10px;
    background: rgba(7, 17, 23, 0.96);
    backdrop-filter: blur(8px);
  }

  .topbar h2 {
    margin: 0;
    font-size: 17px;
    line-height: 1.2;
  }

  .topbar p {
    display: none;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  .topbar-actions {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
  }

  .icon-button {
    display: none;
  }

  .logout-button {
    width: auto;
    min-width: 76px;
    padding: 0 12px;
  }

  .page-content {
    padding: 12px;
    overflow: visible;
  }

  .statusbar {
    display: none;
  }

  .monitor-grid,
  .two-col,
  .content-grid,
  .live-map-layout,
  .system-grid,
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .panel,
  .side-panel,
  .monitor-toolbar,
  .camera-form,
  .metric,
  .camera-tile,
  .yandex-map-shell {
    border-radius: 7px;
  }

  .panel,
  .side-panel {
    padding: 12px;
  }

  .monitor-toolbar {
    margin-bottom: 10px;
  }

  .toolbar-actions,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .camera-grid,
  .camera-grid.single-view,
  .camera-settings,
  .toggle-grid,
  .metric-grid,
  .fixation-strip,
  .system-metrics,
  .ai-status-grid,
  .access-grid,
  .user-access-controls,
  .user-access-head,
  .camera-settings-toolbar,
  .ai-toolbar {
    grid-template-columns: 1fr;
  }

  .single-view .camera-tile,
  .single-view .camera-media {
    min-height: 48vh;
  }

  .camera-actions {
    flex-wrap: wrap;
  }

  .camera-actions button,
  .camera-actions a {
    min-height: 36px;
    flex: 1 1 92px;
    text-align: center;
  }

  .side-panel {
    order: 2;
  }

  .ptz-pad {
    width: min(220px, 78vw);
    height: min(220px, 78vw);
  }

  .control-row {
    grid-template-columns: 1fr 48px 48px;
  }

  .live-map-layout,
  .yandex-map-shell,
  .yandex-map-shell iframe {
    min-height: 360px;
  }

  .map-side {
    max-height: none;
  }

  .table {
    overflow-x: hidden;
  }

  .table-row,
  .table-row.alarms,
  .table-row.events,
  .table-row.processes,
  .table-row.users {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (max-width: 420px) {
  .nav-button {
    width: 68px;
    min-width: 68px;
  }

  .nav-button span:last-child {
    font-size: 9px;
  }

  .topbar h2 {
    font-size: 16px;
  }

  .single-view .camera-tile,
  .single-view .camera-media {
    min-height: 42vh;
  }
}

.fixation-card.image-card {
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  align-content: stretch;
  gap: 10px;
  min-height: 82px;
}

.fixation-thumb {
  width: 76px;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
  background: linear-gradient(145deg, #132a35, #071117);
  color: #cdeaf7;
  font-size: 12px;
  font-weight: 800;
}

.fixation-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.fixation-thumb.plate {
  background: linear-gradient(145deg, #172235, #071117);
  color: #edf7fb;
}

.fixation-thumb.face {
  background: linear-gradient(145deg, rgba(62, 210, 111, 0.18), #071117);
  color: var(--green);
}

.fixation-thumb.person {
  background: linear-gradient(145deg, rgba(245, 165, 36, 0.18), #071117);
  color: var(--orange);
}

.fixation-thumb.car {
  background: linear-gradient(145deg, rgba(29, 155, 240, 0.18), #071117);
  color: #7dd3fc;
}

.fixation-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.fixation-info span {
  font-weight: 800;
}

.fixation-info strong {
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fixation-info small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ptz-fixations .fixation-card.image-card {
  min-height: 78px;
  padding: 8px;
}
.complex-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.complex-search-row button {
  min-height: 38px;
  border: 1px solid rgba(29, 155, 240, 0.42);
  border-radius: 6px;
  padding: 0 12px;
  color: #fff;
  background: #12649b;
}

@media (max-width: 760px) {
  .complex-search-row {
    grid-template-columns: 1fr;
  }
}

/* Compact users page */
.user-access-list {
  gap: 8px;
}

.user-access-card {
  gap: 8px;
  padding: 10px;
  border-radius: 7px;
}

.user-access-head {
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
}

.user-access-head strong {
  font-size: 14px;
}

.user-access-head small {
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.2;
}

.user-access-controls {
  grid-template-columns: minmax(130px, 0.8fr) minmax(120px, 0.7fr) minmax(180px, 1fr);
  gap: 8px;
}

.user-access-controls label,
.user-form label {
  gap: 4px;
  font-size: 12px;
}

.user-access-controls select,
.user-access-controls input,
.user-form input,
.user-form select {
  min-height: 30px;
  padding: 0 8px;
  font-size: 13px;
}

.access-grid {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 6px;
}

.access-check {
  min-height: 30px;
  grid-template-columns: 16px 20px minmax(0, 1fr);
  gap: 6px;
  padding: 5px 6px;
  border-radius: 5px;
}

.access-check input {
  width: 14px;
  height: 14px;
}

.access-check .nav-icon.small {
  width: 18px;
  height: 18px;
}

.access-check .nav-icon svg {
  width: 16px;
  height: 16px;
}

.access-check b {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-form {
  gap: 8px;
}

@media (max-width: 1280px) {
  .access-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}

@media (max-width: 760px) {
  .user-access-head,
  .user-access-controls,
  .access-grid {
    grid-template-columns: 1fr;
  }

  .access-check {
    grid-template-columns: 18px 22px 1fr;
  }
}

.ping-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #09151c;
}

.ping-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.ping-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.ping-row input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #071117;
  color: var(--text);
}

@media (max-width: 760px) {
  .ping-row {
    grid-template-columns: 1fr;
  }
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(320px, 760px);
  gap: 16px;
}

.chat-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.chat-messages {
  min-height: 360px;
  max-height: 58vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #071117;
}

.chat-message {
  max-width: 84%;
  padding: 9px 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 7px;
  background: #09151c;
}

.chat-message.own {
  align-self: flex-end;
  border-color: rgba(29, 155, 240, 0.38);
  background: #0d2b3d;
}

.chat-message-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chat-message-head strong {
  color: var(--text);
}

.chat-message p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  line-height: 1.35;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.chat-compose textarea {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #071117;
  color: var(--text);
  font: inherit;
}

@media (max-width: 760px) {
  .chat-layout,
  .chat-compose {
    grid-template-columns: 1fr;
  }

  .chat-message {
    max-width: 100%;
  }
}

.tickets-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr);
  gap: 16px;
}

.tickets-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.tickets-list {
  display: grid;
  gap: 10px;
}

.ticket-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #09151c;
}

.ticket-head,
.ticket-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.ticket-head small,
.ticket-actions small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.ticket-fields {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
  gap: 10px;
}

.ticket-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.ticket-fields input,
.ticket-fields textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #071117;
  color: var(--text);
  font: inherit;
}

.ticket-fields input {
  min-height: 36px;
}

.ticket-fields textarea {
  resize: vertical;
}

.ticket-actions span {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .ticket-head,
  .ticket-actions,
  .ticket-fields {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .ticket-actions span {
    justify-content: stretch;
  }
}

.chat-message.direct {
  border-color: rgba(245, 165, 36, 0.42);
}

.chat-message em {
  display: block;
  margin-top: 4px;
  color: var(--orange);
  font-size: 11px;
  font-style: normal;
}

.chat-compose {
  grid-template-columns: 180px minmax(0, 1fr) auto;
}

.chat-compose label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.chat-compose select {
  min-height: 52px;
}

@media (max-width: 760px) {
  .chat-compose {
    grid-template-columns: 1fr;
  }
}

/* Chat with side tickets */
.chat-layout {
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 420px);
  align-items: stretch;
}

.chat-panel,
.chat-tickets-panel {
  min-height: calc(100vh - 170px);
}

.chat-panel {
  grid-template-rows: auto minmax(260px, 1fr) auto auto;
  min-width: 0;
}

.chat-messages {
  min-height: 260px;
  height: calc(100vh - 360px);
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #31596a #071117;
  scrollbar-width: thin;
}

.chat-messages::-webkit-scrollbar,
.chat-tickets-list::-webkit-scrollbar {
  width: 9px;
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-tickets-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #31596a;
}

.chat-messages::-webkit-scrollbar-track,
.chat-tickets-list::-webkit-scrollbar-track {
  background: #071117;
}

.chat-tickets-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  min-width: 0;
}

.chat-tickets-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.chat-ticket-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #09151c;
}

.chat-ticket-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.chat-ticket-card .muted-line {
  color: #6f8791;
}

@media (max-width: 1120px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-panel,
  .chat-tickets-panel {
    min-height: auto;
  }

  .chat-messages {
    height: 46vh;
  }
}
