:root {
  --bg: #f8fafc;
  --bg-gradient: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08), transparent 25%), radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.08), transparent 25%);
  --panel: rgba(255, 255, 255, 0.7);
  --panel-border: rgba(255, 255, 255, 0.8);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #3b82f6; 
  --accent-strong: #1d4ed8;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --shadow: 0 10px 40px -10px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.6rem;
  border-bottom: 1px solid rgba(36, 46, 33, 0.08);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand a {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 1.1rem 1rem 2.4rem;
}

.hero,
.grid-two,
.stats-grid {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.hero {
  grid-template-columns: 1fr auto;
  align-items: end;
}

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

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.page-bottom-grid {
  margin-top: 0.9rem;
}

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(95, 64, 40, 0.18);
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-strong);
  font-size: 0.84rem;
  line-height: 1;
}

.chip-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.compact-actions {
  gap: 0.4rem;
  flex-wrap: nowrap;
  align-items: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px -10px rgba(15, 23, 42, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.9) inset;
}

.panel-wide {
  padding: 0.75rem 0.9rem;
}

.panel.narrow {
  max-width: 440px;
  margin: 3rem auto;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 118px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.stat-label {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.stat-value {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.section-head form {
  margin: 0;
}

.section-title-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.compact-head {
  margin-bottom: 0.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.form-grid label,
.inline-form,
.inline-mini-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.inline-form,
.inline-mini-form {
  flex-direction: row;
  align-items: center;
}

.inline-mini-form {
  gap: 0.35rem;
}

.inline-mini-form input {
  min-width: 78px;
}

.full {
  grid-column: 1 / -1;
}

input,
textarea,
button,
.button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(36, 46, 33, 0.14);
  background: rgba(255, 255, 255, 0.94);
}

textarea {
  resize: vertical;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.button:hover, button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.button-secondary {
  background: rgba(241, 245, 249, 0.9);
  color: #475569;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  border: 1px solid rgba(203, 213, 225, 0.5);
}

.button-secondary:hover {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.button-danger {
  background: var(--danger);
  box-shadow: 0 4px 12px var(--danger-soft);
}

.button-danger:hover {
  background: #dc2626;
  box-shadow: 0 6px 16px var(--danger-soft);
}

.button:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.is-loading,
button.is-loading {
  opacity: 0.75;
}

.button-small {
  padding: 0.34rem 0.62rem;
  font-size: 0.84rem;
}

.button-link {
  background: transparent;
  color: var(--text);
  padding: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  overflow-x: auto;
}

.table th,
.table td {
  padding: 0.4rem 0.4rem;
  border-bottom: 1px solid rgba(36, 46, 33, 0.08);
  text-align: left;
  vertical-align: middle;
  line-height: 1.2;
}

.campaign-table {
  min-width: 1380px;
  table-layout: fixed;
}

.campaign-table .col-name {
  width: 12%;
}

.campaign-table .col-select {
  width: 5%;
}

.campaign-table .col-customer {
  width: 9%;
}

.campaign-table .col-url {
  width: 24%;
}

.campaign-table .col-frequency {
  width: 10%;
}

.campaign-table .col-status {
  width: 9%;
}

.campaign-table .col-toggle {
  width: 7%;
}

.campaign-table .col-history {
  width: 8%;
}

.campaign-table .col-actions {
  width: 16%;
}

.campaign-table th,
.campaign-table td {
  white-space: nowrap;
}

.compact-table th,
.compact-table td {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.truncate {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.truncate-inline {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.url-cell {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  min-width: 0;
  max-width: 100%;
}

.cell-nowrap {
  white-space: nowrap;
}

.checkbox-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.checkbox-cell input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.history-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.muted,
.micro {
  color: var(--muted);
}

.micro {
  font-size: 0.8rem;
}

.button-row form,
.history-cell form {
  margin: 0;
}

.alert {
  margin-bottom: 0.9rem;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: rgba(135, 100, 69, 0.15);
}

.alert-success {
  background: rgba(21, 128, 61, 0.14);
  color: var(--success);
}

.alert-warning {
  background: rgba(135, 100, 69, 0.15);
  color: var(--accent-strong);
}

.alert-error {
  background: rgba(180, 35, 24, 0.16);
  color: var(--danger);
}

.detail-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0.35rem 0.8rem;
}

.detail-grid dt {
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-on {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(16, 185, 129, 0.2);
}

.status-off {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.2);
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: currentColor;
}

.browser-run + .browser-run {
  margin-top: 1rem;
}

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.16rem;
  border-radius: 999px;
  background: rgba(95, 64, 40, 0.16);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  position: relative;
}

.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.55rem);
  transform: translateX(-50%);
  width: 250px;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(34, 49, 31, 0.96);
  color: #f7f4ee;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.help-tip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

.icon-button {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 1px solid rgba(36, 46, 33, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  position: relative;
  cursor: pointer;
}

.refresh-button::before {
  content: "\21BB";
  font-size: 1rem;
  line-height: 1;
  color: var(--accent-strong);
}

.refresh-button.is-loading::before {
  animation: refresh-spin 0.85s linear infinite;
}

.refresh-button.is-error::before {
  content: "!";
  color: var(--danger);
  font-weight: 700;
}

.copy-button::before,
.copy-button::after,
.modal-close::before,
.modal-close::after {
  content: "";
  position: absolute;
}

.copy-button::before {
  top: 0.5rem;
  left: 0.62rem;
  width: 0.62rem;
  height: 0.72rem;
  border: 1.4px solid var(--accent-strong);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.92);
}

.copy-button::after {
  top: 0.36rem;
  left: 0.46rem;
  width: 0.62rem;
  height: 0.72rem;
  border: 1.4px solid rgba(95, 64, 40, 0.45);
  border-radius: 2px;
  background: transparent;
}

.copy-button.copied {
  background: var(--success-soft);
}

.modal-close::before,
.modal-close::after {
  top: 0.48rem;
  left: 0.9rem;
  width: 1px;
  height: 0.9rem;
  background: var(--accent-strong);
}

.modal-close::before {
  transform: rotate(45deg);
}

.modal-close::after {
  transform: rotate(-45deg);
}

.modal-shell {
  width: min(1180px, 92vw);
  max-height: 84vh;
  border: none;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.18);
}

.modal-shell::backdrop {
  background: rgba(25, 30, 28, 0.42);
}

.modal-confirm-shell {
  width: min(480px, 92vw);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(36, 46, 33, 0.08);
  background: rgba(247, 240, 230, 0.9);
}

.modal-body {
  padding: 1rem;
  overflow: auto;
}

.modal-section + .modal-section {
  margin-top: 1rem;
}

.modal-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.modal-loading {
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
}

.confirm-message {
  margin: 0 0 1rem;
  line-height: 1.6;
}

.confirm-actions {
  justify-content: flex-end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

pre {
  overflow: auto;
  padding: 1rem;
  border-radius: 14px;
  background: rgba(33, 41, 30, 0.95);
  color: #ecf2e8;
}

@keyframes refresh-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .hero,
  .grid-two,
  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .nav,
  .inline-form,
  .inline-mini-form {
    flex-direction: column;
    align-items: flex-start;
  }

  .truncate,
  .truncate-inline {
    max-width: 100%;
  }
}
