:root {
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --primary-soft: #f0fdfa;
  --accent: #f97316;
  --accent-light: #fff7ed;
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --text: #1c1917;
  --text-light: #57534e;
  --bg: #ffffff;
  --bg-warm: #fffbf7;
  --bg-alt: #fafaf9;
  --border: #e7e5e4;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(28, 25, 23, 0.06);
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.6;
  background: var(--bg-alt);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

.container { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem; }

/* Header */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}
.logo-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #14b8a6 100%);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
  position: relative;
  flex-shrink: 0;
}
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 0.45rem 0.5rem 0.55rem 0.45rem;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 4px 4px 2px 2px;
}
.site-nav { display: flex; align-items: center; gap: 0.15rem; flex-wrap: wrap; }
.nav-link {
  text-decoration: none;
  color: var(--text-light);
  font-weight: 500;
  font-size: 0.925rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
}
.nav-link:hover { color: var(--primary); background: var(--primary-soft); }
.nav-link-active { color: var(--primary); background: var(--primary-light); font-weight: 600; }
.nav-user {
  font-size: 0.85rem;
  color: var(--text-light);
  padding: 0 0.5rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; }
.nav-toggle span {
  display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0;
}

main { flex: 1; padding: 1.75rem 0 3rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary-soft); color: var(--primary-hover); }
.btn-ghost {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2, .card h3 { margin-top: 0; letter-spacing: -0.02em; }
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-title { font-size: 1.65rem; margin: 0 0 0.35rem; letter-spacing: -0.02em; }
.page-lead { color: var(--text-light); margin: 0 0 1.5rem; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
}
.stat-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); }
.stat-value { font-size: 1.1rem; font-weight: 700; margin-top: 0.25rem; word-break: break-all; }
.stat-value code { font-size: 0.85rem; font-weight: 500; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-running, .badge-active, .badge-completed, .badge-approved { background: #d1fae5; color: #065f46; }
.badge-pending, .badge-provisioning, .badge-started, .badge-trialing { background: #fef3c7; color: #92400e; }
.badge-past_due, .badge-error, .badge-failed { background: #fee2e2; color: #991b1b; }
.badge-suspended, .badge-canceled, .badge-rejected, .badge-revoked { background: var(--bg-alt); color: var(--text-light); }
.badge-parent { background: var(--primary-light); color: var(--primary-hover); }
.badge-child { background: #e0f2fe; color: #0369a1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-light); font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* Forms */
.form-group { margin-bottom: 1.15rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.form-control {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
.form-hint, .helptext { display: block; font-size: 0.85rem; color: var(--text-light); margin-top: 0.35rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-error-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.form-error-list li {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error);
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* Alerts */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-error, .alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info { background: var(--primary-soft); border: 1px solid #99f6e4; color: #115e59; }
.alert-close { background: none; border: none; cursor: pointer; font-size: 1.25rem; opacity: 0.6; line-height: 1; }

/* Login */
.login-page {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
  background:
    radial-gradient(ellipse 70% 50% at 80% 10%, rgba(204, 251, 241, 0.6) 0%, transparent 50%),
    var(--bg-warm);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.login-card h1 { font-size: 1.5rem; margin: 0 0 0.35rem; text-align: center; }
.login-subtitle { text-align: center; color: var(--text-light); font-size: 0.95rem; margin-bottom: 1.5rem; }
.login-footer { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-light); }

/* Quick actions */
.action-list { list-style: none; padding: 0; margin: 0; }
.action-list li { margin-bottom: 0.5rem; }
.action-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--bg-alt);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  border: 1px solid transparent;
}
.action-list a:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--text-light); }

/* Footer */
.site-footer {
  background: var(--text);
  color: #a8a29e;
  padding: 1.5rem 0;
  font-size: 0.85rem;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.site-footer a { color: #d6d3d1; text-decoration: none; }
.site-footer a:hover { color: #fff; }

/* Federation sections */
.fed-section { margin-bottom: 2rem; }
.search-results { margin-top: 1rem; }
.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: var(--bg-alt);
}

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
    box-shadow: var(--shadow);
  }
  .site-header { position: relative; }
  .site-header.nav-open .site-nav { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}
