:root {
  --bg: #070a0f;
  --surface: rgba(13, 17, 23, 0.85);
  --border: #1e2438;
  --border-light: #2a3150;
  --text: #e8edf5;
  --text2: #8b95b0;
  --text3: #5a6480;
  --accent: #6c8cff;
  --accent-hover: #8ba4ff;
  --accent-glow: rgba(108, 140, 255, 0.15);
  --green: #4ade80;
  --red: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 0.2s ease;
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { cursor: pointer; font-family: var(--font); border: none; outline: none; }
input, select { font-family: var(--font); outline: none; }
.hidden { display: none !important; }

::selection { background: var(--accent); color: #fff; }

/* ===== LOADING ===== */
.loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }
.loading-content { text-align: center; }
.loading-logo {
  font-size: 48px; font-weight: 800; letter-spacing: -2px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 24px;
}
.loading-text { font-size: 14px; color: var(--text3); margin-top: 16px; }
.spinner-ring {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== APP OVERLAY ===== */
#app {
  position: fixed; inset: 0; z-index: 10;
  pointer-events: none;
}

/* ===== TOPBAR ===== */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 20px;
  pointer-events: auto;
  background: linear-gradient(to bottom, rgba(7,10,15,0.5) 0%, transparent 100%);
}
.logo {
  font-size: 20px; font-weight: 800; letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 100px; background: var(--accent-glow); color: var(--accent);
  border: 1px solid rgba(108, 140, 255, 0.2);
  margin-left: 8px; vertical-align: middle;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); }
.user-info #user-email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  transition: all var(--transition);
}
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text2);
}
.btn-ghost:hover { border-color: var(--border-light); color: var(--text); }
.btn-primary {
  background: var(--accent); color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }
.btn-oauth {
  width: 100%; justify-content: center; padding: 10px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  transition: all var(--transition);
}
.btn-oauth:hover { border-color: var(--border-light); }
.icon-btn {
  background: none; border: none; font-size: 16px;
  cursor: pointer; padding: 4px; opacity: 0.6; transition: opacity var(--transition);
}
.icon-btn:hover { opacity: 1; }

/* ===== TAGLINE ===== */
#tagline {
  position: absolute; bottom: 72px; left: 0; right: 0; z-index: 5;
  text-align: center; pointer-events: none;
  transition: opacity 0.5s ease;
}
#tagline .main {
  font-size: 13px; font-weight: 500;
  color: rgba(232,237,245,0.45);
  letter-spacing: 0.4px; line-height: 1.6;
}
#tagline .sub {
  font-size: 11px; color: rgba(91,100,128,0.5);
  margin-top: 1px;
}

/* ===== SAT BADGE ===== */
#sat-badge {
  position: absolute; top: 44px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 3px 12px;
  background: rgba(13,17,23,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(30,36,56,0.5);
  border-radius: 100px;
  font-size: 11px; color: var(--text2); white-space: nowrap;
  pointer-events: none; z-index: 5;
}
.sat-divider { opacity: 0.3; }

