:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dfe5ec;
  --line-strong: #c8d2dc;
  --text: #172033;
  --muted: #667085;
  --muted-strong: #475467;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e7f5f2;
  --danger: #c2410c;
  --success: #087443;
  --warning: #a15c07;
  --focus: #2563eb;
  --sidebar: #ffffff;
  --shadow: 0 10px 30px rgb(23 32 51 / 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f7fafc 0, var(--bg) 240px);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.app-shell.sidebar-open {
  padding-left: 244px;
}

.sidebar-toggle {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 30;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 8px 24px rgb(17 24 39 / 0.08);
}

.sidebar-toggle:hover {
  background: var(--accent-soft);
}

.app-shell.sidebar-open .sidebar-toggle {
  left: 258px;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  width: 244px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 25;
  overflow-y: auto;
  box-shadow: 8px 0 30px rgb(23 32 51 / 0.04);
}

.app-shell.sidebar-closed .sidebar {
  display: none;
}

.app-shell.sidebar-closed .content {
  padding-left: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-weight: 750;
  font-size: 16px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 750;
}

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

.nav button {
  min-height: 40px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav button.active,
.nav button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 650;
}

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

.nav-group-toggle {
  justify-content: space-between;
}

.nav-group-toggle .chevron {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.nav-group-items {
  display: grid;
  gap: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.nav-group-items button {
  min-height: 36px;
  padding-left: 10px;
}

.content {
  padding: 30px;
  min-width: 0;
  width: 100%;
  max-width: 1720px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 2px 2px 0;
}

.title {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 720;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 820px;
}

.grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}

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

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-pad {
  padding: 18px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 116px;
  align-content: center;
  border-left: 3px solid var(--accent);
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  font-size: 30px;
  font-weight: 760;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

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

.section-title {
  font-weight: 750;
  font-size: 16px;
}

.form {
  display: grid;
  gap: 12px;
}

.admin-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: center;
}

.admin-form-grid .button,
.admin-form-grid .actions {
  align-self: stretch;
}

.form-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.field-note.inline {
  display: inline;
  margin-left: 4px;
  white-space: normal;
}

.raw-term {
  font-weight: 650;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-line {
  min-height: 40px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--muted-strong);
  white-space: nowrap;
}

.toggle-line input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.compatibility-toggle {
  gap: 8px;
}

.info-dot {
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--muted);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex: 0 0 auto;
}

