* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f5f5f7;
  color: #111827;
}

/* Header */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tenant-select {
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 13px;
  border: none;
  background-color: #ffffff;
  color: #4f46e5;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
  cursor: pointer;
  font-weight: 500;
}

/* Buttons */

.btn {
  border: none;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s ease;
  background-color: #e5e7eb;
  color: #111827;
}

.btn-primary {
  background: #ffffff;
  color: #4f46e5;
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.24);
}

/* Action buttons for service cards */
.btn-icon {
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  background: transparent;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.btn-icon span:first-child {
  font-size: 10px;
}

.btn-icon:hover {
  background: #f9fafb;
  color: #4b5563;
  border-color: #d1d5db;
}

.btn-icon:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

/* Layout */

main {
  padding: 20px 24px 32px;
  max-width: 100%;
  margin: 0 auto;
}

.services-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* Login Screen */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.login-container {
  background: white;
  padding: 32px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.35);
}

.login-container h2 {
  margin: 0 0 24px;
  text-align: center;
  color: #111827;
  font-size: 24px;
  font-weight: 600;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #374151;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.error-message {
  color: #b91c1c;
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  main {
    padding: 16px 16px 24px;
  }

  .services-container {
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 12px;
  }

  .service-card {
    padding: 12px;
  }

  .service-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .service-actions {
    align-self: flex-end;
  }

  .modal-inner {
    width: 95%;
    margin: 0 10px;
    max-height: 90vh;
  }

  .tenant-select {
    min-width: 150px;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 12px;
  }

  .service-title {
    width: 100%;
  }

  .service-table {
    font-size: 11px;
  }

  .service-table th,
  .service-table td {
    padding: 4px;
  }

  .btn-icon {
    padding: 4px 8px;
    font-size: 11px;
  }

  .btn-icon span:first-child {
    font-size: 9px;
  }
}

/* Service Card */

.service-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: auto;
  min-width: 280px;
}

.service-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.service-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
}

.service-subtitle {
  font-size: 11px;
  color: #6b7280;
}

.service-actions {
  display: flex;
  gap: 8px;
}

/* Table */

.service-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

/* Copy icon for password fields */
.copy-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 3px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.copy-icon:hover {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.copy-icon.copied {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}

.copy-container {
  display: flex;
  align-items: center;
}

/* Responsive table */
@media (max-width: 768px) {
  .service-table {
    font-size: 11px;
  }

  .service-table th,
  .service-table td {
    padding: 4px 2px;
  }
}

@media (max-width: 480px) {
  .service-table {
    font-size: 10px;
  }

  .service-table th,
  .service-table td {
    padding: 3px 1px;
    min-width: 30px;
  }
}

.service-table thead {
  background: #f9fafb;
}

.service-table th,
.service-table td {
  padding: 6px 6px;
  text-align: left;
}

.service-table th {
  font-weight: 600;
  color: #4b5563;
  border-bottom: 1px solid #e5e7eb;
}

.service-table tbody tr:nth-child(odd) {
  background-color: #fafafa;
}

.service-table tbody tr:hover {
  background-color: #f3f4f6;
}

.empty-row {
  font-size: 12px;
  color: #9ca3af;
}

/* Active Dot */

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 9999px;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.4);
}

.dot-active {
  background-color: #22c55e;
}

.dot-inactive {
  background-color: #9ca3af;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.modal-inner {
  width: 90%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.35);
}

@media (max-width: 768px) {
  .modal-inner {
    width: 95%;
    margin: 0 10px;
    padding: 14px;
    max-height: 80vh;
  }

  .details-table-container {
    max-height: 40vh;
  }
}

.modal-inner h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.modal-description {
  font-size: 12px;
  color: #4b5563;
  margin: 0 0 8px;
}

.modal-description code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 11px;
}

.csv-textarea {
  width: 100%;
  min-height: 160px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  resize: vertical;
}

.csv-textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.4);
}

.details-table-container {
  max-height: 400px;
  overflow-y: auto;
  margin: 10px 0;
}

.modal-footer {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-error {
  font-size: 12px;
  color: #b91c1c;
}

.modal-buttons {
  display: flex;
  gap: 6px;
}

/* Toast */

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 12px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.35);
  z-index: 60;
}

/* Utils */

.hidden {
  display: none;
}

/* Pagination */

.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 0 4px;
  min-height: 32px;
}

@media (max-width: 768px) {
  .pagination-btn {
    min-width: 70px;
    padding: 8px 12px;
  }
}

.pagination-btn {
  border: none;
  background: #e5e7eb;
  color: #111827;
  min-width: 60px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: #d1d5db;
  transform: translateY(-1px);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn-active {
  background: #4f46e5;
  color: #ffffff;
}

.pagination-ellipsis {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  font-size: 13px;
  color: #6b7280;
}

