:root {
  color-scheme: dark;
  --bg: #000000;
  --fg: #f7f7f7;
  --muted: #7dffb1;
  --line: #1aff66;
  --soft: #071107;
  --panel: #030303;
  --field: #050805;
  --accent: #00ff66;
  --accent-2: #00d7ff;
  --warning: #ffd166;
  --danger: #ff5f5f;
  --shadow: rgba(0, 255, 102, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  letter-spacing: 0;
  text-rendering: geometricPrecision;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 50%, rgba(0, 0, 0, 0.08) 50%),
    linear-gradient(90deg, rgba(0, 255, 102, 0.035), rgba(0, 215, 255, 0.025), rgba(255, 209, 102, 0.025));
  background-size: 100% 4px, 7px 100%;
  mix-blend-mode: screen;
  opacity: 0.42;
}

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

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: #000000;
  cursor: pointer;
  padding: 0 18px;
  text-decoration: none;
  text-transform: lowercase;
  box-shadow: 0 0 18px var(--shadow);
}

button:hover,
.button-link:hover {
  background: #ffffff;
  border-color: #ffffff;
  color: #000000;
}

.secondary-button,
.secondary-link {
  background: #000000;
  color: var(--accent);
}

.secondary-button:hover,
.secondary-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #000000;
}

.auth-page {
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(100%, 420px);
  padding: 24px;
}

.auth-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 28px;
  box-shadow: 0 0 0 1px #000000, 0 0 32px var(--shadow);
}

h1,
h2,
p {
  margin-top: 0;
}

.auth-box h1 {
  margin-bottom: 28px;
  font-size: 28px;
  line-height: 1.1;
  color: var(--accent);
  font-weight: 700;
}

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

label {
  color: var(--muted);
  font-size: 14px;
  text-transform: lowercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #155f31;
  border-radius: 3px;
  background: var(--field);
  color: var(--fg);
  padding: 0 12px;
  caret-color: var(--accent);
}

select {
  cursor: pointer;
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 18px var(--shadow);
}

.form button {
  margin-top: 8px;
}

.error {
  background: #150000;
  border: 1px solid var(--danger);
  border-radius: 3px;
  padding: 12px;
  color: var(--danger);
  box-shadow: 0 0 18px rgba(255, 95, 95, 0.16);
}

.success {
  background: #001b09;
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 12px;
  color: var(--accent);
  box-shadow: 0 0 18px var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: #000000;
  padding: 20px 28px;
  box-shadow: 0 1px 18px var(--shadow);
}

.topbar h1 {
  margin-bottom: 4px;
  font-size: 24px;
  line-height: 1.1;
  color: var(--accent);
  font-weight: 700;
}

.topbar p {
  margin-bottom: 0;
  color: var(--accent-2);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.content {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: 28px;
}

.agents-content {
  width: min(100%, 1520px);
}

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

.content-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  color: var(--fg);
}

.content-header h2::before {
  content: "$ ";
  color: var(--accent);
}

.agent-table-section {
  display: block;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid #155f31;
  border-radius: 4px;
  margin-bottom: 12px;
  padding: 10px;
  box-shadow: 0 0 18px rgba(0, 255, 102, 0.1);
}

.search-form .form-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-form .form-field:first-child {
  flex: 1 0 360px;
}

.search-form .form-field:nth-child(2) {
  flex: 0 0 260px;
}

.search-form .form-field:nth-child(3) {
  flex: 0 0 150px;
}

.search-form label {
  flex: 0 0 auto;
  font-size: 12px;
  white-space: nowrap;
}

.search-form input,
.search-form select {
  min-height: 36px;
}

.search-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
}

.search-actions button,
.search-actions .button-link {
  min-height: 36px;
  min-width: 88px;
  padding: 0 12px;
  white-space: nowrap;
}

.search-status {
  color: var(--accent-2);
  font-size: 12px;
  margin: 0;
  white-space: nowrap;
}

.search-status::before {
  content: "> ";
  color: var(--accent);
}

.table-scroll {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow-x: auto;
  box-shadow: 0 0 28px var(--shadow);
}

