/* DeedCoach console styles */
:root {
  --bg: #05060a;
  --bg-elevated: #0b0d15;
  --bg-hover: #151827;
  --border-subtle: #26293b;
  --topbar-height: 64px;
  --accent: #4f8bff;
  --accent-soft: rgba(79, 139, 255, 0.12);
  --accent-strong: #2f63d4;
  --danger: #ff4f6a;
  --text-main: #f2f4ff;
  --text-muted: #c3c7db;
  --text-soft: #8e94ae;
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.55);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --transition-fast: 150ms ease-out;
  --scrollbar-size: 6px;
  --scrollbar-thumb: #56597a;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #181c33 0, #04050b 55%);
  color: var(--text-main);
}

body {
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  min-height: var(--topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  background: linear-gradient(
    90deg,
    rgba(7, 8, 16, 0.96),
    rgba(7, 8, 16, 0.96)
  );
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

a.topbar-left {
  color: inherit;
  text-decoration: none;
}

a.topbar-left:hover {
  opacity: 0.95;
}

.logo-img {
  height: 32px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

.product-label {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-soft);
}

.product-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chip {
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(12, 13, 22, 0.9);
  font-size: 11px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #21c08b;
  box-shadow: 0 0 0 3px rgba(33, 192, 139, 0.35);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 20%, #ffffff, #a6b9ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #02030a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

/* Layout */
.page {
  flex: 1;
  display: grid;
  grid-template-columns: 380px minmax(0, 1.45fr) minmax(0, 0.95fr);
  grid-template-rows: max-content minmax(0, 1fr);
  grid-template-areas:
    "sidebar main detail"
    "preview main detail";
  gap: 18px;
  padding: 16px 20px 20px;
  height: calc(100vh - var(--topbar-height));
  min-height: 0;
  overflow: hidden;
}

.panel-sidebar { grid-area: sidebar; }
.panel-preview { grid-area: preview; }
.panel-main { grid-area: main; }
.panel-detail { grid-area: detail; }

.ads-settings-page .page {
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "sidebar main";
}

@media (max-width: 1100px) {
  .page {
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-rows: max-content minmax(0, 1fr) max-content;
    grid-template-areas:
      "sidebar main"
      "preview main"
      "preview detail";
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    align-content: start;
    align-items: start;
  }
  .panel-sidebar { grid-area: sidebar; }
  .panel-preview { grid-area: preview; }
  .panel-main { grid-area: main; }
  .panel-detail { grid-area: detail; }

  .ads-settings-page .page {
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: 1fr;
    grid-template-areas: "sidebar main";
    overflow: hidden;
  }

  .panel-main .table-wrapper {
    flex: 0 0 auto;
    height: clamp(320px, 52vh, 600px);
  }

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

@media (max-width: 800px) {
  .page {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .page > .panel {
    flex: 0 0 auto;
    width: 100%;
  }
  .panel {
    min-height: auto;
  }
  .panel-body {
    flex: 0 0 auto;
    min-height: auto;
  }
  .panel-main .table-wrapper {
    flex: 0 0 auto;
    height: min(62vh, 560px);
  }
}

.panel {
  background: radial-gradient(circle at top left, #15182a 0, #05060b 55%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow-soft);
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.panel-detail .panel-body {
  overflow-y: auto;
  padding-right: 2px;
}

.panel-preview .panel-body {
  overflow-y: auto;
  padding-right: 2px;
}

.panel-header-preview {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.preview-header-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.preview-header-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.preview-header-kicker .panel-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-soft);
}

.preview-header-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.preview-header-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-main);
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.panel-preview .edit-ad-button {
  align-self: flex-start;
  padding: 6px 10px;
  font-size: 10px;
  box-shadow: 0 6px 14px rgba(20, 81, 201, 0.45);
}

/* Settings page */
.ads-settings-page .panel-main .panel-body {
  overflow-y: auto;
  padding-right: 2px;
}

.settings-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-panel .form-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-soft);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.settings-nav-item:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.04);
  transform: translateY(-1px);
}

.settings-nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(79, 139, 255, 0.7);
  color: var(--text-main);
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.settings-actions .btn {
  width: 100%;
  justify-content: center;
}

/* Sidebar – service & state/county */

.service-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.service-tab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-soft);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.service-tab:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.04);
  transform: translateY(-1px);
}

