:root {
  color: #d8e4ec;
  background: #101415;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #101415;
  --sidebar: #062f53;
  --sidebar-dark: #052944;
  --panel: #161b1c;
  --panel-2: #1b2022;
  --panel-3: #111617;
  --line: #2a3235;
  --line-strong: #354044;
  --text: #d8e4ec;
  --muted: #87949b;
  --muted-2: #5f6c72;
  --accent: #1594ff;
  --accent-2: #50bfff;
  --success: #8ee95c;
  --danger: #ff4f67;
  --warning: #ffb22c;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 13px;
  background: #202629;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: #4f5b60;
  background: #293033;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  color: #e7eef3;
  font-size: 22px;
  font-weight: 800;
}

h2 {
  color: #edf5fb;
  font-size: 18px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #0d4269;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-dark));
  padding: 22px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 24px;
  color: #f1f8ff;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border: 3px solid #67d5ff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px rgba(103, 213, 255, .16), 0 0 18px rgba(21, 148, 255, .35);
}

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

.brand strong {
  font-size: 18px;
}

.brand span {
  margin-top: 2px;
  color: #86b7d8;
  font-size: 12px;
}

.side-search {
  display: grid;
  gap: 7px;
  margin-bottom: 24px;
  color: #9fc4dc;
}

.side-search span {
  font-size: 12px;
}

.side-search input {
  border-color: #0f4b76;
  background: #0b2337;
  color: #d8e4ec;
}

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 88px;
  border-bottom: 1px solid var(--line);
  background: #131718;
  padding: 18px 28px;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}

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

.connection input {
  width: 220px;
  border-color: var(--line-strong);
  background: #0f1415;
}

.tabs {
  display: grid;
  gap: 4px;
}

.tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 14px 9px 42px;
  background: transparent;
  color: #c5dced;
  text-align: left;
}

.tab::before {
  content: "";
  position: absolute;
  left: 18px;
  width: 8px;
  height: 8px;
  border: 2px solid #7ebde7;
  border-radius: 2px;
}

.tab:hover {
  background: rgba(255, 255, 255, .06);
}

.tab.active {
  background: rgba(21, 148, 255, .16);
  color: #fff;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.layout {
  padding: 16px 22px 38px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

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

.metric,
.panel,
.editor,
.table-wrap,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric {
  min-height: 112px;
  padding: 24px 26px;
}

.metric span {
  color: var(--muted);
  font-size: 14px;
}

.metric strong {
  display: block;
  margin-top: 12px;
  color: var(--accent);
  font-size: 30px;
  line-height: 1;
}

.summary .metric:nth-child(1) strong,
.summary .metric:nth-child(5) strong,
#commissionSettleable {
  color: var(--success);
}

.summary .metric:nth-child(2) strong,
#commissionReversed {
  color: var(--danger);
}

.summary .metric:nth-child(4) strong,
.summary .metric:nth-child(6) strong {
  color: var(--warning);
}

.panel {
  display: none;
  padding: 0;
  overflow: hidden;
}

.panel.active {
  display: block;
}

.panel-head,
.panel-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 20px 26px;
  background: var(--panel);
}

.panel-subhead {
  margin: 0;
  border-top: 1px solid var(--line);
}

.panel-head p,
.panel-subhead p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 18px;
}

.route-picker,
.filters {
  padding: 18px 26px 0;
}

.route-picker {
  max-width: 560px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  gap: 12px;
  margin-bottom: 18px;
}

.audit-filters {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.order-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
  padding: 18px;
}

.detail-card {
  padding: 18px;
}

.detail-card h3 {
  margin: 0 0 14px;
  color: #edf5fb;
  font-size: 17px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-row span:first-child {
  color: var(--muted);
}

.detail-section {
  margin-top: 16px;
}

.notice-box,
.external-search,
.asset-manager {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

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

.compact-form[hidden],
.inline-form[hidden],
.asset-manager[hidden] {
  display: none;
}

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

.identity-item,
.external-result,
.asset-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
  padding: 10px;
}

.identity-actions,
.asset-tags,
.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

.inline-form .primary {
  width: auto;
}

.json-box {
  overflow: auto;
  max-height: 340px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0f1415;
  color: #d8e4ec;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
}

.editor {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.external-search-head,
.asset-manager-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.external-search-head strong,
.external-search-head span,
.asset-manager-head strong,
.asset-manager-head span {
  display: block;
}

.external-search-head span,
.asset-manager-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.external-results,
.asset-list {
  display: grid;
  gap: 10px;
}

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

.external-result .row-sub {
  line-height: 1.45;
}

.asset-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.asset-thumb {
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: #0e1a22;
}

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

.asset-thumb span {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.asset-info {
  min-width: 0;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 11px;
  color: var(--text);
  background: #0f1415;
}

textarea {
  resize: vertical;
}

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

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

.table-wrap {
  overflow: auto;
  margin: 0 18px 18px;
}

.workbench .table-wrap,
.order-layout .table-wrap {
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #c3d1d8;
  font-size: 13px;
  white-space: nowrap;
  background: #181e20;
}

td {
  color: var(--text);
  font-size: 14px;
}

tr:hover td {
  background: rgba(255, 255, 255, .02);
}

.selected-row td {
  background: rgba(21, 148, 255, .08);
}

.row-title {
  color: #edf5fb;
  font-weight: 800;
}

.row-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  border: 1px solid rgba(21, 148, 255, .45);
  border-radius: 5px;
  padding: 3px 8px;
  background: rgba(21, 148, 255, .08);
  color: var(--accent);
  font-size: 12px;
}

.link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
}

.link-btn:hover {
  background: transparent;
  color: var(--accent-2);
}

.link-btn + .link-btn {
  margin-left: 10px;
}

.primary {
  width: 100%;
  border-color: #0e84e6;
  background: #0e84e6;
  color: #fff;
}

.primary:hover {
  border-color: var(--accent);
  background: var(--accent);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: none;
  max-width: 360px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: #0f1415;
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}

.toast.show {
  display: block;
}

@media (max-width: 1180px) {
  body {
    min-width: 0;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .connection,
  .workbench,
  .order-layout,
  .filters {
    display: grid;
  }

  .connection input {
    width: 100%;
  }

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