/* ===== RESET & VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0b;
  --card:      #111113;
  --muted:     #18181b;
  --border:    rgba(255,255,255,0.08);
  --border-md: rgba(255,255,255,0.12);
  --text:      #fafafa;
  --text-muted:#a1a1aa;
  --text-dim:  #71717a;
  --green:     #4ade80;
  --yellow:    #facc15;
  --red:       #f87171;
  --blue:      #60a5fa;
  --purple:    #a78bfa;
  --green-bg:  rgba(74,222,128,0.08);
  --yellow-bg: rgba(250,204,21,0.08);
  --red-bg:    rgba(248,113,113,0.08);
  --blue-bg:   rgba(96,165,250,0.08);
  --radius-card: 14px;
  --radius-md:   10px;
  --radius-sm:   6px;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, 'Cascadia Code', monospace;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10,10,11,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 60px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(74,222,128,0.4);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.live-dot.offline { background: var(--red); box-shadow: none; animation: none; }

@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-sub {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.header-spacer { flex: 1; min-width: 40px; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 520px;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1 1 220px;
  max-width: 320px;
  min-width: 180px;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  flex-shrink: 0;
}

#searchInput {
  width: 100%;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  padding: 8px 36px 8px 36px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#searchInput::placeholder { color: var(--text-dim); }
#searchInput:focus { border-color: var(--border-md); background: #1c1c1f; }

.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  pointer-events: none;
}

/* ===== DATE PICKER (Bento-style) ===== */
.date-picker {
  position: relative;
  flex: 0 1 auto;
}
.date-picker.is-open {
  z-index: 120;
}

.date-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 280px;
  font-family: inherit;
}
.date-picker-trigger:hover,
.date-picker-trigger[aria-expanded="true"] {
  border-color: var(--border-md);
  color: var(--text);
  background: #1c1c1f;
}
.date-picker.has-value .date-picker-trigger {
  color: var(--text);
  border-color: rgba(96,165,250,0.25);
  background: rgba(96,165,250,0.06);
}
.date-picker-trigger svg:first-child { color: var(--text-dim); flex-shrink: 0; }
.date-picker-label {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 11px;
}
.date-picker-chevron {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.date-picker-trigger[aria-expanded="true"] .date-picker-chevron { transform: rotate(180deg); }

.date-picker-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  width: min(340px, calc(100vw - 32px));
}
.date-picker-popover.hidden { display: none; }

.date-picker-bento {
  border-radius: 20px;
  border: 1px solid var(--border-md);
  background: var(--card);
  padding: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
}
.date-picker-bento > .dp-panel {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
  box-shadow: inset 0 2px 1.5px rgba(165,174,184,0.12);
  padding: 14px;
}

.dp-side-tabs {
  display: flex;
  gap: 4px;
  padding: 4px 4px 8px;
}
.dp-side-tabs.hidden {
  display: none;
}
.dp-tab {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.dp-tab:hover { color: var(--text); border-color: var(--border-md); }
.dp-tab.active {
  background: rgba(96,165,250,0.12);
  border-color: rgba(96,165,250,0.3);
  color: var(--blue);
}

.dp-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dp-month-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.dp-nav {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}
.dp-nav:hover { color: var(--text); border-color: var(--border-md); background: rgba(255,255,255,0.06); }

.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.dp-weekdays span {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 4px 0;
}

.dp-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.dp-day-empty { height: 32px; }
.dp-day {
  height: 32px;
  width: 100%;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.dp-day:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.dp-day.today { box-shadow: inset 0 0 0 1px rgba(96,165,250,0.35); color: var(--blue); }
.dp-day.in-range { background: rgba(96,165,250,0.08); }
.dp-day.selected {
  background: rgba(96,165,250,0.85);
  color: #fff;
  box-shadow: 0 4px 14px rgba(96,165,250,0.35);
}

.dp-cal-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.dp-text-btn {
  border: none;
  background: none;
  color: var(--blue);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 2px;
  font-family: inherit;
}
.dp-text-btn:hover { text-decoration: underline; }

.dp-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.dp-time-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.dp-time-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
}
.dp-time-inputs input {
  width: 36px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}
.dp-time-inputs input::-webkit-outer-spin-button,
.dp-time-inputs input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dp-time-sep { color: var(--text-dim); font-family: var(--font-mono); }

.dp-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 6px 4px;
}
.dp-actions-right { display: flex; gap: 6px; }
.dp-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--muted);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.dp-btn:hover { color: var(--text); border-color: var(--border-md); }
.dp-btn-primary {
  background: rgba(96,165,250,0.15);
  border-color: rgba(96,165,250,0.35);
  color: var(--blue);
}
.dp-btn-primary:hover { background: rgba(96,165,250,0.25); }

