/* Background-ahead lookup: shared by dashboard + my application */

.ahead-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  overflow: visible;
  position: relative;
  margin-bottom: 1.25rem;
}

.ahead-card::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  height: 3px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, #f59e0b, #fb923c);
  pointer-events: none;
}

.ahead-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d97706;
  margin: 0 0 0.5rem;
}

html[data-theme="dark"] .ahead-kicker {
  color: #fbbf24;
}

.ahead-count {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
  font-variant-numeric: tabular-nums;
}

.ahead-headline {
  font-size: 0.975rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
  max-width: 42rem;
}

.ahead-privacy {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 1rem 0 0;
}

.ahead-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin: -0.35rem 0 1.15rem;
  line-height: 1.5;
}

.ahead-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.875rem 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.ahead-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ahead-form .form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ahead-form input,
.ahead-form select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text-primary);
  width: 100%;
}

.ahead-form input:focus,
.ahead-form select:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.ahead-form .ahead-submit {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.28);
  height: 2.55rem;
  justify-self: start;
  min-width: 8.5rem;
}

.ahead-form .ahead-submit:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ahead-form .ahead-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.ahead-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem;
  cursor: pointer;
  user-select: none;
}

.ahead-toggle input {
  accent-color: #f59e0b;
  width: 1rem;
  height: 1rem;
}

.ahead-error {
  color: var(--error-text);
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
}

.ahead-empty {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  padding: 0.75rem 0;
  margin: 0;
}

.ahead-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
}

.ahead-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.ahead-pager-range {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
}

.ahead-pager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.ahead-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ahead-table th,
.ahead-table td {
  padding: 0.7rem 0.85rem;
  text-align: start;
  white-space: nowrap;
}

.ahead-table thead th {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}

.ahead-table tbody tr {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}

.ahead-table tbody tr:last-child {
  border-bottom: none;
}

.ahead-table tbody tr:hover {
  background: var(--bg-secondary);
}

.ahead-status {
  min-height: 1.25rem;
}

html[data-theme="dark"] .ahead-form input,
html[data-theme="dark"] .ahead-form select {
  color-scheme: dark;
}

.ahead-date-wrap {
  position: relative;
}

.ahead-date-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text-primary);
  cursor: pointer;
  text-align: start;
  min-height: 2.55rem;
}

.ahead-date-btn:hover,
.ahead-date-btn[aria-expanded="true"] {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.ahead-date-btn .ahead-date-placeholder {
  color: var(--text-secondary);
}

.ahead-date-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  color: #d97706;
}

html[data-theme="dark"] .ahead-date-icon {
  color: #fbbf24;
}

.ahead-cal {
  position: fixed;
  z-index: 10000;
  width: min(18.5rem, calc(100vw - 1.5rem));
  padding: 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
}

.ahead-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ahead-cal-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
  text-align: center;
}

.ahead-cal-title-btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
}

.ahead-cal-title-btn:hover {
  background: rgba(245, 158, 11, 0.14);
  color: #d97706;
}

.ahead-cal-pick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.ahead-cal-pick-btn {
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 0.2rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
}

.ahead-cal-pick-btn:hover {
  background: rgba(245, 158, 11, 0.16);
}

.ahead-cal-pick-btn.is-today:not(.is-selected) {
  border-color: #f59e0b;
}

.ahead-cal-pick-btn.is-selected {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: #fff;
  border-color: transparent;
}

.ahead-cal-nav {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.ahead-cal-nav:hover {
  border-color: #f59e0b;
  color: #d97706;
}

.ahead-cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
  margin-bottom: 0.35rem;
}

.ahead-cal-dow {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0.2rem 0;
}

.ahead-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}

.ahead-cal-day {
  aspect-ratio: 1;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-sizing: border-box;
}

.ahead-cal-day:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.14);
}

.ahead-cal-day.is-muted {
  color: var(--text-secondary);
  opacity: 0.45;
}

.ahead-cal-day.is-today:not(.is-selected) {
  border-color: #f59e0b;
}

.ahead-cal-day.is-selected {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: #fff;
  border-color: transparent;
}

.ahead-cal-day:disabled {
  cursor: default;
}

@media (max-width: 640px) {
  .ahead-card {
    padding: 1.15rem;
  }

  .ahead-count {
    font-size: 2.25rem;
  }

  .ahead-form {
    grid-template-columns: 1fr;
  }

  .ahead-form .ahead-submit {
    justify-self: center;
  }

  .ahead-table thead {
    display: none;
  }

  .ahead-table,
  .ahead-table tbody,
  .ahead-table tr,
  .ahead-table td {
    display: block;
    width: 100%;
    white-space: normal;
  }

  .ahead-table tbody tr {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
  }

  .ahead-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0;
  }

  .ahead-table td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    flex-shrink: 0;
  }
}
