:root {
  color: #17201c;
  background: #eef1ef;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  --ink: #17201c;
  --muted: #64716b;
  --line: #d7ddd9;
  --surface: #ffffff;
  --sidebar: #18211d;
  --accent: #147d59;
  --accent-dark: #0f6246;
  --amber: #a96008;
  --danger: #b33030;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
.button-link {
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--accent);
  color: white;
  min-height: 36px;
  padding: 7px 13px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #1c8bff;
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #e8eeeb;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0c1310;
}

.brand {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 19px;
  border-bottom: 1px solid #314039;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #2aa876;
  color: #081b13;
  font-weight: 800;
  font-size: 19px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #91a39a;
  margin-top: 3px;
  font-size: 11px;
}

.sidebar nav {
  display: grid;
  gap: 3px;
  padding: 14px 10px;
}

.sidebar nav button {
  background: transparent;
  border-color: transparent;
  color: #b9c7c0;
  text-align: left;
  min-height: 40px;
  padding: 9px 12px;
}

.sidebar nav button:hover {
  background: #25322c;
  color: white;
}

.sidebar nav button.active {
  background: #e8f5ef;
  color: #105a41;
  font-weight: 700;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px;
  color: #9aaba2;
  font-size: 12px;
  border-top: 1px solid #314039;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d69a2d;
}

.status-dot.online {
  background: #2fc482;
}

.status-dot.offline {
  background: #e15b5b;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 76px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.topbar p {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 12px;
}

.top-actions,
.page-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.quiet-button,
.secondary-button {
  background: white;
  color: var(--ink);
  border-color: #bcc7c1;
}

.quiet-button:hover,
.secondary-button:hover {
  color: var(--accent-dark);
  background: #f1f5f3;
  border-color: var(--accent);
}

main {
  padding: 22px 28px 40px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-actions {
  min-height: 42px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 16px;
}

.metric-strip article {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.metric-strip article:last-child {
  border-right: 0;
}

.metric-strip span,
.metric-strip strong {
  display: block;
}

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

.metric-strip strong {
  margin-top: 6px;
  font-size: 24px;
  line-height: 1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.overview-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(440px, 1.2fr);
  gap: 16px;
  margin-bottom: 16px;
}

.split-grid {
  grid-template-columns: 1fr 1fr;
}

.panel-head {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 14px;
  margin: 0;
}

.control-list {
  display: grid;
}

.control-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 9px 14px;
  border-bottom: 1px solid #edf0ee;
}

.control-row:last-child {
  border-bottom: 0;
}

.control-row small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #e8eee9;
  color: #435249;
}

.state.running,
.state.active,
.state.sent,
.state.succeeded,
.state.healthy,
.state.eligible {
  background: #dbf3e8;
  color: #09633f;
}

.state.paused,
.state.retry_wait,
.state.auth_required,
.state.cleanup_pending,
.state.unknown {
  background: #fff0d5;
  color: #8a4a00;
}

.state.stopped,
.state.banned,
.state.quarantined,
.state.terminal,
.state.sent_unknown,
.state.down,
.state.disabled {
  background: #f8dddd;
  color: #922929;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  height: 43px;
  padding: 8px 12px;
  border-bottom: 1px solid #e8ece9;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  height: 38px;
  color: #56635d;
  background: #f7f9f8;
  font-size: 11px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f6faf8;
}

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

td.wrap {
  white-space: normal;
  min-width: 220px;
  max-width: 420px;
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

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

.key-values {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 1px;
  background: var(--line);
}

.key-values div {
  background: white;
  padding: 14px;
}

.key-values span,
.key-values strong {
  display: block;
}

.key-values span {
  color: var(--muted);
  font-size: 11px;
}

.key-values strong {
  margin-top: 5px;
}

.segmented {
  display: inline-flex;
  border: 1px solid #bcc7c1;
  border-radius: 5px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-right: 1px solid #d5dcd8;
  border-radius: 0;
  background: white;
  color: #53615a;
  min-height: 34px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: white;
  background: var(--accent);
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #b8c3bd;
  border-radius: 4px;
  background: white;
  color: var(--ink);
  padding: 8px 9px;
  min-height: 36px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 6px;
  color: #4f5d56;
  font-size: 12px;
}

dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 1px solid #9eaaa4;
  border-radius: 7px;
  padding: 0;
  box-shadow: 0 18px 60px rgb(22 32 27 / 22%);
}

dialog::backdrop {
  background: rgb(14 22 18 / 48%);
}

dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}

dialog header,
dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

dialog h2 {
  font-size: 17px;
  margin: 0;
}

dialog footer {
  justify-content: flex-end;
  padding-top: 4px;
}

.dialog-close {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: #526058;
  font-size: 22px;
}

.dialog-close:hover {
  color: var(--danger);
  border-color: #e0b4b4;
  background: #fff4f4;
}

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

.span-2 {
  grid-column: span 2;
}

.login-dialog {
  width: min(380px, calc(100vw - 28px));
}

.login-dialog form {
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  margin: 0;
  font-size: 12px;
}

#toast {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 11px 14px;
  border-radius: 5px;
  background: #17201c;
  color: white;
  box-shadow: 0 8px 28px rgb(0 0 0 / 22%);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 160ms ease;
}

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

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .brand {
    padding: 16px 19px;
  }

  .brand > span:last-child,
  .sidebar nav button,
  .sidebar-foot span:last-child {
    font-size: 0;
  }

  .sidebar nav button {
    text-align: center;
  }

  .sidebar nav button::first-letter {
    font-size: 13px;
  }

  .metric-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-strip article {
    border-bottom: 1px solid var(--line);
  }

  .overview-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .brand,
  .sidebar-foot {
    display: none;
  }

  .sidebar nav {
    grid-template-columns: repeat(4, 1fr);
    padding: 6px;
  }

  .sidebar nav button,
  .sidebar nav button::first-letter {
    font-size: 11px;
    text-align: center;
    padding: 5px;
  }

  .topbar {
    min-height: 64px;
    padding: 10px 14px;
  }

  .top-actions #current-user {
    display: none;
  }

  main {
    padding: 14px;
  }

  .metric-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-strip article {
    padding: 13px;
  }

  .metric-strip strong {
    font-size: 20px;
  }

  .form-grid,
  .key-values {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .page-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }
}
