:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1d2633;
  --muted: #647084;
  --line: #d8e0ea;
  --accent: #0b5cab;
  --accent-strong: #08477f;
  --green: #0d7a61;
  --amber: #a45b13;
  --red: #b42318;
  --soft-blue: #eef5fb;
  --soft-green: #edf8f3;
  --soft-red: #fff1f0;
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

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

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 92, 171, .12);
  outline: none;
}

button,
.small-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 34px;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

button.primary:hover,
.primary:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

.small-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.small-button.secondary {
  background: var(--soft-blue);
  color: var(--accent);
}

.small-button.danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.app-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p,
.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.stack-form,
.admin-form {
  display: grid;
  gap: 14px;
}

.stack-form label,
.admin-form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 700;
  font-size: 13px;
}

.app-header {
  min-height: 72px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
}

.page {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px 24px 36px;
}

.narrow-page {
  width: min(920px, 100%);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.tool-card {
  min-height: 168px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
  display: grid;
  align-content: space-between;
  color: inherit;
}

.tool-card.available:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(29, 38, 51, .08);
  text-decoration: none;
}

.tool-card.disabled {
  opacity: .62;
}

.tool-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.tool-card h2 {
  margin: 0;
  font-size: 18px;
}

.tool-card p {
  color: var(--muted);
  line-height: 1.45;
  margin: 12px 0 18px;
}

.tool-card span,
.section-head span {
  border-radius: 999px;
  background: var(--soft-green);
  color: var(--green);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tool-card.disabled span {
  background: #f2f4f7;
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.admin-page {
  display: grid;
  gap: 16px;
}

.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.section-head h2 {
  margin: 0;
  font-size: 16px;
}

.table-wrap {
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
}

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

th {
  background: var(--soft-blue);
  color: var(--accent-strong);
  font-weight: 800;
}

tbody tr:hover td {
  background: #fffdf3;
}

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

.actions-cell form {
  margin: 0;
}

.grid-form {
  padding: 16px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  align-items: end;
}

.grid-form .primary {
  align-self: end;
}

.checkline {
  display: flex !important;
  align-items: center;
  grid-template-columns: auto 1fr;
  gap: 8px !important;
  min-height: 38px;
}

.checkline input {
  width: auto;
  min-height: auto;
}

.alert {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  background: var(--panel);
}

.alert.ok {
  border-color: #b7dfca;
  background: var(--soft-green);
  color: #075f49;
}

.alert.error {
  border-color: #f0b8b2;
  background: var(--soft-red);
  color: var(--red);
}

.alert.warn {
  border-color: #efd49b;
  background: #fff8e5;
  color: var(--amber);
  margin-bottom: 14px;
}

.role {
  border-radius: 999px;
  padding: 3px 8px;
  background: #f2f4f7;
  font-weight: 800;
}

.role.admin {
  background: #fff3d8;
  color: var(--amber);
}

.role.user {
  background: var(--soft-blue);
  color: var(--accent);
}

.good {
  color: var(--green);
  font-weight: 800;
}

.bad {
  color: var(--red);
  font-weight: 800;
}

.ua {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.details {
  max-width: 460px;
  white-space: normal;
  word-break: break-word;
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

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

  .header-actions {
    justify-content: flex-start;
  }

  .page {
    padding: 14px;
  }

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

  .login-panel {
    padding: 22px;
  }
}
