/* ── Page shell ─────────────────────────────────────────────────────────── */
.ipt-page {
  box-sizing: border-box;
  max-width: 100rem;
  width: 100%;
  margin: 0 auto;
  padding: 2.25rem clamp(1rem, 3vw, 2.5rem) 4rem;
  background: #fff;
}

.ipt-hero { margin-bottom: 2rem; }

.ipt-hero h1 {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: clamp(1.75rem, 2.5vw, 2.25rem);
  font-weight: 700;
  color: #111827;
  margin: 0 0 0.6rem;
  line-height: 1.25;
}

.ipt-hero p {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: #6b7280;
  max-width: 52rem;
}

/* ── Toolbar row (filters + search) ───────────────────────────────────── */
.ipt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.ipt-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 10rem;
}

.ipt-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ipt-field select,
.ipt-field input[type="text"],
.ipt-field input[type="date"] {
  padding: 0.4rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #111827;
  background: #fff;
  height: 2.25rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}

.ipt-field select:focus,
.ipt-field input[type="text"]:focus,
.ipt-field input[type="date"]:focus {
  border-color: #5573df;
  box-shadow: 0 0 0 3px rgba(85,115,223,.15);
}

.ipt-date-range {
  display: none;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}
.ipt-date-range.visible { display: flex; }
.ipt-date-range span { font-size: 0.8rem; color: #6b7280; }

.ipt-btn-reset {
  padding: 0 1rem;
  height: 2.25rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: #fff;
  color: #374151;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  align-self: flex-end;
}
.ipt-btn-reset:hover { background: #f3f4f6; border-color: #9ca3af; }

/* ── RIR Tabs ──────────────────────────────────────────────────────────── */
.ipt-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0;
}

.ipt-tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ipt-tab:hover { color: #3548ab; }
.ipt-tab.active {
  color: #3548ab;
  border-bottom-color: #3548ab;
  font-weight: 600;
}

/* ── Status bar ────────────────────────────────────────────────────────── */
.ipt-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  color: #6b7280;
}

.ipt-status-count { font-weight: 600; color: #374151; }

.ipt-last-updated {
  font-size: 0.8125rem;
  color: #9ca3af;
}

/* ── Loading / error / empty states ───────────────────────────────────── */
.ipt-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #374151;
  font-size: 0.9375rem;
  background: #fff;
}
.ipt-state p { margin: 0; }
.ipt-state-error { color: #ef4444; }

/* Inter-RIR badge */
.ipt-inter-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #6d28d9;
  background: #ede9fe;
  border-radius: 0.25rem;
  padding: 0.1rem 0.35rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  white-space: nowrap;
  letter-spacing: 0;
  text-transform: none;
}

/* ── Table scroll wrapper ──────────────────────────────────────────────── */
.ipt-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.75rem;
  border: 1px solid #eef0f3;
}

/* ── Tabulator overrides ───────────────────────────────────────────────── */
#ipt-table .tabulator {
  border: none !important;
  border-radius: 0;
  box-shadow: none !important;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  background: #fff;
  overflow: hidden;
}

#ipt-table .tabulator-tableHolder {
  border: none !important;
  background: #fff !important;
}

#ipt-table .tabulator-placeholder {
  border: none !important;
  background: #fff !important;
}

#ipt-table .tabulator-header {
  background: #fafbfc;
  border-bottom: 1px solid #eef0f3;
  border-top: none;
  border-radius: 0.75rem 0.75rem 0 0;
}

/* Remove outer col padding; set it on col-content so left edge
   aligns exactly with the 0.75rem padding on data cells. */
#ipt-table .tabulator-col {
  background: #fafbfc;
  border-right: 1px solid #e5e7eb !important;
  padding: 0 !important;
  height: auto !important;
}

#ipt-table .tabulator-col:last-child {
  border-right: none !important;
}

#ipt-table .tabulator-col .tabulator-col-content {
  padding: 0.5rem 0.75rem !important;
  box-sizing: border-box;
  height: auto !important;
}

/* Sort arrow sits immediately after the column title text.
   flex: 0 1 auto makes the title take only its natural text width
   (it can shrink, but not grow), so the sort icon follows right after. */
