/* ─── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Mono:wght@400;700&display=swap');

/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0a0a;
  --bg-card:      #111111;
  --bg-input:     #141414;
  --bg-hover:     #1a1a1a;
  --border:       rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.28);
  --text:         #e0e0e0;
  --text-muted:   #888888;
  --text-dim:     #555555;
  --white:        #ffffff;
  --danger:       #e05454;
  --danger-bg:    rgba(224, 84, 84, 0.12);
  --danger-border:rgba(224, 84, 84, 0.22);
  --success:      #4caf72;
  --success-bg:   rgba(76, 175, 114, 0.12);
  --success-border:rgba(76, 175, 114, 0.22);
  --warning:      #d4a017;
  --info-bg:      rgba(96, 165, 250, 0.12);
  --info-border:  rgba(96, 165, 250, 0.22);
  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    14px;
  --shadow:       0 4px 28px rgba(0, 0, 0, 0.55);
  --shadow-hover: 0 8px 36px rgba(0, 0, 0, 0.65);
  --transition:   0.2s ease;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--white); }

ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

main { flex: 1; padding: 48px 0 80px; }

/* ─── Navigation ────────────────────────────────────────────────────────────── */
.nav {
  background: rgba(10, 10, 10, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}

.nav__brand {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--white);
  flex-shrink: 0;
}
.nav__brand:hover { color: var(--white); }

.nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  flex-wrap: wrap;
}

.nav__links a {
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.nav__links a:hover { color: var(--white); background: var(--bg-hover); }

.nav__links a.admin-link { color: var(--warning); }
.nav__links a.admin-link:hover {
  color: var(--white);
  background: rgba(212, 160, 23, 0.12);
}

.nav__user {
  font-size: 13px;
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Flash Messages ────────────────────────────────────────────────────────── */
.flash {
  padding: 13px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  line-height: 1.5;
}

.flash--success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #7de8a8;
}
.flash--error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #f08080;
}
.flash--info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: #93c5fd;
}

/* ─── Auth Wrapper ──────────────────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px 80px;
  min-height: calc(100vh - 60px);
}

/* ─── Auth Card ─────────────────────────────────────────────────────────────── */
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 40px 36px;
  width: 100%;
  box-shadow: var(--shadow);
}
.auth-card--narrow { max-width: 480px; }
.auth-card--wide   { max-width: 620px; }

.auth-card__logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-card__logo-text {
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--white);
}

.auth-card__title {
  font-size: 23px;
  font-weight: 700;
  color: var(--white);
  text-align: center;
  margin-bottom: 6px;
}
.auth-card__subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
  line-height: 1.5;
}

.auth-card__footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-muted);
}
.auth-card__footer a {
  color: var(--white);
  font-weight: 600;
}
.auth-card__footer a:hover { text-decoration: underline; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group--full { grid-column: 1 / -1; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.form-control {
  display: block;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  padding: 11px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}
.form-control::placeholder { color: var(--text-dim); }
.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea.form-control {
  resize: vertical;
  min-height: 88px;
}

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
select.form-control option { background: #1c1c1c; color: var(--text); }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 16px;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.form-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 5px;
  line-height: 1.4;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  user-select: none;
}
.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--white);
  cursor: pointer;
  flex-shrink: 0;
}
.form-check:hover { color: var(--text); }

.recaptcha-wrap { margin: 22px 0; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.2;
}

.btn--primary {
  background: var(--white);
  color: #0a0a0a;
  border-color: var(--white);
}
.btn--primary:hover {
  background: #e8e8e8;
  color: #0a0a0a;
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(255, 255, 255, 0.1);
}

.btn--outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn--outline:hover {
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--white);
  background: var(--bg-hover);
}

.btn--danger {
  background: var(--danger-bg);
  color: #f08080;
  border-color: var(--danger-border);
}
.btn--danger:hover { background: rgba(224, 84, 84, 0.22); }

