:root {
  color-scheme: light;
  --accent: #0f7a3d;
  --accent-dark: #095c2c;
  --accent-soft: #e8f6ed;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --warning: #ad6b00;
  --warning-soft: #fff6df;
  --info: #0b6f85;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee6;
  --panel: #ffffff;
  --surface: #f3f6fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 30px;
  background: linear-gradient(135deg, #0f6f47, #10737a);
  color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 800;
  font-size: 24px;
  color: #e8ffe9;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 25px;
  font-weight: 650;
}

h2 {
  font-size: 17px;
  font-weight: 650;
}

h3 {
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 12px;
}

.app-header p,
.table-header p {
  color: rgba(255, 255, 255, 0.82);
  margin-top: 3px;
}

.table-header p {
  color: var(--muted);
}

.server-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}

.state-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f0b429;
}

.state-dot.ok {
  background: #45d483;
}

.state-dot.error {
  background: #ff766f;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  width: min(1600px, calc(100vw - 40px));
  margin: 20px auto 32px;
}

.workspace {
  min-width: 0;
}

.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
}

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

.panel-body {
  padding: 16px;
}

.panel-body.compact {
  padding-top: 14px;
}

.panel-divider {
  height: 1px;
  background: var(--line);
}

label {
  display: block;
  margin: 0 0 6px;
  color: #2d3748;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #c9d3df;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(11, 111, 133, 0.14);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

button {
  min-height: 36px;
  border: 1px solid #c9d3df;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  padding: 8px 13px;
  cursor: pointer;
}

button:hover {
  background: #f7f9fb;
}

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

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

button.danger {
  border-color: #f1b5ae;
  color: var(--danger);
}

button.warning {
  border-color: #efd08d;
  color: var(--warning);
}

button.linklike {
  min-height: auto;
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--info);
}

.button-row,
.dialog-actions,
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row {
  margin-top: 12px;
}

.full {
  width: 100%;
  margin-top: 12px;
}

.hint {
  color: var(--muted);
  margin-top: 11px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-grid + label,
.panel-body label:not(:first-child) {
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f7;
}

.badge.muted {
  color: #344054;
}

.badge.Available {
  background: var(--accent-soft);
  color: #0b6f3a;
}

.badge.Activated {
  background: #e7f0ff;
  color: #1254a8;
}

.badge.Blocked {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.ReactivationRequired {
  background: var(--warning-soft);
  color: var(--warning);
}

.status {
  display: none;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
}

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

.status.success {
  border-left-color: var(--accent);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 14px;
}

.stat-card strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.stat-card.warning strong {
  color: var(--warning);
}

.stat-card.danger strong {
  color: var(--danger);
}

.table-header {
  align-items: start;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px auto auto;
  gap: 10px;
  align-items: end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid #e7ebf0;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f7f9fb;
  color: #344054;
  font-size: 12px;
  font-weight: 750;
}

.key {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
}

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

.empty {
  text-align: center;
  padding: 28px;
}

dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.22);
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.34);
}

.dialog-head,
.dialog-body,
.dialog-actions {
  padding: 16px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.dialog-head button {
  border: 0;
  min-width: 34px;
  padding: 0;
  font-size: 24px;
}

.dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    width: calc(100vw - 24px);
    margin-top: 12px;
  }

  .toolbar,
  .field-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
