:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --line: #d9e1e8;
  --text: #17202a;
  --muted: #637083;
  --accent: #1f7a6b;
  --accent-strong: #155c51;
  --danger: #b42318;
  --warning: #a15c07;
  --ok: #147a3d;
  --shadow: 0 10px 24px rgba(19, 31, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary,
.panel-heading button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button.primary:hover,
.panel-heading button:hover {
  background: var(--accent-strong);
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #111827;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--accent);
}

.nav {
  display: grid;
  gap: 8px;
}

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

.nav-button.is-active,
.nav-button:hover {
  background: #1f2937;
  color: #fff;
  border-color: #344054;
}

.api-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.api-box label,
.form-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

.api-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.api-row input {
  min-width: 0;
}

.status-text {
  min-height: 18px;
  margin: 0;
  color: #c7d2fe;
  font-size: 12px;
}

.api-box button {
  width: 100%;
}

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

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

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.message {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.message.error {
  color: var(--danger);
  border-color: #f3b6ad;
  background: #fff4f2;
}

.message.success {
  color: var(--ok);
  border-color: #a9dfbf;
  background: #f1fbf4;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 28px;
}

.panel {
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.row-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2f7;
  color: var(--muted);
}

.badge.ok {
  background: #e8f7ee;
  color: var(--ok);
}

.badge.warn {
  background: #fff3db;
  color: var(--warning);
}

.badge.error {
  background: #fff0ee;
  color: var(--danger);
}

.form-panel {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
}

.form-panel label,
.form-panel .primary {
  margin-left: 16px;
  margin-right: 16px;
}

.sub-panel {
  display: grid;
  gap: 12px;
  margin: 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.sub-panel label {
  margin-left: 0;
  margin-right: 0;
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.settings-panel {
  margin-top: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 14px;
  padding: 16px;
}

.settings-grid label,
.system-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

.system-panel {
  max-width: 920px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

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

  .sidebar {
    position: static;
  }

  .metrics,
  .settings-grid,
  .system-grid,
  .inline-grid,
  .split-layout {
    grid-template-columns: 1fr;
  }
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f7;
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 4px 0 0;
  font-size: 24px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

.login-panel .status-text {
  color: var(--danger);
}

.login-brand {
  color: var(--text);
}
