/* =============================================================================
   Available Accounts — redesign (release faadumo34)
   Every rule is scoped to .aa-root, so nothing else on the dashboard changes.
   Light/dark follow the dashboard's .dark class on <html>.
   ============================================================================= */

.aa-root {
  --aa-surface: #ffffff;
  --aa-canvas: #f8fafc;
  --aa-ink: #0f172a;
  --aa-text: #1e293b;
  --aa-muted: #64748b;
  --aa-faint: #94a3b8;
  --aa-line: #e2e8f0;
  --aa-line-soft: #f1f5f9;
  --aa-brand: #dc2626;
  --aa-brand-deep: #b91c1c;
  --aa-brand-soft: #fef2f2;
  --aa-sold: #1e293b;
  --aa-open: #10b981;
  --aa-open-soft: #d1fae5;
  --aa-warn: #b45309;
  --aa-warn-soft: #fef3c7;
  --aa-danger: #b91c1c;
  --aa-danger-soft: #fee2e2;
  --aa-radius: 20px;

  background: var(--aa-surface);
  border: 1px solid var(--aa-line);
  border-radius: var(--aa-radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  color: var(--aa-text);
  overflow: hidden;
  font-feature-settings: "tnum" 1, "cv11" 1;
}

.dark .aa-root {
  --aa-surface: #0f172a;
  --aa-canvas: #111c33;
  --aa-ink: #f8fafc;
  --aa-text: #e2e8f0;
  --aa-muted: #94a3b8;
  --aa-faint: #64748b;
  --aa-line: #1e293b;
  --aa-line-soft: #16213a;
  --aa-brand: #ef4444;
  --aa-brand-deep: #dc2626;
  --aa-brand-soft: rgba(239, 68, 68, 0.12);
  --aa-sold: #cbd5e1;
  --aa-open: #34d399;
  --aa-open-soft: rgba(52, 211, 153, 0.16);
  --aa-warn: #fbbf24;
  --aa-warn-soft: rgba(251, 191, 36, 0.14);
  --aa-danger: #f87171;
  --aa-danger-soft: rgba(248, 113, 113, 0.14);
  box-shadow: none;
}

.aa-root *,
.aa-root *::before,
.aa-root *::after { box-sizing: border-box; }

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

.aa-ico { width: 20px; height: 20px; }
.aa-ico-sm { width: 16px; height: 16px; flex: none; }
.aa-ico-xs { width: 13px; height: 13px; flex: none; }

.aa-root :is(button, input, select):focus-visible {
  outline: 2px solid var(--aa-brand);
  outline-offset: 2px;
}

/* ---------- Header ---------- */
.aa-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 18px;
}
.aa-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.aa-title-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 14px;
  background: var(--aa-brand);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(220, 38, 38, 0.55);
}
.aa-title h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--aa-ink);
}
.aa-title p { margin: 3px 0 0; font-size: 13px; color: var(--aa-muted); }

