:root {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #111;
  background: #f5f5f7;
}

body {
  margin: 0;
  padding: 0;
  background: #f5f5f7;
}

header {
  background: #3949ab;
  color: white;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  margin: 0;
  opacity: 0.85;
}

main {
  padding: 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.tabs {
  margin-top: 2rem;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tab {
  border-radius: 999px;
  padding: 0.4rem 1.2rem;
  background: rgba(57, 73, 171, 0.08);
  color: #3949ab;
  border: 1px solid transparent;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, border 0.2s;
}

.tab.active {
  background: #3949ab;
  color: #fff;
  border-color: #2f3b8c;
}

.tab-panel {
  display: none;
}

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

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 8px 18px rgba(11, 22, 63, 0.08);
}

.stat-card p {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #616161;
}

.stat-card h3 {
  margin: 0.25rem 0 0.35rem;
  font-size: 2rem;
}

.stat-card small {
  color: #757575;
}

button {
  background: #1e88e5;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

button.danger {
  background: #e53935;
}

button:hover {
  opacity: 0.95;
}

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

.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control label {
  font-weight: 600;
  font-size: 0.9rem;
}

.control input,
.control select {
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid #cfd8dc;
  background: #fff;
}

.control select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #888 50%),
    linear-gradient(135deg, #888 50%, transparent 50%);
  background-position:
    calc(100% - 15px) calc(50% + 2px),
    calc(100% - 10px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.control.grow {
  min-width: 240px;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.control-buttons.align-end {
  justify-content: flex-start;
}

.status-text {
  font-size: 0.9rem;
  color: #455a64;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

table thead {
  background: #eeeeff;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

table th,
table td {
  padding: 0.85rem;
  border-bottom: 1px solid #e0e0e0;
  text-align: left;
  vertical-align: middle;
}

table td.actions {
  text-align: right;
}

table td.actions button {
  margin-left: 0.35rem;
}

.owner-cell small {
  display: block;
  color: #757575;
  font-size: 0.8rem;
}

.schedule-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.schedule-cell small {
  color: #757575;
}


tr:hover td {
  background: #fafafa;
}

section.users {
  margin-top: 2rem;
}

section.subscription-history {
  margin-top: 2rem;
}

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

.users-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.users-controls .control {
  min-width: 220px;
}

.history-controls {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

footer {
  padding: 1rem 2rem;
  font-size: 0.9rem;
  color: #555;
}

.empty {
  text-align: center;
  color: #777;
}

#modal-root {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 2rem;
  z-index: 20;
}

#modal-root.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal header {
  background: #3949ab;
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal header h3 {
  margin: 0;
}

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

.modal .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.detail-item {
  background: #f6f7fb;
  border-radius: 10px;
  padding: 0.9rem;
}

.detail-item h5 {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5c6bc0;
}

.detail-item p {
  margin: 0.35rem 0 0;
  font-weight: 600;
}

.detail-item-span {
  grid-column: 1 / -1;
}

.modal .modal-body h4 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.modal table {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.modal table td small {
  display: block;
  color: #757575;
}

.modal-close {
  background: transparent;
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.plan-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.plan-current strong {
  font-size: 1rem;
}

.plan-current small {
  color: #616161;
  display: block;
  font-size: 0.8rem;
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.plan-actions select {
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  min-width: 8rem;
}

.plan-actions button {
  white-space: nowrap;
}

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

.badge {
  display: inline-flex;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge.neutral {
  background: #e8eaf6;
  color: #3949ab;
}

.badge.success {
  background: #e6f4ea;
  color: #1b5e20;
}

.badge.warn {
  background: #fff4e5;
  color: #bf360c;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #ede7f6;
  color: #4527a0;
}

.action-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.action-badge.subscribed {
  background: #e6f4ea;
  color: #1b5e20;
}

.action-badge.upgraded {
  background: #e3f2fd;
  color: #0d47a1;
}

.action-badge.downgraded {
  background: #fff3e0;
  color: #e65100;
}

.action-badge.renewed {
  background: #e0f2f1;
  color: #004d40;
}

.action-badge.canceled {
  background: #ffebee;
  color: #b71c1c;
}

.action-badge.expired {
  background: #f5f5f5;
  color: #616161;
}

.action-badge.restarted {
  background: #f3e5f5;
  color: #4a148c;
}

.action-badge.refunded {
  background: #fce4ec;
  color: #880e4f;
}
