:root {
  --bg: #f6f3ec;
  --bg-accent: #efe8dc;
  --surface: #fffdf8;
  --surface-2: #f4efe6;
  --text: #1f2933;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-2: #f59e0b;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --border: rgba(31, 41, 55, 0.08);
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.12);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Rubik", "Manrope", sans-serif;
}

[data-theme="dark"] {
  --bg: #12161c;
  --bg-accent: #0d1116;
  --surface: #1b212b;
  --surface-2: #232b36;
  --text: #f8fafc;
  --muted: #98a1af;
  --accent: #2dd4bf;
  --accent-2: #fbbf24;
  --accent-soft: rgba(45, 212, 191, 0.16);
  --border: rgba(148, 163, 184, 0.18);
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.5);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 10% -10%, rgba(15, 118, 110, 0.12), transparent 60%),
    radial-gradient(800px 420px at 110% 12%, rgba(245, 158, 11, 0.14), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.2;
  pointer-events: none;
}

.app {
  display: grid;
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
  gap: 20px;
  padding: 18px 16px 24px;
  min-height: 100vh;
  position: relative;
}

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

/* SIDEBAR */

.sidebar {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 16px;
  align-self: start;
}

.logo {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo-orbit {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1.5px solid rgba(15, 118, 110, 0.4);
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, rgba(15, 118, 110, 0.18), transparent 60%);
}

.logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(130deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(15, 118, 110, 0.35);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.logo-sub {
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-btn {
  border: none;
  outline: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: transform var(--transition), background var(--transition), color var(--transition);
}

.nav-btn span:first-child {
  font-size: 16px;
  filter: grayscale(0.4);
}

.nav-btn.active,
.nav-btn:hover {
  background: var(--accent-soft);
  color: var(--text);
  transform: translateX(2px);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-pill {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(31, 41, 55, 0.16);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: var(--surface-2);
}

.status-pill.online {
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.45);
  background: rgba(22, 163, 74, 0.12);
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(15, 118, 110, 0.25);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  color: var(--muted);
}

/* MAIN */

.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  padding: 18px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.2px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.views {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view {
  display: none;
  gap: 16px;
  animation: fadeIn 0.35s ease;
}

.view--active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.card.big {
  padding: 22px 24px;
}

.card.highlight {
  border: 1px solid rgba(15, 118, 110, 0.35);
  box-shadow: 0 18px 36px rgba(15, 118, 110, 0.18);
}

.card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 30px;
  font-weight: 700;
  font-family: var(--font-display);
}

.metric-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.metric-inline {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
  gap: 10px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
}

.card-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart {
  width: 100%;
  max-height: 260px;
}

.roles-legend {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

/* Lists */

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list.dense {
  gap: 8px;
}

.list-item {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.list-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.list-item-title {
  font-weight: 600;
  font-size: 15px;
}

.list-item-label {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Forms */

.apply-form {
  display: grid;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.field.inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

input,
select,
textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

textarea {
  resize: vertical;
}

.quick-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.preset:hover {
  background: var(--accent-soft);
  color: var(--text);
}

/* Buttons */

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  font-family: var(--font-body);
}

.btn.primary {
  background: linear-gradient(130deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.25);
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.wide {
  width: 100%;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-nav {
  border: none;
  background: var(--surface-2);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  cursor: pointer;
}

/* Admin */

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

.admin-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-block h3 {
  margin: 0;
  font-size: 15px;
  font-family: var(--font-display);
}

.metric-sm {
  font-size: 12px;
  color: var(--muted);
}

.select {
  width: 100%;
}

/* Chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.theme-chip {
  cursor: pointer;
}

.theme-toggle-pill {
  position: relative;
  width: 76px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.theme-toggle-knob {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  transition: transform var(--transition);
}

.theme-toggle-pill.dark .theme-toggle-knob {
  transform: translateX(40px);
}

.theme-icon {
  font-size: 12px;
}

/* Onboarding */

.onboarding-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.onboarding-modal .glass {
  padding: 20px;
  width: min(520px, 100%);
}

.onboarding-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Footer */

footer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Responsive */

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    top: 0;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-btn {
    flex: 1 1 120px;
    justify-content: center;
  }

  .topbar {
    flex-direction: column;
  }
}

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

  .topbar h1 {
    font-size: 22px;
  }

  .metric {
    font-size: 26px;
  }

  .card-header {
    flex-direction: column;
  }

  .list-item-header {
    flex-direction: column;
  }
}