.aa-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.aa-select, .aa-search {
  position: relative;
  display: flex; align-items: center;
  height: 40px;
  border: 1px solid var(--aa-line);
  border-radius: 12px;
  background: var(--aa-surface);
  transition: border-color 0.15s ease;
}
.aa-select:focus-within, .aa-search:focus-within { border-color: var(--aa-faint); }
.aa-select select {
  appearance: none; -webkit-appearance: none;
  height: 100%;
  min-width: 168px;
  padding: 0 34px 0 14px;
  border: 0; background: transparent;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--aa-ink);
  cursor: pointer;
}
.aa-select select:focus-visible { outline: none; }
.aa-select-caret { position: absolute; right: 11px; pointer-events: none; color: var(--aa-muted); }
.dark .aa-select select option { background: #0f172a; }

.aa-search { padding-left: 12px; color: var(--aa-faint); width: 280px; }
.aa-search input {
  flex: 1; min-width: 0; height: 100%;
  padding: 0 12px 0 8px;
  border: 0; background: transparent;
  font: inherit; font-size: 13px;
  color: var(--aa-ink);
}
.aa-search input::placeholder { color: var(--aa-faint); }
.aa-search input:focus-visible { outline: none; }

.aa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 14px;
  border: 1px solid var(--aa-line);
  border-radius: 12px;
  background: var(--aa-surface);
  color: var(--aa-ink);
  font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.aa-btn:hover { background: var(--aa-canvas); }
.aa-btn:active { transform: translateY(1px); }
.aa-btn-icon { width: 40px; padding: 0; color: var(--aa-muted); }
.aa-btn-primary { background: var(--aa-brand); border-color: var(--aa-brand); color: #fff; }
.aa-btn-primary:hover { background: var(--aa-brand-deep); border-color: var(--aa-brand-deep); }

/* ---------- Capacity panel ---------- */
.aa-cap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin: 0 24px;
  padding: 20px 22px;
  border-radius: 16px;
  background: var(--aa-canvas);
  border: 1px solid var(--aa-line-soft);
}
.aa-cap-main { min-width: 0; }
.aa-cap-figure { display: flex; align-items: flex-end; gap: 12px; }
.aa-cap-num {
  font-size: 46px;
  line-height: 0.9;
  font-weight: 800;
  letter-spacing: -0.045em;
  color: var(--aa-ink);
}
.aa-cap-of { font-size: 13px; line-height: 1.3; color: var(--aa-muted); padding-bottom: 2px; }

.aa-cap-track {
  position: relative;
  display: flex;
  height: 14px;
  margin-top: 16px;
  border-radius: 999px;
  background: var(--aa-line);
  overflow: hidden;
}
.aa-cap-sold, .aa-cap-open {
  height: 100%;
  transform-origin: left center;
  animation: aa-grow 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.aa-cap-sold { background: var(--aa-sold); }
.aa-cap-open { background: var(--aa-open); animation-delay: 0.12s; }
/* One tick per device seat, so the bar reads as seats, not a vague percentage. */
.aa-cap-track.has-ticks::after {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(var(--aa-seg) - 2px),
    var(--aa-canvas) calc(var(--aa-seg) - 2px),
    var(--aa-canvas) var(--aa-seg)
  );
  pointer-events: none;
}
@keyframes aa-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.aa-cap-legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  margin-top: 10px;
  font-size: 12.5px; color: var(--aa-muted);
}
.aa-cap-legend span { display: inline-flex; align-items: center; gap: 6px; }
.aa-cap-legend strong { color: var(--aa-ink); font-weight: 700; }
.aa-cap-pct { margin-left: auto; }
.aa-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.aa-dot.is-sold { background: var(--aa-sold); }
.aa-dot.is-open { background: var(--aa-open); }

.aa-cap-side { display: flex; margin: 0; }
.aa-cap-side > div { padding: 2px 22px; border-left: 1px solid var(--aa-line); min-width: 112px; }
.aa-cap-side dt { font-size: 12px; color: var(--aa-muted); white-space: nowrap; }
.aa-cap-side dd {
  margin: 6px 0 0;
  font-size: 26px; line-height: 1; font-weight: 800; letter-spacing: -0.03em;
  color: var(--aa-ink);
}
.aa-cap-side .is-warn dd { color: var(--aa-warn); }

/* ---------- Status chips ---------- */
.aa-chips {
  display: flex; gap: 6px;
  padding: 18px 24px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.aa-chips::-webkit-scrollbar { display: none; }
.aa-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 6px 0 14px;
  border: 1px solid var(--aa-line);
  border-radius: 999px;
  background: var(--aa-surface);
  color: var(--aa-text);
  font: inherit; font-size: 13px; font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.aa-chip:hover { border-color: var(--aa-faint); }
.aa-chip-count {
  min-width: 24px; height: 22px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  background: var(--aa-line-soft);
  color: var(--aa-muted);
  font-size: 11.5px; font-weight: 700;
}
.aa-chip.is-soon .aa-chip-count { background: var(--aa-warn-soft); color: var(--aa-warn); }
.aa-chip.is-on { background: var(--aa-ink); border-color: var(--aa-ink); color: var(--aa-surface); }
.aa-chip.is-on .aa-chip-count { background: rgba(255, 255, 255, 0.16); color: inherit; }
.dark .aa-chip.is-on .aa-chip-count { background: rgba(15, 23, 42, 0.12); }

/* ---------- Table ---------- */
.aa-table-wrap { overflow-x: auto; border-top: 1px solid var(--aa-line); }
.aa-table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 13px; }
.aa-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px; font-weight: 600;
  color: var(--aa-muted);
  background: var(--aa-surface);
  border-bottom: 1px solid var(--aa-line);
  white-space: nowrap;
}
.aa-table th:first-child, .aa-table td:first-child { padding-left: 24px; }
.aa-table th:last-child, .aa-table td:last-child { padding-right: 24px; }
.aa-table .aa-right { text-align: right; }
.aa-table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--aa-line-soft);
}
.aa-table tbody tr:last-child td { border-bottom: 0; }
.aa-row { transition: background-color 0.12s ease; }
.aa-row:hover { background: var(--aa-canvas); }

