:root {
  --bg-0: #0b1014;
  --bg-1: #11181f;
  --bg-2: #1a2329;
  --bg-3: #232e36;
  --border: #2a3640;
  --border-bright: #3a4a56;
  --text-0: #e7eef3;
  --text-1: #aab6c0;
  --text-2: #6a7882;
  --accent: #00d4a3;
  --accent-dim: #00a37e;
  --c-green: #21c373;
  --c-orange: #ff8a30;
  --c-yellow: #f5d014;
  --c-red: #ec3d52;
  --c-grey: #6a7882;
  --c-blue: #3a86ff;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px -8px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Manrope', -apple-system, system-ui, sans-serif;
  background: var(--bg-0);
  color: var(--text-0);
  font-size: 14px;
  min-height: 100vh;
}
.mono { font-family: 'JetBrains Mono', monospace; }
.dim { color: var(--text-2); }
.dim.small { font-size: 12px; }
.small { font-size: 12px; }

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  letter-spacing: 0.01em;
  text-align: center;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-bright); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #001a14;
}
.btn.primary:hover { background: var(--accent-dim); }
.btn.danger {
  background: rgba(236, 61, 82, 0.12);
  border-color: rgba(236, 61, 82, 0.4);
  color: var(--c-red);
}
.btn.danger:hover { background: rgba(236, 61, 82, 0.22); }
.btn.block { display: block; width: 100%; margin-top: 8px; }
.btn.small { padding: 5px 10px; font-size: 11px; font-weight: 600; }
.btn-link {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-family: inherit; font-size: inherit; padding: 0;
  text-decoration: underline;
}

/* ========== Forms ========== */
input[type=text], input[type=password], input[type=email], input[type=date], select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 7px;
  width: 100%;
  color-scheme: dark;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 212, 163, 0.15);
}
label {
  display: block;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
label input, label select { margin-top: 5px; text-transform: none; }

/* ========== Flash messages ========== */
.flash {
  padding: 11px 14px;
  border-radius: 7px;
  margin-bottom: 14px;
  font-size: 13.5px;
  border-left: 3px solid;
}
.flash-danger { background: rgba(236, 61, 82, 0.10); color: #ffbcc4; border-color: var(--c-red); }
.flash-success { background: rgba(33, 195, 115, 0.10); color: #98e8c0; border-color: var(--c-green); }
.flash-info { background: rgba(58, 134, 255, 0.10); color: #b8d2ff; border-color: var(--c-blue); }
.flash-warning { background: rgba(245, 208, 20, 0.10); color: #f0e0a0; border-color: var(--c-yellow); }

/* ========== Brand ========== */
.brand-mark {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), #008a6a);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  color: #001a14;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 212, 163, 0.3);
}
.brand-mark.big {
  width: 48px; height: 48px; font-size: 22px; border-radius: 10px;
  margin: 0 auto 16px;
}

/* ========== Topbar ========== */
.topbar {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text-0);
  font-weight: 800; font-size: 15px;
  letter-spacing: -0.01em;
}
.topbar-brand-mark {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), #008a6a);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #001a14; font-size: 14px;
}
.topbar-nav { display: flex; gap: 4px; flex: 1; }
.topbar-nav a {
  text-decoration: none;
  color: var(--text-1);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}
.topbar-nav a:hover { background: var(--bg-2); color: var(--text-0); }
.topbar-nav a.active {
  background: rgba(0, 212, 163, 0.12);
  color: var(--accent);
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-username { font-size: 13px; color: var(--text-1); font-weight: 500; }
.topbar-role {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-admin { background: rgba(0, 212, 163, 0.15); color: var(--accent); }
.role-uploader { background: rgba(255, 165, 0, 0.15); color: var(--c-orange); }
.role-viewer { background: var(--bg-3); color: var(--text-1); }
.topbar-logout {
  text-decoration: none;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.topbar-logout:hover { color: var(--c-red); border-color: var(--c-red); }

/* ========== Login page ========== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at top left, rgba(0, 212, 163, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(58, 134, 255, 0.08) 0%, transparent 50%),
    var(--bg-0);
  z-index: -1;
}
.login-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.04) 1px, transparent 0);
  background-size: 32px 32px;
}
.login-wrap { padding: 30px 20px; width: 100%; max-width: 420px; }
.login-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-card);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { margin: 8px 0 4px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.login-brand p { margin: 0; font-size: 13px; }
.login-foot { text-align: center; font-size: 11.5px; margin: 18px 0 0; }

/* ========== Install page ========== */
.install-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--bg-0);
}
.install-wrap { padding: 30px 20px; width: 100%; max-width: 480px; }
.install-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px;
  box-shadow: var(--shadow-card);
}
.install-header { text-align: center; margin-bottom: 22px; }
.install-header h1 { margin: 6px 0 2px; font-size: 18px; }
.install-header p { margin: 0; font-size: 13px; }
.install-card h3 { font-size: 15px; margin: 0 0 8px; }
.install-card p { margin: 0 0 14px; }
.install-card code {
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

/* ========== Admin page ========== */
.admin-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 24px;
}
.admin-header { margin-bottom: 22px; }
.admin-header h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.admin-header p { margin: 0; }
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.tab {
  text-decoration: none;
  color: var(--text-1);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-0); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 26px;
  margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }

.info-box {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 13px;
  margin: 12px 0 18px;
}

/* Upload dropzone */
.upload-dropzone {
  border: 2px dashed var(--border-bright);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-2);
  margin: 18px 0;
}
.upload-dropzone:hover, .upload-dropzone.over {
  border-color: var(--accent);
  background: rgba(0, 212, 163, 0.05);
}
.dz-icon { font-size: 40px; margin-bottom: 10px; opacity: 0.7; }
.dz-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.dz-sub { font-size: 13px; margin-bottom: 8px; }
.dz-format { font-size: 11px; }
.dz-selected { margin-top: 14px; font-size: 13px; }

