/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}
.page-heading {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.page-subheading { font-size: 14px; color: var(--text-muted); }

.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--accent-dim);
  box-shadow: 0 1px 4px rgba(13,148,136,0.4);
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-new:hover {
  background: var(--accent-dim);
  box-shadow: 0 2px 10px rgba(13,148,136,0.5);
  transform: translateY(-1px);
}

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 28px;
}
.stat-card { background: var(--bg-surface); padding: 18px 22px; }
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-primary);
}
.stat-delta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ── Tabs ── */
.tab-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 450;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.1s;
}
.tab-item:hover { color: var(--text-secondary); }
.tab-item.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-bright);
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 6px;
  height: 18px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 20px;
}
.tab-item.active .tab-count {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dim);
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  width: 220px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-primary);
  width: 100%;
  font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }

/* ── Dropdown filter chip ── */
.filter-dropdown { position: relative; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.1s;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--bg-muted); background: var(--bg-overlay); color: var(--text-primary); }
.filter-chip.has-value {
  border-color: var(--accent);
  color: var(--accent-bright);
  background: var(--accent-glow);
}
.filter-chip .chevron {
  opacity: 0.6;
  transition: transform 0.15s;
}
.filter-chip.open .chevron { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 150;
  overflow: hidden;
  padding: 4px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-secondary);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.1s;
}
.dropdown-item:hover { background: var(--bg-overlay); color: var(--text-primary); }
.dropdown-item.selected { color: var(--accent-bright); }
.dropdown-item .check {
  opacity: 0;
  color: var(--accent);
}
.dropdown-item.selected .check { opacity: 1; }
.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}
.dropdown-clear {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.1s;
}
.dropdown-clear:hover { color: var(--red); background: var(--red-bg); }

/* ── Filter right side ── */
.filter-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.results-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.sort-dropdown { position: relative; }
.sort-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.1s;
  white-space: nowrap;
}
.sort-chip:hover { border-color: var(--bg-muted); background: var(--bg-overlay); color: var(--text-primary); }
.sort-chip .chevron { opacity: 0.6; transition: transform 0.15s; }
.sort-chip.open .chevron { transform: rotate(180deg); }

/* ── Table ── */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}
.table-wrap thead tr {
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border);
}
.table-wrap th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
}
.th-sortable { cursor: pointer; }
.th-sortable:hover { color: var(--text-secondary); }
.th-sortable.sort-active { color: var(--text-secondary); }
.sort-arrow { margin-left: 4px; opacity: 0.5; font-size: 11px; }
.sort-arrow.active { opacity: 1; color: var(--accent-bright); }

.table-wrap tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
}
.table-wrap tbody tr:last-child { border-bottom: none; }
.table-wrap tbody tr:hover { background: var(--bg-overlay); }
.table-wrap td { padding: 14px 16px; vertical-align: middle; }

.op-name { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; font-weight: 500; color: var(--text-primary); }
.op-display { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid;
  letter-spacing: 0.02em;
}
.badge-rest    { color: var(--blue);   background: var(--blue-bg);   border-color: var(--blue-border);   }
.badge-graphql { color: var(--purple); background: var(--purple-bg); border-color: var(--purple-border); }
.badge-grpc    { color: #14b8a6;       background: rgba(13,148,136,0.1); border-color: rgba(13,148,136,0.25); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-active   { color: var(--green); background: var(--green-bg); }
.status-active   .status-dot { background: var(--green); box-shadow: 0 0 0 2px rgba(63,185,80,0.2); }
.status-draft    { color: var(--amber); background: var(--amber-bg); }
.status-draft    .status-dot { background: var(--amber); }
.status-error    { color: var(--red);   background: var(--red-bg);   }
.status-error    .status-dot { background: var(--red); box-shadow: 0 0 0 2px rgba(248,81,73,0.2); }
.status-inactive { color: var(--text-muted); background: var(--bg-overlay); }
.status-inactive .status-dot { background: var(--text-muted); }

.target-url-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.target-url-cell a { color: inherit; text-decoration: none; }
.target-url-cell svg { flex-shrink: 0; opacity: 0.5; }

.date-cell { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.row-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.row-btn {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 12.5px;
  color: var(--text-secondary);
  transition: all 0.1s;
}
.row-btn:hover { border-color: var(--bg-muted); color: var(--text-primary); background: var(--bg-overlay); }
.row-btn.danger:hover { border-color: var(--red-border); color: var(--red); background: var(--red-bg); }

.row-btn-edit {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

/* ── Empty state ── */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; }

/* ── Table footer / pagination ── */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-canvas);
}
.table-footer-info { font-size: 13px; color: var(--text-muted); }

.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}
.page-btn:hover:not(:disabled) { border-color: var(--bg-muted); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent-dim); font-weight: 600; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Banner ── */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: rgba(13,148,136,0.07);
  border: 1px solid rgba(13,148,136,0.2);
  color: var(--accent-bright);
  font-size: 13.5px;
  margin-bottom: 24px;
}
.banner-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent-bright);
  font-size: 16px;
  opacity: 0.6;
  line-height: 1;
}
.banner-close:hover { opacity: 1; }

/* ═══════════════ RESPONSIVE ═══════════════ */

/* Tablet: ≤ 960px */
@media (max-width: 960px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .col-url { display: none; }
  .results-count { display: none; }
}

/* Narrow / mobile: ≤ 720px */
@media (max-width: 720px) {
  /* --- Скрываем колонку CREATED --- */
  .col-created { display: none; }

  /* --- Filter bar → grid --- */
  .filter-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  /* Search во всю ширину */
  .search-box {
    grid-column: 1 / -1;
    width: 100%;
  }
  /* Каждый dropdown занимает ячейку */
  .filter-dropdown {
    width: 100%;
  }
  .filter-chip {
    width: 100%;
    justify-content: space-between;
  }
  /* Sort справа, во всю строку */
  .filter-right {
    grid-column: 1 / -1;
    margin-left: 0;
    justify-content: flex-end;
  }
  .sort-chip { white-space: nowrap; }

  /* action column compact */
  .row-actions { justify-content: center; }

  /* --- Таблица --- */
  .table-wrap td { padding: 12px 10px; }
  .table-wrap th { padding: 8px 10px; }
}

/* Mobile: ≤ 480px */
@media (max-width: 480px) {
  .tab-item { padding: 10px 8px; font-size: 13px; gap: 5px; }

  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .btn-new { width: 100%; justify-content: center; }

}

/* ── Active filter chips ── */
.active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 4px;
}
.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  background: rgba(13,148,136,0.12);
  border: 1px solid rgba(13,148,136,0.3);
  border-radius: 20px;
  font-size: 12px;
  color: var(--accent);
}
.active-filter-chip-remove {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  padding: 1px;
  cursor: pointer;
  color: var(--accent);
  opacity: 0.7;
  border-radius: 50%;
  transition: opacity 0.1s;
}
.active-filter-chip-remove:hover { opacity: 1; }
.active-filter-clear-all {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: color 0.1s;
}
.active-filter-clear-all:hover { color: var(--text-secondary); }

/* ── Operation agent badges ── */
.op-agent-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.op-agent-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 3px;
  color: #818cf8;
  white-space: nowrap;
}

/* ── Row delete button ── */
.row-btn-delete {
  color: var(--text-muted);
  transition: color 0.1s, background 0.1s;
}
.row-btn-delete:hover {
  color: var(--red, #f87171);
  background: rgba(248,113,113,0.08);
}
