:root {
  --bg: #07111f;
  --bg-soft: #0b1728;
  --panel: rgba(12, 23, 40, 0.94);
  --panel-soft: rgba(15, 29, 49, 0.96);
  --line: rgba(120, 146, 186, 0.18);
  --line-strong: rgba(120, 146, 186, 0.32);
  --text: #e6edf7;
  --muted: #8da0bb;
  --side: #081120;
  --side-hover: rgba(70, 115, 190, 0.14);
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-glow: rgba(59, 130, 246, 0.24);
  --gold: #f7c948;
  --green-bg: rgba(34, 197, 94, 0.16);
  --green: #62d394;
  --gray-bg: rgba(148, 163, 184, 0.16);
  --gray: #b0bdd1;
  --red-bg: rgba(239, 68, 68, 0.16);
  --red: #ff8f8f;
  --amber-bg: rgba(245, 158, 11, 0.18);
  --amber: #f8c46c;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 26%),
    radial-gradient(circle at right center, rgba(14, 165, 233, 0.12), transparent 24%),
    linear-gradient(180deg, #08111f 0%, #07111f 100%);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
}

a {
  color: #78b2ff;
  text-decoration: none;
  transition: color 0.18s ease;
}

a:hover {
  color: #a7ccff;
}

button,
.button {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(98, 157, 255, 0.42);
  border-radius: 10px;
  background: linear-gradient(180deg, #3f8cff 0%, #2b6ff3 100%);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.24);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

button:hover,
.button:hover {
  background: linear-gradient(180deg, #5498ff 0%, #3b82f6 100%);
  border-color: rgba(125, 179, 255, 0.62);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.32);
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.ghost {
  background: rgba(11, 21, 36, 0.88);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: none;
}

.ghost:hover {
  background: rgba(35, 59, 96, 0.72);
  border-color: rgba(116, 165, 255, 0.4);
  color: #dceaff;
}

.danger {
  background: rgba(24, 15, 18, 0.9);
  border-color: rgba(239, 68, 68, 0.28);
  color: #ff9e9e;
  box-shadow: none;
}

.danger:hover {
  background: #a42f3a;
  border-color: #c74854;
  color: #fff;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: #c6ddff;
  font-size: 12px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(141, 160, 187, 0.3);
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 18px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(8, 17, 32, 0.98) 0%, rgba(5, 13, 24, 0.98) 100%);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand,
.login-brand {
  color: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  padding: 8px 8px 2px;
}

.brand strong,
.login-brand strong {
  display: block;
  color: #f8fbff;
  font-size: 16px;
  line-height: 1.2;
}

.brand small,
.login-brand small {
  color: var(--muted);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffd666 0%, var(--gold) 100%);
  color: #111827;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.sidebar-panel {
  margin: 0 4px;
  padding: 12px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(15, 29, 49, 0.96), rgba(11, 21, 36, 0.96));
  box-shadow: var(--shadow-soft);
}

.sidebar-panel-label {
  display: block;
  margin-bottom: 6px;
  color: #94a9c5;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-panel strong {
  display: block;
  color: #edf5ff;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sidebar-panel small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.nav {
  display: grid;
  gap: 14px;
  padding: 2px 4px 0;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-title {
  padding: 0 8px;
  color: #7287a5;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #b8c7da;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.nav-item:hover {
  background: var(--side-hover);
  border-color: rgba(76, 113, 173, 0.2);
  color: #edf5ff;
}

.nav-item.active {
  background: linear-gradient(180deg, rgba(35, 63, 106, 0.56), rgba(21, 43, 78, 0.56));
  border-color: rgba(87, 141, 231, 0.3);
  color: #eaf3ff;
  box-shadow: inset 0 0 0 1px rgba(91, 151, 255, 0.08);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #5ea2ff 0%, #3b82f6 100%);
}

.nav-icon {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #5c6f8e;
  font-size: 0;
  box-shadow: 0 0 0 3px rgba(92, 111, 142, 0.1);
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  background: #79b7ff;
  box-shadow: 0 0 12px rgba(121, 183, 255, 0.45);
}

.nav-text {
  font-weight: 600;
  font-size: 13px;
}

.logout {
  margin-top: auto;
  padding: 8px 4px 0;
}

.logout button {
  width: 100%;
  background: rgba(12, 23, 40, 0.96);
  border-color: var(--line-strong);
  color: #dbe8fb;
  box-shadow: none;
}

.logout button:hover {
  background: rgba(34, 61, 99, 0.88);
  border-color: rgba(102, 154, 248, 0.36);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 22px 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(10, 20, 36, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.page-meta {
  display: grid;
  gap: 6px;
}

.topbar p {
  margin: 0;
  color: #89a3c7;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
  line-height: 1.35;
}

.page-note {
  color: var(--muted);
  font-size: 13px;
}

.top-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-content: flex-start;
}

.tag-card {
  min-width: 140px;
  max-width: 380px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 29, 49, 0.92);
  box-shadow: var(--shadow-soft);
}

.tag-card small {
  display: block;
  margin-bottom: 4px;
  color: #8da4c8;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tag-card strong {
  display: block;
  font-size: 13px;
  color: #ecf5ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-card em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-wide {
  max-width: 440px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 18px 20px;
  border: 1px solid rgba(64, 110, 184, 0.24);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(18, 35, 60, 0.96) 0%, rgba(10, 23, 42, 0.96) 100%);
  box-shadow: var(--shadow);
}

.hero-main {
  display: grid;
  gap: 8px;
  max-width: 700px;
}

.hero-kicker {
  color: #82b7ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h2 {
  font-size: 23px;
  color: #f4f8ff;
}

.hero p {
  margin: 0;
  color: #9cb0cb;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats article,
.panel,
.toolbar,
.detail,
.login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.stats article {
  position: relative;
  min-height: 148px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
  transition:
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.stats article::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 0;
  width: 34px;
  height: 2px;
  border-radius: 0 0 999px 999px;
  background: var(--accent);
}

.stats article:hover {
  border-color: rgba(86, 140, 228, 0.34);
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.24);
}

.stat-tickets::before {
  background: #22c55e;
}

.stat-rooms::before {
  background: #f59e0b;
}

.stat-records::before {
  background: #8b5cf6;
}

.stats span {
  display: inline-block;
  margin-top: 6px;
  color: #9ab0cf;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stats small {
  display: block;
  margin-top: auto;
  padding-top: 12px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 12px;
}

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

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  min-height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.panel-head small,
.panel-head span {
  color: var(--muted);
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: rgba(255, 255, 255, 0.02);
  color: #8ea3c1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.18s ease;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.07);
}

tbody tr:last-child td {
  border-bottom: 0;
}

small {
  color: var(--muted);
}

td small {
  display: block;
  margin-top: 4px;
}

.text-cell {
  max-width: 360px;
  white-space: normal;
}

.empty {
  padding: 32px 14px;
  text-align: center;
  color: var(--muted);
}

.badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--gray-bg);
  color: var(--gray);
  font-size: 12px;
  font-weight: 700;
}

