:root {
  --bg: #0a0a0f;
  --card: #111118;
  --card-hover: #16161f;
  --border: #1e1e2a;
  --text: #e5e5e5;
  --text-muted: #888;
  --text-dim: #555;
  --brand: #6366f1;
  --brand-hover: #4f46e5;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --cyan: #06b6d4;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Login --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px;
  width: 400px;
  max-width: 90%;
}
.login-card h1 { font-size: 24px; text-align: center; margin-bottom: 4px; }
.login-card .sub { color: var(--text-muted); font-size: 13px; text-align: center; margin-bottom: 28px; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: #1a1a24;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--brand); }
.totp-input {
  text-align: center;
  font-size: 28px;
  letter-spacing: 0.4em;
  padding: 14px !important;
}
.error { color: var(--red); font-size: 13px; text-align: center; margin-bottom: 12px; }
.success { color: var(--green); font-size: 13px; text-align: center; margin-bottom: 12px; }

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  text-align: center;
}
.btn-brand { background: var(--brand); color: white; width: 100%; }
.btn-brand:hover { background: var(--brand-hover); }
.btn-brand:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 8px 16px; font-size: 13px; width: auto; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #16a34a; }

/* --- Shell --- */
.shell { display: none; flex-direction: column; min-height: 100vh; }
.shell.active { display: flex; }

.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.navbar-left { display: flex; align-items: center; gap: 24px; }
.navbar-brand { font-weight: 700; font-size: 16px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.nav-links a:hover { color: var(--text); background: #1a1a24; }
.nav-links a.active { background: var(--brand); color: white; }
.nav-links .admin-only { display: none; }
.nav-links .admin-divider {
  width: 1px;
  background: var(--border);
  margin: 4px 6px;
  display: none;
}
.navbar-right { display: flex; align-items: center; gap: 16px; }
.navbar-right .org { font-size: 13px; color: var(--text-muted); }
.navbar-right .role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--brand);
  color: white;
  display: none;
}
/* --- User dropdown menu --- */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px 5px 5px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s;
}
.user-menu-btn:hover { border-color: var(--text-dim); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
}
.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chevron { font-size: 10px; color: var(--text-dim); transition: transform 0.15s; }
.user-menu.open .user-chevron { transform: rotate(180deg); }

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 180px;
  padding: 4px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.user-menu.open .user-dropdown { display: block; }

.dropdown-item {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.1s;
}
.dropdown-item:hover { background: #1a1a24; color: var(--text); }
.dropdown-danger { color: var(--red); }
.dropdown-danger:hover { background: rgba(239,68,68,0.1); color: var(--red); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

.content { flex: 1; padding: 24px; overflow-y: auto; }
.container { max-width: 960px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* --- Status cards --- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card { padding: 16px; border-radius: 12px; }
.stat-card .label { font-size: 13px; color: var(--text-muted); }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 2px; }
.stat-uploading { background: rgba(59,130,246,0.08); }
.stat-uploading .value { color: var(--blue); }
.stat-processing { background: rgba(234,179,8,0.08); }
.stat-processing .value { color: var(--yellow); }
.stat-ready { background: rgba(34,197,94,0.08); }
.stat-ready .value { color: var(--green); }
.stat-failed { background: rgba(239,68,68,0.08); }
.stat-failed .value { color: var(--red); }

/* --- Upload list --- */
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.upload-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.upload-item .info { flex: 1; min-width: 0; }
.upload-item .filename { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item .meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.badge {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-uploading { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-upload_complete { background: rgba(6,182,212,0.15); color: var(--cyan); }
.badge-processing { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-dailies_ready { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-failed { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-active { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-inactive { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-admin { background: rgba(99,102,241,0.15); color: var(--brand); }

.progress-wrap { width: 120px; }
.progress-bar { height: 5px; background: #1a1a24; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 4px; transition: width 0.3s; }
.progress-text { font-size: 11px; color: var(--text-dim); text-align: right; margin-top: 2px; }
.empty { text-align: center; padding: 48px; color: var(--text-dim); }

/* --- Profile --- */
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}
.profile-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.profile-row:last-child { border-bottom: none; }
.profile-row .key { color: var(--text-muted); font-size: 13px; }
.profile-row .val { font-size: 14px; }

/* --- Download --- */
.download-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  margin-bottom: 16px;
}
.download-card h2 { font-size: 22px; margin-bottom: 4px; }
.download-card .ver { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.download-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-mac { background: var(--brand); color: white; padding: 14px 32px; border-radius: 10px; font-size: 15px; }
.btn-mac:hover { background: var(--brand-hover); }
.btn-win { background: #1e40af; color: white; padding: 14px 32px; border-radius: 10px; font-size: 15px; }
.btn-win:hover { background: #1e3a8a; }
.btn-disabled { background: #222; color: #555; pointer-events: none; padding: 14px 32px; border-radius: 10px; font-size: 15px; }

/* --- Upload dropzone --- */
.upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.upload-dropzone.dragging {
  border-color: var(--brand);
  background: rgba(99,102,241,0.05);
}
.upload-dropzone-title { color: var(--text); font-size: 18px; margin-bottom: 4px; }
.upload-dropzone-sub { color: var(--text-dim); font-size: 14px; }

.upload-queue-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 8px;
}
.upload-queue-item .uq-row { display: flex; align-items: center; gap: 16px; }
.upload-queue-item .uq-info { flex: 1; min-width: 0; }
.upload-queue-item .uq-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-queue-item .uq-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.upload-queue-item .uq-status { font-size: 12px; font-weight: 600; }
.upload-queue-item .uq-remove {
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px;
}
.upload-queue-item .uq-remove:hover { color: var(--red); }
.upload-queue-item .uq-progress {
  margin-top: 8px; height: 5px; background: #1a1a24; border-radius: 4px; overflow: hidden;
}
.upload-queue-item .uq-fill {
  height: 100%; background: var(--brand); border-radius: 4px; transition: width 0.3s;
}

/* --- Admin tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--card-hover); }
.data-table .actions { white-space: nowrap; }
.data-table .actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.data-table .actions button:hover { color: var(--text); background: #1a1a24; }
.data-table .actions .btn-del:hover { color: var(--red); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 440px;
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .login-card { padding: 32px 24px; }
  .download-buttons { flex-direction: column; }
  .data-table { font-size: 12px; }
}
