:root {
  --rail: #123246;
  --rail-soft: #1d455d;
  --bg: #f3f5f7;
  --panel: #fff;
  --line: #d8dde5;
  --text: #17212b;
  --muted: #73808c;
  --blue: #0b73d9;
  --green: #23a36b;
  --red: #d84d4d;
  --orange: #d98b0b;
  --shadow: 0 18px 48px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Helvetica Neue", sans-serif;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

.page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
}
.rail {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px 7px;
  background: var(--rail);
  color: #d8e6ef;
}
.rail-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: #fff;
  color: var(--rail);
  font-weight: 900;
}
.rail-item {
  position: relative;
  width: 52px;
  height: 52px;
  display: block;
  border-radius: 10px;
  color: inherit;
}
.rail-item::before {
  content: "";
  width: 25px;
  height: 25px;
  display: block;
  margin: 13px auto 0;
  border: 2px solid currentColor;
  border-radius: 8px;
}
.rail-item.active,
.rail-item:hover { background: var(--rail-soft); color: #fff; }
.rail-item span {
  position: absolute;
  left: 62px;
  top: 50%;
  z-index: 30;
  transform: translateY(-50%);
  display: none;
  border-radius: 8px;
  background: #0f2636;
  color: #fff;
  padding: 7px 9px;
  white-space: nowrap;
  font-size: 12px;
  box-shadow: var(--shadow);
}
.rail-item:hover span { display: block; }

.workspace {
  min-width: 0;
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 16px;
}
.topbar {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 16px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; }
.topbar p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.ghost, .primary {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #25313b;
  padding: 0 14px;
  font-weight: 700;
}
.primary { border-color: var(--blue); background: var(--blue); color: #fff; }

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric, .provider-card, .catalog-card, .table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(16, 24, 40, .06);
}
.metric { padding: 14px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric b { display: block; margin-top: 8px; font-size: 24px; }

.runtime {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
  box-shadow: 0 8px 22px rgba(16, 24, 40, .06);
}
.runtime p { color: var(--muted); font-size: 13px; }
.runtime strong { display: block; margin-bottom: 4px; }
.runtime a {
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.catalog-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.catalog-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.catalog-card h2 {
  font-size: 17px;
}
.catalog-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.catalog-grid span,
.catalog-grid b {
  min-width: 0;
  border: 1px solid #edf1f5;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
}
.catalog-grid span {
  color: var(--muted);
  background: #f8fafc;
}
.catalog-grid b {
  font-weight: 800;
}
.catalog-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
}
.catalog-status-grid div {
  min-width: 0;
  border: 1px solid #edf1f5;
  border-radius: 6px;
  background: #f8fafc;
  padding: 9px;
}
.catalog-status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.catalog-status-grid b {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #25313b;
  font-size: 13px;
}
.catalog-command code {
  display: block;
  min-width: 0;
  overflow: auto;
  border: 1px solid #edf1f5;
  border-radius: 6px;
  background: #f8fafc;
  padding: 9px;
  color: #25313b;
  font-size: 12px;
  white-space: nowrap;
}
.catalog-web-accounts {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.catalog-web-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.catalog-web-head strong {
  color: #25313b;
  font-size: 14px;
}
.catalog-web-head span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}
.catalog-web-row {
  display: grid;
  grid-template-columns: minmax(90px, .8fr) minmax(120px, 1fr) minmax(180px, 1.2fr) auto auto auto;
  gap: 8px;
  align-items: center;
}
.catalog-web-row input,
.catalog-web-row select {
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 9px;
  color: #25313b;
  font: inherit;
  font-size: 13px;
}
.catalog-web-row input[readonly] {
  background: #f8fafc;
  color: var(--muted);
}
.catalog-web-row button {
  min-height: 34px;
}
.catalog-web-new {
  grid-template-columns: minmax(130px, .8fr) minmax(140px, 1fr) minmax(180px, 1.2fr) auto auto;
}
.catalog-files {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.catalog-file-list {
  display: grid;
  gap: 6px;
}
.catalog-file-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto auto auto auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 6px 8px;
  color: #25313b;
  font-size: 13px;
}
.catalog-file-row b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.catalog-file-row span {
  color: var(--muted);
  white-space: nowrap;
}
.catalog-file-row button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #25313b;
  padding: 0 9px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.catalog-file-row button:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.catalog-file-row .delete-avito-catalog:hover {
  border-color: #f2b6b6;
  background: #fff5f5;
  color: #8f1f1f;
}
.catalog-files-empty {
  min-height: 52px;
}
.catalog-upload-row {
  display: flex;
  justify-content: flex-start;
}
.catalog-upload-row button {
  min-height: 34px;
}
.catalog-auth-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.catalog-auth-frame iframe {
  display: block;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 520px;
  border: 0;
  background: #fff;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.provider-card { display: grid; gap: 12px; padding: 14px; }
.provider-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.provider-card h2 { font-size: 17px; }
.badge {
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef2f6;
  color: #354252;
  font-size: 12px;
  font-weight: 700;
}
.badge.ok { background: #eaf7f0; color: var(--green); }
.badge.warn { background: #fff5df; color: var(--orange); }
.badge.bad { background: #fff0f0; color: var(--red); }
.provider-card p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions a,
.actions button {
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #25313b;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 700;
}
.actions a.primary-link,
.actions button.primary-link { border-color: var(--blue); background: var(--blue); color: #fff; }

.table-wrap { overflow: hidden; }
.table-wrap header {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
}
.table-wrap header a { color: var(--blue); font-weight: 700; font-size: 13px; }
.table { display: grid; overflow: auto; }
.row {
  min-width: 860px;
  display: grid;
  grid-template-columns: 110px minmax(220px, 1fr) 108px 120px 140px 80px 178px;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border-bottom: 1px solid #edf1f5;
  padding: 0 14px;
}
.row.head {
  min-height: 36px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.row span, .row b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.delete-row,
.rename-row {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #25313b;
  font-size: 12px;
  font-weight: 800;
}
.delete-row {
  border-color: #ffd1d1;
  background: #fff8f8;
  color: var(--red);
}
.rename-row:hover { background: #f4f8fc; }
.delete-row:hover { background: #fff0f0; }
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.row-actions a {
  color: var(--blue);
  font-weight: 800;
  font-size: 12px;
  text-decoration: none;
}
.empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

@media (max-width: 1000px) {
  .page { grid-template-columns: 56px minmax(0, 1fr); }
  .rail { padding-inline: 4px; }
  .rail-item { width: 48px; }
  .topbar, .summary, .runtime, .catalog-grid, .catalog-status-grid, .catalog-web-row, .catalog-web-new, .catalog-file-row, .cards { grid-template-columns: 1fr; }
  .catalog-card header { display: grid; }
  .catalog-auth-frame iframe {
    height: 70vh;
    min-height: 460px;
  }
}
