:root {
  font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0d1117;
  color: #e6edf3;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #05070b 0%, #101523 100%);
}

.portal-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.portal-shell header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.title-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.title-bar h1 {
  margin: 0;
  font-size: 1.75rem;
}

.logo {
  width: 40px;
  height: 40px;
  background: #fff;
  border-radius: 50%;
  padding: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}

.shell-root {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  width: min(90vw, 420px);
}

.toast {
  background: rgba(15, 23, 32, 0.95);
  color: #f5f5f5;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border-left: 4px solid #1f6feb;
  min-width: 260px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toast.error {
  border-color: #d0342c;
}

.toast.success {
  border-color: #3fb950;
}

.toast button {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1rem;
  cursor: pointer;
  width: auto;
  padding: 0.25rem;
}

/* Account chip */
.account-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
  color: #f5f5f5;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1f6feb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.logout-icon {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: transparent;
  color: #f5f5f5;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  width: auto;
  cursor: pointer;
}

/* Forms */
.form-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input,
textarea,
select,
button {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(13, 17, 23, 0.85);
  color: #f0f6fc;
  font-size: 1rem;
  box-sizing: border-box;
}

input:focus,
textarea:focus,
select:focus,
button:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}

button {
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, background 0.2s ease;
}

button.primary {
  background: #1f6feb;
  border-color: #1f6feb;
}

button.secondary {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.24);
}

button.danger {
  background: #d0342c;
  border-color: #d0342c;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.muted {
  color: #8b949e;
}

.small {
  font-size: 0.85rem;
}

/* Portal Layout */
.portal-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

@media (max-width: 768px) {
  .portal-layout {
    flex-direction: column;
  }

  .side-nav {
    width: 100%;
  }
}

.side-nav {
  width: 220px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.nav-item {
  border: none;
  background: rgba(255, 255, 255, 0.04);
  color: #f5f5f5;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
}

.nav-link {
  display: block;
  text-decoration: none;
}

.nav-link::after {
  content: '↗';
  float: right;
  opacity: 0.75;
}

.nav-item.active {
  background: #1f6feb;
}

.main-panel {
  flex: 1;
  min-width: 0;
}

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.25rem;
}

.stat-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #8b949e;
  font-weight: 500;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 600;
}

.stat-card .subtitle {
  font-size: 0.85rem;
  color: #8b949e;
  margin-top: 0.25rem;
}

/* Status pills */
.status-pill {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  display: inline-block;
}

.status-pill.active {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
}

.status-pill.pending {
  background: rgba(250, 204, 21, 0.18);
  color: #fcd34d;
}

.status-pill.inactive {
  background: rgba(139, 148, 158, 0.18);
  color: #8b949e;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.data-table th {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  color: #8b949e;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Codes section */
.codes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.codes-header h3 {
  margin: 0;
}

.codes-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.codes-actions button {
  width: auto;
  padding: 0.6rem 1rem;
}

.code-display {
  font-family: 'Space Mono', 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  letter-spacing: 1px;
  background: rgba(15, 23, 42, 0.75);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  display: inline-block;
}

/* Generate codes form */
.generate-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.generate-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.generate-form .form-group label {
  font-size: 0.85rem;
  color: #8b949e;
}

.generate-form input {
  width: 120px;
}

.generate-form button {
  width: auto;
  padding: 0.75rem 1.25rem;
}

/* Team section */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.team-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.team-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.team-card h4 {
  margin: 0;
  font-size: 1rem;
}

.team-card .email {
  color: #8b949e;
  font-size: 0.9rem;
}

.team-card .team-role {
  color: #8b949e;
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

.team-meta-pills {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.role-pill.admin {
  background: rgba(31, 111, 235, 0.18);
  border: 1px solid rgba(31, 111, 235, 0.4);
  color: #79c0ff;
}

.role-pill.member {
  background: rgba(139, 148, 158, 0.16);
  border: 1px solid rgba(139, 148, 158, 0.35);
  color: #c9d1d9;
}

.team-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.team-card-actions button {
  width: auto;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

/* Invite form */
.invite-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.invite-form .form-group {
  flex: 1;
  min-width: 200px;
}

.invite-form .form-group label {
  font-size: 0.85rem;
  color: #8b949e;
}

.invite-form button {
  width: auto;
  padding: 0.75rem 1.25rem;
}

/* Settings section */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-group {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.25rem;
}

.settings-group h4 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-form .form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.settings-form .form-group {
  flex: 1;
  min-width: 200px;
}

.settings-form .form-group label {
  font-size: 0.85rem;
  color: #8b949e;
}

.settings-form button {
  width: auto;
  padding: 0.75rem 1.25rem;
}

/* API Keys */
.api-key-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.api-key-reveal {
  margin-top: 1rem;
  background: rgba(31, 111, 235, 0.12);
  border: 1px solid rgba(31, 111, 235, 0.45);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.api-key-reveal h5 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.api-key-reveal p {
  margin: 0 0 0.75rem;
}

.api-key-reveal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.api-key-secret {
  flex: 1;
  min-width: 220px;
  font-family: 'Space Mono', 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  letter-spacing: 0.4px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.api-key-reveal-actions {
  display: flex;
  gap: 0.5rem;
}

.api-key-reveal-actions button {
  width: auto;
  padding: 0.5rem 0.9rem;
}

.api-key-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.api-key-info h5 {
  margin: 0;
  font-size: 0.95rem;
}

.api-key-info .meta {
  color: #8b949e;
  font-size: 0.85rem;
}

.api-key-item button {
  width: auto;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

/* Tier selection */
.tier-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.tier-card {
  background: rgba(255, 255, 255, 0.02);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1.5rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.tier-card:hover {
  border-color: rgba(31, 111, 235, 0.5);
}

.tier-card.selected {
  border-color: #1f6feb;
  background: rgba(31, 111, 235, 0.1);
}

.tier-card h4 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.tier-card p {
  margin: 0;
  color: #8b949e;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination-info {
  color: #8b949e;
  font-size: 0.9rem;
}

.pagination-controls {
  display: flex;
  gap: 0.5rem;
}

.pagination-controls button {
  width: auto;
  padding: 0.5rem 1rem;
}

/* Empty & loading states */
.empty-state,
.loading-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #8b949e;
}

/* Auth pages */
.auth-container {
  max-width: 400px;
  margin: 0 auto;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-form h2 {
  margin: 0 0 0.5rem;
  text-align: center;
}

.auth-form p {
  margin: 0 0 1rem;
  text-align: center;
  color: #8b949e;
}

.auth-form .error {
  color: #ff9b92;
  text-align: center;
  margin: 0;
}

.auth-form .links {
  text-align: center;
  margin-top: 1rem;
}

.auth-form .links a {
  color: #58a6ff;
  text-decoration: none;
}

.auth-form .links a:hover {
  text-decoration: underline;
}

/* Export button */
.export-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.24);
}
