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

:root {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-hover: #222;
  --border: #333;
  --text: #f5f5f5;
  --text-muted: #888;
  --accent: #007AFF;
  --accent-hover: #0066d6;
  --danger: #ff3b30;
  --success: #30d158;
  --radius: 12px;
}

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

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 20px; font-weight: 700; }

nav { display: flex; gap: 8px; }

nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

nav a:hover, nav a.active {
  color: var(--text);
  background: var(--bg);
}

nav a.logout { color: var(--danger); }
nav a.logout:hover { background: rgba(255,59,48,0.1); }

/* Main */
main { max-width: 900px; margin: 0 auto; padding: 24px; }

/* App Grid */
.app-grid { display: flex; flex-direction: column; gap: 12px; }

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.app-card:hover { background: var(--surface-hover); border-color: #444; }

.app-icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  overflow: hidden;
}

.app-icon img { width: 100%; height: 100%; object-fit: cover; }

.app-info { flex: 1; min-width: 0; }
.app-name { font-weight: 600; font-size: 16px; }
.app-bundle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.app-version { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.app-action { flex-shrink: 0; }

.btn, button[type="submit"] {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  display: inline-block;
}

.btn:hover, button[type="submit"]:hover { background: var(--accent-hover); }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #e0342a; }

.install-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

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

.empty-state p { font-size: 18px; margin-bottom: 16px; }

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 320px;
  text-align: center;
}

.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
  outline: none;
}

.login-card input:focus { border-color: var(--accent); }

.login-card button {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
}

.login-card .error { color: var(--danger); font-size: 14px; margin-bottom: 8px; }

/* Upload */
.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.upload-card h2 { margin-bottom: 16px; font-size: 20px; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(0,122,255,0.05);
}

.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { font-size: 32px; color: var(--text-muted); margin-bottom: 8px; }
.drop-zone p { color: var(--text-muted); font-size: 14px; }

.file-info {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 14px;
  color: var(--text-muted);
}

textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 12px;
  outline: none;
}

textarea:focus { border-color: var(--accent); }

.upload-card button[type="submit"] { width: 100%; }

.progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.2s;
}

.result { margin-top: 16px; padding: 12px; border-radius: 10px; font-size: 14px; }
.result.success { background: rgba(48,209,88,0.1); color: var(--success); }
.result.error { background: rgba(255,59,48,0.1); color: var(--danger); }
.result a { color: var(--accent); }

.api-info {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.api-info h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }

.api-info pre {
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text); }

.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-header .app-icon { width: 64px; height: 64px; }

.build-list { display: flex; flex-direction: column; gap: 8px; }

.build-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}

.build-meta { flex: 1; }
.build-version { font-weight: 600; font-size: 14px; }
.build-date { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.build-notes { color: var(--text-muted); font-size: 12px; margin-top: 4px; font-style: italic; }
.build-size { color: var(--text-muted); font-size: 12px; }

.build-actions { display: flex; gap: 8px; align-items: center; }

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
}

.delete-btn:hover { color: var(--danger); background: rgba(255,59,48,0.1); }

.modal-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: right;
}

/* Responsive */
@media (max-width: 600px) {
  header { padding: 12px 16px; }
  header h1 { font-size: 17px; }
  nav a { padding: 6px 10px; font-size: 13px; }
  main { padding: 16px; }
  .app-card { padding: 12px; gap: 12px; }
  .app-icon { width: 48px; height: 48px; border-radius: 11px; font-size: 22px; }
  .app-name { font-size: 15px; }
  .upload-card { padding: 16px; }
  .drop-zone { padding: 32px 16px; }
}
