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

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a25;
  --border: #2a2a3a;
  --text: #e0e0e5;
  --text-dim: #8888a0;
  --accent: #4a7cff;
  --accent-dim: #3a5cc0;
  --danger: #ff4a5e;
  --success: #4aff7c;
  --warning: #ffaa4a;
  --font: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* LOGIN */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 50%, #0f0f1a 0%, #0a0a0f 100%);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(74, 124, 255, 0.3);
}

.logo-sm {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
}

.subtitle {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-top: 8px;
}

.login-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 24px;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

button {
  cursor: pointer;
  font-family: var(--font);
}

#loginBtn, .btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: background 0.2s;
}

#loginBtn:hover, .btn-primary:hover {
  background: var(--accent-dim);
}

#loginBtn:disabled, .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error-msg {
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

/* APP LAYOUT */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(74, 255, 124, 0.4);
}

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

.user-name {
  font-size: 12px;
  color: var(--text-dim);
}

.btn-logout {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.app-main {
  display: flex;
  flex: 1;
}

/* SIDEBAR */
.sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  text-align: left;
  font-size: 13px;
  border-radius: 4px;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
}

.nav-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* PANELS */
.panel-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.panel {
  display: none;
  max-width: 800px;
}

.panel.active {
  display: block;
}

.panel h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.panel-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.query-input {
  margin-bottom: 16px;
}

.query-input textarea {
  margin-bottom: 12px;
  resize: vertical;
}

.query-options {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.query-options label {
  font-size: 12px;
  color: var(--text-dim);
}

.query-options input[type="number"] {
  width: 80px;
}

.query-options select {
  width: auto;
}

/* RESULTS */
.result-box {
  margin-top: 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 60px;
}

.result-box:empty {
  display: none;
}

.result-box .sources {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

/* UPLOAD */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
}

.upload-zone:hover {
  border-color: var(--accent);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}

.progress-bar {
  margin-top: 16px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  height: 32px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
}

#progressText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* LOADING */
.loading {
  color: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* MOBILE */
@media (max-width: 768px) {
  .app-main {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .nav-btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .nav-divider {
    display: none;
  }
  
  #adminNav {
    display: contents !important;
  }
  
  .panel-container {
    padding: 16px;
  }
  
  .query-options {
    flex-direction: column;
    align-items: stretch;
  }
  
  .query-options input[type="number"] {
    width: 100%;
  }
}