.aa-svc { display: flex; align-items: center; gap: 12px; min-width: 0; }
.aa-avatar {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.02em;
}
.aa-tone-0 { background: #fee2e2; color: #b91c1c; }
.aa-tone-1 { background: #dbeafe; color: #1d4ed8; }
.aa-tone-2 { background: #dcfce7; color: #15803d; }
.aa-tone-3 { background: #ede9fe; color: #6d28d9; }
.aa-tone-4 { background: #ffedd5; color: #c2410c; }
.aa-tone-5 { background: #cffafe; color: #0e7490; }
.dark .aa-tone-0 { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.dark .aa-tone-1 { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }
.dark .aa-tone-2 { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.dark .aa-tone-3 { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.dark .aa-tone-4 { background: rgba(249, 115, 22, 0.16); color: #fdba74; }
.dark .aa-tone-5 { background: rgba(6, 182, 212, 0.16); color: #67e8f9; }
.aa-svc-name { font-weight: 700; color: var(--aa-ink); white-space: nowrap; }

.aa-acct { display: flex; align-items: center; gap: 6px; min-width: 0; }
.aa-email {
  max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500; color: var(--aa-text);
}
.aa-row.is-full .aa-email { color: var(--aa-muted); }
.aa-copy {
  display: grid; place-items: center;
  width: 26px; height: 26px; flex: none;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--aa-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.aa-row:hover .aa-copy, .aa-copy:focus-visible, .aa-copy.is-done { opacity: 1; }
.aa-copy:hover { background: var(--aa-line-soft); color: var(--aa-ink); }
.aa-copy.is-done { color: var(--aa-open); }
.aa-secret {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 3px 8px;
  border-radius: 8px;
  background: var(--aa-brand-soft);
  color: var(--aa-brand);
}
.aa-secret code { font-size: 12px; font-weight: 600; }

/* Seats: one square per device. Dark = sold to a client, green = still open. */
.aa-seats { display: flex; flex-direction: column; gap: 6px; }
.aa-seat-row { display: flex; gap: 4px; }
.aa-seat { width: 14px; height: 14px; border-radius: 4px; }
.aa-seat.is-sold { background: var(--aa-sold); }
.aa-seat.is-open { background: var(--aa-open-soft); box-shadow: inset 0 0 0 1.5px var(--aa-open); }
.aa-seat-meter { width: 96px; height: 8px; border-radius: 999px; background: var(--aa-open-soft); box-shadow: inset 0 0 0 1px var(--aa-open); overflow: hidden; }
.aa-seat-meter span { display: block; height: 100%; background: var(--aa-sold); }
.aa-seat-text { font-size: 12px; color: var(--aa-muted); white-space: nowrap; }
.aa-seat-text strong { color: var(--aa-ink); font-weight: 700; }
.aa-row.is-full .aa-seat-text strong { color: var(--aa-muted); }

.aa-status {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.aa-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.aa-status.is-available { background: var(--aa-open-soft); color: #047857; }
.aa-status.is-partial { background: var(--aa-warn-soft); color: var(--aa-warn); }
.aa-status.is-soldout { background: var(--aa-line-soft); color: var(--aa-muted); }
.dark .aa-status.is-available { color: #6ee7b7; }

.aa-c-price { text-align: right; }
.aa-cost { font-weight: 600; color: var(--aa-ink); }

.aa-exp { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.aa-exp-date { font-weight: 600; color: var(--aa-text); white-space: nowrap; }
.aa-exp-date.is-none { font-weight: 500; color: var(--aa-faint); }
.aa-days {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--aa-muted); white-space: nowrap;
}
.aa-days.is-soon, .aa-days.is-expired {
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  font-weight: 700;
}
.aa-days.is-soon { background: var(--aa-warn-soft); color: var(--aa-warn); }
.aa-days.is-expired { background: var(--aa-danger-soft); color: var(--aa-danger); }

.aa-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.aa-sell {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 78px; height: 34px; padding: 0 12px;
  border: 0; border-radius: 10px;
  background: var(--aa-brand);
  color: #fff;
  font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px -6px rgba(220, 38, 38, 0.7);
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.aa-sell:hover { background: var(--aa-brand-deep); }
.aa-sell:active { transform: translateY(1px); }
.aa-sell-off {
  display: inline-grid; place-items: center;
  min-width: 78px; height: 34px;
  font-size: 12px; font-weight: 600;
  color: var(--aa-faint);
}
.aa-icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--aa-line);
  border-radius: 10px;
  background: var(--aa-surface);
  color: var(--aa-muted);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.aa-icon-btn:hover { background: var(--aa-canvas); color: var(--aa-ink); }
.aa-icon-btn.is-danger:hover { background: var(--aa-danger-soft); border-color: transparent; color: var(--aa-danger); }

/* ---------- Loading, empty, footer ---------- */
.aa-skel {
  display: block; height: 18px; border-radius: 6px;
  background: linear-gradient(90deg, var(--aa-line-soft), var(--aa-line), var(--aa-line-soft));
  background-size: 200% 100%;
  animation: aa-shimmer 1.2s linear infinite;
}
@keyframes aa-shimmer { to { background-position: -200% 0; } }
.aa-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 44px 16px; text-align: center; }
.aa-empty p { margin: 0; font-size: 14px; color: var(--aa-muted); }
.aa-empty-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--aa-line-soft); color: var(--aa-faint); }
.aa-foot { padding: 12px 24px 16px; font-size: 12px; color: var(--aa-faint); border-top: 1px solid var(--aa-line-soft); }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .aa-cap { grid-template-columns: 1fr; }
  .aa-cap-side { border-top: 1px solid var(--aa-line); padding-top: 16px; }
  .aa-cap-side > div:first-child { border-left: 0; padding-left: 0; }
  .aa-search { width: 220px; }
}

/* ---------- Phone: rows become cards ---------- */
@media (max-width: 760px) {
  .aa-head { padding: 18px 16px 14px; }
  .aa-tools { width: 100%; }
  .aa-select { flex: 1 1 140px; }
  .aa-select select { min-width: 0; width: 100%; }
  .aa-search { order: 5; flex: 1 1 100%; width: auto; }
  .aa-cap { margin: 0 16px; padding: 16px; }
  .aa-cap-num { font-size: 40px; }
  .aa-cap-pct { margin-left: 0; }
  .aa-cap-side > div { padding: 0 12px; min-width: 0; flex: 1; }
  .aa-cap-side dt { white-space: normal; }
  .aa-cap-side dd { font-size: 22px; }
  .aa-chips { padding: 14px 16px 12px; }

  .aa-table-wrap { overflow: visible; border-top: 0; padding: 0 12px 4px; }
  .aa-table { min-width: 0; }
  .aa-table thead { display: none; }
  .aa-table, .aa-table tbody { display: block; }
  .aa-table tbody tr.aa-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "svc svc status"
      "acct acct acct"
      "seats exp price"
      "actions actions actions";
    gap: 12px 12px;
    margin-bottom: 10px;
    padding: 14px;
    border: 1px solid var(--aa-line);
    border-radius: 16px;
    background: var(--aa-surface);
  }
  .aa-table tbody tr.aa-row:hover { background: var(--aa-surface); }
  .aa-table tbody tr.aa-row > td { display: block; padding: 0 !important; border: 0; }
  .aa-c-service { grid-area: svc; min-width: 0; }
  .aa-c-status { grid-area: status; justify-self: end; }
  .aa-c-account { grid-area: acct; min-width: 0; }
  .aa-c-seats { grid-area: seats; }
  .aa-c-exp { grid-area: exp; }
  .aa-c-price { grid-area: price; text-align: right; }
  .aa-c-actions { grid-area: actions; padding-top: 12px !important; border-top: 1px solid var(--aa-line-soft) !important; }
  .aa-actions { justify-content: stretch; }
  .aa-sell, .aa-sell-off { flex: 1; }
  .aa-sell-off { justify-items: start; }
  .aa-table td[data-label]:is(.aa-c-seats, .aa-c-exp, .aa-c-price)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    font-size: 11.5px; color: var(--aa-faint);
  }
  .aa-c-account { padding-top: 12px !important; border-top: 1px solid var(--aa-line-soft) !important; }
  .aa-email { max-width: none; flex: 1; }
  .aa-copy { opacity: 1; }
  .aa-svc-name { white-space: normal; }
  .aa-table tbody tr.aa-empty-row, .aa-table tbody tr.aa-skel-row { display: block; }
  .aa-table tbody tr.aa-empty-row td, .aa-table tbody tr.aa-skel-row td { display: block; padding: 8px 4px; border: 0; }
  .aa-foot { padding: 10px 16px 16px; border-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .aa-root *, .aa-root *::before, .aa-root *::after {
    animation: none !important;
    transition: none !important;
  }
}
