:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #60717c;
  --line: #d8e0e4;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --warn: #a15c07;
  --ok: #1f7a3a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

body.console-route {
  background: transparent;
}

body.console-route #app {
  min-height: 100%;
  width: auto;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
}

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

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

button:disabled {
  opacity: 0.55;
  cursor: default;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #ffffff;
  color: var(--ink);
}

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

.sidebar {
  background: #122025;
  color: #d8e8ec;
  padding: 14px;
}

.brand {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #20a39e;
  color: #ffffff;
}

.nav {
  display: grid;
  gap: 4px;
  margin-top: 18px;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #d8e8ec;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
  padding: 18px;
}

.topbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.title {
  font-size: 20px;
  font-weight: 700;
}

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

.toolbar .compact-input {
  width: 180px;
  min-width: 140px;
  flex: 0 1 180px;
}

.action-stack {
  display: grid;
  gap: 12px;
}

.rebuild-toolbar {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.rebuild-toolbar select {
  flex: 1 1 240px;
  min-width: min(100%, 240px);
}

.server-detail {
  display: grid;
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
  align-items: stretch;
}

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

.metrics-panel {
  width: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.3;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #f9fbfb;
}

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

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.running {
  background: var(--ok);
}

.dot.off,
.dot.stopped {
  background: var(--danger);
}

.dot.busy {
  background: var(--warn);
}

.form {
  display: grid;
  gap: 10px;
  max-width: 360px;
}

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

.login-panel {
  width: min(360px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.kv {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 8px 12px;
}

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

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.assignment-list {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.assignment-item {
  display: grid;
  gap: 6px;
}

.assignment-expiration {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(170px, 210px) minmax(170px, 220px) auto auto;
  gap: 6px;
  align-items: center;
  padding-left: 22px;
}

.field-inline {
  display: flex;
  gap: 6px;
  align-items: center;
}

.field-inline span {
  color: var(--muted);
  white-space: nowrap;
}

.check-row {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: normal;
}

.check-row input {
  width: auto;
  min-height: 0;
}

.console-app {
  grid-template-columns: 220px max-content;
  width: max-content;
  min-height: 100vh;
}

.console-main {
  width: max-content;
  min-width: 0;
  min-height: 0;
  padding: 0;
}

.console-controls {
  display: flex;
  width: max-content;
  margin: 8px 0;
  gap: 8px;
  align-items: center;
}

.console-frame {
  display: contents;
}

.console-frame[hidden] {
  display: none;
}

.console-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  outline: none;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  .main {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