.upload-result {
  margin-top: 18px;
  padding: 18px 20px;
  border-radius: 10px;
  border-left: 3px solid;
}
.upload-result.success { background: rgba(33, 195, 115, 0.08); border-color: var(--c-green); }
.upload-result.error { background: rgba(236, 61, 82, 0.08); border-color: var(--c-red); }
.upload-result.loading {
  background: var(--bg-2); border-color: var(--accent);
  display: flex; gap: 14px; align-items: center;
}
.upload-result h3 { margin: 0 0 12px; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.result-grid > div {
  background: var(--bg-2);
  padding: 9px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
}
.result-grid > div span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: block; margin-bottom: 2px;
}
.result-grid > div strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
}

.cols-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px;
  margin: 8px 0;
}
.cols-grid span {
  background: var(--bg-2);
  padding: 5px 10px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border: 1px solid var(--border);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: var(--bg-2); }

.role-pill {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
}

.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }

.inline-form {
  display: flex; gap: 6px; align-items: stretch;
  padding: 12px;
  background: var(--bg-2);
  border-radius: 8px;
}
.inline-form input, .inline-form select {
  font-size: 13px;
  padding: 7px 10px;
  flex: 1;
  min-width: 120px;
}

/* Empty state */
.empty-state {
  display: flex;
  align-items: center; justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 20px;
}
.empty-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 32px;
  text-align: center;
  max-width: 420px;
}
.empty-card h2 { margin: 0 0 8px; font-size: 18px; }
.empty-card p { margin: 0 0 16px; }

/* Loading */
.loading {
  position: fixed; inset: 0;
  background: var(--bg-0);
  display: flex;
  align-items: center; justify-content: center;
  z-index: 9999;
  flex-direction: column;
  gap: 14px;
}
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--bg-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-spinner.small { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-1); font-size: 13px; font-weight: 500; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }
