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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #e50000;
  --accent-hover: #cc0000;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- NAV ---- */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

nav .logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.5px;
}

nav .spacer { flex: 1; }

nav .nav-user {
  color: var(--muted);
  font-size: 13px;
}

nav .nav-user strong { color: var(--text); }

/* ---- BUTTONS ---- */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}
.btn-danger:hover { background: var(--error); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 13px; }

button:disabled, .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- FORMS ---- */
.form-group { display: flex; flex-direction: column; gap: 6px; }

label { font-size: 13px; color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="url"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

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

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-card p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-card .form-group { margin-bottom: 16px; }

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 11px;
  font-size: 15px;
}

/* ---- MAIN LAYOUT ---- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---- SUBMIT CARD ---- */
.submit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}

.submit-card h2 {
  font-size: 17px;
  margin-bottom: 16px;
}

.submit-row {
  display: flex;
  gap: 10px;
}

.submit-row input { flex: 1; }

.submit-options {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  width: 100%;
}

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

/* ---- DOWNLOAD LIST ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 { font-size: 17px; }

.download-list { display: flex; flex-direction: column; gap: 10px; }

.download-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.download-item-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.download-item-info { flex: 1; min-width: 0; }

.download-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.download-url {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.status-queued { background: #2a2a3e; color: #8b8bff; }
.status-downloading { background: #1e3a2a; color: var(--success); }
.status-done { background: #1a2e1a; color: var(--success); }
.status-error { background: #2e1a1a; color: var(--error); }
.status-cancelled { background: #2a2a2a; color: var(--muted); }
.status-paused    { background: #2a2a2a; color: var(--muted); }
.status-active    { background: #1e3a2a; color: var(--success); }


.progress-bar-wrap {
  flex: 1;
  background: var(--surface2);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--success);
  border-radius: 99px;
  transition: width 0.4s ease;
}

.download-error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--error);
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

/* ---- ALERT ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error { background: #2e1a1a; color: var(--error); border: 1px solid var(--error); }
.alert-success { background: #1a2e1a; color: var(--success); border: 1px solid var(--success); }
.hidden { display: none !important; }

/* ---- ADMIN ---- */
.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.admin-section-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.admin-section-body { padding: 20px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }

.badge-admin {
  background: #2e1f00;
  color: var(--warning);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
}

.badge-fmt, .badge-subs {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
}

.badge-fmt-video { background: #1a2a1e; color: #4ade80; }
.badge-fmt-audio { background: #1e2a3a; color: #60a5fa; }
.badge-subs      { background: #2a1e2e; color: #c084fc; }
.badge-monitor   { background: #1a2535; color: #6ab0f5; }

.create-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.create-user-form .form-group:last-of-type {
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  .create-user-form { grid-template-columns: 1fr; }
  .submit-row { flex-direction: column; }
}

@media (max-width: 768px) {
  .monitors-table { display: block; }
  .monitors-table thead { display: none; }
  .monitors-table tbody { display: block; }
  .monitors-table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 12px 14px;
  }
  .monitors-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: none;
    font-size: 13px;
  }
  .monitors-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    width: 90px;
  }
  .monitors-table td:first-child {
    display: block;
    margin-bottom: 8px;
    padding-right: 0;
  }
  .monitors-table td:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    text-align: left;
  }
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
}

.modal h3 { margin-bottom: 18px; font-size: 17px; }

.modal .form-group { margin-bottom: 14px; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}