.badge.open,
.badge.created,
.badge.closed,
.badge.replied {
  background: var(--green-bg);
  color: var(--green);
}

.badge.pending,
.badge.processing {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.overdue,
.badge.failed,
.badge.rejected,
.badge.cancelled,
.badge.blocked {
  background: var(--red-bg);
  color: var(--red);
}

.toolbar {
  padding: 12px 14px;
  margin-bottom: 16px;
}

.filters,
.inline-form,
.wide-form form,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filters input {
  min-width: 240px;
  flex: 1 1 260px;
}

input,
select,
textarea {
  min-height: 36px;
  min-width: 170px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(7, 16, 29, 0.92);
  color: var(--text);
  font: inherit;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(120, 146, 186, 0.46);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(105, 160, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

textarea {
  min-height: 98px;
  padding: 10px 11px;
  resize: vertical;
}

select {
  color-scheme: dark;
}

.wide-form input {
  min-width: 150px;
}

.form-panel {
  margin-bottom: 16px;
}

.inline-form {
  padding: 16px 18px;
}

.menu-create-form,
.lookup-form {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
}

.compact {
  gap: 12px;
}

.lookup-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.lookup-form-grid input,
.lookup-form-grid textarea {
  width: 100%;
  min-width: 0;
}

.bot-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px 18px 18px;
}

.bot-type-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 17, 32, 0.72);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
}

.bot-type-card h3 {
  margin: 0;
  font-size: 16px;
}

.bot-type-card p {
  margin: 0;
  color: var(--muted);
}

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

.badge.running {
  background: var(--green-bg);
  color: var(--green);
}

