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

:root {
  --bg:           #080c18;
  --surface:      rgba(11, 17, 38, 0.88);
  --border:       rgba(99, 102, 241, 0.1);
  --accent:       #6366f1;
  --accent2:      #06b6d4;
  --glow:         rgba(99, 102, 241, 0.22);
  --text:         #f1f5f9;
  --muted:        #94a3b8;
  --danger:       #f43f5e;
  --danger-bg:    rgba(244, 63, 94, 0.08);
  --success:      #10b981;
  --success-bg:   rgba(16, 185, 129, 0.08);
  --input-bg:     rgba(255, 255, 255, 0.03);
  --input-bd:     rgba(255, 255, 255, 0.07);
  --input-focus:  rgba(99, 102, 241, 0.45);
}

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Animated background ── */
.orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.orb-1 {
  width: 720px; height: 720px;
  top: -280px; left: -160px;
  background: radial-gradient(circle at 40% 40%,
    rgba(99, 102, 241, 0.22) 0%,
    rgba(99, 102, 241, 0.04) 50%,
    transparent 70%);
  animation: drift 14s ease-in-out infinite;
}
.orb-2 {
  width: 600px; height: 600px;
  bottom: -220px; right: -120px;
  background: radial-gradient(circle at 60% 60%,
    rgba(6, 182, 212, 0.18) 0%,
    rgba(6, 182, 212, 0.04) 50%,
    transparent 70%);
  animation: drift 18s ease-in-out infinite reverse;
}
@keyframes drift {
  0%,100% { transform: translate(0, 0) scale(1); }
  33%     { transform: translate(40px, -55px) scale(1.04); }
  66%     { transform: translate(-28px, 32px) scale(0.97); }
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, .028) 1px, transparent 1px);
  background-size: 52px 52px;
  z-index: 0;
  pointer-events: none;
}

/* ── Page layout ── */
.page {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 36px 24px;
}

/* ── Card ── */
.card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px 40px;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .04) inset,
    0 48px 96px rgba(0, 0, 0, .55),
    0  0  80px rgba(99, 102, 241, .07);
  animation: rise .65s cubic-bezier(.16, 1, .3, 1) both;
  overflow: hidden;
}

/* Top shimmer line */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, var(--accent) 30%, var(--accent2) 70%, transparent);
  opacity: .55;
}

/* Inner glass highlight */
.card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .025) 0%, transparent 100%);
  border-radius: 24px 24px 0 0;
  pointer-events: none;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(30px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Logo ── */
.logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.logo-box {
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg,
    rgba(99, 102, 241, .18) 0%, rgba(6, 182, 212, .18) 100%);
  border: 1px solid rgba(99, 102, 241, .28);
  border-radius: 18px;
  box-shadow: 0 0 32px rgba(99, 102, 241, .18), 0 0 0 1px rgba(255, 255, 255, .05) inset;
}

/* ── Typography ── */
.card-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.4px;
  text-align: center;
  background: linear-gradient(135deg, #f1f5f9 0%, rgba(241, 245, 249, .65) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.card-sub {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
}

/* ── Divider ── */
.divider {
  height: 1px;
  margin: 0 -40px 28px;
  background: linear-gradient(90deg,
    transparent, rgba(99, 102, 241, .12), transparent);
}

/* ── Form fields ── */
.field {
  position: relative;
  margin-bottom: 14px;
}

.field input {
  width: 100%;
  height: 52px;
  padding: 18px 14px 6px;
  background: var(--input-bg);
  border: 1px solid var(--input-bd);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
  appearance: none;
}

.field.has-toggle input { padding-right: 46px; }

.field input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--glow);
  background: rgba(99, 102, 241, .045);
}

/* Kill autofill yellow */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 100px #0c1228 inset;
  -webkit-text-fill-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
  caret-color: var(--text);
}

/* Floating label */
.field label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14.5px;
  font-family: inherit;
  transition: top .18s ease, transform .18s ease, color .18s ease, font-size .18s ease;
  pointer-events: none;
  user-select: none;
}