.btn--success {
  background: var(--success-bg);
  color: #7de8a8;
  border-color: var(--success-border);
}
.btn--success:hover { background: rgba(76, 175, 114, 0.22); }

.btn--warning {
  background: rgba(212, 160, 23, 0.12);
  color: #fbbf24;
  border-color: rgba(212, 160, 23, 0.22);
}
.btn--warning:hover { background: rgba(212, 160, 23, 0.22); }

.btn--sm { padding: 6px 13px; font-size: 13px; }
.btn--full { width: 100%; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}
.page-title small {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  display: block;
  margin-top: 5px;
  letter-spacing: 0.5px;
}

/* ─── Download Grid ─────────────────────────────────────────────────────────── */
.download-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.download-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.download-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.download-card__icon {
  font-size: 34px;
  line-height: 1;
  flex-shrink: 0;
  width: 50px;
  text-align: center;
}

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

.download-card__name {
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-card__meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.download-card__action { flex-shrink: 0; }

/* ─── Cards (generic) ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 16px;
}

/* ─── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead th {
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.8px;
  font-weight: 600;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.012); }

tbody td {
  padding: 11px 16px;
  color: var(--text);
  vertical-align: middle;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tbody td.td-wrap { white-space: normal; }

.td-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  white-space: normal;
}

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge--green  { background: var(--success-bg);           color: #7de8a8; border: 1px solid var(--success-border); }
.badge--red    { background: var(--danger-bg);            color: #f08080; border: 1px solid var(--danger-border); }
.badge--yellow { background: rgba(212, 160, 23, 0.12);   color: #fbbf24; border: 1px solid rgba(212,160,23,0.22); }
.badge--gray   { background: rgba(255, 255, 255, 0.05);  color: var(--text-dim); border: 1px solid var(--border); }

/* ─── Admin Sub-Nav ─────────────────────────────────────────────────────────── */
.admin-nav {
  display: flex;
  gap: 2px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.admin-nav a {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
}
.admin-nav a:hover { color: var(--white); background: var(--bg-hover); }
.admin-nav a.active { color: var(--white); border-bottom-color: var(--white); }

/* ─── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--text-muted);
}
.empty-state__icon { font-size: 44px; margin-bottom: 14px; opacity: 0.35; }
.empty-state__text { font-size: 16px; }

/* ─── File Upload Area ──────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-area:hover,
.upload-area.dragover {
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--bg-hover);
}
.upload-area input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.upload-area__icon { font-size: 32px; margin-bottom: 10px; }
.upload-area__label { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-area__hint  { font-size: 12px; color: var(--text-dim); }
#file-name-display {
  margin-top: 10px;
  font-size: 13px;
  color: #7de8a8;
  font-family: 'Space Mono', monospace;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 22px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--text-muted); }

/* ─── Utility ───────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-dim     { color: var(--text-dim); }
.text-white   { color: var(--white); }
.text-danger  { color: #f08080; }
.text-success { color: #7de8a8; }
.text-mono    { font-family: 'Space Mono', monospace; }
.text-sm      { font-size: 13px; }
.text-xs      { font-size: 12px; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flex-center  { display: flex; align-items: center; justify-content: center; gap: 8px; }
.flex-gap     { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .auth-wrap { padding: 32px 12px 60px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-group--full { grid-column: 1; }
  .download-card { flex-direction: column; align-items: flex-start; gap: 14px; }
  .download-card__action { width: 100%; }
  .download-card__action .btn { width: 100%; justify-content: center; }
  .nav__inner { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 8px; }
  .nav__brand { font-size: 14px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-title { font-size: 22px; }
  .admin-nav { overflow-x: auto; padding-bottom: 0; }
  .admin-nav::-webkit-scrollbar { display: none; }
}

@media (max-width: 480px) {
  main { padding: 28px 0 60px; }
  .container { padding: 0 14px; }
  table { font-size: 12.5px; }
  tbody td { padding: 10px 12px; }
  thead th { padding: 10px 12px; }
}
