/* © 2024-2026 CBM Civil Engineering · QTO shared styles · v0.5 */

:root {
  --bg-app: #0e141c; --bg-card: #11161d; --bg-elevated: #1a2332; --bg-deep: #060a0f;
  --border: #2a394c; --border-soft: #1f2937;
  --text-primary: #e8eef7; --text-muted: #9fb0c3; --text-dim: #6b7280;
  --accent-blue: #4da3ff; --accent-orange: #ff9800; --accent-green: #4ade80;
  --accent-red: #ff5454; --accent-yellow: #fbbf24; --accent-purple: #a78bfa;
  --shadow-card: 0 4px 16px rgba(0,0,0,0.25);
}

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

html, body {
  font-family: 'Heebo', system-ui, -apple-system, sans-serif;
  background: var(--bg-app); color: var(--text-primary);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(77,163,255,0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255,152,0,0.05), transparent),
    var(--bg-app);
  background-attachment: fixed;
}

/* === Header === */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(14,20,28,0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-orange), #b84d11);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 4px 12px rgba(255,152,0,0.3);
}
.brand-text h1 {
  font-family: 'Rubik', sans-serif;
  font-size: 20px; font-weight: 900; letter-spacing: 1px;
  color: var(--text-primary); line-height: 1;
}
.brand-text .subtitle {
  font-size: 11px; color: var(--text-muted);
  font-weight: 500; letter-spacing: 0.3px;
}
.header-actions { display: flex; align-items: center; gap: 8px; }

#langSelect {
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-family: inherit; cursor: pointer;
}
#langSelect:hover { border-color: var(--accent-blue); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 18px; transition: all 0.2s;
  cursor: pointer; font-family: inherit;
}
.icon-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.icon-btn.danger:hover { border-color: var(--accent-red); color: var(--accent-red); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 10px;
  font-size: 13px; color: var(--text-primary);
  max-width: 180px;
}
.user-chip .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.user-chip .email {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* === Main === */
main { max-width: 1400px; margin: 0 auto; padding: 24px 20px 80px; }

/* === Buttons === */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-orange), #b84d11);
  color: white; border: none;
  padding: 12px 22px; border-radius: 10px;
  font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 12px rgba(255,152,0,0.25);
  transition: all 0.2s;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255,152,0,0.35);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border); padding: 9px 16px;
  border-radius: 10px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-secondary.danger:hover { border-color: var(--accent-red); color: var(--accent-red); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Loading splash === */
#splash {
  position: fixed; inset: 0;
  background: var(--bg-app);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000; flex-direction: column; gap: 16px;
}
#splash .splash-logo {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-orange), #b84d11);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; animation: pulse 1.4s ease-in-out infinite;
}
#splash .splash-text {
  font-size: 14px; color: var(--text-muted); font-weight: 600;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.94); opacity: 0.7; }
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Toast === */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); color: var(--text-primary);
  padding: 12px 20px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999; max-width: 90%;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-8px); }
#toast.error { border-color: var(--accent-red); }
#toast.success { border-color: var(--accent-green); }
#toast.warn { border-color: var(--accent-yellow); }

/* === Modal backdrop === */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(8px); padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px;
  max-width: 520px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-title {
  font-family: 'Rubik', sans-serif;
  font-size: 18px; font-weight: 700;
  margin-bottom: 6px; color: var(--text-primary);
}
.modal-hint {
  font-size: 13px; color: var(--text-muted); margin-bottom: 16px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* === Form fields === */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 12px; color: var(--text-muted);
  font-weight: 600; margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.form-group label .required { color: var(--accent-red); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--bg-elevated);
  border: 1px solid var(--border); color: var(--text-primary);
  padding: 10px 14px; border-radius: 10px;
  font-size: 14px; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(77,163,255,0.15);
}
.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Logo upload field */
.logo-field {
  display: flex; gap: 12px; align-items: center;
}
.logo-preview {
  width: 64px; height: 64px;
  background: var(--bg-elevated); border: 1px dashed var(--border);
  border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-preview .placeholder { font-size: 24px; color: var(--text-dim); }
.logo-upload-controls {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
}
.logo-upload-btn {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--accent-blue); padding: 7px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s; align-self: flex-start;
}
.logo-upload-btn:hover { border-color: var(--accent-blue); }
.logo-upload-btn input { display: none; }
.logo-remove {
  font-size: 11px; color: var(--text-muted); cursor: pointer;
  background: none; border: none; padding: 0; font-family: inherit;
  align-self: flex-start;
}
.logo-remove:hover { color: var(--accent-red); }

