:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #667169;
  --line: #dfe5e0;
  --soft: #f4f7f4;
  --paper: #ffffff;
  --brand: #173e2d;
  --brand-hover: #0f2f21;
  --accent: #c99a52;
  --danger: #a73535;
  --danger-soft: #fff0ef;
  --success: #21734b;
  --warning: #946200;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #eef2ee; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 128px;
  padding: 28px max(28px, calc((100vw - 1500px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: white;
  background: linear-gradient(120deg, #102c20, #1e523a);
  border-bottom: 4px solid var(--accent);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 500; }
h2 { margin-bottom: 6px; font-family: Georgia, serif; font-size: 1.7rem; font-weight: 500; }
h3 { margin-bottom: 16px; font-size: 1rem; }
.eyebrow { margin-bottom: 5px; color: #d5c09c; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.connection { margin-right: 8px; font-size: .82rem; color: #d8e6dd; }
.connection::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #f1bb55; }
.connection.online::before { background: #64d190; }

main { max-width: 1500px; margin: 0 auto; padding: 26px 28px 50px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 18px rgba(23, 33, 27, .04); }
.metric strong { display: block; margin-top: 5px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.metric span { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

.workspace { overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 24px rgba(23, 33, 27, .05); }
.toolbar { display: grid; grid-template-columns: minmax(300px, 1fr) repeat(3, minmax(135px, 190px)); gap: 12px; padding: 18px; border-bottom: 1px solid var(--line); background: #fbfcfb; }
label > span, legend { display: block; margin-bottom: 6px; color: var(--muted); font-size: .76rem; font-weight: 750; }
small { font-weight: 500; }
input, textarea, select { width: 100%; padding: 10px 11px; color: var(--ink); background: white; border: 1px solid #cfd8d1; border-radius: 7px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23, 62, 45, .1); }
input:disabled, select:disabled { color: #8f9891; background: #f2f4f2; }
.table-heading { display: flex; justify-content: space-between; padding: 12px 18px 5px; color: var(--muted); font-size: .78rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; text-align: left; color: var(--muted); border-bottom: 1px solid var(--line); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
td { max-width: 260px; padding: 14px; border-bottom: 1px solid #edf0ed; vertical-align: top; font-size: .84rem; }
tr:hover td { background: #fafcf9; }
.provider-name { display: block; margin-bottom: 4px; font-weight: 750; }
.provider-key { display: block; max-width: 250px; overflow: hidden; color: var(--muted); font-family: ui-monospace, monospace; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; margin: 0 4px 4px 0; padding: 4px 7px; color: #425047; background: var(--soft); border-radius: 999px; font-size: .7rem; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; font-size: .7rem; font-weight: 750; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.status.active { color: var(--success); background: #e9f7ef; }
.status.active::before { background: var(--success); }
.status.inactive { color: #6d7470; background: #edf0ee; }
.status.inactive::before { background: #8a928d; }
.status.invalid { color: var(--danger); background: var(--danger-soft); }
.status.invalid::before { background: var(--danger); }
.actions { white-space: nowrap; }
.actions button { margin: 0 3px 5px 0; padding: 5px 8px; color: var(--brand); background: transparent; border: 1px solid #d5ddd7; border-radius: 6px; font-size: .72rem; }
.actions button:hover { background: var(--soft); }
.actions .delete { color: var(--danger); }
.empty { padding: 50px; text-align: center; color: var(--muted); }

.button { padding: 10px 14px; border: 1px solid transparent; border-radius: 7px; font-weight: 750; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-hover); }
.button.secondary { color: var(--brand); background: white; border-color: #cfd8d1; }
.topbar .button.secondary { color: white; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); }
.button.danger { color: white; background: var(--danger); }
.button.small { padding: 7px 10px; font-size: .75rem; }

::backdrop { background: rgba(9, 22, 15, .62); backdrop-filter: blur(2px); }
dialog { color: var(--ink); background: var(--paper); border: 0; border-radius: 14px; box-shadow: 0 22px 70px rgba(0,0,0,.3); }
.editor-dialog { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; }
.editor-dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; padding: 22px 24px 15px; }
.icon-button { width: 36px; height: 36px; color: var(--muted); background: transparent; border: 0; font-size: 1.6rem; }
.muted { margin-bottom: 0; color: var(--muted); font-family: ui-monospace, monospace; font-size: .7rem; word-break: break-all; }
.tabs { display: flex; padding: 0 24px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 15px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; font-weight: 750; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.panel { display: none; overflow-y: auto; padding: 20px 24px; }
.panel.active { display: block; }
.form-section { padding: 4px 0 21px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.form-section:last-child { margin-bottom: 0; border-bottom: 0; }
.grid { display: grid; gap: 13px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.form-section > label { display: block; margin-top: 12px; }
.check-grid { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.check-grid label, .switch-row { display: flex; align-items: center; gap: 7px; font-size: .85rem; }
.check-grid input, .switch-row input { width: auto; }
.section-title { display: flex; justify-content: space-between; align-items: center; }
fieldset { margin: 16px 0 0; padding: 13px; border: 1px solid var(--line); border-radius: 8px; }
.disabled-group { opacity: .55; }
.json-toolbar { display: flex; align-items: center; justify-content: space-between; }
.json-toolbar p { margin-bottom: 8px; color: var(--muted); font-size: .78rem; }
.json-editor { min-height: 460px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.validation { margin: 0 24px 12px; padding: 12px; color: var(--danger); background: var(--danger-soft); border-radius: 8px; font-size: .8rem; }
.validation.success { color: var(--success); background: #e9f7ef; }
.validation ul { margin: 5px 0 0; padding-left: 20px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 24px; background: #fafbf9; border-top: 1px solid var(--line); }
.confirm-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; }
.confirm-dialog > p, .confirm-dialog > label { margin-left: 24px; margin-right: 24px; }
.key-box { padding: 10px; color: var(--muted); background: var(--soft); border-radius: 7px; font: .72rem ui-monospace, monospace; word-break: break-all; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 13px 16px; color: white; background: var(--brand); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: .82rem; }
.toast.error { background: var(--danger); }
.hidden { display: none !important; }

@media (max-width: 950px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search { grid-column: 1 / -1; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 600px) {
  main { padding: 16px 10px 30px; }
  .topbar { padding: 24px 18px; }
  .metrics, .toolbar, .grid.two { grid-template-columns: 1fr; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; }
}
