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

:root {
  --bg: #0d0d0f;
  --surface: #18181c;
  --surface2: #222228;
  --border: #2e2e38;
  --accent: #a855f7;
  --accent2: #7c3aed;
  --text: #f0f0f5;
  --muted: #888899;
  --danger: #ef4444;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 60px;
}
.nav-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.nav-links { display: flex; gap: 20px; flex: 1; }
.nav-links a { color: var(--muted); font-size: 14px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.nav-user a { color: var(--muted); }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 40px 24px; }

/* Auth */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.auth-box h1 { font-size: 28px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.tagline { color: var(--muted); margin-bottom: 28px; }
.auth-box form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-box input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  width: 100%;
}
.auth-box input:focus { outline: none; border-color: var(--accent); }
.auth-box button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.auth-box button:hover { background: var(--accent2); }
.switch { margin-top: 20px; color: var(--muted); font-size: 14px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }

/* Dashboard welcome */
.welcome { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; }
.welcome h2 { font-size: 24px; font-weight: 700; }
.credits { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 16px; font-size: 14px; color: var(--accent); }

/* Action cards */
.action-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 48px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
  display: block;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.card-icon { font-size: 32px; margin-bottom: 12px; }
.card h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.card p { font-size: 13px; color: var(--muted); }

/* Section title */
.section-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.gallery-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.gallery-item img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.gallery-item .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  color: var(--accent);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  font-weight: 600;
}
.caption-result { padding: 16px; font-size: 14px; color: var(--text); font-style: italic; }
.prompt-preview { padding: 0 12px 8px; font-size: 12px; color: var(--muted); }
.meta { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--border); }
.date { font-size: 11px; color: var(--muted); }
.btn-download-sm {
  display: block;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  background: var(--surface2);
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.btn-download-sm:hover { color: var(--accent); text-decoration: none; }

/* Empty state */
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 16px; }

/* Generate page */
.generate-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 768px) { .generate-layout { grid-template-columns: 1fr; } }

.generate-form { display: flex; flex-direction: column; gap: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field textarea, .field select, .field input[type=text], .field input[type=file] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
.field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.btn-generate {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
}
.btn-generate:hover:not(:disabled) { opacity: 0.9; }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

.generate-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 20px;
  flex-direction: column;
  gap: 16px;
}
.result-placeholder { color: var(--muted); font-size: 15px; }

.generating { text-align: center; color: var(--muted); }
.spinner {
  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 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-download {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
}
.btn-download:hover { border-color: var(--accent); text-decoration: none; }
.credits-left { font-size: 13px; color: var(--muted); }

/* Admin panel */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.admin-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.admin-card.wide { grid-column: 1 / -1; }
.admin-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 15px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.dot-red    { background: #ef4444; }
.dot-yellow { background: #f59e0b; animation: pulse 1s infinite; }
.dot-loading{ background: var(--muted); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.instance-info { margin-bottom: 16px; }
.info-row, .info-row-list .info-row {
    display: flex; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.info-row span:first-child { color: var(--muted); }
.info-row span:last-child  { font-weight: 500; }

.server-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn-action { padding: 10px 20px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-start  { background: #22c55e; color: #000; }
.btn-stop   { background: #ef4444; color: #fff; }
.btn-launch { background: var(--accent); color: #fff; }
.btn-action:disabled { opacity: 0.5; cursor: not-allowed; }

.action-msg { margin-top: 12px; font-size: 14px; padding: 8px 12px; border-radius: 6px; }
.action-msg.info    { background: rgba(168,85,247,0.15); color: var(--accent); }
.action-msg.success { background: rgba(34,197,94,0.15); color: #86efac; }
.action-msg.error-msg { background: rgba(239,68,68,0.15); color: #fca5a5; }

.user-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; flex-wrap: wrap; }
.uname { font-weight: 600; min-width: 100px; }
.uemail { color: var(--muted); flex: 1; }
.ucredits { color: var(--accent); }
.udate { color: var(--muted); font-size: 12px; }
.btn-sm { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 4px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.btn-sm:hover { border-color: var(--accent); }

.caption-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  font-size: 16px;
  font-style: italic;
  line-height: 1.7;
  text-align: center;
  width: 100%;
}
