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

:root {
  --bg: #0d0d10;
  --surface: #16161b;
  --surface-2: #1c1c22;
  --border: #26262e;
  --text: #e8e8ec;
  --text-dim: #9a9aa8;
  --purple: #5b21b6;
  --purple-light: #7c3aed;
  --red: #dc2626;
  --green: #22c55e;
  --yellow: #eab308;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
body.app { padding-top: 56px; }

/* ---------- Auth ---------- */
.auth-body { display: grid; place-items: center; padding: 20px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 36px 28px;
  max-width: 380px; width: 100%; text-align: center;
}
.logo-big { font-size: 2.5rem; color: var(--purple-light); margin-bottom: 8px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-card .muted { margin-bottom: 20px; display: block; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 12px 14px;
  border-radius: 8px; font-size: .95rem;
}
.auth-form input:focus { outline: none; border-color: var(--purple-light); }
.flash {
  background: #7f1d1d; color: #fca5a5;
  padding: 10px; border-radius: 8px;
  margin-bottom: 16px; font-size: .85rem;
}
.small-note { font-size: .8rem; margin-top: 16px; }

.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--bg); padding: 4px; border-radius: 8px;
}
.tab {
  flex: 1; padding: 8px 12px; border: none;
  background: transparent; color: var(--text-dim);
  cursor: pointer; border-radius: 6px;
  font-size: .9rem; font-weight: 500;
}
.tab.active { background: var(--surface-2); color: var(--text); }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px; gap: 12px;
  z-index: 100;
}
.menu-btn {
  background: none; border: none; color: var(--text);
  font-size: 1.4rem; cursor: pointer; padding: 4px 8px;
}
.workspace {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 8px; flex: 1;
}
.avatar, .user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--purple-light); color: white;
  display: grid; place-items: center;
  font-weight: 600; font-size: .85rem;
  text-decoration: none;
}
.ws-name { font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  color: var(--text-dim); text-decoration: none;
  font-size: 1.3rem; padding: 6px 12px;
}
.badge-admin {
  font-size: .65rem; letter-spacing: .08em;
  background: var(--purple); color: white;
  padding: 3px 6px; border-radius: 4px;
  margin-left: 6px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 56px; bottom: 0; left: -320px;
  width: 300px; background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px; overflow-y: auto;
  transition: left .25s ease; z-index: 99;
  display: flex; flex-direction: column;
}
.sidebar.open { left: 0; }
.sidebar-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.logo { font-size: 1.5rem; color: var(--purple-light); }
.close-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 1.2rem; cursor: pointer;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px;
  color: var(--text); text-decoration: none;
  font-size: .95rem; margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-section {
  margin: 20px 12px 8px;
  font-size: .7rem; letter-spacing: .1em;
  color: var(--text-dim); font-weight: 600;
}
.sidebar-footer {
  margin-top: auto; padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ---------- Content ---------- */
.content { max-width: 900px; margin: 0 auto; padding: 32px 20px 80px; }
.page-title { font-size: 2rem; font-weight: 700; margin-bottom: 20px; }
.section-title { font-size: 1.3rem; font-weight: 700; margin: 28px 0 14px; }
.back-link {
  color: var(--text-dim); text-decoration: none;
  font-size: .9rem; display: inline-block; margin-bottom: 12px;
}
.muted { color: var(--text-dim); }

/* ---------- Project grid ---------- */
.project-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px;
}
@media (min-width: 640px) { .project-grid { grid-template-columns: 1fr 1fr; } }

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s;
}
.project-card:hover { border-color: #444; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.card-head strong { font-size: 1.1rem; }
.card-head small { font-size: .8rem; }
.card-meta small { color: var(--text-dim); font-size: .8rem; }
.card-url {
  color: var(--text-dim);
  font-size: .75rem;
  font-family: ui-monospace, monospace;
  word-break: break-all;
}

.pill {
  display: inline-block; padding: 6px 12px;
  border-radius: 4px; font-size: .85rem; font-weight: 500;
}
.pill-green, .pill-running { background: #14532d; color: #86efac; }
.pill-red, .pill-failed, .pill-error { background: #7f1d1d; color: #fca5a5; }
.pill-yellow, .pill-building { background: #713f12; color: #fde68a; }
.pill-gray, .pill-uploaded, .pill-stopped { background: #27272a; color: #a1a1aa; }

.create-card {
  border: 1px dashed #3a3a44;
  background: transparent;
  display: grid; place-items: center;
  color: var(--text-dim); font-size: 1rem; min-height: 110px;
}
.create-card:hover { border-color: var(--purple-light); color: var(--text); }

/* ---------- Forms ---------- */
.deploy-form { display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.deploy-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .9rem; color: var(--text-dim);
}
.deploy-form input, .deploy-form textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px; border-radius: 8px;
  font-family: inherit; font-size: .95rem;
  resize: vertical;
}
.deploy-form input:focus, .deploy-form textarea:focus {
  outline: none; border-color: var(--purple-light);
}

.resource-picker {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.resource-picker legend {
  padding: 0 8px;
  font-size: .8rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .08em;
}
.resource-picker label {
  display: grid;
  grid-template-columns: 100px 1fr 90px;
  align-items: center; gap: 10px;
  color: var(--text);
}
.resource-picker input[type=range] {
  width: 100%; accent-color: var(--purple-light);
}
.resource-picker output {
  font-family: ui-monospace, monospace;
  font-size: .85rem; color: var(--text-dim);
}

.upload-box {
  border: 2px dashed #3a3a44; border-radius: 12px;
  padding: 48px 20px; text-align: center;
  cursor: pointer; transition: .2s;
}
.upload-box:hover, .upload-box.dragover {
  border-color: var(--purple-light); background: var(--surface);
}
.upload-icon { font-size: 2rem; margin-bottom: 12px; }
.link { color: var(--purple-light); text-decoration: underline; }

.file-list {
  font-size: .85rem; color: var(--text-dim);
  max-height: 240px; overflow-y: auto;
}
.file-list div { padding: 2px 0; }

.primary-btn {
  background: var(--purple); color: white; border: none;
  padding: 12px 24px; border-radius: 8px;
  font-size: 1rem; font-weight: 500; cursor: pointer;
  align-self: flex-start;
  text-decoration: none;
  display: inline-block;
}
.primary-btn:disabled { background: #333; cursor: not-allowed; }
.primary-btn:hover:not(:disabled) { background: var(--purple-light); }

.status-text { color: var(--text-dim); font-size: .9rem; }

.meta-row {
  display: flex; gap: 16px; align-items: center;
  margin: 8px 0 12px; flex-wrap: wrap;
}
.actions { margin: 20px 0; display: flex; gap: 10px; flex-wrap: wrap; }
.ghost-btn, .danger-btn {
  padding: 10px 20px; border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text);
  cursor: pointer; font-size: .9rem;
  text-decoration: none;
}
.danger-btn { border-color: #7f1d1d; color: #fca5a5; }
.danger-btn:hover { background: #7f1d1d; color: white; }
.ghost-btn:hover { background: var(--surface-2); }

.public-link-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.public-link-box label {
  display: block; font-size: .8rem;
  color: var(--text-dim); margin-bottom: 8px;
}
.url-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.url-row input {
  flex: 1; min-width: 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: .85rem;
}

.env-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 0;
}
.env-row {
  display: flex; justify-content: space-between;
  padding: 8px 16px; font-size: .85rem;
}
.env-row code {
  background: var(--surface-2);
  padding: 2px 6px; border-radius: 4px;
}
.env-val { color: var(--text-dim); font-family: ui-monospace, monospace; }

pre#logs {
  background: #08080a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: ui-monospace, monospace;
  font-size: .82rem; max-height: 500px; overflow-y: auto;
  white-space: pre-wrap; color: #b8b8c0;
}

/* ---------- Billing / Usage ---------- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.plan-card.current {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 2px rgba(124,58,237,.25);
}
.plan-head {
  display: flex; justify-content: space-between; align-items: baseline;
}
.plan-head h3 { font-size: 1.1rem; }
.price { font-size: 1.5rem; font-weight: 700; color: var(--purple-light); }
.price small { font-size: .8rem; color: var(--text-dim); font-weight: 400; }
.plan-specs {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  font-size: .9rem;
}
.plan-specs li { color: var(--text-dim); }
.plan-specs strong { color: var(--text); }

.usage-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: 12px;
}
.usage-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; text-align: center;
}
.usage-item span {
  font-size: 1.2rem; font-weight: 700; display: block;
  margin-bottom: 4px;
}
.usage-item small { color: var(--text-dim); font-size: .8rem; }
.bar {
  height: 6px; background: #222; border-radius: 3px;
  overflow: hidden; margin-top: 10px;
}
.bar i { display: block; height: 100%; background: var(--purple-light); }

/* ---------- Admin ---------- */
.broadcast-list { display: flex; flex-direction: column; gap: 10px; }
.broadcast-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.broadcast-item p { font-size: .85rem; margin-top: 4px; }
.mini-link { color: var(--purple-light); font-size: .8rem; text-decoration: none; }

.user-table { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}

/* ---------- Broadcast modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: grid; place-items: center;
  z-index: 999; padding: 20px;
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 480px; width: 100%;
  padding: 24px;
  animation: slideUp .25s ease;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; margin-bottom: 14px;
}
.modal-head h3 { font-size: 1.2rem; }
.modal-body {
  color: var(--text-dim);
  font-size: .95rem; line-height: 1.5;
  margin-bottom: 20px;
  white-space: pre-wrap;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}