/* Reset and base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light dark; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
  color: #0f172a;
  background: linear-gradient(180deg, #ffffff, #f7f8fb 60%, #eef2ff);
}

:root {
  --maxw: 1120px;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(2,6,23,0.08);
  --bg-card: #ffffffcc;
  --border: #e5e7eb;
  --primary: #4338ca;
  --primary-700: #3730a3;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.skip-link { position: absolute; left: -999px; top: -999px; background: #111827; color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 12px; top: 12px; z-index: 200; }

/* Header */
.site-header { position: sticky; top: 0; backdrop-filter: blur(8px); background: rgba(255,255,255,0.7); border-bottom: 1px solid var(--border); z-index: 50; }
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; font-weight: 700; }
.brand .logo { font-size: 22px; }
.brand.small .logo { font-size: 18px; }
.brand-text { letter-spacing: 0.2px; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.link { color: #334155; text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* Buttons */
.btn { border: 1px solid var(--border); background: #fff; color: #0f172a; padding: 10px 16px; border-radius: 10px; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 1px 0 rgba(0,0,0,0.04); transition: transform .05s ease, box-shadow .2s ease, background .2s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--primary-700); }
.btn.disabled, .btn:disabled { background: #e5e7eb !important; color: #9ca3af !important; border-color: #e5e7eb !important; cursor: not-allowed !important; transform: none !important; box-shadow: none !important; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ''; position: absolute; top: 50%; left: 50%; margin: -8px 0 0 -8px; width: 16px; height: 16px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 1s linear infinite; color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.secondary { background: #0f172a; color: #fff; border-color: #0f172a; }
.btn.ghost { background: transparent; }
.btn.lg { padding: 14px 18px; border-radius: 12px; }

/* Hero */
.hero { padding: 72px 0 48px; }
.hero-inner { text-align: center; }
.eyebrow { color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; margin: 0 0 10px; }
h1 { font-size: clamp(28px, 4.8vw, 52px); margin: 0 0 12px; letter-spacing: -0.02em; }
.subhead { color: #475569; font-size: clamp(16px, 2.4vw, 20px); margin: 0 auto 20px; max-width: 780px; }
.cta-row { display: inline-flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: center; margin-top: 8px; }
.trust { color: #64748b; margin-top: 22px; font-size: 14px; }

/* Sections */
section { padding: 48px 0; }
h2 { font-size: clamp(22px, 3vw, 32px); margin: 0 0 16px; }
h3 { font-size: 18px; margin: 0 0 6px; }
.muted { color: #6b7280; }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.card { grid-column: span 4; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); backdrop-filter: blur(3px); }
.card .icon { font-size: 24px; }
.features .card p { margin: 0; color: #334155; }
.price.price { text-align: left; }
.price-tag { font-weight: 800; font-size: 18px; margin-top: 8px; }
.cta-center { text-align: center; margin-top: 16px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: #fff; }
.footer-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 28px 0; flex-wrap: wrap; }
.footer-base { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0 28px; border-top: 1px dashed var(--border); }
.footer-left { display: flex; align-items: center; gap: 24px; }
.footer-nav { display: flex; gap: 16px; }
.footer-link { color: #64748b; text-decoration: none; font-size: 14px; }
.footer-link:hover { text-decoration: underline; color: var(--primary); }

/* Responsive */
@media (max-width: 900px) {
  .card { grid-column: span 6; }
}
@media (max-width: 640px) {
  .nav { height: 56px; }
  .card { grid-column: span 12; }
  .footer-cta { flex-direction: column; text-align: center; }
}

/* Modal */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 100; display: none; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.modal-content { position: relative; background: #fff; border-radius: 16px; padding: 32px; width: 90%; max-width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,0.25); animation: modalIn 0.2s ease; }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 24px; color: #6b7280; cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.modal-close:hover { background: #f3f4f6; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Auth tabs */
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn { background: none; border: none; padding: 12px 16px; font-weight: 600; color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; transition: color 0.2s ease, border-color 0.2s ease; }
.tab-btn.active, .tab-btn:hover { color: var(--primary); }
.tab-btn.active { border-bottom-color: var(--primary); }

/* Auth forms */
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-form h2 { margin: 0 0 8px; font-size: 24px; }
.auth-form p { margin: 0 0 24px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; color: #374151; }
.form-group input { width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.1); }

.btn.full { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 14px; }
.auth-error { background: #fef2f2; color: #dc2626; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; border: 1px solid #fecaca; }

/* Invoices Modal */
.invoices-modal { max-width: 600px; }
.modal-subtitle { color: #64748b; margin: 0 0 24px; }
.invoices-list { margin-bottom: 24px; }
.invoice-item { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); }
.invoice-item:last-child { border-bottom: none; }
.invoice-info { display: flex; flex-direction: column; gap: 4px; }
.invoice-date { font-weight: 600; }
.invoice-amount { font-size: 18px; font-weight: 800; color: var(--primary); }
.invoice-actions { display: flex; align-items: center; gap: 12px; }
.invoice-number { color: #64748b; font-size: 14px; font-family: monospace; }
.invoice-link { text-decoration: none; }
.invoices-total { display: flex; justify-content: space-between; align-items: center; padding-top: 16px; border-top: 2px solid var(--border); font-size: 18px; font-weight: 700; }
.total-amount { color: var(--primary); }

/* Dark mode tweaks */
@media (prefers-color-scheme: dark) {
  body { color: #e5e7eb; background: linear-gradient(180deg, #0b1020, #0b1224 60%, #0a132e); }
  .site-header, .site-footer { background: rgba(14,18,36,0.7); }
  .btn { background: #0f172a; color: #e5e7eb; border-color: #1f2937; }
  .btn.secondary { background: #111827; border-color: #111827; }
  .link { color: #cbd5e1; }
  .card { background: rgba(17,24,39,0.6); border-color: #1f2937; }
  .features .card p { color: #cbd5e1; }
  .muted { color: #94a3b8; }
  
  .modal-content { background: #111827; border: 1px solid #1f2937; }
  .modal-close { color: #9ca3af; }
  .modal-close:hover { background: #1f2937; }
  .form-group label { color: #d1d5db; }
  .form-group input { background: #1f2937; border-color: #374151; color: #e5e7eb; }
  .form-group input::placeholder { color: #6b7280; }
  .form-group input:focus { border-color: var(--primary); }
  .tab-btn { color: #9ca3af; }
  .auth-error { background: #1f2937; color: #f87171; border-color: #374151; }
  .modal-subtitle { color: #94a3b8; }
  .invoice-number { color: #94a3b8; }
}

/* Dashboard */
.dashboard { min-height: 100vh; background: #f8fafc; }
.dashboard-header { background: #fff; border-bottom: 1px solid var(--border); }
.dash-nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.dash-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.dash-actions { display: flex; gap: 10px; align-items: center; }

.dashboard-main { padding: 32px 0; }
.dash-welcome { margin-bottom: 32px; }
.dash-welcome h1 { font-size: 32px; margin: 0 0 8px; }
.dash-welcome p { color: #64748b; margin: 0; }

/* Stats */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 40px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-card.clickable { cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }
.stat-icon { font-size: 24px; }
.stat-number { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.stat-label { color: #64748b; font-size: 14px; }

/* Sections */
.dash-section { margin-bottom: 40px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h2 { margin: 0; font-size: 20px; }

/* Instances */
.instances-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.instance-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.instance-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.instance-name { font-weight: 600; }
.instance-status { padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; }
.instance-status.running { background: #dcfce7; color: #166534; }
.instance-status.stopped { background: #f1f5f9; color: #64748b; }
.instance-details { margin-bottom: 16px; }
.instance-gpu { font-weight: 600; margin-bottom: 4px; }
.instance-time { color: #64748b; font-size: 14px; }
.instance-actions { display: flex; gap: 8px; }

.instance-empty { text-align: center; padding: 20px; }
.empty-icon { font-size: 32px; margin-bottom: 12px; }
.empty-text { color: #64748b; margin-bottom: 16px; }

/* Jobs */
.jobs-list { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.job-item { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.job-item:last-child { border-bottom: none; }
.job-name { font-weight: 600; margin-bottom: 4px; }
.job-details { color: #64748b; font-size: 14px; }
.job-status { padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; }
.job-status.success { background: #dcfce7; color: #166534; }
.job-status.running { background: #dbeafe; color: #1e40af; }
.job-status.failed { background: #fef2f2; color: #dc2626; }

/* Dashboard responsive */
@media (max-width: 768px) {
  .dash-nav { flex-direction: column; height: auto; padding: 16px 0; gap: 12px; }
  .dashboard-main { padding: 20px 0; }
  .dash-stats { grid-template-columns: 1fr; }
  .instances-grid { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .job-item { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* Dashboard dark mode */
@media (prefers-color-scheme: dark) {
  .dashboard { background: #0f172a; }
  .dashboard-header { background: #1e293b; border-color: #334155; }
  .stat-card, .instance-card, .jobs-list { background: #1e293b; border-color: #334155; }
  .dash-welcome p, .stat-label, .instance-time, .job-details { color: #94a3b8; }
  .instance-status.stopped { background: #334155; color: #94a3b8; }
  .btn.disabled, .btn:disabled { background: #374151 !important; color: #6b7280 !important; border-color: #374151 !important; }
}

/* About Page */
.about-page { min-height: 100vh; background: linear-gradient(180deg, #ffffff, #f7f8fb 60%, #eef2ff); }
.about-main { padding: 48px 0; }
.about-content { max-width: 800px; margin: 0 auto; }
.about-content h1 { font-size: clamp(28px, 4vw, 42px); margin: 0 0 32px; text-align: center; }

.about-section { margin-bottom: 40px; }
.about-section h2 { font-size: 24px; margin: 0 0 16px; color: #1e293b; }
.about-section p { line-height: 1.7; color: #475569; margin-bottom: 16px; }

.company-info { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-top: 16px; }
.company-info h3 { font-size: 20px; margin: 0 0 16px; color: var(--primary); }
.company-detail { margin-bottom: 16px; }
.company-address { margin-top: 16px; }
.company-address address { font-style: normal; line-height: 1.6; color: #64748b; margin-top: 8px; }

/* About page dark mode */
@media (prefers-color-scheme: dark) {
  .about-page { background: linear-gradient(180deg, #0b1020, #0b1224 60%, #0a132e); color: #e5e7eb; }
  .about-section h2 { color: #e5e7eb; }
  .about-section p { color: #cbd5e1; }
  .company-info { background: #1e293b; border-color: #334155; }
  .company-info h3 { color: var(--primary); }
  .company-address address { color: #94a3b8; }
  .footer-link { color: #94a3b8; }
}


