: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,
.lookup-form label span,
.auto-route-panel 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;
  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: 1180px;
}

.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: 260px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.sidebar {
  position: sticky;
  top: 86px;
  display: grid;
  align-content: start;
  gap: 14px;
  height: calc(100vh - 104px);
  overflow: auto;
}

.sidebar-section,
.sidebar-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

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

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

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

.route-nav button,
.route-nav .route-link,
.group-nav button {
  width: 100%;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.route-nav button,
.route-nav .route-link {
  display: grid;
  gap: 2px;
  height: auto;
  padding: 10px 12px;
}

.route-nav .route-link {
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.route-nav .route-link:hover {
  border-color: rgba(24, 112, 100, 0.25);
  background: #f2f8f6;
  color: var(--primary);
}

.group-nav button {
  display: flex;
  justify-content: space-between;
}

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

.route-nav-label {
  font-weight: 700;
}

.route-nav-meta,
.group-nav span {
  color: var(--muted);
  font-size: 12px;
}

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

.app-view {
  min-width: 0;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.view-head h2,
.detail-head h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.view-head p,
.detail-head p,
.helper-text {
  margin: 4px 0 0;
  color: var(--muted);
}

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

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

.metric.wide {
  grid-column: span 1;
}

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

.metric strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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,
.lookup-panel,
.detail-panel,
.auto-route-panel {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px 180px auto;
  gap: 10px;
  align-items: end;
}

.inline-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.inline-panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.inline-panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.user-cache-panel {
  display: grid;
  gap: 10px;
}

.cache-status {
  min-height: 20px;
}

.user-toolbar {
  grid-template-columns:
    minmax(240px, 1.4fr)
    150px
    120px
    120px
    100px
    auto
    minmax(140px, 0.8fr);
}

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

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

.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;
}

.auto-route-status {
  min-height: 34px;
  line-height: 34px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  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-scroll {
  overflow-x: auto;
}

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 select {
  min-width: 0;
}

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

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

.lookup-form {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 96px;
  gap: 10px;
  align-items: end;
}

.rate-summary {
  margin-bottom: 12px;
}

.detail-head {
  margin-bottom: 12px;
}

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

.detail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

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

.detail-item strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.5;
}

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

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

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

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

.role-badge.user {
  background: #f4f7ff;
  color: #3751a6;
}

.role-badge.admin {
  background: #eef9f5;
  color: var(--primary);
}

.role-badge.root {
  background: #fff5ec;
  color: var(--accent);
}

.notes-list ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.notes-list li {
  line-height: 1.5;
}

.user-table {
  min-width: 1680px;
}

.user-col-main {
  width: 230px;
}

.user-col-role {
  width: 156px;
}

.user-col-group {
  width: 140px;
}

.user-col-number {
  width: 108px;
}

.user-col-rate {
  width: 144px;
}

.user-col-time {
  width: 164px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

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

.pagination-actions {
  display: flex;
  gap: 8px;
}

.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);
}

.compact-empty {
  min-height: 120px;
}

.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: 1200px) {
  .dashboard-page {
    min-width: 1080px;
  }

  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .user-toolbar {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

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

  .pagination-bar {
    flex-wrap: wrap;
  }
}

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

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

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