:root {
  --blue: #2868df;
  --green: #21a67a;
  --purple: #7367f0;
  --orange: #f39c2d;
  --danger: #d93355;
  --ink: #10203f;
  --muted: #68758a;
  --line: #e4eaf3;
  --bg: #f4f7fb;
  --sidebar: #10203f;
  --card: #fff;
  --shadow: 0 18px 45px rgba(16, 32, 68, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 78% -8%, rgba(40, 104, 223, .12), transparent 34%), var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 282px;
  padding: 22px;
  color: #dce8ff;
  background: linear-gradient(180deg, rgba(255,255,255,.04), transparent 24%), var(--sidebar);
  box-shadow: 20px 0 50px rgba(16, 32, 68, .12);
}
.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 28px; }
.admin-brand { display: grid; grid-template-columns: 48px 1fr; column-gap: 12px; align-items: center; }
.admin-brand span {
  grid-row: 1 / 3;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), #5e9cff);
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(40,104,223,.28);
}
.admin-brand strong { color: #fff; font-size: 18px; letter-spacing: 1px; }
.admin-brand small { color: #9fb2d2; font-size: 12px; }
.sidebar-close, .menu-button { display: none; border: 0; color: inherit; background: transparent; cursor: pointer; }
.admin-sidebar nav { display: grid; align-content: start; gap: 8px; }
.admin-sidebar nav a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  color: #d7e4fb;
  border-radius: 10px;
  font-weight: 700;
}
.admin-sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.ghost-button {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: #dce8ff;
  text-align: center;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  cursor: pointer;
}
.admin-main { min-height: 100vh; margin-left: 282px; padding: 24px clamp(22px, 3vw, 42px) 42px; }
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  margin: -24px clamp(-42px, -3vw, -22px) 28px;
  padding: 12px clamp(22px, 3vw, 42px);
  background: rgba(244,247,251,.86);
  border-bottom: 1px solid rgba(228,234,243,.78);
  backdrop-filter: blur(14px);
}
.admin-topbar strong { display: block; }
.admin-topbar small { color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.topbar-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
  color: var(--blue);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 800;
}
.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 28px;
  color: #fff;
  background: linear-gradient(135deg, rgba(255,255,255,.12), transparent 44%), linear-gradient(135deg, #173f98, #2868df);
  border-radius: 14px;
  box-shadow: 0 22px 52px rgba(40,104,223,.22);
}
.dashboard-hero h1, .dashboard-hero p { margin: 0; }
.dashboard-hero h1 { margin-bottom: 10px; font-size: clamp(36px, 5vw, 58px); line-height: .95; }
.dashboard-hero > div:first-child > p:not(.kicker) { max-width: 700px; color: #dce8ff; font-size: 17px; line-height: 1.6; }
.kicker { margin: 0 0 8px; color: var(--blue); font-size: 12px; font-weight: 900; letter-spacing: 3px; text-transform: uppercase; }
.dashboard-hero .kicker { color: #bcd3ff; }
.hero-actions-admin { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.button, button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}
.button.light { color: #173f98; background: #fff; }
button.is-loading { position: relative; color: transparent; pointer-events: none; }
button.is-loading::after {
  position: absolute;
  width: 18px;
  height: 18px;
  content: "";
  border: 3px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 22px; }
.metric-card {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 154px;
  padding: 22px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.metric-card::after {
  position: absolute;
  inset: auto -26px -34px auto;
  width: 105px;
  height: 105px;
  content: "";
  border-radius: 50%;
  opacity: .12;
}
.metric-card i { display: grid; width: 42px; height: 42px; place-items: center; color: #fff; font-style: normal; font-weight: 900; border-radius: 12px; }
.metric-card span { font-size: 42px; font-weight: 900; line-height: 1; }
.metric-card strong { font-size: 17px; }
.metric-card small { color: var(--muted); }
.accent-blue i, .accent-blue::after { background: var(--blue); }
.accent-blue span { color: var(--blue); }
.accent-green i, .accent-green::after { background: var(--green); }
.accent-green span { color: var(--green); }
.accent-purple i, .accent-purple::after { background: var(--purple); }
.accent-purple span { color: var(--purple); }
.accent-orange i, .accent-orange::after { background: var(--orange); }
.accent-orange span { color: var(--orange); }
.panel {
  padding: 22px;
  margin-bottom: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.panel-head h2, .panel h2 { margin: 0; font-size: 24px; }
.panel-head a { color: var(--blue); font-weight: 800; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .85fr); gap: 22px; }
.dashboard-grid.lower { grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr); }
.bar-chart { display: flex; min-height: 280px; align-items: end; gap: 18px; padding: 12px 4px 0; }
.bar-item { display: grid; flex: 1; min-width: 80px; gap: 8px; text-align: center; }
.bar-track {
  position: relative;
  display: flex;
  height: 190px;
  align-items: end;
  justify-content: center;
  background: linear-gradient(180deg, #f8fbff, #eef4fc);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.bar-track span {
  display: block;
  width: 58%;
  min-height: 8px;
  background: linear-gradient(180deg, #64a0ff, var(--blue));
  border-radius: 10px 10px 4px 4px;
  box-shadow: 0 12px 24px rgba(40,104,223,.2);
}
.bar-item strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.bar-item small { color: var(--muted); font-size: 12px; }
.rank-list, .content-list, .quick-actions { display: grid; gap: 12px; }
.rank-list a, .content-list div, .quick-actions a {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid #eaf0f8;
  border-radius: 12px;
}
.rank-list span, .content-list span, .quick-actions span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--blue);
  font-weight: 900;
  background: #eaf2ff;
  border-radius: 10px;
}
.rank-list strong, .content-list strong, .quick-actions strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list small, .content-list small, .quick-actions small { color: var(--muted); }
.content-list div, .quick-actions a { grid-template-columns: 42px 1fr; }
.content-list small, .quick-actions small { grid-column: 2; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.user-list { display: grid; gap: 14px; }
.user-card {
  position: relative;
  padding: 16px;
  background: #f8fbff;
  border: 1px solid #eaf0f8;
  border-radius: 14px;
}
.user-card .form-grid {
  grid-template-columns: 54px minmax(170px, 1fr) minmax(210px, 1fr) minmax(210px, 1fr) auto;
  align-items: end;
}
.user-avatar {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), #65a3ff);
  border-radius: 14px;
}
.user-actions { display: flex; gap: 10px; align-items: center; }
.delete-user-form { position: absolute; right: 16px; top: 16px; }
.delete-user-form button {
  min-height: 34px;
  color: var(--danger);
  background: #fff1f4;
}
.self-note {
  position: absolute;
  right: 16px;
  top: 18px;
  color: var(--muted);
  font-weight: 800;
}
.empty-note { color: var(--muted); }
.notice, .alert {
  padding: 14px 16px;
  margin-bottom: 18px;
  color: #0d6848;
  background: #e7f8f1;
  border: 1px solid #c5eedf;
  border-radius: 10px;
}
.alert { color: #8a1f38; background: #ffeef3; border-color: #ffd4df; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 38px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card { padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--blue); font-size: 42px; font-weight: 900; }
.stat-card p { margin: 4px 0 0; color: var(--muted); }
.action-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 8px; color: #34425b; font-weight: 800; }
input, textarea, select { width: 100%; padding: 12px 13px; color: var(--ink); background: #fff; border: 1px solid #d8e0eb; border-radius: 10px; font: inherit; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #5b6980; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.table-actions { display: flex; gap: 10px; align-items: center; }
.table-actions a { color: var(--blue); font-weight: 800; }
.table-actions form { margin: 0; }
.table-actions button { min-height: 34px; color: var(--danger); background: #fff1f4; }
.admin-preview { max-width: 180px; max-height: 110px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.upload-field { display: grid; grid-template-columns: minmax(0,1fr) 180px; gap: 16px; align-items: stretch; }
.upload-field-wide { grid-template-columns: minmax(0, .9fr) minmax(260px, 1.1fr); }
.upload-field input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.upload-dropzone {
  position: relative;
  display: grid;
  min-height: 150px;
  place-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #30405d;
  background: linear-gradient(135deg, #f7fbff, #fff);
  border: 2px dashed #b9c9df;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.upload-dropzone::before {
  position: absolute;
  inset: 12px;
  content: "";
  background: linear-gradient(135deg, rgba(40,104,223,.08), rgba(46,169,125,.08));
  border-radius: 10px;
  opacity: 0;
  transform: scale(.95);
  transition: opacity .2s ease, transform .2s ease;
}
.upload-dropzone > * { position: relative; z-index: 1; }
.upload-dropzone:hover, .upload-dropzone.is-dragging { border-color: var(--blue); box-shadow: 0 18px 40px rgba(40,104,223,.14); transform: translateY(-2px); }
.upload-dropzone.is-dragging::before { opacity: 1; transform: scale(1); }
.upload-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  color: #fff;
  font-size: 28px;
  background: var(--blue);
  border-radius: 50%;
  animation: floatUpload 2.4s ease-in-out infinite;
}
.upload-dropzone small { max-width: 360px; color: var(--muted); font-weight: 600; }
.upload-preview { display: grid; min-height: 150px; place-items: center; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.upload-preview:empty::before { content: "Preview"; color: #9ba8bc; font-weight: 800; }
.upload-preview img { width: 100%; max-height: 132px; object-fit: contain; border-radius: 8px; }
.gallery-preview {
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  align-content: start;
  gap: 10px;
}
.gallery-preview img {
  height: 86px;
  object-fit: cover;
}
.existing-gallery {
  display: grid;
  gap: 12px;
}
.existing-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.existing-gallery-grid figure {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px;
  background: #f8fbff;
  border: 1px solid #eaf0f8;
  border-radius: 12px;
}
.existing-gallery-grid img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
}
.existing-gallery-grid button {
  width: 100%;
  min-height: 34px;
  color: var(--danger);
  background: #fff1f4;
}
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(245,248,252,.76);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease;
  user-select: none;
}
.page-loader.is-active { opacity: 1; visibility: visible; pointer-events: auto; }
.loader-card { display: grid; min-width: 240px; place-items: center; gap: 10px; padding: 28px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 60px rgba(16,32,68,.16); }
.loader-card small { color: var(--muted); }
.spinner { width: 42px; height: 42px; border: 4px solid #dbe6f5; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.swal2-popup { border-radius: 12px !important; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important; }
.swal2-confirm, .swal2-cancel { border-radius: 8px !important; }
.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 12% 12%, rgba(40,104,223,.16), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(33,166,122,.12), transparent 28%),
    linear-gradient(135deg, #eff7ff, #fff);
}
.login-shell {
  display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(390px, 520px);
  width: min(100%, 1040px);
  min-height: 620px;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(216,224,235,.9);
  border-radius: 22px;
  box-shadow: 0 34px 90px rgba(16,32,68,.16);
}
.login-brand-panel {
  position: relative;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(34px, 5vw, 58px);
  color: #fff;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255,255,255,.13), transparent 40%),
    linear-gradient(145deg, #10203f, #1f63d6);
}
.login-brand-panel::before {
  position: absolute;
  right: -90px;
  bottom: -90px;
  width: 260px;
  height: 260px;
  content: "";
  border: 34px solid rgba(255,255,255,.11);
  border-radius: 50%;
}
.login-brand-panel::after {
  position: absolute;
  top: 34px;
  right: 38px;
  width: 90px;
  height: 90px;
  content: "";
  background: rgba(255,255,255,.12);
  border-radius: 26px;
  transform: rotate(12deg);
}
.login-brand-panel > * { position: relative; z-index: 1; }
.login-brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  color: #1e5ed0;
  font-size: 22px;
  font-weight: 900;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0,0,0,.18);
}
.login-brand-panel .kicker { color: #bdd3ff; margin: 0; }
.login-brand-panel h1 {
  max-width: 520px;
  margin: 0;
  color: #fff;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.02;
}
.login-brand-panel p:not(.kicker) {
  max-width: 480px;
  margin: 0;
  color: #dbe7ff;
  font-size: 17px;
  line-height: 1.7;
}
.login-badges { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.login-badges span {
  padding: 9px 12px;
  color: #eaf2ff;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}
.login-card {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(34px, 5vw, 58px);
  background: #fff;
}
.login-head span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 12px;
  color: var(--blue);
  background: #eaf2ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.login-head h2 {
  margin: 16px 0 8px;
  font-size: 38px;
  line-height: 1;
}
.login-head p { margin: 0; color: var(--muted); }
.login-card label { display: grid; gap: 9px; color: #34425b; font-weight: 900; }
.input-icon {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  min-height: 54px;
  padding: 0 8px 0 0;
  background: #f8fbff;
  border: 1px solid #d8e0eb;
  border-radius: 12px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.input-icon:focus-within {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(40,104,223,.1);
}
.input-icon > span {
  display: grid;
  place-items: center;
  color: var(--blue);
  font-weight: 900;
}
.input-icon input {
  min-height: 52px;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
}
.password-toggle {
  min-height: 36px;
  padding: 0 12px;
  color: var(--blue);
  background: #eaf2ff;
  border-radius: 9px;
  font-size: 13px;
}
.login-submit {
  width: 100%;
  min-height: 54px;
  margin-top: 4px;
  gap: 12px;
  box-shadow: 0 18px 35px rgba(40,104,223,.24);
}
.login-note { color: var(--muted); text-align: center; }
.sidebar-backdrop { display: none; }
@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .dashboard-grid.lower { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .auth-body { padding: 16px; }
  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    border-radius: 18px;
  }
  .login-brand-panel {
    min-height: 270px;
    padding: 28px;
  }
  .login-brand-panel h1 { font-size: 34px; }
  .login-card { padding: 28px; }
  .login-head h2 { font-size: 32px; }
  .admin-sidebar { transform: translateX(-105%); transition: transform .22s ease; }
  .admin-sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: rgba(9, 19, 38, .46);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .sidebar-backdrop.is-active { opacity: 1; pointer-events: auto; }
  .sidebar-close, .menu-button { display: inline-grid; place-items: center; }
  .sidebar-close { width: 38px; height: 38px; font-size: 30px; }
  .menu-button { width: 42px; height: 42px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; }
  .admin-main { margin-left: 0; padding: 18px 16px 34px; }
  .admin-topbar { margin: -18px -16px 20px; padding: 10px 16px; }
  .topbar-actions { margin-left: auto; }
  .topbar-link { display: none; }
  .topbar-actions .topbar-link:first-child { display: inline-flex; }
  .dashboard-hero { flex-direction: column; padding: 22px; }
  .metric-grid, .stat-grid, .form-grid, .upload-field, .upload-field-wide, .profile-grid { grid-template-columns: 1fr; }
  .user-card .form-grid { grid-template-columns: 1fr; }
  .delete-user-form, .self-note { position: static; margin-top: 12px; }
  .bar-chart { min-height: 240px; overflow-x: auto; }
  .bar-item { min-width: 92px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
@media (max-width: 520px) {
  .dashboard-hero h1, .page-head h1 { font-size: 36px; }
  .metric-card { min-height: 132px; padding: 18px; }
  .metric-card span { font-size: 34px; }
  .panel { padding: 18px; }
  .rank-list a { grid-template-columns: 38px 1fr; }
  .rank-list small { grid-column: 2; }
  .hero-actions-admin, .action-row { display: grid; }
  .button { width: 100%; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floatUpload {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