/* ===== PANEL ===== */
#panel {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  background: transparent; border: none; border-radius: var(--radius);
  opacity: 0.35; z-index: 10;
  transition: opacity 0.4s ease, background 0.3s ease, border 0.3s ease;
  pointer-events: auto;
}
#panel:hover {
  opacity: 1;
  background: rgba(13,17,23,0.55);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(30,36,56,0.8);
}
.panel-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  font-size: 16px; cursor: pointer; transition: all 0.2s ease;
  opacity: 0.5;
}
.panel-btn:disabled { opacity: 0.2; cursor: not-allowed; }
#panel:hover .panel-btn:not(:disabled):hover { opacity: 1; background: rgba(108,140,255,0.1); }
.panel-btn-primary:not(:disabled) { opacity: 0.6; color: var(--accent); }
#panel:hover .panel-btn-primary:not(:disabled):hover { background: rgba(108,140,255,0.15); }
.panel-divider {
  width: 1px; height: 20px; margin: 0 2px;
  background: rgba(30,36,56,0.3); flex-shrink: 0;
  transition: background 0.3s ease;
}
#panel:hover .panel-divider { background: rgba(30,36,56,0.6); }
.panel-group { display: flex; gap: 2px; }
.v-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: none; background: transparent;
  font-size: 16px; cursor: pointer; transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.5;
}
.v-btn:disabled { opacity: 0.15; cursor: not-allowed; }
#panel:hover .v-btn:not(:disabled):hover { opacity: 1; background: rgba(108,140,255,0.08); }
.v-btn.active { opacity: 1; background: rgba(108,140,255,0.12); }
.panel-select {
  padding: 3px 6px; border-radius: 4px;
  border: none; background: transparent;
  color: var(--text2); font-size: 11px; cursor: pointer;
  transition: all 0.2s ease;
  min-width: 52px; max-width: 70px;
  opacity: 0.5;
}
.panel-select:disabled { opacity: 0.15; cursor: not-allowed; }
#panel:hover .panel-select:not(:disabled) { opacity: 0.8; }
#panel:hover .panel-select:not(:disabled):hover { opacity: 1; }
.panel-select option { background: #0d1117; color: var(--text); }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 400px;
  padding: 32px;
  max-height: 90vh; overflow-y: auto;
}
.modal-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; font-size: 18px;
  color: var(--text3); cursor: pointer; padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.auth-desc { font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: rgba(7,10,15,0.5);
  color: var(--text); font-size: 14px;
  transition: border-color var(--transition);
}
.auth-form input:focus { border-color: var(--accent); }
.form-error {
  font-size: 13px; color: var(--red); padding: 8px 12px;
  background: rgba(248,113,113,0.1); border-radius: var(--radius-sm);
  border: 1px solid rgba(248,113,113,0.2);
}
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; font-size: 12px; color: var(--text3);
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.auth-oauth { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.auth-switch { font-size: 13px; color: var(--text2); text-align: center; }

/* ===== MODAL PROCESS ===== */
.modal-process { max-width: 480px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 24px; }
.modal-footer { margin-top: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text2); }
.form-group input[type="date"] {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: rgba(7,10,15,0.5);
  color: var(--text); font-size: 14px;
}
.proc-value { font-size: 18px; font-weight: 600; color: var(--accent); font-family: var(--mono); }
.range-slider {
  width: 100%; height: 6px; appearance: none;
  background: var(--border); border-radius: 3px; outline: none;
}
.range-slider::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid #0d1117;
}
.accent { color: var(--accent); font-weight: 600; }
.fine-print { font-size: 11px; color: var(--text3); text-align: center; margin-top: 10px; }

/* ===== HISTORY ===== */
.history-empty { text-align: center; padding: 40px; color: var(--text3); font-size: 14px; }
.modal-history { max-width: 520px; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed; top: 72px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; max-width: 380px;
  animation: slideIn 0.3s ease; pointer-events: auto;
}
.toast.success { background: rgba(74,222,128,0.15); border: 1px solid rgba(74,222,128,0.3); color: var(--green); }
.toast.error { background: rgba(248,113,113,0.15); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }
.toast.info { background: rgba(108,140,255,0.15); border: 1px solid rgba(108,140,255,0.3); color: var(--accent); }
.toast.fade-out { animation: fadeOut 0.3s ease forwards; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { transform: translateX(100%); opacity: 0; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #topbar { padding: 4px 12px; }
  #sat-badge { font-size: 10px; padding: 2px 8px; gap: 4px; top: 38px; }
  #panel { padding: 4px 8px; gap: 2px; }
  .panel-btn { width: 28px; height: 28px; font-size: 14px; }
  .v-btn { width: 28px; height: 28px; font-size: 14px; }
  .panel-select { min-width: 44px; font-size: 10px; }
  .user-info #user-email { max-width: 80px; }
}