.field input:focus ~ label,
.field input:not(:placeholder-shown) ~ label {
  top: 9px;
  transform: translateY(0);
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* ── Eye toggle ── */
.eye-btn {
  position: absolute;
  right: 11px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  transition: color .15s, background .15s;
}

.eye-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .07);
}

/* ── Alert messages ── */
.msg-box { overflow: hidden; }
.msg-box:not(:empty) { margin-bottom: 14px; }

.alert {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  animation: slide-in .25s cubic-bezier(.16, 1, .3, 1);
}
.alert svg { flex-shrink: 0; }

.alert-error {
  background: var(--danger-bg);
  border: 1px solid rgba(244, 63, 94, .2);
  color: #fca5a5;
}
.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, .22);
  color: #6ee7b7;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Submit button ── */
.btn {
  width: 100%;
  height: 50px;
  margin-top: 18px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(110deg, #6366f1 0%, #818cf8 50%, #06b6d4 100%);
  background-size: 200% 200%;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 22px rgba(99, 102, 241, .38);
  animation: grad-shift 5s ease infinite;
  letter-spacing: .15px;
}

@keyframes grad-shift {
  0%,100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(99, 102, 241, .48);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 12px rgba(99, 102, 241, .3);
}
.btn:disabled,
.btn.htmx-request {
  opacity: .72;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading state */
.btn .spinner  { display: none; }
.btn.htmx-request .label   { display: none; }
.btn.htmx-request .spinner { display: block; }

.ring {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer link ── */
.footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 22px;
}
.footer-text { font-size: 13.5px; color: var(--muted); }
.footer a {
  font-size: 13.5px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color .15s;
}
.footer a:hover { color: #818cf8; text-decoration: underline; }

/* ════════════════════════════════════════════
   DASHBOARD LAYOUT
════════════════════════════════════════════ */

/* ── Shell ── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(8, 12, 24, 0.95);
  border-right: 1px solid var(--border);
  padding: 20px 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.logo-box-sm {
  width: 36px; height: 36px;
  border-radius: 10px;
}

.sidebar-brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--text);
}

/* ── Nav links ── */
.sidebar-nav {
  flex: 1;
  padding: 0 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, .05);
  color: var(--text);
}

.nav-link.active {
  background: rgba(99, 102, 241, .14);
  color: var(--accent);
}

/* ── Sidebar bottom (lang toggle) ── */
.sidebar-bottom {
  padding: 16px 18px 4px;
  border-top: 1px solid var(--border);
}

/* ── Main area ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-username {
  font-size: 13.5px;
  color: var(--muted);
}

/* ── Scrollable content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

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

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

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, .025);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, .04);
  vertical-align: middle;
}

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

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, .025);
}

.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; }

.cell-center {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px !important;
}

.cell-error { color: var(--danger); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .2px;
}

.badge-admin {
  background: rgba(99, 102, 241, .15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, .25);
}

.badge-user {
  background: rgba(148, 163, 184, .1);
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, .15);
}

/* ── Delete button ── */
.btn-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}

.btn-del:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(244, 63, 94, .2);
}

.btn-del:disabled { opacity: .4; cursor: not-allowed; }

/* ── Logout button (topbar) ── */
.btn-logout {
  height: 32px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.btn-logout:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .09);
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.page-btn {
  height: 34px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.page-btn:hover {
  background: rgba(99, 102, 241, .1);
  border-color: rgba(99, 102, 241, .3);
}

.page-num {
  font-size: 13px;
  color: var(--muted);
  padding: 0 6px;
}

/* ── Language toggle (shared) ── */
.lang-toggle {
  display: flex;
  gap: 4px;
}

.lang-btn {
  height: 28px;
  padding: 0 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}

.lang-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .06);
}

.lang-btn.active {
  color: var(--accent);
  background: rgba(99, 102, 241, .12);
  border-color: rgba(99, 102, 241, .25);
}

/* ── Floating lang switcher (user view) ── */
.lang-float {
  position: fixed;
  top: 20px;
  right: 24px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
