:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #5d6878;
  --line: #d9dee7;
  --accent: #2457a6;
  --ok: #147a4d;
  --warn: #b44900;
  --soft-ok: #e6f4ed;
  --soft-warn: #fff0e1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 17px;
}

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

button,
input,
select,
.button-link,
.icon-link {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 14px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.secondary {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.icon-link {
  display: inline-flex;
  width: 42px;
  min-width: 42px;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  color: var(--ink);
  font-size: 21px;
  line-height: 1;
  text-decoration: none;
}

button.danger {
  background: #a62929;
  border-color: #a62929;
}

.is-saving button,
.is-saving input,
.is-saving select {
  opacity: 0.72;
}

input,
select {
  width: 100%;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.message {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.status-ok {
  background: var(--soft-ok);
  border-color: #b8dfca;
}

.status-warn {
  background: var(--soft-warn);
  border-color: #f1c499;
}

.panel {
  margin-top: 18px;
  overflow: hidden;
}

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

.save-status {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

form {
  display: grid;
  grid-template-columns: 150px 150px 170px 1fr 120px auto;
  gap: 10px;
  padding: 16px;
}

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

.settings-grid.compact-actions {
  grid-template-columns: repeat(2, auto);
  justify-content: start;
}

.settings-note {
  margin: 0;
  padding: 14px 16px 10px;
  color: var(--muted);
}

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

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

th {
  color: var(--muted);
  background: #fafbfc;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

td input,
td select {
  min-height: 34px;
}

td.actions-cell {
  width: 190px;
  white-space: nowrap;
}

td.actions-cell button {
  min-width: 74px;
}

td button + button {
  margin-left: 8px;
}

.number {
  text-align: right;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  min-width: 82px;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
}

.ok {
  color: var(--ok);
  background: var(--soft-ok);
}

.warn {
  color: var(--warn);
  background: var(--soft-warn);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  header {
    display: block;
  }

  .icon-link,
  .button-link {
    margin-top: 14px;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  form,
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .summary,
  form,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 8px;
    font-size: 14px;
  }
}
