:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #eef4f7;
  color: #23414a;
}

button.secondary:hover {
  background: #dce9ee;
}

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

button.danger:hover {
  background: #ffd8d5;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

code {
  overflow-wrap: anywhere;
  color: #344054;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.login-panel {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
}

.login-form {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-form h1,
.topbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

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

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

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

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

.create-provider {
  padding: 20px;
  margin-bottom: 24px;
}

h2,
h3,
h4 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

h3 {
  font-size: 18px;
}

h4 {
  font-size: 15px;
  margin-bottom: 12px;
}

.provider-form,
.provider-edit {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.providers {
  display: grid;
  gap: 18px;
}

.provider-card {
  padding: 18px;
}

.provider-head,
.section-title,
.provider-key {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.provider-head {
  margin-bottom: 16px;
}

.provider-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.provider-edit {
  grid-template-columns: 1fr 2fr minmax(150px, 0.8fr) auto;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.provider-key {
  flex-wrap: wrap;
  justify-content: flex-start;
  border: 1px solid #d7ebea;
  border-radius: 6px;
  background: #f0fdfa;
  margin: 16px 0;
  padding: 10px;
}

.provider-key span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.inline-form,
.condition-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 12px;
}

.condition-form {
  grid-template-columns: 150px minmax(0, 1fr) auto;
}

.key-list,
.condition-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  padding: 8px;
}

.list-item.dragging {
  opacity: 0.55;
}

.drag-handle {
  width: 30px;
  min-height: 30px;
  padding: 0;
  background: #eef4f7;
  color: #52616b;
  cursor: grab;
}

.list-item input,
.list-item select {
  min-height: 34px;
}

.condition-item {
  grid-template-columns: 130px minmax(0, 1fr) auto auto;
}

@media (max-width: 900px) {
  .provider-form,
  .provider-edit,
  .columns,
  .condition-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .provider-head,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .list-item,
  .condition-item {
    grid-template-columns: 1fr;
  }
}