.service-tab.active {
  background: var(--accent-soft);
  border-color: rgba(79, 139, 255, 0.7);
  color: var(--text-main);
}

.service-pill { display: none; }

.sidebar-divider {
  margin: 6px 0;
  border-top: 1px solid var(--border-subtle);
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.select {
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(6, 7, 13, 0.96);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  appearance: none;
  position: relative;
}

.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.4);
}

.state-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.state-filter {
  position: relative;
}

.state-button {
  width: auto;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  text-transform: none;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 6px;
}

.state-bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 6px;
}

.state-bulk-btn {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
}

.state-bulk-btn:hover {
  color: var(--text-main);
}

.state-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: -16px;
  right: -16px;
  background: rgba(10, 12, 22, 0.98);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  padding: 8px;
  display: none;
  max-height: 240px;
  min-width: 240px;
  overflow: auto;
  z-index: 30;
}

.state-filter.open .state-dropdown {
  display: block;
}

.state-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-main);
  text-transform: none;
}

.state-option:hover {
  background: rgba(255, 255, 255, 0.04);
}

.county-list {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-md);
  background: rgba(4, 6, 15, 0.95);
  border: 1px solid var(--border-subtle);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #050714;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}

.input::placeholder {
  color: var(--text-soft);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.35);
}

.county-scroll {
  flex: 1;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: #56597a transparent;
}

.county-scroll::-webkit-scrollbar {
  width: 6px;
}

.county-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.county-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

.county-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.county-row:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
  transform: translateY(-0.5px);
}

.county-row.active {
  background: var(--accent-soft);
  color: var(--text-main);
}

.county-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.county-tag {
  font-size: 11px;
  color: var(--text-soft);
}

.badge { display: none; }

.badge-sponsored {
  display: none;
}

/* Main panel – coverage table */

.bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.currency-input-wrapper {
  display: inline-flex;
  align-items: center;
  background: rgba(7, 8, 16, 0.96);
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 4px 6px;
  gap: 6px;
}

.currency-input-wrapper span {
  font-size: 12px;
  color: var(--text-soft);
}

.num-btn {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1px solid rgba(79, 139, 255, 0.35);
  background: linear-gradient(135deg, rgba(79, 139, 255, 0.2), rgba(47, 99, 212, 0.25));
  color: #dfe7ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
  box-shadow: 0 4px 12px rgba(20, 81, 201, 0.35);
}

.num-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(79, 139, 255, 0.35), rgba(47, 99, 212, 0.35));
  border-color: rgba(79, 139, 255, 0.6);
  box-shadow: 0 6px 16px rgba(20, 81, 201, 0.55);
}

.num-btn:active {
  transform: translateY(0);
}

.num-btn.ghost {
  background: rgba(79, 139, 255, 0.08);
  box-shadow: none;
}

.currency-input {
  width: 70px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

.currency-input::-webkit-outer-spin-button,
.currency-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.btn {
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fdfdff;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(20, 81, 201, 0.6);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(20, 81, 201, 0.75);
}

.btn-outline {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-subtle);
  box-shadow: none;
}

.btn-outline:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.02);
}

