:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee7;
  --line-strong: #b9c3d0;
  --primary: #187064;
  --primary-dark: #0f574d;
  --accent: #9a5b13;
  --danger: #b42318;
  --warning: #a15c07;
  --ok: #167647;
  --shadow: 0 18px 45px rgba(22, 34, 48, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

button.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
  color: #fff;
}

input,
select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(24, 112, 100, 0.16);
  border-color: var(--primary);
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-mark.large {
  width: 48px;
  height: 48px;
  font-size: 22px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(24, 112, 100, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(154, 91, 19, 0.12), transparent 32%),
    var(--bg);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 420px;
  gap: 28px;
  width: min(920px, 100%);
  align-items: stretch;
}

.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 420px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111923;
  color: #fff;
  box-shadow: var(--shadow);
}

.login-copy h1 {
  margin: 22px 0 8px;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

.login-copy p {
  max-width: 320px;
  margin: 0;
  color: #cbd5e1;
}

.login-form {
  min-height: 420px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-form h2 {
  margin: 0 0 20px;
  font-size: 22px;
  letter-spacing: 0;
}

.login-form label {
  display: grid;
  gap: 6px;
  margin: 16px 0;
}

.login-form span,
.toolbar label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.wide-button {
  width: 100%;
  margin-top: 4px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.check-field input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.login-form .check-field {
  display: flex;
  grid-template-columns: none;
  margin: 10px 0 16px;
}

.login-form .check-field span {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
}

.dashboard-page {
  min-width: 1120px;
}

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

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

.brand-block h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.brand-block p {
  overflow: hidden;
  max-width: 640px;
  margin: 2px 0 0;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions,
.group-actions,
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.sidebar {
  position: sticky;
  top: 86px;
  height: calc(100vh - 104px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.side-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.group-nav button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.group-nav button.active {
  border-color: rgba(24, 112, 100, 0.25);
  background: #e9f6f3;
  color: var(--primary);
}

.group-nav span {
  color: var(--muted);
}

.content-pane {
  min-width: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) minmax(280px, 1.4fr);
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
}

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

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.2;
}

.metric small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice {
  margin-bottom: 12px;
  border: 1px solid #f0c36a;
  border-radius: 8px;
  background: #fff8e8;
  color: var(--accent);
  padding: 10px 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px 180px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.toolbar label {
  display: grid;
  gap: 5px;
}

.toolbar-meta {
  min-width: 120px;
  height: 34px;
  line-height: 34px;
  color: var(--muted);
  text-align: right;
}

.auto-route-panel {
  display: grid;
  grid-template-columns: 128px 180px 130px 150px 96px minmax(220px, 1fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.auto-route-panel label:not(.check-field) {
  display: grid;
  gap: 5px;
}

.auto-route-panel label > span,
.auto-route-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.auto-route-status {
  min-height: 34px;
  line-height: 34px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.group-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

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

.group-title h2 {
  overflow: hidden;
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  white-space: nowrap;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #fff;
}

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

.col-id {
  width: 70px;
}

.col-name {
  width: 230px;
}

.col-status {
  width: 88px;
}

.col-number {
  width: 78px;
}

.col-latency {
  width: 132px;
}

.col-model {
  width: 330px;
}

.col-actions {
  width: 286px;
}

.name-main {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.name-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

.status.ok {
  color: var(--ok);
  background: #eaf8ef;
}

.status.bad {
  color: var(--danger);
  background: #fff0ee;
}

.status.warn {
  color: var(--warning);
  background: #fff6e6;
}

.model-box {
  display: flex;
  gap: 6px;
}

.model-box input,
.model-box select {
  min-width: 0;
}

.latency-ok {
  color: var(--ok);
  font-weight: 700;
}

.latency-bad {
  color: var(--danger);
  font-weight: 700;
}

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

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: 460px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  color: var(--text);
}

.toast.error {
  border-color: #f1a199;
  color: var(--danger);
}

@media (max-width: 760px) {
  .login-page {
    padding: 18px;
  }

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

  .login-copy {
    min-height: 220px;
  }
}
