:root {
  --bg: #0b1024;
  --bg-elevated: #121833;
  --surface: #1a2140;
  --surface-hover: #232b4d;
  --border: #2e3760;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #007aff;
  --primary-hover: #0066d6;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
}

.login-card {
  width: min(420px, calc(100% - 32px));
  margin: 10vh auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  height: 32px;
  width: auto;
  margin: 0 auto 16px;
}

.brand-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
}

.brand h1,
.panel-header h2,
.empty-state h2 {
  margin: 0 0 8px;
}

.brand p,
.muted,
.empty-state p {
  color: var(--muted);
}

label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

input[type='text'],
input[type='email'],
input[type='url'],
input[type='password'],
input[type='number'],
input[type='file'],
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

textarea {
  min-height: 84px;
  resize: vertical;
  font: inherit;
}

input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

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

.error-text {
  color: #fca5a5;
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-inline {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand-inline img {
  display: block;
  height: 24px;
  width: auto;
}

.badge {
  margin-left: 10px;
  font-size: 12px;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 57px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 16px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 16px;
}

.list-item {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 8px;
}

.list-item:hover {
  background: var(--surface);
}

.list-item.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.45);
}

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

.list-item-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.content {
  padding: 24px;
}

.empty-state {
  margin-top: 10vh;
  text-align: center;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.panel-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.section {
  margin-bottom: 28px;
}

.section h3 {
  margin: 0 0 12px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
}

.card:hover,
.card.active {
  border-color: rgba(37, 99, 235, 0.55);
}

.card-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.upload-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.span-2 {
  grid-column: span 2;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 28px;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: -8px 0 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.analytics-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.share-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  min-width: 80px;
}

.share-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #0140ba);
}

@media (max-width: 900px) {
  .analytics-split {
    grid-template-columns: 1fr;
  }
}

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse-online 2s infinite;
  margin-right: 6px;
  vertical-align: middle;
}

.online-dot.offline {
  background: var(--muted);
  box-shadow: none;
  animation: none;
}

@keyframes pulse-online {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.rollout-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 108px;
}

.rollout-input {
  width: 72px;
  margin: 0;
  padding: 6px 8px;
}

.tag-online {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

td .muted {
  font-size: 12px;
  margin-top: 2px;
}

.form-actions,
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.upload-progress {
  margin-top: 12px;
}

.progress-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #0140ba);
  transition: width 0.15s ease;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tag-success {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.tag-muted {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.tag-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  width: min(420px, calc(100% - 32px));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 100;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}