@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg: #0d0d10;
  --surface: #141418;
  --surface2: #1c1c22;
  --surface3: #242430;
  --border: #2a2a38;
  --border-light: #36364a;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-dim: #16163a;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  --success: #22c55e;
  --success-dim: #052e16;
  --danger: #ef4444;
  --danger-dim: #2d0808;
  --warn: #f59e0b;
  --warn-dim: #2d1900;
  --text: #e8e8f2;
  --text-muted: #6e6e88;
  --text-dim: #36364c;
  --radius: 7px;
  --radius-lg: 11px;
  --radius-xl: 17px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.65);
  --glow: 0 0 40px rgba(129, 140, 248, 0.14);
  --ring: 0 0 0 3px rgba(129, 140, 248, 0.22);
  --t: 0.15s ease;
}

body {
  font-family:
    'Outfit',
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 55% 45% at 25% 35%, rgba(99, 102, 241, 0.1) 0%, transparent 60%), radial-gradient(ellipse 45% 40% at 78% 68%, rgba(129, 140, 248, 0.07) 0%, transparent 55%), var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-xl);
  padding: 44px 40px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow:
    var(--shadow-lg),
    0 0 80px rgba(129, 140, 248, 0.05);
  position: relative;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.login-logo-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1;
}
.login-tagline {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 13.5px;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  width: 212px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.main {
  flex: 1;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-text {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.sidebar-nav {
  padding: 8px 7px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius);
  transition:
    background var(--t),
    color var(--t);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin-bottom: 1px;
}
.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.sidebar-footer strong {
  color: var(--text);
  font-weight: 600;
}

.content {
  padding: 32px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.form-group {
  margin-bottom: 16px;
}
label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
input[type='text'],
input[type='password'],
input[type='email'],
input[type='url'],
textarea,
select {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition:
    border-color var(--t),
    box-shadow var(--t);
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}
textarea {
  resize: vertical;
  min-height: 80px;
}
select option {
  background: var(--surface2);
}

.input-wrap {
  position: relative;
}
.input-wrap input {
  padding-right: 54px;
}
.input-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--t);
  border-radius: 4px;
  font-family: inherit;
}
.input-toggle:hover {
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--t);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
  line-height: 1.4;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(129, 140, 248, 0.2);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow:
    0 4px 20px rgba(129, 140, 248, 0.3),
    0 0 0 1px rgba(129, 140, 248, 0.2);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: none;
  filter: brightness(0.95);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}
.btn-danger:active:not(:disabled) {
  transform: none;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface3);
  color: var(--text);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background: #16a34a;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}
.btn-xs {
  padding: 3px 9px;
  font-size: 11px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
}
.card-body {
  padding: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th {
  text-align: left;
  padding: 9px 15px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: var(--surface2);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge-blue {
  background: var(--accent-dim);
  color: var(--accent);
}
.badge-green {
  background: var(--success-dim);
  color: #86efac;
}
.badge-yellow {
  background: var(--warn-dim);
  color: #fde68a;
}
.badge-red {
  background: var(--danger-dim);
  color: #fca5a5;
}

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-item {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s cubic-bezier(0.22, 0.68, 0, 1.25);
  max-width: 320px;
  pointer-events: auto;
}
.toast-success {
  background: #031a0d;
  color: #86efac;
  border: 1px solid #22c55e28;
}
.toast-error {
  background: #1a0303;
  color: #fca5a5;
  border: 1px solid #ef444430;
}
.toast-info {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-light);
}
@keyframes toastIn {
  from {
    transform: translateX(20px) scale(0.93);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(6px);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-xl);
  padding: 30px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(12px);
  transition: transform 0.24s cubic-bezier(0.22, 0.68, 0, 1.1);
}
.modal-overlay.open .modal {
  transform: none;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.2px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}
.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.ext-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition:
    border-color var(--t),
    box-shadow var(--t),
    transform var(--t);
}
.ext-card + .ext-card {
  margin-top: 10px;
}
.ext-card:hover {
  border-color: var(--border-light);
  box-shadow:
    0 6px 28px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(129, 140, 248, 0.06);
  transform: translateY(-1px);
}
.ext-card-body {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.ext-info {
  flex: 1;
  min-width: 0;
}
.ext-info .ext-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ext-info .ext-internal-name {
  font-size: 10px;
  font-family: 'Courier New', monospace;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 400;
}
.ext-info .ext-description {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 500px;
}
.ext-info .ext-meta {
  font-size: 12px;
  color: var(--text-dim);
}
.ext-card-footer {
  border-top: 1px solid var(--border);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
}
.ext-card-footer-right {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.key-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--text-muted);
}

