:root {
  --bg: #0a0c16;
  --bg-alt: #0d1020;
  --panel: #141828;
  --panel-2: #191e33;
  --panel-border: #262c47;
  --panel-border-soft: #1e2338;
  --text: #e9ebf5;
  --muted: #8a90ab;
  --accent: #7c6bf0;
  --accent-2: #5b8cff;
  --accent-grad: linear-gradient(135deg, #5b8cff 0%, #8a63ff 100%);
  --danger: #f0507c;
  --success: #4ade80;
  --warning: #f0c050;
  --shadow-color: 222deg 60% 3%;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(124, 108, 240, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(91, 140, 255, 0.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  animation: bodyFadeIn 0.4s ease both;
}

/* Custom scrollbar -- a "smooth" feeling dashboard should not have the
   default OS scrollbar clashing with a dark theme. */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 999px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

@keyframes bodyFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes markGlow {
  0%, 100% { filter: drop-shadow(0 2px 10px rgba(124, 108, 240, 0.45)); }
  50% { filter: drop-shadow(0 2px 16px rgba(91, 140, 255, 0.65)); }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--panel-border-soft);
  background: rgba(13, 16, 32, 0.6);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px;
  height: 30px;
  animation: markGlow 4s ease-in-out infinite;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }

.main-nav { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--panel-border-soft); border-radius: 10px; padding: 3px; }
.main-nav[hidden] { display: none; }
.main-nav .nav-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 6px 14px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}
.main-nav .nav-btn:hover { color: var(--text); }
.main-nav .nav-btn.active { background: var(--accent-grad); color: white; box-shadow: 0 2px 10px rgba(124, 108, 240, 0.35); }

main { padding: 28px; max-width: 1200px; margin: 0 auto; animation: fadeInUp 0.35s ease both; }

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.table-toolbar h2 { font-size: 20px; letter-spacing: -0.01em; margin: 0; }

.detections-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border-soft);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px hsl(var(--shadow-color) / 0.6);
}
.detections-table th, .detections-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--panel-border-soft);
  font-size: 13px;
}
.detections-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.02);
}
.detections-table tbody tr { cursor: pointer; transition: background 0.15s ease, transform 0.15s ease; animation: fadeInUp 0.3s ease both; }
.detections-table tbody tr:nth-child(1) { animation-delay: 0.02s; }
.detections-table tbody tr:nth-child(2) { animation-delay: 0.05s; }
.detections-table tbody tr:nth-child(3) { animation-delay: 0.08s; }
.detections-table tbody tr:nth-child(4) { animation-delay: 0.11s; }
.detections-table tbody tr:nth-child(5) { animation-delay: 0.14s; }
.detections-table tbody tr:nth-child(n+6) { animation-delay: 0.16s; }
.detections-table tbody tr:hover { background: var(--panel-2); }
.detections-table tbody tr:last-child td { border-bottom: none; }
.detections-table .empty { text-align: center; color: var(--muted); padding: 32px; cursor: default; }

.score-pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f0507c, #f07c50);
  color: white;
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(240, 80, 124, 0.35);
}

.status-pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.status-pill.new { background: rgba(240, 192, 80, 0.16); color: var(--warning); border: 1px solid rgba(240, 192, 80, 0.3); }
.status-pill.reviewed { background: rgba(74, 222, 128, 0.14); color: var(--success); border: 1px solid rgba(74, 222, 128, 0.3); }