#ipt-table .tabulator-col-title-holder {
  display: flex !important;
  justify-content: flex-start !important;
  align-items: center !important;
  overflow: hidden !important;
  gap: 4px;
}

#ipt-table .tabulator-col-title {
  flex: 0 1 auto !important;
  width: auto !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-weight: 600;
  font-size: 0.8125rem;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

/* Long org-column headers wrap to a second line so they never truncate.
   All other (short) column headers stay on a single line. */
#ipt-table .tabulator-col[tabulator-field="so"] .tabulator-col-title-holder,
#ipt-table .tabulator-col[tabulator-field="ro"] .tabulator-col-title-holder {
  overflow: visible !important;
  flex-wrap: wrap;
  align-items: flex-start !important;
}

#ipt-table .tabulator-col[tabulator-field="so"] .tabulator-col-title,
#ipt-table .tabulator-col[tabulator-field="ro"] .tabulator-col-title {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: break-word;
}

#ipt-table .tabulator-col-sorter {
  flex: 0 0 auto !important;
  margin-left: 0 !important;
  align-self: center;
}

/* Dynamic row height — rows and cells must not have a fixed
   height so content (dates, long org names) never gets clipped. */
#ipt-table .tabulator-tableHolder .tabulator-table {
  height: auto !important;
}

#ipt-table .tabulator-row {
  border-bottom: 1px solid #f5f6f8;
  transition: background 0.1s;
  height: auto !important;
  min-height: 2.5rem;
}

#ipt-table .tabulator-row:last-child { border-bottom: none; }

#ipt-table .tabulator-row:hover { background: #f4f7ff; }

/* Cell padding matches col-content padding (same 0.75rem horizontal)
   so headers and values are perfectly left-aligned. */
#ipt-table .tabulator-row .tabulator-cell {
  padding: 0.6rem 0.75rem;
  color: #111827;
  border-right: none !important;
  white-space: normal;
  word-break: break-word;
  height: auto !important;
  align-items: flex-start;
  box-sizing: border-box;
}

#ipt-table .tabulator-cell[tabulator-field="b"] {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8125rem;
  color: #425AD6;
  white-space: nowrap;
}

/* ── Pagination ─────────────────────────────────────────────────────────── */
#ipt-table .tabulator-footer {
  background: #fafbfc;
  border-top: 1px solid #eef0f3;
  padding: 0.5rem 0.75rem;
  border-radius: 0 0 0.75rem 0.75rem;
}

/* Prevent page-number buttons from overlapping the prev/next arrows. */
#ipt-table .tabulator-footer .tabulator-footer-contents {
  display: flex !important;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 2rem;
}

#ipt-table .tabulator-paginator {
  display: inline-flex !important;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
}

#ipt-table .tabulator-pages {
  display: inline-flex !important;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
}

#ipt-table .tabulator-page {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  border: 1px solid #eef0f3;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  line-height: 1;
  color: #374151;
  background: #fff;
  margin: 0;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

#ipt-table .tabulator-page:hover { background: #f5f6f8; border-color: #dde0e6; }

#ipt-table .tabulator-page.active {
  background: #425AD6;
  color: #fff;
  border-color: #425AD6;
}

#ipt-table .tabulator-page[data-page="prev"],
#ipt-table .tabulator-page[data-page="next"],
#ipt-table .tabulator-page[data-page="first"],
#ipt-table .tabulator-page[data-page="last"] {
  padding: 0.25rem 0.6rem;
}

#ipt-table .tabulator-page-size {
  font-size: 0.8125rem;
  padding: 0.2rem 1.75rem 0.2rem 0.5rem;
  border: 1px solid #eef0f3;
  border-radius: 0.375rem;
  cursor: pointer;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ipt-toolbar { flex-direction: column; align-items: stretch; }
  .ipt-field   { min-width: 0; }
  .ipt-tabs    { gap: 0; }
  .ipt-tab     { font-size: 0.8125rem; padding: 0.45rem 0.6rem; }
  .ipt-table-scroll { border-radius: 0.5rem; }
}