.editor-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.editor-sidebar {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.editor-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-panel {
  width: 292px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-sidebar-header,
.editor-panel-header {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, var(--surface2), var(--surface));
  flex-shrink: 0;
}
.page-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.page-item {
  padding: 11px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
.page-item:hover {
  background: var(--surface2);
}
.page-item.active {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
}
.page-item-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-item-url {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-toolbar {
  padding: 7px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-height: 44px;
}
.preview-frame-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.preview-frame-wrap.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#previewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  transition: opacity 0.35s ease;
}

.edit-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.edit-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 52px;
  padding: 0 20px;
}
.edit-field {
  margin-bottom: 13px;
}
.edit-warning {
  background: var(--warn-dim);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius);
  padding: 7px 11px;
  font-size: 11.5px;
  margin-bottom: 10px;
}
.advanced-toggle {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  user-select: none;
  padding: 4px 0;
}
.advanced-toggle:hover {
  color: var(--text);
}
.edit-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 13px;
}
.edit-actions {
  padding: 11px 13px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 7px;
  background: var(--surface2);
  flex-shrink: 0;
}
.edit-history {
  margin-top: 18px;
}
.edit-history-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.edit-history-item {
  font-size: 12px;
  color: var(--text-muted);
  padding: 7px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.style-section {
  margin-top: 13px;
}
.style-section-title {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.style-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}
.style-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 56px;
  flex-shrink: 0;
}
.style-input {
  flex: 1;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  min-width: 0;
  transition:
    border-color var(--t),
    box-shadow var(--t);
}
.style-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.18);
}
.style-select {
  flex: 1;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  min-width: 0;
  transition: border-color var(--t);
}
.style-select:focus {
  border-color: var(--accent);
}
.style-color-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
input[type='color'].style-color {
  width: 30px;
  height: 26px;
  padding: 1px 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
}
.style-color-text {
  flex: 1;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  min-width: 0;
}
.style-color-text:focus {
  border-color: var(--accent);
}
.style-divider {
  height: 1px;
  background: var(--border);
  margin: 9px 0 7px;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.text-muted {
  color: var(--text-muted);
}
.text-sm {
  font-size: 13px;
}
.mt-4 {
  margin-top: 16px;
}
.mt-6 {
  margin-top: 24px;
}
.flex {
  display: flex;
}
.gap-2 {
  gap: 8px;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.hidden {
  display: none !important;
}
code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: 'Courier New', monospace;
}

.icon-upload-area {
  width: 96px;
  height: 96px;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    border-color var(--t),
    background var(--t);
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.icon-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.icon-upload-area img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: calc(var(--radius-lg) - 2px);
}
.icon-upload-placeholder {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px;
}
.icon-upload-placeholder .icon-plus {
  font-size: 20px;
  margin-bottom: 4px;
  color: var(--text-dim);
}
.icon-upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ext-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  background: var(--surface2);
  object-fit: contain;
  flex-shrink: 0;
}
.ext-card-icon-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  background: var(--accent-dim);
  border: 1px solid rgba(129, 140, 248, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  color: var(--accent);
}

@keyframes shimmer {
  from {
    background-position: -200% 0;
  }
  to {
    background-position: 200% 0;
  }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
