:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --soft-panel: #f6f8fb;
  --line: #dfe5eb;
  --line-strong: #cfd8e2;
  --text: #28313d;
  --muted: #7c8794;
  --accent: #00a878;
  --danger: #e6374f;
  --success: #14966d;
  --warning: #b7791f;
  --accent-ring: rgba(0, 168, 120, 0.18);
  --success-bg: rgba(20, 150, 109, 0.12);
  --success-line: rgba(20, 150, 109, 0.28);
  --danger-bg: rgba(230, 55, 79, 0.12);
  --danger-line: rgba(230, 55, 79, 0.3);
  --muted-bg: rgba(124, 135, 148, 0.12);
  --muted-line: rgba(124, 135, 148, 0.24);
  --shadow: 0 10px 26px rgba(38, 50, 64, 0.08);
  --shadow-soft: 0 4px 14px rgba(38, 50, 64, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101820;
    --panel: #17212b;
    --soft-panel: #1c2834;
    --line: #2b3a47;
    --line-strong: #3a4b59;
    --text: #d7dee5;
    --muted: #96a3ae;
    --accent: #23c59b;
    --danger: #ff5268;
    --success: #36c08d;
    --warning: #d9a441;
    --accent-ring: rgba(35, 197, 155, 0.2);
    --success-bg: rgba(54, 192, 141, 0.14);
    --success-line: rgba(54, 192, 141, 0.3);
    --danger-bg: rgba(255, 82, 104, 0.14);
    --danger-line: rgba(255, 82, 104, 0.32);
    --muted-bg: rgba(150, 163, 174, 0.14);
    --muted-line: rgba(150, 163, 174, 0.26);
    --shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
    --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.18);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, var(--soft-panel) 0, var(--bg) 280px);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.logo {
  width: 52px;
  height: 36px;
  object-fit: contain;
}

.brand {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
}

.refresh-meta {
  margin-left: auto;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.refresh-meta span,
.refresh-meta small {
  display: block;
}

.icon-button,
.small-button,
.add-button,
.notify-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  border-radius: 8px;
  min-height: 36px;
  font-weight: 650;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.icon-button {
  width: 36px;
  border-radius: 999px;
}

.add-button,
.notify-button {
  width: 100%;
  margin-top: 14px;
  min-height: 44px;
  text-align: left;
  padding: 0 12px;
  color: var(--accent);
}

.add-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: var(--shadow-soft);
}

.notify-button {
  margin-top: 8px;
  background: var(--panel);
}

.small-button {
  padding: 6px 10px;
  color: var(--accent);
}

.server-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.status-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-weight: 650;
  white-space: nowrap;
}

.status-button:disabled {
  cursor: default;
  opacity: 1;
}

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

.small-button.danger {
  color: var(--danger);
}

button:focus-visible,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

button:hover {
  background: var(--soft-panel);
  border-color: var(--line-strong);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.add-button:hover,
.small-button.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.error {
  color: var(--danger);
  margin: 12px 0 0;
  line-height: 1.5;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.metric,
.card,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  background: linear-gradient(180deg, var(--panel) 0, var(--soft-panel) 100%);
  min-height: 48px;
  padding: 10px 12px;
  box-shadow: var(--shadow-soft);
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 19px;
  line-height: 1.1;
  color: var(--text);
}

.metric:nth-child(4) strong {
  color: var(--success);
}

.metric:nth-child(5) strong {
  color: var(--danger);
}

.metric:nth-child(6) strong {
  color: var(--warning);
}

.section {
  margin-top: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.section-title h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}

.section-title button {
  margin-left: auto;
}

.stack {
  display: grid;
  gap: 10px;
}

.card {
  background: linear-gradient(180deg, var(--panel) 0, var(--soft-panel) 100%);
  padding: 12px;
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.row > :last-child {
  margin-left: auto;
}

.title {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.25;
}

.state,
.success {
  color: var(--success);
  font-weight: 650;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.status-ok {
  color: var(--success);
  background: var(--success-bg);
  border-color: var(--success-line);
}

.status-bad {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-line);
}

.status-muted {
  color: var(--muted);
  background: var(--muted-bg);
  border-color: var(--muted-line);
}

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

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

.meta {
  margin-top: 8px;
  font-size: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.value {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.value span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.value strong {
  display: inline;
  margin-top: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.message-content {
  margin-top: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.empty {
  background: var(--soft-panel);
  min-height: 72px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

dialog {
  width: min(92vw, 420px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.36);
}

.dialog-card {
  padding: 16px;
}

.dialog-card h3 {
  margin: 0 0 12px;
}

.dialog-card input,
.dialog-card select {
  width: 100%;
  min-height: 42px;
  margin: 8px 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

iframe.panel-frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
  z-index: 10;
}

.panel-toolbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 58px;
  padding: 10px 14px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.panel-toolbar .icon-button {
  margin-left: auto;
}

iframe.panel-frame.with-toolbar {
  top: 58px;
  height: calc(100% - 58px);
}