.agent-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.agent-table.has-distance {
  min-width: 1120px;
}

.agent-table th,
.agent-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.agent-table th {
  background: #001b09;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  text-transform: lowercase;
}

.agent-table tbody tr + tr td {
  border-top: 1px solid #12381f;
}

.agent-table tbody tr:hover td {
  background: #031605;
  color: #ffffff;
}

.agent-table th:nth-child(1),
.agent-table td:nth-child(1) {
  width: 18%;
}

.agent-table th:nth-child(2),
.agent-table td:nth-child(2) {
  width: 18%;
}

.agent-table th:nth-child(3),
.agent-table td:nth-child(3) {
  width: 34%;
}

.agent-table th:nth-child(4),
.agent-table td:nth-child(4),
.agent-table th:nth-child(5),
.agent-table td:nth-child(5),
.agent-table th:nth-child(6),
.agent-table td:nth-child(6) {
  width: 10%;
}

.agent-table.has-distance th:nth-child(1),
.agent-table.has-distance td:nth-child(1) {
  width: 16%;
}

.agent-table.has-distance th:nth-child(2),
.agent-table.has-distance td:nth-child(2) {
  width: 16%;
}

.agent-table.has-distance th:nth-child(3),
.agent-table.has-distance td:nth-child(3) {
  width: 30%;
}

.agent-table.has-distance th:nth-child(4),
.agent-table.has-distance td:nth-child(4),
.agent-table.has-distance th:nth-child(5),
.agent-table.has-distance td:nth-child(5) {
  width: 9%;
}

.agent-table.has-distance th:nth-child(6),
.agent-table.has-distance td:nth-child(6),
.agent-table.has-distance th:nth-child(7),
.agent-table.has-distance td:nth-child(7) {
  width: 10%;
}

.agent-id {
  font-family: Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: var(--accent-2);
}

.muted-value {
  color: #6a786e;
}

.table-actions {
  text-align: right;
}

.small-link {
  min-height: 34px;
  padding: 0 12px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  font-size: 14px;
}

.pagination a,
.pagination-disabled,
.pagination-status {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid #155f31;
  border-radius: 3px;
  padding: 0 12px;
  text-decoration: none;
}

.pagination a {
  color: var(--accent);
}

.pagination a:hover {
  background: var(--accent);
  color: #000000;
}

.pagination-disabled {
  color: var(--muted);
}

.empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 0;
  padding: 18px;
  color: var(--warning);
}

.agent-context {
  color: var(--accent-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.agent-action-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
}

.compact-action-button {
  min-height: 36px;
  min-width: 92px;
  padding: 0 14px;
}

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

.danger-button:hover {
  background: #ffffff;
  border-color: #ffffff;
  color: #000000;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.78);
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(100%, 460px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
  box-shadow: 0 0 0 1px #000000, 0 0 34px var(--shadow);
}

.modal-panel h3 {
  margin: 0 0 16px;
  color: var(--accent);
  font-size: 18px;
  line-height: 1.2;
  text-transform: lowercase;
}

.modal-copy {
  margin-bottom: 18px;
  color: var(--danger);
}

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

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions button {
  min-width: 90px;
}

.clone-error {
  margin-bottom: 12px;
}

.panel-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
  box-shadow: 0 0 28px var(--shadow);
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field-wide,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.empty-agent-page {
  min-height: calc(100vh - 82px);
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .topbar form,
  .topbar button {
    width: 100%;
  }

  .content {
    padding: 18px;
  }

  .content-header {
    align-items: stretch;
    flex-direction: column;
  }

  .content-header .button-link {
    width: 100%;
  }

  .search-actions {
    flex-direction: row;
  }

  .auth-shell {
    padding: 18px;
  }

  .auth-box {
    padding: 22px;
  }

  .pagination {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .panel-form {
    grid-template-columns: 1fr;
    padding: 16px;
  }

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

  .agent-action-row {
    justify-content: stretch;
  }

  .agent-action-row button {
    flex: 1;
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }
}