.badge.starting {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.stopped {
  background: var(--gray-bg);
  color: var(--gray);
}

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

.lookup-notes {
  grid-column: span 3;
  display: grid;
  gap: 8px;
}

.lookup-notes span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.lookup-table input,
.lookup-table textarea {
  width: 100%;
  min-width: 160px;
}

.lookup-table textarea {
  min-height: 84px;
}

.menu-create-grid {
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) minmax(150px, 0.9fr) minmax(240px, 1.7fr) 110px auto auto;
  gap: 12px;
  align-items: center;
}

.menu-content-form {
  display: grid;
  gap: 18px;
}

.menu-content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.5fr) minmax(240px, 0.8fr);
  gap: 16px;
  padding: 18px;
}

.menu-content-grid label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.menu-content-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.menu-content-grid input,
.menu-content-grid textarea {
  width: 100%;
  min-width: 0;
}

.menu-content-grid .span-2 {
  grid-column: span 2;
}

.menu-extra-grid,
.menu-response-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) minmax(220px, 0.8fr) minmax(280px, 1.2fr);
  gap: 14px;
}

.menu-extra-grid label,
.menu-response-grid label,
.response-button-editor {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.menu-extra-grid span,
.menu-response-grid span,
.response-button-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.menu-create-form input,
.menu-create-form select,
.menu-create-form textarea,
.menu-response-grid input,
.menu-response-grid textarea {
  width: 100%;
  min-width: 0;
}

.response-button-editor {
  padding: 0 18px 18px;
}

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

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

.response-button-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1.35fr) 92px auto;
  gap: 10px;
  align-items: center;
}

.response-button-row input {
  width: 100%;
  min-width: 0;
}

.menu-detail-row td {
  padding: 0;
  background: rgba(255, 255, 255, 0.02);
}

.menu-detail-row details {
  padding: 0 16px;
}

.menu-detail-row summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  color: var(--muted);
  list-style: none;
}

.menu-detail-row summary::-webkit-details-marker {
  display: none;
}

.menu-detail-row summary strong {
  color: var(--text);
}

.menu-detail-row summary::before {
  content: "+";
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #abd0ff;
  background: rgba(7, 16, 29, 0.88);
  font-weight: 700;
}

.menu-detail-row details[open] summary::before {
  content: "-";
}

.menu-detail-row details[open] {
  padding-bottom: 14px;
}

.menu-summary-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin-right: auto;
}

.menu-summary-action {
  min-height: 30px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(7, 16, 29, 0.88);
  color: #abd0ff;
  white-space: nowrap;
  font-size: 0;
}

.menu-summary-action::before {
  font-size: 13px;
}

.menu-response-details[open] .menu-summary-action::before {
  content: "收起";
}

.menu-response-details:not([open]) .menu-summary-action::before {
  content: "展开编辑";
}

.menu-table input,
.menu-table select {
  min-width: 140px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.check input {
  min-width: auto;
  min-height: auto;
  width: 16px;
  height: 16px;
}

.detail {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.detail-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

.detail-grid > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.detail-grid span,
.settings-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong,
.settings-grid strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.detail-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.detail-actions form {
  margin: 0;
}

.ticket-action-stack {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ticket-alerts {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.ticket-alert {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.ticket-alert strong {
  display: block;
  margin-bottom: 6px;
}

.ticket-alert p {
  margin: 0;
  color: var(--muted);
}

.ticket-alert.warning {
  border-color: rgba(245, 158, 11, 0.24);
  background: rgba(96, 57, 10, 0.32);
}

.ticket-alert.danger {
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(85, 28, 35, 0.34);
}

.ticket-panel-body {
  padding: 16px;
}

.ticket-form-stack,
.ticket-template-manager {
  display: grid;
  gap: 16px;
}

.ticket-form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15, 29, 49, 0.72);
}

.ticket-subsection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.ticket-subsection-head h3 {
  margin: 0;
  font-size: 15px;
}

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

.ticket-note-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 16, 29, 0.82);
}

.ticket-note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ticket-note-content {
  white-space: pre-wrap;
  color: #d8e5f8;
}

.ticket-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ticket-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #b8d8ff;
  font-size: 12px;
  font-weight: 600;
}

.ticket-template-list {
  display: grid;
  gap: 12px;
}

.ticket-template-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15, 29, 49, 0.72);
}

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

