:root {
  --ink: #102335;
  --muted: #66798a;
  --navy: #0b2033;
  --navy-2: #163c5c;
  --blue: #1677b8;
  --blue-2: #0e5f96;
  --cyan: #37b8d8;
  --surface: #ffffff;
  --soft: #f3f7fa;
  --soft-blue: #eaf4fb;
  --line: #d7e2ea;
  --success: #167a55;
  --warning: #9b6000;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(11, 32, 51, .1);
  --radius: 16px;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--soft);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--soft); }
body { margin: 0; min-height: 100vh; background: var(--soft); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
:focus-visible { outline: 3px solid rgba(22, 119, 184, .35); outline-offset: 2px; }

.skip-link { position: fixed; left: 12px; top: -80px; z-index: 200; background: #fff; padding: 10px 14px; border-radius: 8px; color: var(--ink); }
.skip-link:focus { top: 12px; }

.loading-screen { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--line); } * { scroll-behavior: auto !important; } }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(360px, 560px); background: var(--surface); }
.auth-hero { padding: clamp(36px, 7vw, 92px); background: radial-gradient(circle at 15% 20%, #23618d 0, transparent 38%), linear-gradient(145deg, #071926, #123a58); color: #fff; display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; gap: 12px; align-items: center; font-weight: 800; letter-spacing: .02em; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: block; border-radius: 10px; box-shadow: 0 10px 24px rgba(55,184,216,.25); }
.auth-hero h1 { font-size: clamp(30px, 4vw, 52px); line-height: 1.15; margin: 54px 0 18px; max-width: 620px; }
.auth-hero p { color: #d4e3ed; font-size: 17px; line-height: 1.8; max-width: 600px; }
.hero-points { list-style: none; padding: 0; margin: 34px 0 0; display: grid; gap: 16px; }
.hero-points li { display: flex; gap: 10px; align-items: flex-start; color: #e9f4fa; }
.hero-points li::before { content: "✓"; color: #7be0f2; font-weight: 800; }
.auth-panel { padding: clamp(28px, 7vw, 72px); display: grid; align-content: center; }
.auth-panel h2 { font-size: 28px; margin: 0 0 10px; }
.auth-panel > p { color: var(--muted); margin: 0 0 28px; line-height: 1.7; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field label, .field-label { font-size: 14px; font-weight: 700; color: #30485c; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.setting-links { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin-top: 4px; }
.setting-links-indented { margin-left: 29px; }
.setting-link { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 0; border: 0; background: none; color: var(--blue-2); font: inherit; font-size: 13px; font-weight: 700; line-height: 1.45; text-align: left; text-decoration: underline; text-underline-offset: 3px; white-space: normal; cursor: pointer; }
.setting-link:hover { color: var(--navy-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.input, .select, .textarea { width: 100%; min-height: 44px; border: 1px solid #c8d6e0; border-radius: 10px; padding: 10px 12px; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,119,184,.12); outline: none; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; min-height: 36px; color: #30485c; }
.checkbox input { width: 19px; height: 19px; margin-top: 1px; accent-color: var(--blue); }

.btn { min-height: 42px; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; text-decoration: none; white-space: nowrap; transition: transform .12s, background .12s, border-color .12s; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-2); }
.btn-secondary { color: var(--ink); background: #fff; border-color: #c8d6e0; }
.btn-secondary:hover:not(:disabled) { border-color: #8ea8ba; background: #f8fbfd; }
.btn-danger { background: #fff; color: var(--danger); border-color: #e9b8b3; }
.btn-sm { min-height: 34px; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.btn-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; }
.sidebar .brand { padding: 2px 8px 12px; }
.nav { display: grid; gap: 6px; }
.nav-button { width: 100%; min-height: 43px; border: 0; background: transparent; color: #c7d8e3; border-radius: 10px; text-align: left; padding: 10px 12px; font-weight: 650; display: flex; justify-content: space-between; align-items: center; }
.nav-button:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-button.active { background: #fff; color: var(--navy); }
.sidebar-footer { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user { font-size: 13px; color: #c7d8e3; margin-bottom: 10px; }
.link-button { border: 0; padding: 0; background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

.workspace { min-width: 0; }
.topbar { height: 72px; padding: 0 clamp(20px, 4vw, 50px); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 21px; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.main { padding: 28px clamp(18px, 4vw, 50px) 60px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h2 { margin: 0 0 6px; font-size: 26px; }
.page-head p { margin: 0; color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 8px 24px rgba(11,32,51,.045); }
.card h3 { margin: 0 0 16px; font-size: 17px; }
.metric { min-height: 118px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-value { font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.metric-foot { font-size: 12px; color: var(--muted); }
.section { margin-top: 22px; }
.section-head { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 12px; }
.section-head h3 { margin: 0; font-size: 18px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.table { width: 100%; border-collapse: collapse; min-width: 760px; }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13.5px; }
.table th { background: #f0f5f8; color: #3c5365; font-size: 12.5px; text-transform: none; position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdfe; }
.table-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.mono { font-family: Consolas, ui-monospace, monospace; font-size: .92em; word-break: break-all; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 7px; }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; background: #edf2f5; color: #4b6070; }
.badge.available, .badge.active, .badge.downloaded, .badge.published { background: #e5f6ef; color: var(--success); }
.badge.reserved, .badge.downloading { background: #e7f3fb; color: var(--blue-2); }
.badge.pending_review { background: #fff2d9; color: var(--warning); }
.badge.disabled, .badge.archived, .badge.failed { background: #fce9e7; color: var(--danger); }

.inline-form { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; align-items: end; }
.span-2 { grid-column: span 2; }.span-3 { grid-column: span 3; }.span-4 { grid-column: span 4; }.span-6 { grid-column: span 6; }.span-12 { grid-column: span 12; }
.notice { color: #3c5365; background: var(--soft-blue); border-left: 4px solid var(--blue); padding: 12px 14px; border-radius: 8px; line-height: 1.6; }
.notice.warning { background: #fff7e8; border-color: #d28a11; }
.notice.danger { background: #fff0ef; border-color: var(--danger); }
.stock-list { display: grid; gap: 10px; }
.stock-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stock-row:last-child { border-bottom: 0; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: grid; gap: 10px; max-width: min(390px, calc(100vw - 36px)); }
.toast { background: var(--navy); color: #fff; padding: 13px 15px; border-radius: 11px; box-shadow: var(--shadow); line-height: 1.5; }
.toast.error { background: #7d211c; }

dialog { width: min(520px, calc(100vw - 28px)); border: 0; border-radius: 16px; padding: 0; box-shadow: var(--shadow); color: var(--ink); }
dialog::backdrop { background: rgba(7,25,38,.56); backdrop-filter: blur(2px); }
.dialog-body { padding: 24px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; font-size: 21px; }
.icon-button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 20px; }

.public-shell { min-height: 100vh; padding: max(18px, env(safe-area-inset-top)) 16px max(26px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% -10%, #2a6d9b, transparent 36%), linear-gradient(160deg, #071926, #0e2c43 60%, #102b3d); color: #fff; display: grid; place-items: center; }
.public-card { width: min(100%, 520px); background: rgba(255,255,255,.98); color: var(--ink); border-radius: 24px; padding: clamp(22px, 6vw, 34px); box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.public-brand { color: #d4e3ed; position: fixed; top: max(18px, env(safe-area-inset-top)); left: 20px; }
.public-icon { width: 74px; height: 74px; border-radius: 22px; display: grid; place-items: center; background: linear-gradient(145deg, #e6f6fc, #d6ebf7); color: var(--blue); margin-bottom: 22px; }
.public-icon svg { width: 34px; height: 34px; }
.public-card h1 { font-size: 27px; margin: 0 0 10px; line-height: 1.25; }
.public-subtitle { margin: 0; color: var(--muted); line-height: 1.65; }
.status-panel { margin: 24px 0; padding: 15px; border-radius: 12px; background: var(--soft); display: flex; gap: 13px; align-items: flex-start; }
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex: 0 0 auto; box-shadow: 0 0 0 5px rgba(22,119,184,.12); }
.status-dot.success { background: var(--success); box-shadow: 0 0 0 5px rgba(22,122,85,.12); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 5px rgba(180,35,24,.12); }
.status-title { font-weight: 800; margin-bottom: 4px; }
.status-detail { color: var(--muted); line-height: 1.55; font-size: 14px; }
.video-summary { border: 1px solid var(--line); border-radius: 13px; padding: 15px; margin-bottom: 18px; }
.video-summary .label { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.video-summary .title { font-weight: 800; }
.public-actions { display: grid; gap: 10px; }
.public-actions .btn { min-height: 50px; font-size: 16px; }
.privacy-note { margin: 18px 0 0; color: var(--muted); line-height: 1.55; font-size: 12px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .span-2, .span-3 { grid-column: span 3; }
  .span-4, .span-6 { grid-column: span 6; }
  .span-12 { grid-column: span 6; }
}

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { min-height: 260px; padding: 28px 24px; }
  .auth-hero h1 { margin-top: 32px; font-size: 31px; }
  .hero-points { display: none; }
  .auth-panel { padding: 34px 22px 54px; }
  .admin-shell { display: block; }
  .sidebar { position: sticky; z-index: 40; top: 0; height: auto; padding: 10px 12px; display: block; overflow-x: auto; white-space: nowrap; }
  .sidebar .brand, .sidebar-footer { display: none; }
  .nav { display: flex; gap: 6px; min-width: max-content; }
  .nav-button { width: auto; min-height: 40px; padding: 8px 12px; }
  .topbar { position: static; height: auto; padding: 18px; align-items: flex-start; }
  .main { padding: 20px 14px 48px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4, .span-6, .span-12 { grid-column: span 1; }
  .card { padding: 16px; border-radius: 13px; }
  .table-wrap { border: 0; overflow: visible; background: transparent; }
  .table { min-width: 0; display: block; }
  .table thead { display: none; }
  .table tbody { display: grid; gap: 12px; }
  .table tr { display: grid; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
  .table td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid #edf2f5; align-items: start; word-break: break-word; }
  .table td:last-child { border-bottom: 0; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 750; }
  .table-actions { justify-content: flex-start; }
  .public-brand { position: absolute; }
  .public-shell { align-items: start; padding-top: 74px; }
}

@media (max-width: 400px) {
  .public-card { border-radius: 19px; padding: 22px 18px; }
  .public-card h1 { font-size: 24px; }
  .table td { grid-template-columns: 92px minmax(0, 1fr); }
}
