:root {
  color-scheme: light;
  --page: #f6f7f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-hover: #f3f5f6;
  --line: #e3e7e9;
  --line-strong: #cfd6da;
  --text: #171a1c;
  --muted: #6d7880;
  --soft: #929ca3;
  --accent: #c6dc02;
  --accent-hover: #b8ce00;
  --danger: #c83f3b;
  --danger-soft: #fff4f3;
  --warn: #9b6814;
  --ok: #168252;
  --shadow: 0 16px 42px rgba(24, 31, 35, .12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.login-box {
  width: min(356px, 100%);
  display: grid;
  gap: 16px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(24, 31, 35, .08);
}

.login-logo {
  width: 184px;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2px 0 8px;
}

.login-box label,
.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
  outline: 0;
}

input:focus,
select:focus {
  border-color: #909ba1;
  box-shadow: 0 0 0 3px rgba(32, 38, 42, .06);
}

button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  padding: 7px 11px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}

button:hover { background: var(--surface-hover); }
button:disabled { opacity: .45; cursor: default; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent);
  border-color: var(--accent);
  color: #171a10;
  font-size: 14px;
  font-weight: 700;
}

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

.login-submit { width: 100%; min-height: 38px; }
.danger { color: var(--danger); }
.error { min-height: 16px; color: var(--danger); font-size: 12px; }

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 19px 12px 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
}

.brand-wrap {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.brand-logo {
  width: 164px;
  max-width: 100%;
  height: auto;
  display: block;
}

.rail nav {
  display: grid;
  align-content: start;
  gap: 3px;
}

.rail nav button,
.rail-action {
  min-height: 38px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: var(--muted);
  padding: 0 10px;
  font-size: 14px;
  font-weight: 500;
}

.rail nav button:hover,
.rail-action:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.rail nav button.active {
  background: #f3f5ef;
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.rail-footer {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.relay-state {
  min-height: 31px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.workspace { min-width: 0; }

.bar {
  height: 56px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(255, 255, 255, .96);
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(10px);
}

.bar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.bar-title strong {
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
}

.relay-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

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

.icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.content {
  padding: 20px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

th, td {
  height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

th {
  height: 40px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-soft);
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
td strong { font-weight: 600; }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.row-actions button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border-color: transparent;
}

.row-actions button:hover {
  background: var(--surface-hover);
  border-color: var(--line);
}

.row-actions button.danger:hover {
  background: var(--danger-soft);
  border-color: #f1d3d1;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8f9aa1;
  flex: 0 0 auto;
}

.dot.ok { background: var(--ok); }
.dot.bad { background: var(--danger); }
.dot.warn { background: var(--warn); }

.muted { color: var(--muted); }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.protocol {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #4e5960;
  background: var(--surface-soft);
  font-size: 10.5px;
  font-weight: 650;
}

.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 46px 16px;
  text-align: center;
  font-size: 14px;
  background: var(--surface);
}

.relay-down {
  margin-bottom: 10px;
  border: 1px solid #ead7ae;
  border-radius: 7px;
  color: #7e5716;
  background: #fffaf0;
  padding: 9px 11px;
  font-size: 12px;
}

dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(24, 31, 35, .34); }
#dialog-form { margin: 0; }

.dialog-bar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-bar strong {
  font-size: 14px;
  font-weight: 650;
}

#dialog-body {
  padding: 16px;
  display: grid;
  gap: 12px;
  max-height: 64vh;
  overflow: auto;
}

.dialog-actions {
  min-height: 56px;
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.check-list {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  display: grid;
}

.check-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.check-row:last-child { border-bottom: 0; }
.check-row input { width: auto; min-height: 0; }

.key-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.key-box code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px;
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 180px;
  max-width: 360px;
  background: #202529;
  color: #fff;
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .16s ease;
  z-index: 20;
  box-shadow: 0 10px 28px rgba(20, 25, 28, .2);
}

.toast.show { opacity: 1; transform: translateY(0); }

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

  .rail {
    position: static;
    height: auto;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }

  .brand-wrap { padding: 0; }
  .brand-logo { width: 144px; }

  .rail nav {
    display: flex;
    gap: 2px;
    overflow: auto;
    justify-self: end;
  }

  .rail nav button {
    white-space: nowrap;
    padding: 0 9px;
  }

  .rail nav button.active {
    box-shadow: inset 0 -3px 0 var(--accent);
  }

  .rail-footer { display: none; }
  .bar { top: 0; padding: 0 12px; }
  .relay-badge { display: none; }
  .content { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}


.clickable-row { cursor: pointer; }

.customer-workspace {
  display: grid;
  gap: 16px;
}

.customer-toolbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.customer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.customer-name {
  display: block;
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
}

.customer-subline {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.customer-subline .name-cell {
  gap: 6px;
}

.separator { color: var(--soft); }

.quiet {
  border-color: transparent;
  background: transparent;
}

.customer-toolbar > button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

@media (max-width: 760px) {
  .customer-toolbar {
    align-items: flex-start;
  }
}


#import-channels {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}

#import-channels svg {
  width: 16px;
  height: 16px;
}

.import-path {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.import-path strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 500;
}
