:root {
  color-scheme: dark;
  --bg: #0c0806;
  --panel: #17100d;
  --panel-2: #20140f;
  --panel-3: #29180f;
  --line: #42271a;
  --line-soft: rgba(111, 65, 41, .45);
  --text: #fff5ea;
  --muted: #b59e8f;
  --accent: #ff9f4d;
  --accent-2: #ffd09b;
  --good: #62d89a;
  --warn: #f2c46d;
  --bad: #ff8177;
  --shadow: 0 28px 80px rgba(0, 0, 0, .3);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 80% -10%, rgba(170, 67, 14, .2), transparent 34rem),
    radial-gradient(circle at 0 70%, rgba(118, 48, 18, .1), transparent 30rem),
    var(--bg);
}
button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #2f1407;
  font-weight: 950;
  font-size: 20px;
  background: linear-gradient(140deg, #ffd39d, #ff8f3b);
  box-shadow: 0 12px 38px rgba(255, 138, 53, .23);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 9px; letter-spacing: .19em; }
.brand-large .brand-mark { width: 52px; height: 52px; border-radius: 15px; font-size: 24px; }
.brand-large strong { font-size: 21px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}
.muted { color: var(--muted); }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(390px, .7fr);
}
.login-story {
  min-height: 100vh;
  padding: clamp(42px, 7vw, 110px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(130deg, rgba(22, 12, 8, .68), rgba(47, 21, 10, .74)),
    radial-gradient(circle at 35% 40%, rgba(255, 147, 65, .16), transparent 24rem);
}
.login-story .brand { position: absolute; top: 42px; }
.login-story h1 {
  max-width: 780px;
  margin: 18px 0 22px;
  font-size: clamp(48px, 7vw, 92px);
  line-height: 1.03;
  letter-spacing: -.055em;
}
.login-story .lead {
  max-width: 640px;
  margin: 0;
  color: #d2bbae;
  font-size: 17px;
  line-height: 1.9;
}
.security-list {
  max-width: 700px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 34px;
}
.security-list span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-2);
  background: rgba(255, 153, 70, .06);
  font-size: 12px;
}
.login-panel {
  align-self: center;
  margin: 36px clamp(28px, 5vw, 78px);
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(23, 15, 11, .92);
  box-shadow: var(--shadow);
}
.status-pill, .environment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid rgba(98, 216, 154, .25);
  border-radius: 999px;
  color: var(--good);
  background: rgba(98, 216, 154, .07);
  font-size: 12px;
}
.status-pill { margin-bottom: 36px; }
.status-pill i, .environment-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 12px var(--good);
}
.login-panel h2 { margin: 0; font-size: 30px; }
.login-panel > .muted { margin: 8px 0 28px; line-height: 1.7; }
label { display: block; color: #dcc6b7; font-size: 12px; }
input {
  width: 100%;
  height: 49px;
  margin: 7px 0 18px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #100b09;
  transition: border-color .18s, box-shadow .18s;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 159, 77, .1);
}
.password-field { position: relative; }
.password-field input { padding-right: 66px; }
.password-field button {
  position: absolute;
  top: 7px;
  right: 4px;
  height: 49px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
}
.primary-button, .ghost-button, .icon-button, .text-button {
  border: 0;
  cursor: pointer;
  transition: transform .16s, border-color .16s, background .16s, opacity .16s;
}
.primary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 19px;
  border-radius: 11px;
  color: #301407;
  font-weight: 850;
  background: linear-gradient(135deg, #ffc481, #ff9143);
  box-shadow: 0 14px 34px rgba(255, 132, 43, .2);
}
.primary-button:hover, .ghost-button:hover, .icon-button:hover { transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .56; }
.login-panel .primary-button { width: 100%; }
.primary-button.compact { min-height: 43px; }
.form-message { min-height: 22px; margin: -4px 0 12px; color: var(--bad); font-size: 12px; }
.form-message.success { color: var(--good); }
.login-footnote { margin: 20px 0 0; color: #8d776a; font-size: 11px; line-height: 1.6; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-rows: 72px minmax(0, 1fr);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 8, 6, .91);
  backdrop-filter: blur(18px);
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.sync-time { color: var(--muted); font-size: 11px; }
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 18px;
}
.account-chip { display: flex; align-items: center; gap: 9px; margin-left: 5px; }
.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #2f1407;
  font-weight: 900;
  background: linear-gradient(140deg, #ffd39d, #ff8f3b);
}
.account-chip strong, .account-chip small { display: block; }
.account-chip strong { font-size: 12px; }
.account-chip small { color: var(--muted); font-size: 8px; letter-spacing: .12em; }
.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: #dac4b5;
}
.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(14, 9, 7, .7);
}
.nav-label { margin: 0 10px 10px; color: #735a4c; font-size: 10px; letter-spacing: .16em; }
.nav-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 5px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #a99486;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.nav-button span { width: 22px; color: #816454; font-size: 17px; text-align: center; }
.nav-button:hover { color: var(--text); background: rgba(255, 255, 255, .025); }
.nav-button.active {
  border-color: #4f2e1d;
  color: var(--text);
  background: linear-gradient(90deg, rgba(110, 52, 21, .38), rgba(57, 30, 18, .28));
}
.nav-button.active span { color: var(--accent); }
.sidebar-policy {
  position: absolute;
  right: 18px;
  bottom: 20px;
  left: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.sidebar-policy .policy-icon { color: var(--good); }
.sidebar-policy p { margin: 8px 0 2px; color: var(--muted); font-size: 10px; }
.sidebar-policy strong { color: var(--good); font-size: 11px; }

.workspace {
  min-width: 0;
  padding: 34px clamp(22px, 3.5vw, 54px) 80px;
}
.view { display: none; }
.view.active { display: block; animation: reveal .2s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(3px); } }
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.page-heading h1 { margin: 0; font-size: clamp(29px, 4vw, 44px); letter-spacing: -.035em; }
.page-heading p:last-child { margin: 6px 0 0; color: var(--muted); }
.safety-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid rgba(98, 216, 154, .25);
  border-radius: 999px;
  color: var(--good);
  background: rgba(98, 216, 154, .06);
  font-size: 11px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric-card {
  min-height: 142px;
  padding: 19px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(31, 18, 12, .94), rgba(20, 13, 10, .94));
}
.metric-card.featured {
  border-color: #6f3c21;
  background: linear-gradient(145deg, #3b1e0f, #20110b);
}
.metric-card span, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; margin: 15px 0 5px; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.metric-card small { color: #776157; font-size: 10px; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 16px;
}
.panel {
  min-width: 0;
  padding: 21px;
  border: 1px solid var(--line-soft);
  border-radius: 17px;
  background: rgba(23, 15, 12, .88);
  box-shadow: 0 18px 52px rgba(0, 0, 0, .12);
}
.panel.span-2 { min-width: 0; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 17px;
}
.panel-heading h2 { margin: 0; font-size: 18px; }
.panel-heading .eyebrow { margin-bottom: 4px; font-size: 9px; }
.text-button { padding: 5px; color: var(--accent-2); background: none; font-size: 11px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}
th { color: #7f695c; font-size: 10px; font-weight: 650; letter-spacing: .08em; }
td { color: #d7c4b8; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
.series-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.series-cover {
  width: 38px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 7px;
  object-fit: cover;
  background: var(--panel-3);
}
.series-cell strong, .series-cell small { display: block; }
.series-cell strong { color: var(--text); font-size: 12px; }
.series-cell small { margin-top: 3px; color: #816d61; font-size: 9px; }
.tag {
  display: inline-block;
  margin: 2px 3px 2px 0;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #bea696;
  font-size: 9px;
}
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--warn);
  background: rgba(242, 196, 109, .08);
  font-size: 9px;
}
.status-tag.good { color: var(--good); background: rgba(98, 216, 154, .08); }
.status-tag.bad { color: var(--bad); background: rgba(255, 129, 119, .08); }
.row-action {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-2);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}
.empty-state { padding: 34px 10px; color: #897267; text-align: center; font-size: 12px; }
.batch-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.batch-stat { padding: 12px; border: 1px solid var(--line-soft); border-radius: 11px; background: #120c09; }
.batch-stat span, .batch-stat strong { display: block; }
.batch-stat span { color: #806a5e; font-size: 9px; }
.batch-stat strong { margin-top: 5px; font-size: 17px; }
.progress-track { height: 8px; margin: 18px 0 8px; overflow: hidden; border-radius: 99px; background: #0c0806; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ff8d3c, #ffc071); }
.progress-copy { display: flex; justify-content: space-between; color: #91796b; font-size: 9px; }
.toolbar { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 18px; }
.search-field { min-width: 240px; flex: 1; }
.search-field input { margin: 5px 0 0; height: 43px; }
.table-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; color: #806b5f; font-size: 11px; }
.policy-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  padding: 16px 19px;
  border: 1px solid rgba(98, 216, 154, .2);
  border-radius: 15px;
  background: rgba(98, 216, 154, .035);
}
.policy-panel strong { margin-right: auto; }
.policy-panel span { padding: 6px 8px; border-radius: 8px; color: var(--good); background: rgba(98, 216, 154, .07); font-size: 9px; }
.failure-item { padding: 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: #120c09; }
.failure-item + .failure-item { margin-top: 9px; }
.failure-item strong { color: var(--bad); font-size: 11px; }
.failure-item p { margin: 5px 0 0; color: #90786b; font-size: 10px; line-height: 1.55; }
.system-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 16px;
}
.system-card { padding: 20px; border: 1px solid var(--line-soft); border-radius: 15px; background: var(--panel); }
.system-card .system-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--good); box-shadow: 0 0 12px rgba(98, 216, 154, .5); }
.system-card strong, .system-card small { display: block; }
.system-card strong { margin: 18px 0 4px; }
.system-card small { color: var(--muted); }
.configuration-panel dl { margin: 0; }
.configuration-panel dl div { display: grid; grid-template-columns: 190px 1fr; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.configuration-panel dl div:last-child { border-bottom: 0; }
.configuration-panel dt { color: var(--muted); }
.configuration-panel dd { margin: 0; color: var(--good); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(5, 3, 2, .76);
  backdrop-filter: blur(12px);
}
.dialog {
  position: relative;
  width: min(920px, 100%);
  max-height: min(850px, calc(100vh - 44px));
  overflow: auto;
  padding: 29px;
  border: 1px solid #66402a;
  border-radius: 22px;
  background: #18100d;
  box-shadow: 0 38px 120px rgba(0, 0, 0, .56);
}
.dialog-close {
  position: sticky;
  top: 0;
  z-index: 2;
  float: right;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent-2);
  background: #21140f;
  cursor: pointer;
  font-size: 23px;
}
.detail-hero { display: grid; grid-template-columns: 150px 1fr; gap: 22px; padding-right: 42px; }
.detail-cover { width: 150px; aspect-ratio: 3 / 4; border-radius: 13px; object-fit: cover; background: var(--panel-3); }
.detail-hero h2 { margin: 5px 0 8px; font-size: 30px; }
.detail-hero p { color: var(--muted); line-height: 1.8; }
.detail-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 12px; }
.credit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.credit { padding: 10px; border-radius: 9px; background: #110b09; }
.credit strong, .credit small { display: block; }
.credit small { margin-top: 3px; color: var(--muted); }
.episode-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.episode { min-height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: #8e7568; background: #110b09; font-size: 9px; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: 360px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: #271710;
  box-shadow: var(--shadow);
  font-size: 12px;
}

@media (max-width: 1250px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-story { min-height: 48vh; padding: 90px 32px 50px; border-right: 0; border-bottom: 1px solid var(--line); }
  .login-story .brand { top: 24px; }
  .login-panel { width: min(520px, calc(100% - 40px)); margin: 36px auto; }
  .app-shell { display: block; }
  .topbar { height: 68px; padding: 0 16px; }
  .environment-pill, .sync-time, .account-chip span:not(.avatar) { display: none; }
  .sidebar {
    position: sticky;
    top: 68px;
    z-index: 16;
    width: 100%;
    height: auto;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    background: rgba(12, 8, 6, .94);
  }
  .sidebar .nav-label, .sidebar-policy { display: none; }
  #navigation { display: flex; min-width: max-content; }
  .nav-button { width: auto; min-height: 38px; margin: 0 4px 0 0; padding: 0 11px; }
  .workspace { padding: 28px 18px 60px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .system-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar .brand small, .topbar .brand strong { display: none; }
  .topbar-actions { gap: 7px; }
  .ghost-button { padding: 0 10px; }
  .page-heading { align-items: flex-start; }
  .page-heading .safety-badge { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { min-height: 122px; padding: 15px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .search-field { width: 100%; min-width: 100%; }
  .toolbar button { flex: 1; }
  .system-grid { grid-template-columns: 1fr 1fr; }
  .configuration-panel dl div { grid-template-columns: 1fr; gap: 3px; }
  .detail-hero { grid-template-columns: 90px 1fr; gap: 14px; padding-right: 0; }
  .detail-cover { width: 90px; }
  .detail-hero h2 { font-size: 21px; }
  .credit-grid { grid-template-columns: repeat(2, 1fr); }
  .episode-grid { grid-template-columns: repeat(6, 1fr); }
  .dialog { padding: 20px; }
}