/* === Empty state === */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 60px 20px;
}
.empty-icon {
  width: 96px; height: 96px; border-radius: 24px;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-card));
  border: 1px solid var(--border); display: flex; align-items: center;
  justify-content: center; font-size: 48px; margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.empty-state h2 {
  font-family: 'Rubik', sans-serif;
  font-size: 26px; font-weight: 700; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.empty-state p {
  color: var(--text-muted); font-size: 15px;
  max-width: 520px; line-height: 1.6; margin-bottom: 24px;
}

/* === Version + auth banners === */
.version-tag {
  position: fixed; bottom: 12px; inset-inline-start: 12px;
  font-size: 11px; color: var(--text-dim);
  font-family: 'Courier New', monospace;
  background: rgba(14,20,28,0.7);
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border-soft);
  letter-spacing: 0.5px; z-index: 50;
}

@media (max-width: 480px) {
  header { padding: 10px 14px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text .subtitle { font-size: 10px; }
  main { padding: 16px 14px 80px; }
  .empty-state { padding: 32px 12px; }
  .empty-state h2 { font-size: 22px; }
  .empty-state p { font-size: 14px; }
  .empty-icon { width: 76px; height: 76px; font-size: 36px; }
  .version-tag { font-size: 10px; }
  .user-chip { padding: 5px 8px; font-size: 12px; max-width: 130px; }
  .user-chip .avatar { width: 22px; height: 22px; font-size: 11px; }
  .modal-card { padding: 18px; }
}

/* ============================================================
   QTO Premium — Banner + Upgrade Modal (v1.6)
   ============================================================ */

/* Top banner */
.qto-premium-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #1A2332;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.qto-premium-banner.info {
  background: linear-gradient(90deg, #E6F4FF 0%, #DBEAFE 100%);
  color: #1E3A8A;
}
.qto-premium-banner.warn {
  background: linear-gradient(90deg, #FEF3C7 0%, #FDE68A 100%);
  color: #92400E;
}
.qto-premium-banner.urgent {
  background: linear-gradient(90deg, #FEE2E2 0%, #FECACA 100%);
  color: #991B1B;
}
.qto-premium-banner-cta {
  display: inline-block;
  padding: 6px 14px;
  background: linear-gradient(135deg, #FFD700, #FF8C00);
  color: #1A2332;
  font-weight: 700;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 6px rgba(255, 140, 0, 0.3);
}
.qto-premium-banner-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.45);
}

/* Upgrade modal */
.qto-premium-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.qto-premium-modal.show { display: flex; }
.qto-premium-card {
  background: var(--bg-card, #1A2332);
  border: 1px solid var(--border, #2a3548);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: qto-premium-slide-in 0.25s cubic-bezier(.2, .8, .2, 1);
}
@keyframes qto-premium-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.qto-premium-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px; height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border, #2a3548);
  border-radius: 50%;
  color: var(--text, #E8EEF7);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.qto-premium-close:hover { background: rgba(255, 255, 255, 0.12); }
.qto-premium-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 12px rgba(255, 215, 0, 0.4));
}
.qto-premium-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text, #E8EEF7);
  margin: 0 0 12px;
  background: linear-gradient(135deg, #FFD700, #FF8C00);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.qto-premium-msg {
  color: var(--text-muted, #9AA8C0);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 20px;
}
.qto-premium-features {
  text-align: start;
  margin: 0 auto 20px;
  display: inline-block;
}
.qto-premium-feat {
  color: var(--text, #E8EEF7);
  font-size: 13px;
  padding: 5px 0;
}
.qto-premium-price {
  margin: 16px 0 20px;
  padding: 16px;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 10px;
}
.qto-premium-price-num {
  font-size: 36px;
  font-weight: 900;
  color: #FFD700;
  line-height: 1;
}
.qto-premium-price-period {
  font-size: 12px;
  color: var(--text-muted, #9AA8C0);
  margin-top: 4px;
}
.qto-premium-cta {
  display: block;
  padding: 14px 24px;
  background: linear-gradient(135deg, #FFD700, #FF8C00);
  color: #1A2332;
  font-weight: 800;
  font-size: 16px;
  text-decoration: none;
  border-radius: 10px;
  margin-top: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.35);
}
.qto-premium-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255, 140, 0, 0.5);
}
.qto-premium-hint {
  font-size: 11px;
  color: var(--text-muted, #9AA8C0);
  margin-top: 10px;
}

/* Mobile */
@media (max-width: 600px) {
  .qto-premium-banner {
    font-size: 12px;
    padding: 8px 12px;
  }
  .qto-premium-banner-cta {
    font-size: 11px;
    padding: 5px 10px;
  }
  .qto-premium-card { padding: 24px 18px; }
  .qto-premium-title { font-size: 20px; }
  .qto-premium-icon { font-size: 44px; }
  .qto-premium-price-num { font-size: 30px; }
}