.stack {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.input {
  height: 42px;
  padding: 0 12px;
}

select.input[multiple] {
  height: 96px;
  padding: 8px 11px;
}

.multi-select {
  position: relative;
  min-width: 0;
}

.multi-select summary {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.multi-select summary::-webkit-details-marker {
  display: none;
}

.multi-select summary span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select .chevron {
  color: var(--muted);
  flex: 0 0 auto;
}

.multi-options {
  position: absolute;
  z-index: 25;
  inset: calc(100% + 4px) 0 auto 0;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.multi-option {
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.multi-option:hover {
  background: #f1f5f9;
}

.multi-option input {
  width: 15px;
  height: 15px;
  margin: 0;
  flex: 0 0 auto;
}

.multi-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.multi-option small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.kv-list {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.kv-list > div {
  display: grid;
  grid-template-columns: minmax(86px, 0.36fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.kv-list span {
  color: var(--muted-strong);
  font-size: 12px;
}

.kv-list strong {
  min-width: 0;
  color: var(--text);
  font-weight: 620;
  overflow-wrap: anywhere;
}

.kv-list.compact {
  gap: 4px;
}

.textarea {
  min-height: 110px;
  padding: 11px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.button.secondary {
  background: #fff;
  color: var(--accent-strong);
  border: 1px solid var(--line-strong);
}

.button.secondary.attention {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.button.ghost {
  background: transparent;
  color: var(--muted-strong);
}

.button.danger {
  color: #fff;
  background: var(--danger);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 8px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted-strong);
  font-weight: 560;
  font-size: 12px;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover td {
  background: #fbfefd;
}

.panel-table {
  table-layout: fixed;
  min-width: 1280px;
}

.panel-table th:nth-child(1),
.panel-table td:nth-child(1) {
  width: 100px;
}

.panel-table th:nth-child(2),
.panel-table td:nth-child(2) {
  width: 210px;
}

.panel-table th:nth-child(8),
.panel-table td:nth-child(8) {
  width: 260px;
}

.panel-table th:nth-child(9),
.panel-table td:nth-child(9) {
  width: 130px;
}

.panel-table th:nth-child(11),
.panel-table td:nth-child(11) {
  width: 390px;
}

.date-cell {
  color: var(--muted-strong);
  font-size: 12px;
  white-space: nowrap;
}

.panel-url span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-api {
  white-space: normal;
}

.api-summary {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.api-summary div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

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

.api-summary strong {
  min-width: 0;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xui-table-panel {
  background: #23272e;
  border-color: #353b45;
  overflow: hidden;
}

.xui-table {
  background: #23272e;
  color: #eef2f7;
  min-width: 1120px;
}

.xui-table th,
.xui-table td {
  border-top: 1px solid #3a414d;
  padding: 10px 12px;
  vertical-align: middle;
}

.xui-table th {
  background: #2b3037;
  color: #f3f7fb;
  font-weight: 650;
}

.xui-table tbody tr:hover td {
  background: #272d35;
}

.xui-table strong {
  color: #f8fafc;
  font-weight: 700;
}

.xui-table .hint {
  color: #a8b2c2;
  font-size: 12px;
}

.xui-check span {
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 1px solid #566174;
  border-radius: 4px;
  background: #20242b;
}

.xui-actions {
  display: inline-flex;
  gap: 8px;
  color: #d7dde8;
  font-size: 12px;
}

.xui-actions span,
.xui-actions button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
}

.xui-actions span:hover,
.xui-actions button:hover {
  border-bottom-color: #7aa2ff;
  color: #9bbcff;
}

.xui-switch {
  width: 44px;
  height: 22px;
  display: inline-block;
  border-radius: 999px;
  position: relative;
  background: #4b5563;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
}

.xui-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.35);
}

.xui-switch.on {
  background: #2684ff;
}

.xui-switch.on::after {
  transform: translateX(22px);
}

.xui-switch-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
}

.xui-online,
.xui-offline {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 650;
}

.xui-online {
  background: #0f3f16;
  color: #5cf05f;
}

.xui-offline {
  background: #343943;
  color: #f1f5f9;
}

.xui-tags {
  display: inline-flex;
  gap: 5px;
  flex-wrap: wrap;
}

.xui-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 3px 7px;
  background: #111d34;
  color: #52a2ff;
  font-size: 12px;
}

.xui-tag:first-child {
  background: #25153b;
  color: #bd7cff;
}

.xui-client-count,
.xui-inbound-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 3px 7px;
  background: #0d2342;
  color: #69a8ff;
  font-size: 12px;
  font-weight: 650;
}

.xui-traffic {
  min-width: 260px;
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: center;
  gap: 9px;
  color: #f8fafc;
  font-size: 12px;
}

.xui-meter {
  height: 8px;
  border-radius: 999px;
  background: #38404a;
  overflow: hidden;
}

.xui-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #7b8794;
}

.xui-remain,
.xui-duration {
  display: inline-flex;
  border-radius: 4px;
  padding: 4px 8px;
  background: #0d350b;
  color: #6df36b;
  font-size: 12px;
  font-weight: 650;
}

.xui-duration {
  background: #173b13;
}

.xui-duration.danger {
  background: #4b1b1b;
  color: #ff8b8b;
}

.xui-more {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  border-radius: 4px;
  padding: 3px 7px;
  background: #343943;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 650;
}

.modal.xui-client-modal {
  width: min(700px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  background: #2b3038;
  border-color: #444b57;
  color: #edf2f7;
  padding: 0;
}

.xui-client-form {
  display: grid;
  gap: 0;
}

.xui-client-modal-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}

.xui-client-modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
}

.xui-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  color: #b8c0cc;
  font-size: 26px;
  line-height: 1;
}

.xui-close:hover {
  background: #363c46;
  color: #fff;
}

.xui-tabs {
  display: flex;
  gap: 26px;
  padding: 0 18px;
  border-bottom: 1px solid #444b57;
}

.xui-tabs button {
  height: 36px;
  padding: 0;
  background: transparent;
  color: #d6dce6;
  border-bottom: 2px solid transparent;
}

.xui-tabs button.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

.xui-client-pane {
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px 16px;
  padding: 18px;
}

.xui-client-pane.active {
  display: grid;
}

.xui-field {
  display: grid;
  gap: 7px;
  color: #d8dee8;
  font-size: 13px;
  min-width: 0;
}

.xui-field.required > span::before {
  content: "* ";
  color: #ff6b6b;
}

.xui-field-wide {
  grid-column: 1 / -1;
}

.modal.xui-client-modal .input {
  background: #242933;
  border-color: #4b5566;
  color: #f8fafc;
}

.modal.xui-client-modal .input::placeholder {
  color: #7f8795;
}

.xui-input-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
}

.xui-input-with-action .input {
  border-radius: 7px 0 0 7px;
}

.xui-input-with-action button {
  border: 1px solid #4b5566;
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background: #20252d;
  color: #dbe3ee;
}

.xui-inline-switch {
  width: 44px;
  height: 22px;
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.xui-inline-switch input {
  position: absolute;
  opacity: 0;
}

.xui-inline-switch i {
  width: 44px;
  height: 22px;
  border-radius: 999px;
  background: #5b6470;
  position: relative;
}

.xui-inline-switch i::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.xui-inline-switch input:checked + i {
  background: #2684ff;
}

.xui-inline-switch input:checked + i::after {
  transform: translateX(22px);
}

.xui-client-inbounds {
  min-height: 42px;
  max-height: 116px;
  overflow: auto;
  border: 1px solid #4b5566;
  border-radius: 7px;
  background: #242933;
  padding: 7px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.xui-client-inbound {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid #4b5566;
  border-radius: 5px;
  background: #343a44;
}

.xui-client-inbound input {
  margin: 0;
  cursor: pointer;
}

.xui-client-inbound span {
  display: grid;
  gap: 1px;
}

.xui-client-inbound small,
.xui-client-empty,
.xui-link-note span {
  color: #aab4c3;
  font-size: 12px;
}

.xui-link-note {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #4b5566;
  border-radius: 7px;
  background: #242933;
}

.xui-client-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
}

.sub-link-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.sub-link-row {
  display: grid;
  grid-template-columns: minmax(130px, 170px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.sub-link-row code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted-strong);
  font-size: 12px;
}

.sub-link-row > span {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.wrap {
  white-space: normal;
  word-break: break-all;
}

.badge {
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  display: inline-flex;
  align-items: center;
  background: #eef2f6;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
}

.badge.ok {
  background: #e8f7ee;
  color: var(--success);
}

.badge.off {
  background: #f3f4f6;
  color: var(--muted);
}

.badge.warn {
  background: #fff4df;
  color: var(--warning);
}

.actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.link-actions {
  display: grid;
  gap: 8px;
  min-width: 460px;
}

.import-panel {
  padding: 14px;
}

.compact-import-form {
  gap: 8px;
}

.import-grid-main,
.import-grid-filters {
  display: grid;
  gap: 10px;
  align-items: stretch;
}

.import-grid-main {
  grid-template-columns: minmax(170px, 0.7fr) minmax(150px, 0.55fr) minmax(280px, 1.5fr) auto;
}

.import-grid-filters {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto minmax(180px, 0.7fr);
}

.import-panel .textarea {
  min-height: 72px;
  width: 100%;
  min-width: 220px;
  resize: both;
}

.import-panel .input,
.import-panel .textarea {
  min-height: 40px;
}

.group-create-form {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 10px;
  align-items: center;
}

.group-card {
  display: grid;
  gap: 12px;
}

.group-card-main {
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.group-source-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.source-mini-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: var(--panel-soft);
}

.source-mini-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.source-mini-main input {
  flex: 0 0 auto;
}

.group-move-controls,
.group-add-source,
.group-bulk-move {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.group-add-source {
  margin-top: 12px;
}

.group-bulk-move {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.group-move-select,
.source-group-filter {
  width: 180px;
}

.import-panel .toggle-line,
.import-panel .row {
  min-height: 40px;
}

.source-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-bottom: 0;
}

.source-toolbar > .source-search {
  flex: 1 1 360px;
}

.source-toolbar-bottom {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.source-search {
  width: min(420px, 42vw);
}

.source-sort-button {
  flex: 0 0 auto;
}

.source-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.source-page-size {
  width: 120px;
}

.source-card-list {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.source-card {
  border: 1.5px solid #111827;
  border-radius: 7px;
  padding: 9px 10px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.source-card:first-child {
  border-top: 1.5px solid #111827;
}

.source-card-head {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.source-leading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.source-index {
  min-width: 26px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.source-check {
  height: 24px;
  display: grid;
  place-items: center;
}

.source-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.source-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-url {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  line-height: 1.35;
}

.source-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  gap: 8px;
  align-items: center;
}

.source-url-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-info-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.source-info-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: var(--panel-soft);
}

.source-info-grid p {
  margin: 4px 0 0;
  line-height: 1.35;
  word-break: break-word;
  max-height: 38px;
  overflow: auto;
  font-size: 13px;
}

.source-info-grid .field-line {
  align-items: flex-start;
}

.source-info-grid .field-line span:not(.badge) {
  max-height: 38px;
  overflow: auto;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  font-size: 13px;
}

.info-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.source-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.op-times {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.field-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.field-line span,
.field-line strong {
  min-width: 0;
}

.icon-button {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted-strong);
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.icon-button:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.op-time {
  color: var(--text);
  font-size: 13px;
  line-height: 26px;
  white-space: nowrap;
}

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

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

.login-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: 0 24px 70px rgb(23 32 51 / 0.12);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--accent-strong);
  color: #fff;
  padding: 16px 18px;
  border-radius: 8px;
  box-shadow: 0 16px 50px rgb(17 24 39 / 0.18);
  font-size: 15px;
  line-height: 1.45;
  z-index: 60;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(17 24 39 / 0.38);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
  overflow: hidden;
}

.modal {
  width: min(720px, 100%);
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 20px;
  box-shadow: 0 28px 90px rgb(23 32 51 / 0.2);
}

.modal-wide {
  width: min(920px, 100%);
}

.modal-full {
  width: min(1560px, calc(100vw - 40px));
  height: min(900px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  padding: 12px;
}

.fixed-modal {
  align-items: center;
}

.modal-create-panel {
  padding: 10px;
}

.modal-create-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1.1fr) minmax(210px, 0.9fr) minmax(210px, 0.9fr) minmax(170px, 0.75fr) auto auto;
  gap: 8px;
  align-items: center;
}

.modal-links-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.modal-table-wrap {
  min-height: 0;
  overflow: auto;
  max-width: 100%;
}

.modal-table-wrap table {
  min-width: 1280px;
  table-layout: fixed;
}

.modal-table-wrap th,
.modal-table-wrap td {
  padding: 10px 9px;
  vertical-align: top;
}

.modal-table-wrap th:nth-child(1),
.modal-table-wrap td:nth-child(1) {
  width: 42px;
}

.modal-table-wrap th:nth-child(2),
.modal-table-wrap td:nth-child(2) {
  width: 190px;
}

.modal-table-wrap th:nth-child(3),
.modal-table-wrap td:nth-child(3) {
  width: 125px;
}

.modal-table-wrap th:nth-child(4),
.modal-table-wrap td:nth-child(4) {
  width: 180px;
}

.modal-table-wrap th:nth-child(5),
.modal-table-wrap td:nth-child(5) {
  width: 80px;
}

.modal-table-wrap th:nth-child(6),
.modal-table-wrap td:nth-child(6) {
  width: 155px;
}

.modal-table-wrap th:nth-child(7),
.modal-table-wrap td:nth-child(7) {
  width: 260px;
}

.modal-table-wrap th:nth-child(8),
.modal-table-wrap td:nth-child(8) {
  width: 110px;
}

.modal-table-wrap th:nth-child(9),
.modal-table-wrap td:nth-child(9) {
  width: 380px;
}

.modal-table-wrap td.wrap {
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  line-height: 1.45;
}

.modal-table-wrap .link-actions {
  min-width: 0;
}

.modal-table-wrap .link-actions > .actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, max-content));
  justify-content: start;
  gap: 7px;
}

.modal-table-wrap .link-actions .button {
  min-width: 82px;
}

.modal-table-wrap .op-times {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.modal-table-wrap .op-time {
  white-space: normal;
  line-height: 1.35;
  font-size: 12px;
}

.modal-table-wrap .field-line {
  align-items: flex-start;
}

.modal-filter-input {
  width: min(320px, 36vw);
}

.modal-filter-select {
  width: 150px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  border-top: 1px solid var(--line);
}

.link-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.link-label {
  color: var(--muted-strong);
  font-weight: 650;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

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

  .app-shell.sidebar-open {
    padding-left: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 25;
    width: min(280px, calc(100vw - 72px));
    min-height: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 0 20px 60px rgb(17 24 39 / 0.16);
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .nav button {
    justify-content: flex-start;
    text-align: left;
  }

  .content {
    padding: 18px 14px 18px 66px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .app-shell.sidebar-closed .content {
    padding-left: 66px;
  }

  .app-shell.sidebar-open .sidebar-toggle {
    left: min(292px, calc(100vw - 54px));
  }

  .topbar,
  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .link-row {
    grid-template-columns: 1fr;
  }

  .source-title,
  .source-toolbar,
  .source-pager,
  .source-card-actions,
  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .source-badges {
    justify-content: flex-start;
  }

  .source-info-grid,
  .import-grid-main,
  .import-grid-filters,
  .modal-create-grid,
  .group-create-form,
  .source-mini-card {
    grid-template-columns: 1fr;
  }

  .source-search,
  .source-sort-button,
  .source-page-size {
    width: 100%;
  }

  .source-group-filter,
  .group-move-select {
    width: 100%;
  }

  .modal-filter-input,
  .modal-filter-select {
    width: 100%;
  }

  .modal-full {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
