:root {
  --bg: #0f1419;
  --panel: #171d25;
  --border: #2a3441;
  --text: #e8eef6;
  --muted: #93a0b0;
  --accent: #3d9cf0;
  --ok: #2f9e6b;
  --danger: #d45454;
  --warn: #c9953a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2740 0%, var(--bg) 45%);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: #121820;
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { font-weight: 700; letter-spacing: .02em; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a {
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
}
.sidebar nav a.active,
.sidebar nav a:hover {
  background: #1d2734;
  color: var(--text);
}
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.content { flex: 1; }
.topbar { padding: 22px 28px 0; }
.topbar h1 { margin: 0; font-size: 1.4rem; }
.page { padding: 20px 28px 40px; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.card, .panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.card-label { color: var(--muted); font-size: .85rem; }
.card-value { font-size: 1.8rem; font-weight: 700; margin-top: 6px; }
.grid-2 {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
}
.form { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
input, select, textarea, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f151d;
  color: var(--text);
  padding: 10px 12px;
}
button {
  background: var(--accent);
  border: none;
  color: #041018;
  font-weight: 700;
  cursor: pointer;
}
.btn-secondary { background: #2a3648; color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.tight input { width: 120px; padding: 6px 8px; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: .92rem; }
th { color: var(--muted); font-weight: 600; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #243041;
  font-size: .78rem;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 35%, black); }
.badge.invalid_key, .badge.revoked, .badge.ip_denied, .badge.expired { background: color-mix(in srgb, var(--danger) 35%, black); }
.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #243041;
}
.alert.ok { background: color-mix(in srgb, var(--ok) 25%, black); }
.alert.error { background: color-mix(in srgb, var(--danger) 25%, black); }

.processor-grid { align-items: start; }
.processor-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.processor-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.button-link {
  display: inline-block;
  background: var(--accent);
  color: #041018 !important;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 8px;
}
.badge.done, .badge.ready { background: color-mix(in srgb, var(--ok) 35%, black); }
.badge.processing, .badge.scanning, .badge.uploaded { background: color-mix(in srgb, var(--warn) 35%, black); }
.badge.error { background: color-mix(in srgb, var(--danger) 35%, black); }

.dropzone {
  position: relative;
  border: 2px dashed #4a5d75;
  border-radius: 14px;
  background: #101822;
  min-height: 280px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
  margin-bottom: 10px;
  outline: none;
  overflow: hidden;
}
.dropzone-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
  font-size: 0;
}
.dropzone:hover {
  border-color: #6f879f;
  background: #132033;
}
.dropzone.dragover {
  border-style: solid;
  border-color: #2f9e6b !important;
  background: #1b3d2d !important;
  box-shadow: 0 0 0 4px rgba(47, 158, 107, .4), inset 0 0 50px rgba(47, 158, 107, .25);
  transform: scale(1.02);
}
.dropzone.dragover strong { color: #9af0c8; }
.dropzone.dragover #dropzone-hint { color: #8fddb8; }
.dropzone.has-file {
  border-style: solid;
  border-color: #2f9e6b;
  background: #163528;
  box-shadow: 0 0 0 2px rgba(47, 158, 107, .3);
}
.dropzone.has-file strong { color: #9af0c8; }
.dropzone-inner {
  display: grid;
  gap: 8px;
  text-align: center;
  padding: 22px 18px;
  pointer-events: none;
  z-index: 1;
  position: relative;
}
.dropzone-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: #9eb0c3;
  background: #1a2432;
  border: 1px solid #2a3648;
}
.dropzone.dragover .dropzone-icon,
.dropzone.has-file .dropzone-icon {
  color: #0d281c;
  background: #2f9e6b;
  border-color: #3cbc80;
}
.dropzone-file {
  margin-top: 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .85rem;
  word-break: break-all;
}
#upload-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.hidden { display: none !important; }

.upload-progress {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.upload-progress-bar,
.overlay-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #243041;
  overflow: hidden;
}
.upload-progress-bar span,
.overlay-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f7cc8, #3d9cf0);
  transition: width .15s ease;
}
.upload-progress-text {
  color: var(--muted);
  font-size: .9rem;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 16, .72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 9999;
  padding: 20px;
}
.loading-card {
  width: min(420px, 100%);
  background: #171d25;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 22px;
  text-align: center;
  display: grid;
  gap: 10px;
}
.loading-card h3 { margin: 0; }
.loading-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 6px;
  border-radius: 50%;
  border: 3px solid #2a3648;
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
body.loading-lock { overflow: hidden; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.auth-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 12px;
}
.auth-card h1 { margin: 0; font-size: 1.3rem; }
.auth-card form { display: grid; gap: 12px; }

@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; }
  .cards, .grid-2 { grid-template-columns: 1fr; }
}
