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

[hidden], .modal-overlay[hidden], .view-container[hidden] {
  display: none !important;
}

:root {
  --bg-dark: #08080a;
  --bg-panel: #111215;
  --bg-card: rgba(18, 19, 23, 0.75);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f3f4f6;
  --text-dim: #9ca3af;
  --accent: #ff5e1e;
  --accent-hover: #ff7438;
  --sidebar-width: 290px;
  --topbar-height: 56px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  height: 100vh;
}

#ambientBg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-size: cover;
  background-position: center;
  filter: blur(50px) brightness(0.22);
  opacity: 0.55;
  z-index: 0;
  pointer-events: none;
  transition: background-image 0.4s ease-in-out;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: rgba(12, 13, 16, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}

.brand span {
  color: var(--accent);
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 18px 16px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.nav-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(255, 94, 30, 0.05);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.user-badge {
  background: rgba(255, 94, 30, 0.12);
  color: var(--accent);
  border: 1px solid rgba(255, 94, 30, 0.3);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  text-transform: uppercase;
}

.btn-primary, .btn-ghost, .btn-danger {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

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

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
}

.btn-danger {
  background: #c02626;
  color: #fff;
  border: 1px solid #c02626;
}

.btn-danger:hover {
  background: #dc2626;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-container {
  width: 100%;
  height: 100%;
}

.toast-banner {
  padding: 10px 16px;
  margin: 16px 24px 0 24px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-hover);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.toast-banner.error {
  background: #c02626;
  border-color: #dc2626;
}

.toast-banner.success {
  background: #2ea043;
  border-color: #3fb950;
}

.sidebar {
  width: var(--sidebar-width);
  background: rgba(13, 14, 17, 0.82);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.search-input {
  width: 100%;
  background: #090a0c;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sidebar-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  display: block;
}

.level-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.level-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.15s ease;
}

.level-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.level-item.active {
  background: var(--accent);
  color: #fff;
}

.level-pos {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.7;
  width: 28px;
}

.level-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail {
  flex: 1;
  padding: 24px 36px;
  overflow-y: auto;
  background: rgba(10, 11, 13, 0.6);
}

.detail-header {
  margin-bottom: 24px;
}

.detail-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-name {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

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

.detail-main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: start;
}

.detail-center-col {
  width: 100%;
}

.detail-desc {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.video-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  background: #111215;
  border: 1px solid var(--line);
  margin-bottom: 20px;
}

.video-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

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

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 16px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.detail-right-col {
  width: 340px;
}

.widget-box {
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 16px;
}

.widget-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 16px;
}

.admin-panel {
  padding: 32px;
  max-width: 1100px;
  margin: 0 auto;
  overflow-y: auto;
  height: 100%;
}

.admin-panel h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 20px;
}

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

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

.sub-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.sub-card-body h3 {
  font-size: 16px;
  font-weight: 700;
}

.sub-id {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: normal;
}

.sub-card-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.role-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  overflow: hidden;
}

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

.role-table th {
  background: rgba(8, 9, 11, 0.6);
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 11px;
}

select.form-input {
  background: #090a0c;
  color: var(--text);
  border: 1px solid var(--line-strong);
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-card {
  background: #141518;
  border: 1px solid var(--line-strong);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
}

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

form {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  width: 100%;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.form-input, 
.form-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #0a0b0d;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
}

.form-input:focus, 
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}