/* ===== INFINITE SCROLL ===== */
.list-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 0 8px;
  color: var(--text-dim);
  font-size: 12px;
}
.scroll-sentinel {
  width: 100%;
  height: 1px;
}
.load-more-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.refresh-btn:hover { border-color: var(--border-md); color: var(--text); }
.refresh-btn svg { flex-shrink: 0; }
.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== DEMO BANNER ===== */
.demo-banner {
  background: rgba(250,204,21,0.08);
  border-bottom: 1px solid rgba(250,204,21,0.2);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--yellow);
}
.demo-banner.hidden { display: none; }

/* ===== STATS BAR ===== */
.stats-bar {
  padding: 16px 24px 0;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.stat-pill .num {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.stat-pill .num.green { color: var(--green); }
.stat-pill .num.red   { color: var(--red); }
.stat-pill .num.blue  { color: var(--blue); }
.stat-pill .num.yellow{ color: var(--yellow); }
.stat-sep { color: var(--text-dim); }

/* ===== FILTERS ===== */
.filters {
  padding: 12px 24px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--border-md); color: var(--text); }
.filter-chip.active {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: var(--text);
  font-weight: 500;
}
.filter-chip.active.s-success  { background: var(--green-bg);  border-color: rgba(74,222,128,0.3);  color: var(--green); }
.filter-chip.active.s-failed   { background: var(--red-bg);    border-color: rgba(248,113,113,0.3); color: var(--red); }
.filter-chip.active.s-duplicate{ background: var(--blue-bg);   border-color: rgba(96,165,250,0.3);  color: var(--blue); }
.filter-chip.active.s-skipped  { background: var(--yellow-bg); border-color: rgba(250,204,21,0.3);  color: var(--yellow); }
.filter-chip.active.s-queued   { background: var(--blue-bg);   border-color: rgba(96,165,250,0.3);  color: var(--blue); }
.filter-chip.active.s-error    { background: var(--red-bg);    border-color: rgba(248,113,113,0.3); color: var(--red); }
.filter-divider { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }

/* ===== COLUMN HEADERS ===== */
.list-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

.col-headers {
  display: grid;
  grid-template-columns: 44px 130px 82px 1fr 80px 180px 72px 100px;
  gap: 0 12px;
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ===== WEBHOOK LIST ===== */
.webhook-list {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 40px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ===== WEBHOOK CARD ===== */
.wh-card {
  display: grid;
  grid-template-columns: 44px 130px 82px 1fr 80px 180px 72px 100px;
  gap: 0 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sc, var(--border-md));
  background: linear-gradient(90deg, var(--sg, transparent) 0%, transparent 35%);
  cursor: pointer;
  transition: border-color 0.15s, background 0.12s, transform 0.1s;
  position: relative;
}
.wh-card:hover {
  border-color: var(--border-md);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Status color vars */
.wh-card.s-success   { --sc: var(--green);  --sg: rgba(74,222,128,0.06); }
.wh-card.s-duplicate { --sc: var(--blue);   --sg: rgba(96,165,250,0.06); }
.wh-card.s-skipped   { --sc: var(--yellow); --sg: rgba(250,204,21,0.06); }
.wh-card.s-queued    { --sc: var(--blue);   --sg: rgba(96,165,250,0.06); }
.wh-card.s-processing{ --sc: var(--blue);   --sg: rgba(96,165,250,0.06); }
.wh-card.s-failed    { --sc: var(--red);    --sg: rgba(248,113,113,0.06); }
.wh-card.s-error     { --sc: var(--red);    --sg: rgba(248,113,113,0.06); }

.col-no {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-align: right;
}

.col-time {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
}

.flow-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.flow-badge.telegram { background: rgba(96,165,250,0.12); color: var(--blue); border: 1px solid rgba(96,165,250,0.2); }
.flow-badge.web      { background: rgba(167,139,250,0.12); color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }
.flow-badge.gift     { background: rgba(74,222,128,0.12); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }
.flow-badge.unknown  { background: rgba(255,255,255,0.05); color: var(--text-dim); border: 1px solid var(--border); }

.col-pid {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-amount {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text);
  white-space: nowrap;
}
.col-amount.dim { color: var(--text-dim); }

.col-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.user-tg {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--blue);
  white-space: nowrap;
}
.user-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-dur {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
  text-align: right;
}
.col-dur.slow { color: var(--yellow); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-badge.s-success   { background: var(--green-bg);  color: var(--green);  border: 1px solid rgba(74,222,128,0.25); }
.status-badge.s-duplicate { background: var(--blue-bg);   color: var(--blue);   border: 1px solid rgba(96,165,250,0.25); }
.status-badge.s-skipped   { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(250,204,21,0.25); }
.status-badge.s-queued    { background: var(--blue-bg);   color: var(--blue);   border: 1px solid rgba(96,165,250,0.25); }
.status-badge.s-processing{ background: var(--blue-bg);   color: var(--blue);   border: 1px solid rgba(96,165,250,0.25); }
.status-badge.s-failed    { background: var(--red-bg);    color: var(--red);    border: 1px solid rgba(248,113,113,0.25); }
.status-badge.s-error     { background: var(--red-bg);    color: var(--red);    border: 1px solid rgba(248,113,113,0.25); }

/* ===== EMPTY & LOADING ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  gap: 12px;
  color: var(--text-dim);
  text-align: center;
}
.empty-state svg { opacity: 0.3; }
.empty-state .empty-title { font-size: 16px; font-weight: 500; color: var(--text-muted); }
.empty-state .empty-sub { font-size: 13px; }

.skeleton {
  background: linear-gradient(90deg, var(--muted) 25%, #222225 50%, var(--muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.modal-backdrop.hidden { display: none; }

.modal {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-md);
  border-radius: 20px;
  width: 100%;
  max-width: 860px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  overflow: hidden;
  margin: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.modal-header-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.modal-header-left { flex: 1; min-width: 0; }

.modal-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.modal-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-meta .sep { color: var(--text-dim); }
.modal-meta .http-ok  { color: var(--green); }
.modal-meta .http-err { color: var(--red); }

.modal-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--muted);
  color: var(--text-muted);
}
.btn:hover { border-color: var(--border-md); color: var(--text); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.btn-primary { background: rgba(96,165,250,0.12); border-color: rgba(96,165,250,0.3); color: var(--blue); }
.btn.btn-primary:hover { background: rgba(96,165,250,0.2); }
.btn.btn-danger {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.35);
  color: var(--red);
}
.btn.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn.btn-danger:disabled { opacity: 0.45; }
.btn.btn-close { padding: 7px; border-radius: var(--radius-md); }

.confirm-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  padding: 24px;
  border-radius: inherit;
}
.confirm-overlay.hidden { display: none; }
.confirm-dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.35);
}
.confirm-dialog h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.confirm-dialog p {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}
.confirm-dialog .confirm-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 16px;
  word-break: break-all;
}
.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}


.modal-body { padding: 0 24px 24px; overflow-y: auto; }

/* Action banner */
.action-banner {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}
.action-banner.info   { background: var(--blue-bg);   border: 1px solid rgba(96,165,250,0.2);  color: var(--blue); }
.action-banner.success{ background: var(--green-bg);  border: 1px solid rgba(74,222,128,0.2);  color: var(--green); }
.action-banner.error  { background: var(--red-bg);    border: 1px solid rgba(248,113,113,0.2); color: var(--red); }
.action-banner.hidden { display: none; }
.banner-link { color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

/* Change email form */
.change-email-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.change-email-form.hidden { display: none; }
.change-email-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-md);
  background: var(--muted);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.change-email-input:focus { border-color: rgba(96,165,250,0.5); }

/* Stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.stat-card {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border-md); }
.stat-card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.stat-card-value {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-card-value.dim { color: var(--text-dim); }
.stat-card-hint { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* Section titles */
.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Error message card */
.error-card {
  background: var(--red-bg);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--red);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ===== STAGE TIMELINE ===== */
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stage-item {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 4px;
}

.stage-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 22px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.stage-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  position: relative;
  z-index: 1;
}
.stage-dot.ok      { background: rgba(74,222,128,0.15);  border: 1.5px solid var(--green);  color: var(--green); }
.stage-dot.warn    { background: rgba(250,204,21,0.15);  border: 1.5px solid var(--yellow); color: var(--yellow); }
.stage-dot.error   { background: rgba(248,113,113,0.15); border: 1.5px solid var(--red);    color: var(--red); }
.stage-dot.skipped { background: rgba(255,255,255,0.05); border: 1.5px solid var(--border-md); color: var(--text-dim); }

.stage-content { flex: 1; min-width: 0; }

.stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}
.stage-header:hover { background: rgba(255,255,255,0.04); }

.stage-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}
.stage-name.skipped { color: var(--text-dim); }

