:root {
  --bg: #111416;
  --bg-2: #171b1e;
  --card: #1c2124;
  --card-2: #242a2e;
  --line: #343c41;
  --line-2: #48535a;
  --text: #f3f5f6;
  --text-2: #c6ced2;
  --text-3: #94a0a6;
  --accent: #35b9a8;
  --accent-2: #4e91db;
  --ok: #4bc58a;
  --warn: #e8b657;
  --err: #ed747c;
  --radius: 7px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .2);
  --sidebar-w: 226px;
  --sidebar-bg: #15191b;
}

/* JavDB mirror: preserve the source site's light layout inside the admin view. */
#view-javdb4k { margin: -20px -24px -36px; }
.javdb-source-host {
  position: relative;
  width: 100%;
  height: calc(100vh - 62px);
  min-height: 700px;
  overflow: hidden;
  background: #f4f4f2;
}
.javdb-source-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #f4f4f2;
}
.javdb-source-status {
  display: none;
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid #3273dc;
  border-radius: 3px;
  background: #fff;
  color: #245cb3;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .14);
  font-size: 13px;
}
.javdb-source-status.is-visible { display: block; }
.javdb-source-status.is-error { border-color: #d33b55; color: #b4233d; }
.jdb-mirror { min-height: calc(100vh - 62px); background: #f3f3f1; color: #363636; font-family: Arial, "Microsoft YaHei", sans-serif; }
.jdb-navbar { display: flex; align-items: center; min-height: 58px; padding: 0 max(24px, calc((100% - 1500px)/2)); background: #090909; color: #fff; }
.jdb-logo { margin-right: 26px; font-size: 31px; font-weight: 800; letter-spacing: 0; }
.jdb-logo span { margin-left: 2px; padding: 0 3px; background: #3273dc; color: #fff; }
.jdb-nav-menu { display: flex; align-self: stretch; }
.jdb-nav-dropdown { position: relative; }
.jdb-nav-dropdown > div { display: none; position: absolute; top: 58px; left: 0; z-index: 40; min-width: 130px; padding: 6px 0; background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.jdb-nav-dropdown:hover > div { display: block; }
.jdb-nav-dropdown > div button { display: block; width: 100%; height: 36px; padding: 0 16px; color: #363636; text-align: left; }
.jdb-nav-dropdown > div button:hover { background: #f2f2f2; }
.jdb-navbar button { height: 100%; padding: 0 17px; border: 0; background: transparent; color: #fff; font-size: 15px; font-weight: 650; cursor: pointer; }
.jdb-navbar button:hover { background: #222; }
.jdb-nav-end { margin-left: auto; font-size: 14px; }
.jdb-notice { min-height: 30px; padding: 6px 20px; background: #d7d7d5; color: #5f5f5f; text-align: center; font-size: 12px; }
.jdb-content { width: min(1500px, calc(100% - 36px)); margin: 0 auto; padding: 18px 0 76px; }
.jdb-search-panel { padding: 12px; background: #3273dc; color: #fff; }
.jdb-search-row { display: grid; grid-template-columns: 90px minmax(0,1fr) 92px 102px; min-height: 45px; }
.jdb-search-row select, .jdb-search-row input, .jdb-search-row button { border: 0; border-radius: 0; font-size: 14px; }
.jdb-search-row select { padding: 0 12px; background: #fff; color: #555; }
.jdb-search-row input { min-width: 0; padding: 0 15px; border-left: 1px solid #eee; background: #fff; color: #363636; }
.jdb-search-row button { background: #3f8ee8; color: #fff; font-weight: 700; cursor: pointer; }
.jdb-search-row .jdb-actress-search { margin-left: 8px; background: #2764bd; }
.jdb-hot { display: flex; align-items: center; gap: 4px; min-height: 34px; padding: 4px 8px 0; font-size: 12px; font-weight: 700; }
.jdb-hot button { padding: 3px 8px; border: 0; background: transparent; color: #fff; font-size: 12px; cursor: pointer; }
.jdb-progress { min-height: 24px; padding: 10px 2px 0; color: #777; font-size: 12px; }
.jdb-progress .hint { color: #777; }
.jdb-weekly h2 { margin: 10px 0 14px; color: #363636; font-size: 20px; }
.jdb-weekly h2 span { color: #777; font-size: 12px; font-weight: 400; }
.jdb-movie-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 20px 10px; }
.jdb-movie-grid.is-small { grid-template-columns: repeat(8, minmax(0,1fr)); }
.jdb-movie-card { min-width: 0; overflow: hidden; background: transparent; }
.jdb-cover { display: block; width: 100%; aspect-ratio: 2/3; object-fit: cover; background: #ddd; cursor: pointer; }
.jdb-movie-card h3 { height: 42px; margin: 7px 0 2px; overflow: hidden; color: #3273dc; font-size: 14px; font-weight: 700; line-height: 1.45; }
.jdb-score { overflow: hidden; color: #666; font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.jdb-score span { color: #ffb400; letter-spacing: 0; }
.jdb-card-meta { margin-top: 2px; color: #888; font-size: 11px; }
.jdb-tags { display: flex; gap: 3px; margin-top: 4px; overflow: hidden; }
.jdb-tags span { padding: 2px 5px; background: #48c78e; color: #fff; font-size: 10px; white-space: nowrap; }
.jdb-magnets { margin-top: 6px; }
.jdb-magnet-row { position: relative; margin-top: 4px; padding: 6px 58px 6px 6px; border: 1px solid #d4d4d4; background: #fff; font-size: 10.5px; }
.jdb-magnet-row label { display: flex; gap: 4px; min-width: 0; color: #3273dc; cursor: pointer; }
.jdb-magnet-row label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jdb-magnet-row input { flex: 0 0 auto; margin: 1px 0 0; }
.jdb-magnet-meta { min-height: 15px; color: #777; }
.jdb-magnet-meta b { margin-right: 4px; color: #e23d3d; }
.jdb-copy { position: absolute; top: 5px; right: 4px; padding: 2px 5px; border: 0; background: transparent; color: #3273dc; font-size: 10px; cursor: pointer; }
.jdb-magnet-actions { display: flex; gap: 3px; position: absolute; right: 4px; bottom: 4px; }
.jdb-magnet-actions button { padding: 2px 5px; border: 0; background: #3273dc; color: #fff; font-size: 10px; cursor: pointer; }
.jdb-magnet-actions button:last-child { background: #00a883; }
.jdb-main-tabs { display: flex; margin-top: 24px; border-bottom: 2px solid #3273dc; }
.jdb-main-tabs button, .jdb-filterbar button, .jdb-pager button, .jdb-transfer-tools button { padding: 9px 15px; border: 1px solid #ddd; background: #fff; color: #4a4a4a; font-size: 12px; cursor: pointer; }
.jdb-main-tabs button { border: 0; background: transparent; font-size: 14px; }
.jdb-main-tabs button.active, .jdb-filterbar button.active { background: #3273dc; color: #fff; }
.jdb-filterbar { display: flex; flex-wrap: wrap; gap: 2px; margin: 8px 0 15px; }
.jdb-filterbar button { padding: 7px 12px; }
.jdb-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 24px; color: #666; font-size: 12px; }
.jdb-transfer-tools { display: flex; align-items: center; gap: 6px; position: fixed; right: 20px; bottom: 18px; z-index: 30; padding: 7px; border: 1px solid #d0d0d0; background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.15); color: #666; font-size: 11px; }
.jdb-transfer-tools button { padding: 6px 9px; }
.jdb-transfer-tools button:last-child { background: #3273dc; color: #fff; }

@media (max-width: 1199px) {
  .jdb-movie-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .jdb-movie-grid.is-small { grid-template-columns: repeat(6, minmax(0,1fr)); }
}
@media (max-width: 991.98px) {
  #view-javdb4k { margin: -15px -13px -28px; }
  .javdb-source-host { height: calc(100vh - 54px); min-height: 620px; }
  .jdb-navbar { padding: 0 14px; }
  .jdb-nav-menu button:nth-child(n+4), .jdb-nav-end { display: none; }
  .jdb-content { width: calc(100% - 24px); }
  .jdb-movie-grid, .jdb-movie-grid.is-small { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 640px) {
  .jdb-logo { margin-right: 8px; font-size: 24px; }
  .jdb-navbar button { padding: 0 8px; font-size: 12px; }
  .jdb-search-row { grid-template-columns: 72px minmax(0,1fr) 68px; }
  .jdb-search-row .jdb-actress-search { grid-column: 1 / -1; margin: 6px 0 0; min-height: 34px; }
  .jdb-hot { overflow-x: auto; white-space: nowrap; }
  .jdb-movie-grid, .jdb-movie-grid.is-small { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px 8px; }
  .jdb-transfer-tools { right: 8px; bottom: 8px; left: 8px; overflow-x: auto; }
  .jdb-transfer-tools span { display: none; }
}

* { letter-spacing: 0 !important; }
html { background: var(--bg); }
body {
  background: var(--bg) !important;
  color: var(--text);
  font-size: 14px;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  box-shadow: none;
}
.sidebar-brand {
  min-height: 66px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.sidebar-brand small { color: var(--text-3); font-size: 11px; }
.sidebar-nav { padding: 8px 9px 22px; }
.nav-section {
  margin: 17px 10px 5px;
  color: #859197;
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}
.sidebar-nav a {
  min-height: 38px;
  margin: 1px 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #bdc6ca;
  font-size: 13.5px;
}
.sidebar-nav a:hover { color: #fff; background: #202629; }
.sidebar-nav a.active {
  padding-left: 10px;
  border: 1px solid rgba(53, 185, 168, .42);
  border-left: 3px solid var(--accent);
  background: rgba(53, 185, 168, .11);
  color: #e8fffb;
  box-shadow: none;
}
.sidebar-nav a i { color: #8ea0a7; }
.sidebar-nav a.active i { color: #6ed8ca; }

.page { margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  background: rgba(17, 20, 22, .96);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}
.topbar-inner { height: 58px; padding: 0 22px; }
.topbar .brand { font-size: 15px; }
.brand-sub {
  border-radius: 4px;
  background: var(--card-2);
  border-color: var(--line);
}
.online i { box-shadow: 0 0 0 3px rgba(75, 197, 138, .13); }
.user-chip {
  min-height: 36px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--card);
}
.user-chip .dot, .avatar { background: #357d98 !important; }

.wrap {
  width: min(100%, 1680px);
  max-width: none;
  margin: 0 auto;
  padding: 20px 24px 38px;
}
.wrap.media-wide { width: 100%; padding-left: 18px; padding-right: 18px; }
.page-title {
  min-height: 50px;
  margin: 0 0 16px;
  padding: 0 0 13px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.page-title h1 { font-size: 20px; font-weight: 720; line-height: 1.25; }
.page-title .sub { max-width: 760px; color: var(--text-3); font-size: 12.5px; text-align: right; }
.view { min-width: 0; animation: none; }

.card {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: none;
}
.card:hover { border-color: #3c464b; }
.card h3 {
  min-height: 24px;
  margin: 0 0 13px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}
.card h3 .bar { width: 3px; height: 15px; background: var(--accent); }
.card .card {
  margin: 12px 0 0;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}
.stat {
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
}
.stat .n { font-size: 20px; line-height: 1.25; }
.stat .l { margin-top: 4px; color: var(--text-3); font-size: 12px; }
.stat[onclick]:hover { border-color: var(--accent); background: #1d2627; }

.toolbar, .videos-toolbar, .inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.toolbar { margin-bottom: 13px; }
.toolbar > input.input { flex: 1 1 240px; }
.toolbar > .input { width: auto; min-width: 130px; }
.field { min-width: 0; }
.field label { color: var(--text-2); font-size: 12px; font-weight: 650; }
.input {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #131719;
  color: var(--text);
  font-size: 13.5px;
  box-shadow: none;
}
.input:hover { border-color: #5b686f; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(53, 185, 168, .12); }
.input::placeholder { color: #717e84; }

.btn, .btn-icon {
  min-height: 36px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--card-2);
  color: var(--text-2);
  box-shadow: none;
}
.btn { padding: 7px 11px; font-size: 13px; }
.btn:hover, .btn-icon:hover { border-color: #68767d; background: #2a3236; color: #fff; }
.btn--primary, .btn.active {
  border-color: #2ca797;
  background: #2ca797;
  color: #071714;
  font-weight: 700;
}
.btn--primary:hover, .btn.active:hover { background: #38b9a8; color: #071714; }
.btn--danger { border-color: rgba(237, 116, 124, .52); background: rgba(237, 116, 124, .1); color: #ff9da3; }
.btn--sm { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.btn:disabled { filter: grayscale(.2); opacity: .48; }

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #181d20;
  scrollbar-width: thin;
}
.table {
  min-width: 720px;
  margin: 0;
  color: var(--text);
  font-size: 13px;
}
.table > :not(caption) > * > * { color: var(--text); background: transparent; box-shadow: none; }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 11px;
  border-color: var(--line);
  background: #242b2f;
  color: #c8d0d4;
  font-size: 12px;
  font-weight: 700;
}
.table td { padding: 9px 11px; border-color: #2d3438; line-height: 1.45; }
.table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .012); }
.table tbody tr:hover td { background: rgba(78, 145, 219, .075); }
.table a { color: #7db5ef; }

.tag { padding: 3px 7px; border-radius: 4px; font-size: 11.5px; white-space: nowrap; }
.hint { color: var(--text-3); font-size: 12px; line-height: 1.55; }
.conn-row { min-height: 40px; padding: 8px 0; border-color: var(--line); }
.card pre {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line) !important;
  border-radius: 5px !important;
  background: #0d1012 !important;
  color: #dbe2e5;
}

.videos-grid { grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 11px; }
.video-card { border-radius: 6px; background: var(--card); box-shadow: none; }
.video-card:hover { transform: none; border-color: #557079; box-shadow: 0 6px 16px rgba(0, 0, 0, .22); }
.video-meta h4 { font-size: 13px; }
.video-actions button { min-height: 30px; border-radius: 5px; }
#view-forum4k .videos-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.javdb-results-grid { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 12px; }
.cat-chip { border-radius: 5px; }
.cat-chip.active { border-color: var(--accent); background: rgba(53, 185, 168, .11); color: #91e6dc; }
.pager button { border-radius: 5px; }
.pager button.active { border-color: var(--accent); background: var(--accent); color: #071714; }

.overlay { background: rgba(5, 8, 10, .82); }
.auth-card { border-radius: 8px; background: #1b2023; }
.tabs { border-radius: 6px; }
#toast { border-radius: 6px; background: #253036; }

@media (max-width: 1199px) {
  .wrap { padding: 18px 18px 34px; }
  .javdb-results-grid { grid-template-columns: 1fr; }
}
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 10px 0 30px rgba(0, 0, 0, .35); }
  .page { margin-left: 0; }
  .topbar-inner { padding: 0 12px; }
  .wrap, .wrap.media-wide { width: 100%; padding: 15px 13px 28px; }
  .card { padding: 14px; }
  #view-forum4k .videos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar-inner { height: 54px; }
  .topbar .online, .brand-sub { display: none !important; }
  .user-chip { max-width: 44vw; }
  .page-title { align-items: flex-start; flex-direction: column; gap: 3px; min-height: 0; }
  .page-title h1 { font-size: 18px; }
  .page-title .sub { text-align: left; line-height: 1.45; }
  .card { margin-bottom: 10px; padding: 11px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .stat { min-height: 72px; padding: 10px; }
  .toolbar, .videos-toolbar { align-items: stretch; }
  .toolbar > .input, .toolbar > input.input, .toolbar > select.input {
    flex: 1 1 100%; width: 100% !important; max-width: none !important;
  }
  .inline-form .field { min-width: 100%; }
  .inline-form .input { max-width: none !important; }
  .table { min-width: 780px; font-size: 12.5px; }
  #userTblWrap .table { min-width: 1060px; }
  .videos-grid, #view-forum4k .videos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .video-meta { padding: 8px; }
  .video-meta h4 { font-size: 12px; }
  .conn-row { align-items: flex-start; flex-direction: column; gap: 3px; }
}
