:root {
  --bg: #07122c;
  --surface: #0d1d42;
  --surface-2: #122756;
  --border: rgba(8, 184, 237, 0.22);
  --royal: #0735B8;
  --cyan: #08B8ED;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --danger: #EF4444;
  --success: #10B981;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: 12px;
  background: #0f295c;
  border: 1px solid var(--cyan);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 14px 35px rgba(0,0,0,0.45);
}
.toast.error { border-color: var(--danger); background: #450a0a; }
.toast.success { border-color: var(--success); background: #064e3b; }

/* Auth Screen */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: radial-gradient(circle at 50% 10%, #0735B8 0%, #09245F 45%, #040c21 100%);
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(13, 29, 66, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  backdrop-filter: blur(14px);
}

.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  object-fit: contain;
  border: 2px solid var(--cyan);
  margin-bottom: 12px;
}
.auth-brand h1 { font-size: 1.45rem; font-weight: 800; }
.auth-brand p { font-size: 0.84rem; color: var(--muted); margin-top: 2px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 0.84rem; }
.auth-footer a { color: var(--cyan); text-decoration: none; }

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-input-wrap input {
  padding-right: 64px;
}
.toggle-pw-btn {
  position: absolute;
  right: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(8, 184, 237, 0.12);
  color: var(--cyan);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}
.toggle-pw-btn:hover {
  background: rgba(8, 184, 237, 0.24);
}

/* Fields & Buttons */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 0.78rem; font-weight: 600; color: #CBD5E1; }
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(7, 18, 44, 0.8);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
}
.field input[type="color"] {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: transparent;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-full { width: 100%; }
.btn-primary { background: linear-gradient(135deg, #0735B8, #08B8ED); color: #fff; }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost { background: transparent; border-color: rgba(148, 163, 184, 0.25); color: var(--text); }
.btn-danger-outline { background: transparent; border-color: rgba(239, 68, 68, 0.5); color: #FCA5A5; }
.btn-link {
  background: none; border: none; color: var(--cyan); font-size: 0.82rem;
  cursor: pointer; text-align: center; padding: 4px;
}

.form-error {
  padding: 10px 12px; border-radius: 10px; background: rgba(239,68,68,0.16);
  border: 1px solid rgba(239,68,68,0.4); color: #FCA5A5; font-size: 0.82rem;
  line-height: 1.45; word-break: break-word; overflow-wrap: anywhere;
}
.form-info {
  padding: 10px 12px; border-radius: 10px; background: rgba(8,184,237,0.14);
  border: 1px solid rgba(8,184,237,0.4); color: #BAE6FD; font-size: 0.82rem;
  line-height: 1.45; word-break: break-word; overflow-wrap: anywhere;
}

/* Dashboard Layout */
.dashboard-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo { width: 38px; height: 38px; border-radius: 50%; object-fit: contain; border: 1.5px solid var(--cyan); }
.topbar-title { font-weight: 800; font-size: 1rem; }
.topbar-meta { font-size: 0.75rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.dirty-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #FCD34D;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 420px;
  min-height: 0;
}

.sidebar {
  background: #0a1736;
  border-right: 1px solid var(--border);
  padding: 14px 10px;
}

.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.nav-item:hover { background: rgba(8, 184, 237, 0.1); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(7,53,184,0.8), rgba(8,184,237,0.35)); color: #fff; }

.editor-pane {
  padding: 22px;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel h2 { font-size: 1.25rem; margin-bottom: 16px; }
.tab-panel h3 { font-size: 0.96rem; margin-bottom: 12px; color: #E2E8F0; }

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

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.stat-label { font-size: 0.78rem; color: var(--muted); }
.stat-value { font-size: 1.35rem; font-weight: 800; color: var(--cyan); margin: 4px 0 10px; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  cursor: pointer;
}

.logo-upload-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.admin-logo-thumb {
  width: 72px; height: 72px; border-radius: 50%; object-fit: contain;
  border: 2px solid var(--cyan); background: #0735B8;
}
.logo-upload-controls { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.inline-upload { display: flex; gap: 8px; align-items: center; }
.inline-upload input { flex: 1; }
.row-gap { display: flex; flex-wrap: wrap; gap: 10px; }
.muted-note { font-size: 0.84rem; color: var(--muted); margin-bottom: 6px; }

.stack-list { display: flex; flex-direction: column; gap: 12px; }
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.item-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.item-card-title { font-weight: 700; font-size: 0.95rem; }
.item-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Logs Table */
.table-wrap { overflow-x: auto; }
.logs-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.logs-table th, .logs-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.logs-table th { color: var(--muted); font-weight: 600; }

/* Live Preview Pane */
.preview-pane {
  background: #060f24;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 64px);
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.preview-title { font-size: 0.82rem; font-weight: 700; color: var(--cyan); }
.preview-modes { display: flex; gap: 6px; }
.mode-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.mode-btn.active { background: var(--cyan); color: #041235; border-color: var(--cyan); }

.preview-stage {
  flex: 1;
  padding: 14px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
}
.preview-device {
  width: 390px;
  height: 100%;
  min-height: 680px;
  border-radius: 26px;
  overflow: hidden;
  border: 4px solid #1e3a8a;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  transition: width 0.25s ease;
}
.preview-device.desktop {
  width: 100%;
  border-radius: 12px;
}
.preview-device iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #041235;
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 200px 1fr; }
  .preview-pane { grid-column: 1 / -1; max-height: 760px; border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .nav-list { flex-direction: row; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .auth-screen {
    padding: 16px 12px;
    align-items: flex-start;
    padding-top: 28px;
  }
  .auth-card {
    padding: 24px 18px;
    border-radius: 18px;
  }
  .auth-logo {
    width: 68px;
    height: 68px;
  }
  .auth-brand h1 {
    font-size: 1.3rem;
  }
  .field input[type="text"],
  .field input[type="password"],
  .field input[type="email"] {
    font-size: 16px; /* Prevents iOS auto-zoom on focus */
    padding: 10px 12px;
  }
  .btn-full {
    min-height: 44px;
    font-size: 0.92rem;
  }
}