.table-wrapper {
  flex: 1;
  min-height: 0;
  --table-scrollbar-width: 0px;
  --coverage-table-columns:
    22px
    minmax(180px, 1.5fr)
    minmax(90px, 120px)
    minmax(110px, max-content)
    minmax(130px, max-content)
    minmax(90px, max-content)
    minmax(90px, max-content);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: rgba(5, 7, 16, 0.96);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.table-header {
  border-bottom: 1px solid var(--border-subtle);
}

.table-header-inner {
  display: grid;
  grid-template-columns: var(--coverage-table-columns);
  gap: 6px;
  padding: 8px 8px;
  padding-right: calc(8px + var(--table-scrollbar-width, 0px));
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  align-items: center;
  will-change: transform;
}

.table-header-inner > *,
.row > * {
  min-width: 0;
}

.table-body {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  /* Prevent browser scroll anchoring fighting virtualization spacers. */
  overflow-anchor: none;
  scrollbar-width: thin;
  scrollbar-color: #56597a transparent;
}

.virtual-window {
  overflow-anchor: none;
}

.table-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-body::-webkit-scrollbar-thumb {
  background: #56597a;
  border-radius: 999px;
}

.row {
  display: grid;
  grid-template-columns: var(--coverage-table-columns);
  gap: 6px;
  padding: 7px 8px;
  height: 46px;
  font-size: 12px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.row.section-header {
  background: rgba(8, 10, 20, 0.95) !important;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.row.section-header:hover {
  background: rgba(12, 14, 26, 0.95);
  transform: none;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-chevron {
  font-size: 11px;
  opacity: 0.8;
}

.row:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

.row:hover {
  background: rgba(255, 255, 255, 0.02);
  transform: translateY(-0.5px);
}

.row.selected {
  background: rgba(79, 139, 255, 0.08);
}

.row.active-county {
  box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.35);
  background: rgba(79, 139, 255, 0.06);
}

.row.error {
  background: rgba(255, 79, 106, 0.06);
  border-color: rgba(255, 79, 106, 0.25);
}

.row.disabled {
  /* Inactive rows use the status toggle/pill for affordance;
     keep visual weight the same as active rows. */
}

.row label {
  cursor: pointer;
}

.row-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.state-cell {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: center;
}

.status-header {
  display: inline-flex;
  align-items: center;
  justify-self: stretch;
  width: 100%;
  justify-content: center;
}

.status-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-pill.active {
  background: rgba(33, 192, 139, 0.12);
  border-color: rgba(33, 192, 139, 0.45);
  color: #b9f4de;
}

.status-pill.inactive {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-soft);
}

.coverage-toggle {
  appearance: none;
  width: 30px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.coverage-toggle::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-soft);
  transition: left var(--transition-fast), background var(--transition-fast);
}

.coverage-toggle:checked {
  background: var(--accent-soft);
  border-color: rgba(79, 139, 255, 0.7);
}

.coverage-toggle:checked::after {
  left: 15px;
  background: var(--accent);
}

.bid-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
}

.bid-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #02040c;
}

.bid-control-placeholder {
  justify-content: center;
  min-width: 108px; /* matches minus + input + plus width */
  color: var(--text-soft);
  border-style: dashed;
  background: transparent;
}

.last-cell {
  justify-self: center;
  min-width: 9ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bid-input {
  width: 56px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: #050914;
  color: var(--text-main);
  font-size: 12px;
  padding: 5px 6px;
  outline: none;
  text-align: right;
  appearance: textfield;
  -moz-appearance: textfield;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.bid-input::placeholder {
  color: var(--text-soft);
}

.bid-input.wide {
  width: 96px;
}

.bid-input::-webkit-outer-spin-button,
.bid-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.bid-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.35);
  background-color: #0a0d1b;
}

.last-month {
  font-size: 11px;
  color: var(--text-soft);
}

.last-month strong {
  color: #d2d5ff;
}

.sortable {
  background: transparent;
  border: none;
  color: inherit;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  transition: color var(--transition-fast);
}

.sortable:hover {
  color: var(--text-main);
}

.metric-cell {
  justify-self: center;            /* center the number block within column */
  min-width: 6ch;                 /* keep right edge consistent */
  text-align: right;              /* line digits up cleanly */
  font-variant-numeric: tabular-nums;
}