.ticket-template-content {
  min-height: 110px;
  width: 100%;
}

.ticket-template-editor {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.ticket-template-editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 180px);
  gap: 14px;
  align-items: start;
}

.ticket-template-editor-grid input,
.ticket-template-editor-grid textarea {
  width: 100%;
  min-width: 0;
}

.ticket-template-editor-grid .lookup-notes {
  grid-column: span 2;
}

.settings-actions form {
  margin: 0;
}

.settings-grid {
  padding: 16px;
}

.settings-form {
  display: grid;
}

.settings-form .settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.settings-form input,
.settings-form textarea {
  width: 100%;
  min-width: 0;
}

.settings-form .span-2 {
  grid-column: span 2;
}

.telegram-account-create-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr) minmax(0, 0.7fr);
}

.settings-form .check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 0;
}

.settings-form .check-row input {
  width: auto;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel-soft);
}

.text-template-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.text-template-item {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(12, 23, 40, 0.96);
}

.text-template-item summary {
  min-height: 56px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  background: rgba(15, 29, 49, 0.98);
}

.text-template-item summary::-webkit-details-marker {
  display: none;
}

.text-template-item summary::before {
  content: "+";
  width: 22px;
  height: 22px;
  margin-right: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #abd0ff;
  font-weight: 700;
  flex: 0 0 auto;
}

.text-template-item[open] summary {
  border-bottom: 1px solid var(--line);
}

.text-template-item[open] summary::before {
  content: "-";
}

.text-template-item strong {
  display: block;
}

.text-template-item small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.text-template-item textarea {
  width: 100%;
  min-width: 0;
  min-height: 150px;
  border: 0;
  border-radius: 0;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.flash {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 29, 49, 0.94);
}

.flash.success {
  background: rgba(25, 70, 43, 0.42);
  border-color: rgba(72, 176, 107, 0.24);
  color: var(--green);
}

.flash.error {
  background: rgba(85, 28, 35, 0.4);
  border-color: rgba(239, 68, 68, 0.22);
  color: var(--red);
}

.flash.warning {
  background: rgba(96, 57, 10, 0.36);
  border-color: rgba(245, 158, 11, 0.24);
  color: var(--amber);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 30%),
    linear-gradient(180deg, #08111f 0%, #07111f 100%);
}

.login-box {
  width: min(440px, 100%);
  padding: 28px;
}

.login-brand {
  color: var(--text);
  margin-bottom: 16px;
}

.login-brand strong {
  color: #f7fbff;
}

.login-intro {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.login-form input,
.login-form button {
  width: 100%;
}

@media (max-width: 1280px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.admin-account-form {
  display: grid;
  gap: 16px;
}

.admin-account-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.permission-groups {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.permission-group {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.permission-group legend {
  padding: 0 6px;
  color: var(--text);
  font-weight: 700;
}

.permission-inline {
  display: grid;
  gap: 8px;
  min-width: 420px;
}

.permission-inline > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.permission-inline strong {
  min-width: 72px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .admin-account-fields,
  .permission-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .admin-account-fields,
  .permission-groups {
    grid-template-columns: 1fr;
  }

  .permission-inline {
    min-width: 0;
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main {
    padding: 20px;
  }

  .two-col,
  .detail-grid,
  .settings-grid,
  .text-template-list,
  .settings-form .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .topbar,
  .detail,
  .hero {
    display: grid;
  }

  .top-tags,
  .hero-actions {
    justify-content: flex-start;
  }

  .menu-create-grid,
  .lookup-form-grid,
  .menu-content-grid,
  .menu-extra-grid,
  .menu-response-grid,
  .response-button-row,
  .ticket-template-editor-grid {
    grid-template-columns: 1fr;
  }

  .menu-content-grid .span-2,
  .lookup-notes,
  .ticket-template-editor-grid .lookup-notes {
    grid-column: span 1;
  }

  .settings-actions {
    display: grid;
    justify-items: start;
  }

  .telegram-account-create-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

  .stats,
  .two-col,
  .detail-grid,
  .settings-grid,
  .text-template-list,
  .settings-form .settings-grid {
    grid-template-columns: 1fr;
  }

  .filters input,
  input,
  select,
  textarea,
  .filters button,
  .filters .button,
  .inline-form button,
  .row-actions button,
  .row-actions .button,
  .tag-card,
  .tag-wide {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}