.stage-dur {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}
.stage-dur.slow { color: var(--yellow); }

.stage-state-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stage-state-badge.ok      { background: var(--green-bg);  color: var(--green); }
.stage-state-badge.warn    { background: var(--yellow-bg); color: var(--yellow); }
.stage-state-badge.error   { background: var(--red-bg);    color: var(--red); }
.stage-state-badge.skipped { background: rgba(255,255,255,0.05); color: var(--text-dim); }

.stage-expand-icon { color: var(--text-dim); transition: transform 0.2s; flex-shrink: 0; }
.stage-item.expanded .stage-expand-icon { transform: rotate(90deg); }

.stage-detail {
  display: none;
  margin: 0 10px 8px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  line-height: 1.7;
  overflow-x: auto;
}
.stage-item.expanded .stage-detail { display: block; }

/* ===== JSON VIEWER ===== */
.json-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
}

.json-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid transparent;
  transition: background 0.12s;
  user-select: none;
}
.json-block-header:hover { background: rgba(255,255,255,0.04); }
.json-block.open .json-block-header { border-bottom-color: var(--border); }
.json-block-label { font-size: 12px; font-weight: 500; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.json-block-meta  { font-size: 11px; font-family: var(--font-mono); color: var(--text-dim); }
.json-block-chevron { color: var(--text-dim); transition: transform 0.2s; }
.json-block.open .json-block-chevron { transform: rotate(180deg); }

.json-content {
  display: none;
  max-height: 280px;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
}
.json-block.open .json-content { display: block; }

/* JSON syntax colors */
.json-key  { color: #60a5fa; }
.json-str  { color: #86efac; }
.json-num  { color: #fde68a; }
.json-bool { color: #f9a8d4; }
.json-null { color: var(--text-dim); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #27272a;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toast-in 0.2s ease;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.success { border-color: rgba(74,222,128,0.3); }
.toast.error   { border-color: rgba(248,113,113,0.3); }
@keyframes toast-in { from { opacity:0; transform: translateY(8px); } }
@keyframes toast-out { to   { opacity:0; transform: translateY(8px); } }
.toast.out { animation: toast-out 0.2s ease forwards; }

/* ===== COPY BUTTON ===== */
.copy-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 2px;
  border-radius: 4px;
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
}
.copy-btn:hover { color: var(--text); }
.copy-btn.copied { color: var(--green); }

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .col-headers,
  .support-console .support-list-header .col-headers {
    display: none;
  }

  .wh-card,
  .support-console .support-results-wrap .wh-card {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "no time"
      "flow amount"
      "pid pid"
      "user user"
      "dur status";
    gap: 8px 12px;
    padding: 14px 16px;
    align-items: center;
  }

  .col-no     { grid-area: no; justify-self: start; }
  .col-time   { grid-area: time; justify-self: end; font-size: 11px; }
  .col-flow   { grid-area: flow; justify-self: start; }
  .col-amount { grid-area: amount; justify-self: end; }
  .col-pid    { grid-area: pid; justify-self: stretch; max-width: 100%; }
  .col-user   { grid-area: user; min-width: 0; }
  .col-dur    { grid-area: dur; display: block; justify-self: start; text-align: left; }
  .col-status { grid-area: status; justify-self: end; }

  .support-console .support-results-wrap .wh-card {
    grid-template-areas:
      "no time"
      "flow amount"
      "user user"
      "status status";
  }

  .support-console .col-status {
    justify-self: start;
  }

  .stat-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .header {
    padding: 0 16px;
  }

  .header-inner {
    gap: 10px;
    padding: 8px 0;
  }

  .header-spacer {
    display: none;
  }

  .header-brand {
    flex: 1;
    min-width: 0;
  }

  .header-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }

  .header-controls {
    flex: 1 1 100%;
    order: 3;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search-wrap {
    max-width: none;
    flex: 1 1 100%;
    min-width: 0;
  }

  .date-picker {
    flex: 1 1 100%;
    width: 100%;
  }

  .date-picker-trigger {
    max-width: none;
    width: 100%;
    justify-content: flex-start;
  }

  .date-picker-popover {
    left: 0;
    right: 0;
    width: auto;
  }

  .refresh-btn {
    margin-left: auto;
  }

  .stats-bar,
  .filters,
  .list-header,
  .webhook-list {
    padding-left: 16px;
    padding-right: 16px;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .filter-divider {
    display: none;
  }

  .filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 2px;
  }

  .filter-group::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    flex-shrink: 0;
  }

  .support-console .support-fields-row {
    grid-template-columns: 1fr 1fr;
  }

  .support-console .support-fields-row .login-field:first-child {
    grid-column: 1 / -1;
  }

  .support-console .support-fields-row .support-search-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .header-title {
    font-size: 14px;
  }

  .search-kbd {
    display: none;
  }

  #searchInput {
    padding-right: 12px;
    font-size: 16px;
  }

  .login-field input,
  .change-email-input {
    font-size: 16px;
  }

  .stats-row {
    gap: 6px;
  }

  .stat-pill {
    font-size: 11px;
  }

  .webhook-list {
    padding-bottom: 24px;
    gap: 8px;
  }

  .wh-card {
    padding: 12px 14px;
  }

  .user-email {
    white-space: normal;
    word-break: break-all;
  }

  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }

  .modal {
    border-radius: 0;
    min-height: 100dvh;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-header {
    padding: 16px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--card);
  }

  .modal-header-top {
    padding-right: 0;
  }

  .modal-actions {
    width: 100%;
    gap: 6px;
  }

  .modal-actions .btn {
    flex: 1 1 calc(50% - 3px);
    justify-content: center;
    font-size: 12px;
    padding: 8px 10px;
  }

  .modal-header-top .btn-close {
    flex: 0 0 auto;
  }

  .modal-body {
    padding: 0 16px 24px;
    flex: 1;
    overflow-y: auto;
  }

  .stat-cards {
    grid-template-columns: 1fr;
  }

  .change-email-form {
    flex-direction: column;
    align-items: stretch;
  }

  .change-email-input {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .change-email-form .btn {
    width: 100%;
    justify-content: center;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }

  .date-picker.is-open .date-picker-popover {
    position: fixed;
    left: 16px !important;
    right: 16px !important;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    z-index: 200;
  }

  .empty-state {
    padding: 48px 16px;
  }

  /* Support console */
  .support-console .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .support-console .support-search-card {
    margin: 12px 16px 0;
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .support-console .support-results-wrap {
    padding: 0 16px 24px;
  }

  .support-console .support-fields-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .support-console .support-fields-row .support-search-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .support-console .support-search-actions .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 11px 16px;
  }

  .support-console .header-inner {
    flex-wrap: nowrap;
  }

  .support-console .header-sub {
    display: block;
    max-width: 100px;
  }

  .support-console .logout-btn {
    flex-shrink: 0;
    padding: 8px 12px;
  }

  .support-console .support-hint-box {
    font-size: 11px;
  }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .modal {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .toast-container {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