.muted { opacity: 0.65; font-size: 12px; }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--panel-border-soft);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.lang-toggle button {
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--muted);
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease;
}
.lang-toggle button.active { background: var(--accent-grad); color: white; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
button:active { transform: translateY(1px) scale(0.98); }

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

.btn-primary {
  background: linear-gradient(135deg, #4ade80, #22c55e);
  color: #06240f;
  box-shadow: 0 4px 14px rgba(74, 222, 128, 0.3);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(74, 222, 128, 0.4); }

.btn-secondary {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 4px 14px rgba(124, 108, 240, 0.3);
}
.btn-secondary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(124, 108, 240, 0.4); }

.btn-danger {
  background: linear-gradient(135deg, #f0507c, #d93b66);
  color: white;
  box-shadow: 0 4px 14px rgba(240, 80, 124, 0.28);
}
.btn-danger:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(240, 80, 124, 0.38); }

/* Login page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-border-soft);
  border-radius: 16px;
  padding: 36px 32px;
  width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 24px 60px -16px hsl(var(--shadow-color) / 0.75), 0 0 0 1px rgba(124, 108, 240, 0.06);
  animation: modalIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.login-mark { width: 52px; height: 52px; margin-bottom: 2px; animation: markGlow 4s ease-in-out infinite; }
.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.login-card h1 .brand-tag {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-transform: none;
  letter-spacing: -0.01em;
  font-weight: 700;
  font-size: 22px;
}
.login-card .subtitle { margin: 0 0 4px; text-align: center; color: var(--muted); font-size: 13px; }
.login-card label { width: 100%; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.login-card input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--panel-border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}
.login-card button {
  width: 100%;
  margin-top: 6px;
  background: var(--accent-grad);
  color: white;
  padding: 11px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(124, 108, 240, 0.35);
}
.login-card button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.login-card .error { color: var(--danger); font-size: 13px; text-align: center; margin: 0; }

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 14, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.overlay[hidden] {
  display: none;
}
.overlay:not([hidden]) { animation: overlayIn 0.2s ease both; }
.modal {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-border-soft);
  border-radius: 14px;
  width: 720px;
  max-width: 92vw;
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px 26px;
  box-shadow: 0 30px 70px -20px hsl(var(--shadow-color) / 0.8);
}
.overlay:not([hidden]) .modal { animation: modalIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) both; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--panel-border-soft); margin-bottom: 18px; }
.tab-btn {
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 9px 14px;
  font-weight: 600;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent-2); }
.badge {
  background: var(--danger);
  color: white;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  margin-left: 4px;
}

.info-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.info-grid h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-2); font-weight: 700; }
.info-grid p { margin: 4px 0; font-size: 13px; word-break: break-all; }
.score { font-size: 30px; font-weight: 800; background: linear-gradient(135deg, #f0507c, #f07c50); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 0; }

#notesBox {
  width: 100%;
  min-height: 80px;
  background: var(--bg-alt);
  border: 1px solid var(--panel-border-soft);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#notesBox:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15); }
.actions { display: flex; gap: 10px; margin-top: 14px; }

.tab-content[hidden] { display: none; }
.tab-content:not([hidden]) { animation: fadeInUp 0.25s ease both; }

.signal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.signal-list li {
  background: var(--bg-alt);
  border: 1px solid var(--panel-border-soft);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 13px;
  transition: border-color 0.15s ease;
}
.signal-list li:hover { border-color: var(--panel-border); }
.signal-list .sig-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.signal-list .sig-type { color: var(--accent-2); font-weight: 700; }
.signal-list .sig-severity { color: var(--danger); font-weight: 700; }
.signal-list .sig-detail { color: var(--muted); }
.signal-list .sig-time { color: var(--muted); font-size: 11px; margin-top: 4px; }
.signal-list .empty { color: var(--muted); text-align: center; padding: 20px; }

/* Customer admin form */
.form-grid { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.form-grid input {
  background: var(--bg-alt);
  border: 1px solid var(--panel-border-soft);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-grid input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15); }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.error[hidden] { display: none; }

.file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li a {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-alt);
  border: 1px solid var(--panel-border-soft);
  border-radius: 8px;
  padding: 9px 12px;
  display: block;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.file-list li a:hover { background: var(--panel-2); border-color: var(--panel-border); transform: translateX(2px); }

.btn-primary[disabled] { opacity: 0.55; cursor: default; transform: none !important; filter: none !important; }