.table-header #sortImpressions,
.table-header #sortClicks {
  justify-self: stretch;
  width: 100%;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 0 14px; /* reserve space for absolute sort indicator */
}

.table-header #sortBid,
.table-header #sortLast {
  justify-self: stretch;
  width: 100%;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 0 14px;
}

.table-header #sortImpressions .sort-indicator,
.table-header #sortClicks .sort-indicator,
.table-header #sortBid .sort-indicator,
.table-header #sortLast .sort-indicator {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.sort-indicator {
  font-size: 12px;
  color: var(--text-soft);
}

.pill-soft {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.hint {
  font-size: 11px;
  color: var(--text-muted);
}

.current-bid {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.current-bid strong {
  color: #dfe7ff;
}

.current-bid-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.bid-limit-row {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bid-limit-label {
  white-space: nowrap;
}

.bid-limit-prefix {
  font-size: 12px;
  color: var(--text-soft);
  padding-left: 2px;
}

.edit-ad-button {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fdfdff;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 18px rgba(20, 81, 201, 0.6);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.edit-ad-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(20, 81, 201, 0.75);
}

/* Detail panel – preview & metrics */

.detail-sections {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.detail-sections > .preview-card,
.detail-sections > .metrics-card {
  flex-shrink: 0;
}

.preview-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top, #171b33 0, #05060b 65%);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.preview-header-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.preview-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.preview-top-box {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(4, 6, 15, 0.88);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.preview-top-box .ad-slot-plain {
  margin-top: 0;
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(6, 9, 24, 0.92);
  padding: 7px 8px;
  opacity: 0.96;
}

.preview-top-box .ad-slot-plain .ad-slot-rank {
  border-color: rgba(255, 255, 255, 0.14);
}

.ad-slot {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 7px 8px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: rgba(6, 9, 24, 0.96);
  position: relative;
}

.ad-slot:nth-child(1) {
  box-shadow: 0 0 0 1px rgba(255, 226, 150, 0.3),
    0 10px 24px rgba(0, 0, 0, 0.7);
  background: radial-gradient(circle at top left, #2a2240 0, #040412 55%);
}

.ad-slot-rank {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-soft);
  background: radial-gradient(circle at 30% 20%, #ffffff, #c9d2ff);
  align-self: center;
}

.ad-slot-rank-inline {
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  min-width: 18px;
  padding: 0 6px;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(-0.5px);
  flex: 0 0 auto;
}

.ad-slot-rank-inline[data-rank="1"] {
  background: rgba(255, 226, 150, 0.12);
  border-color: rgba(255, 226, 150, 0.24);
  color: #ffe1ad;
}

.ad-slot-rank-inline[data-rank="2"] {
  background: rgba(79, 139, 255, 0.12);
  border-color: rgba(79, 139, 255, 0.26);
  color: #dbe6ff;
}

.ad-slot-rank-inline[data-rank="3"] {
  background: rgba(165, 131, 255, 0.11);
  border-color: rgba(165, 131, 255, 0.24);
  color: #eadbff;
}

.ad-slot-rank-inline[data-rank="4+"] {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
}

.ad-slot-plain {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(12, 14, 20, 0.8);
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 6px;
  opacity: 0.85;
}

.ad-slot-plain .ad-slot-rank {
  background: #0f1220;
  color: var(--text-soft);
  border-color: rgba(255, 255, 255, 0.05);
}

.ad-slot-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: flex-start;
}

.ad-slot-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ad-slot-tagline {
  font-size: 11px;
  color: #e5e8ff;
  line-height: 1.35;
  height: auto;
  white-space: nowrap;
  word-break: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.ad-slot-contact {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-slot-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.slot-cta {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: #fdfdff;
  background: transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
  transition: transform var(--transition-fast), background var(--transition-fast),
    border-color var(--transition-fast), box-shadow var(--transition-fast),
    color var(--transition-fast);
}

.slot-cta-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.slot-cta-label {
  flex: 0 0 auto;
}

.slot-cta-secondary {
  border-color: rgba(79, 139, 255, 0.65);
  background: rgba(79, 139, 255, 0.12);
}

.slot-cta-secondary:hover {
  border-color: rgba(79, 139, 255, 0.85);
  background: rgba(79, 139, 255, 0.18);
  box-shadow: 0 8px 18px rgba(20, 81, 201, 0.22);
  transform: translateY(-0.5px);
}

.slot-cta:active {
  transform: translateY(0.5px);
}

.slot-cta:focus-visible {
  outline: 2px solid rgba(79, 139, 255, 0.55);
  outline-offset: 2px;
}

.slot-cta[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.slot-cta-primary {
  background: linear-gradient(
    135deg,
    rgba(79, 139, 255, 0.95),
    rgba(47, 99, 212, 0.95)
  );
  border-color: rgba(79, 139, 255, 0.65);
  color: #fdfdff;
  box-shadow: 0 8px 18px rgba(20, 81, 201, 0.35);
}

.slot-cta-primary:hover {
  border-color: rgba(79, 139, 255, 0.85);
  box-shadow: 0 10px 22px rgba(20, 81, 201, 0.45);
  transform: translateY(-0.5px);
}

.metrics-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(5, 7, 17, 0.97);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  font-size: 11px;
}

@media (max-width: 480px) {
  .metrics-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.metric {
  padding: 6px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-soft);
  margin-bottom: 3px;
}

.metric-value {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-soft);
}

.empty-state {
  font-size: 12px;
  color: var(--text-soft);
  padding: 18px 6px;
  text-align: center;
}

.logo-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 10px;
  color: #fdfdff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  max-width: 120px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.bid-changer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.num-btn.small {
  width: 22px;
  height: 22px;
  font-size: 12px;
  padding: 0;
}

/* Info tooltip */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 10px;
  color: var(--text-soft);
  cursor: default;
  position: relative;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 130%;
  width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #020308;
  color: var(--text-main);
  font-size: 11px;
  line-height: 1.4;
  border: 1px solid var(--border-subtle);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  pointer-events: none;
}
.info-icon:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Trending icons */
.trend-icon {
  margin-left: 4px;
  font-size: 12px;
}
.trend-icon.up { color: #21c08b; }
.trend-icon.down { color: #ff4f6a; transform: rotate(180deg); }

.edit-chip {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: #d9e4ff;
  font-size: 10px;
  padding: 4px 8px;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  line-height: 1;
}

.edit-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.ad-slot .edit-chip {
  position: absolute;
  top: 8px;
  right: 8px;
}

.ad-slot-plain .edit-chip {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 100;
}

.modal {
  background: #0c0f1b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  padding: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-soft);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-grid .field-label {
  margin-bottom: 4px;
}

.contact-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.service-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(6, 7, 13, 0.96);
  font-size: 13px;
  cursor: pointer;
}

.service-toggle:hover {
  background: rgba(255, 255, 255, 0.02);
}

.service-toggle input {
  margin: 0;
}

.service-toggle input:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.service-toggle input:disabled ~ span {
  color: var(--text-soft);
}

#accountServicesList {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.member-row {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 8px;
  align-items: end;
}

.admin-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-entry {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(6, 7, 13, 0.96);
}

.modal-backdrop .modal .btn {
  max-width: 100%;
}

@media (max-width: 720px) {
  .contact-row {
    grid-template-columns: 1fr;
  }

  .admin-row,
  .member-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .member-entry {
    grid-template-columns: 1fr;
  }
}

.member-entry-label {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.25;
}

.member-entry-role {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(9, 10, 18, 0.95);
  color: var(--text-main);
  outline: none;
}

.member-entry-role:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.admin-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(6, 7, 13, 0.96);
  color: var(--text-soft);
  font-size: 12px;
}

.input-rect {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(9, 10, 18, 0.95);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.input-rect:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.4);
}

.modal-preview-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  background: rgba(8, 10, 20, 0.9);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
