:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #d8dce1;
  --text: #1c2127;
  --text-soft: #5b6470;
  --accent: #1f5fd6;
  --accent-hover: #1a52ba;
  --ok: #1f9d55;
  --warn: #c47f17;
  --err: #c0392b;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand__name {
  font-weight: 700;
  font-size: 16px;
}

.brand__sub {
  color: var(--text-soft);
  font-size: 12px;
}

.brand__scope {
  color: var(--text-soft);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 8px;
}

/* Page */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Config bar */
.config {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 600;
}

.field select,
.field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}

.field input[readonly] {
  background: #eef0f3;
  color: var(--text-soft);
}

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

/* Status indicator */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 13px;
}

.status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-soft);
  flex: none;
}

.status[data-state="idle"] .status__dot { background: var(--text-soft); }
.status[data-state="connecting"] .status__dot { background: var(--warn); }
.status[data-state="ok"] .status__dot { background: var(--ok); }
.status[data-state="error"] .status__dot { background: var(--err); }

/* Actions */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: #eef0f3;
}

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

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Accounts list */
.accounts__title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.accounts__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.accounts__list li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.accounts__list li:last-child {
  border-bottom: none;
}

.accounts__empty {
  color: var(--text-soft);
  font-style: italic;
}

.account__main {
  min-width: 0;
}

.account__name {
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.account__type {
  font-size: 12px;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.tag {
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 8px;
  flex: none;
}

.tag--active { color: var(--ok); border-color: var(--ok); }
.tag--expired { color: var(--warn); border-color: var(--warn); }
.tag--disconnected { color: var(--err); border-color: var(--err); }

/* Log / feedback */
.log {
  font-size: 13px;
  border-radius: var(--radius);
  min-height: 0;
}

.log:empty {
  display: none;
}

.log[data-kind="error"] {
  background: #fdecea;
  color: var(--err);
  border: 1px solid #f3c7c1;
  padding: 10px 12px;
}

.log[data-kind="ok"] {
  background: #e9f6ee;
  color: var(--ok);
  border: 1px solid #bfe3cd;
  padding: 10px 12px;
}

.log[data-kind="info"] {
  background: #eef0f3;
  color: var(--text-soft);
  border: 1px solid var(--border);
  padding: 10px 12px;
}

/* Footer */
.footer {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 16px 24px;
  color: var(--text-soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* Mobile */
@media (max-width: 640px) {
  .config {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .panel__head {
    align-items: flex-start;
  }
}
