:root {
  --ink: #162126;
  --muted: #68757b;
  --line: #dfe4e6;
  --wash: #f4f6f6;
  --paper: #fff;
  --sidebar: #14231f;
  --sidebar-muted: #9eaaa6;
  --green: #1f8a5b;
  --green-dark: #176d48;
  --green-soft: #e4f3eb;
  --red: #c1453d;
  --shadow: 0 14px 40px rgba(26, 44, 39, .14);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--wash); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(420px, 560px); background: var(--sidebar); }
.login-brand { display: flex; align-items: flex-start; gap: 14px; padding: 48px; color: white; }
.login-brand strong, .brand strong { display: block; font-size: 19px; letter-spacing: 0; }
.login-brand span, .brand span { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 12px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.24); background: var(--green); color: #fff; font: 700 18px/1 Georgia, serif; }
.login-panel { align-self: center; width: min(430px, calc(100% - 48px)); margin: auto; padding: 48px; background: var(--paper); box-shadow: var(--shadow); border-top: 3px solid var(--green); }
.login-panel h1 { margin: 7px 0 8px; font-size: 30px; }
.muted { color: var(--muted); }
.login-panel > .muted { margin: 0 0 30px; font-size: 14px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 220px; display: flex; flex-direction: column; padding: 24px 14px; background: var(--sidebar); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 13px; border: 0; background: transparent; color: var(--sidebar-muted); text-align: left; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { box-shadow: inset 3px 0 var(--green); }
.nav-icon { width: 20px; color: #d5deda; font-size: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.12); color: var(--sidebar-muted); font-size: 13px; }
.main { grid-column: 2; min-width: 0; padding: 34px clamp(22px, 4vw, 58px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.topbar h1 { margin: 4px 0 0; font-size: 28px; font-weight: 680; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.date-label { color: var(--muted); font-size: 13px; }

.button { min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 4px; font-weight: 650; font-size: 13px; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { border-color: var(--line); background: var(--paper); color: var(--ink); }
.button.danger { background: var(--red); color: #fff; }
.button.full { width: 100%; margin-top: 6px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: inherit; font-size: 20px; }
.text-button { padding: 0; border: 0; background: none; color: var(--green); font-size: 13px; font-weight: 650; }

.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric { min-height: 145px; padding: 22px 24px; border: 1px solid var(--line); background: var(--paper); }
.metric span, .metric small { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin: 12px 0 8px; font: 600 35px/1.1 Georgia, serif; }
.metric.accent { border-top: 3px solid var(--green); padding-top: 20px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); gap: 18px; }
.section-block, .table-wrap { border: 1px solid var(--line); background: var(--paper); }
.section-block { padding: 23px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-head h2 { margin: 0; font-size: 16px; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.legend { color: var(--muted); font-size: 11px; }
.legend i { display: inline-block; width: 18px; height: 2px; margin: 0 6px 3px 0; background: var(--green); }
.chart { height: 220px; display: flex; align-items: flex-end; gap: 8px; padding-top: 26px; }
.bar-col { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 8px; }
.bar { width: min(26px, 70%); min-height: 2px; background: var(--green); opacity: .82; transition: height .25s ease; }
.bar.h-0 { height: 2px; }
.bar.h-1 { height: 10%; }
.bar.h-2 { height: 20%; }
.bar.h-3 { height: 30%; }
.bar.h-4 { height: 40%; }
.bar.h-5 { height: 50%; }
.bar.h-6 { height: 60%; }
.bar.h-7 { height: 70%; }
.bar.h-8 { height: 80%; }
.bar.h-9 { height: 90%; }
.bar.h-10 { height: 100%; }
.bar-col:hover .bar { opacity: 1; }
.bar-col span { color: var(--muted); font-size: 10px; white-space: nowrap; }
.quick-list .section-head { margin-bottom: 8px; }
.quick-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 15px 0; border-top: 1px solid var(--line); }
.quick-link strong, .quick-link span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-link strong { margin-bottom: 5px; font-size: 13px; }
.quick-link span, .quick-link small { color: var(--muted); font-size: 11px; }
.quick-link b { align-self: center; color: var(--green); font-size: 12px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 14px; }
.search-wrap { position: relative; flex: 1; max-width: 520px; }
.search-wrap > span { position: absolute; left: 13px; top: 9px; color: var(--muted); font-size: 20px; }
.search-wrap input { width: 100%; padding-left: 40px; }
input, select, textarea { width: 100%; border: 1px solid #cfd6d8; border-radius: 3px; background: white; color: var(--ink); outline: none; }
input, select { min-height: 42px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,138,91,.1); }
.toolbar select { width: 150px; }
.table-wrap { overflow: hidden; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { padding: 13px 16px; background: #f8f9f9; color: var(--muted); font-size: 10px; letter-spacing: .6px; text-align: left; text-transform: uppercase; }
td { height: 72px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th:nth-child(1) { width: 23%; } th:nth-child(2) { width: 29%; } th:nth-child(3) { width: 11%; } th:nth-child(4) { width: 10%; } th:nth-child(5) { width: 15%; } th:nth-child(6) { width: 12%; }
.cell-title, .cell-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-title { margin-bottom: 5px; font-weight: 650; }
.cell-sub { color: var(--muted); font-size: 11px; }
.cell-sub.link { color: var(--green-dark); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.badge::before { width: 6px; height: 6px; border-radius: 50%; background: var(--green); content: ""; }
.badge.paused { color: var(--muted); }
.badge.paused::before { background: #aab2b5; }
.align-right { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-actions button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); font-size: 15px; }
.row-actions button:hover { background: var(--wash); color: var(--ink); }
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 7px; color: var(--muted); font-size: 12px; }
.visit-head { padding: 20px 22px; }

label { display: grid; gap: 7px; color: #38464b; font-size: 12px; font-weight: 650; }
label + label { margin-top: 17px; }
label small { color: var(--muted); font-weight: 400; line-height: 1.5; }
.form-error { min-height: 18px; margin: 10px 0 6px; color: var(--red); font-size: 12px; }
dialog { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 36px); padding: 0; border: 0; background: var(--paper); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(11, 26, 22, .58); }
dialog form { padding: 26px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.dialog-head h2, .confirm-dialog h2 { margin: 6px 0 0; font-size: 21px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px 14px; }
.form-grid > label, .form-grid input, .form-grid textarea, .form-grid select { min-width: 0; }
.form-grid label + label { margin-top: 0; }
.form-grid .wide { grid-column: 1 / -1; }
.platform-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.platform-fieldset legend { padding: 0; color: #38464b; font-size: 12px; font-weight: 650; }
.platform-fieldset > p { margin: 5px 0 10px; color: var(--muted); font-size: 11px; }
.platform-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.platform-picker label { display: block; min-width: 0; }
.platform-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.platform-choice { min-height: 70px; display: grid; place-items: center; align-content: center; gap: 6px; padding: 7px 3px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.platform-choice img { width: 27px; height: 27px; padding: 5px; border-radius: 7px; object-fit: contain; }
.platform-choice b { max-width: 100%; overflow: hidden; font-size: 10px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.platform-bilibili img { background: #fb7299; }
.platform-wechat img { background: #07c160; }
.platform-qq img { background: #12b7f5; }
.platform-douyin img { background: #111; }
.platform-kuaishou img { background: #ff4906; }
.platform-picker input:checked + .platform-choice { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); box-shadow: inset 0 0 0 1px var(--green); }
.platform-picker input:focus-visible + .platform-choice { outline: 2px solid var(--green); outline-offset: 2px; }
.prefix-input { display: flex; border: 1px solid #cfd6d8; border-radius: 3px; overflow: hidden; }
.prefix-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,138,91,.1); }
.prefix-input span { display: grid; place-items: center; padding: 0 10px; background: var(--wash); color: var(--muted); font-weight: 400; }
.prefix-input input { width: auto; min-width: 0; flex: 1; border: 0; box-shadow: none !important; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.switch-row:first-of-type { margin-top: 8px; border-top: 1px solid var(--line); }
.switch-row strong, .switch-row span { display: block; }
.switch-row strong { font-size: 12px; }
.switch-row div > span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.switch { display: block; flex: 0 0 auto; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch span { position: relative; width: 38px; height: 22px; border-radius: 11px; background: #c2c9cb; transition: .2s; }
.switch span::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; content: ""; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.confirm-dialog { width: min(430px, calc(100vw - 32px)); }
.confirm-dialog p { color: var(--muted); line-height: 1.6; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: calc(100vw - 48px); padding: 13px 17px; background: var(--sidebar); color: white; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 920px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .date-label { display: none; }
  th:nth-child(2), td:nth-child(2), th:nth-child(5), td:nth-child(5) { display: none; }
  th:nth-child(1) { width: 40%; } th:nth-child(3), th:nth-child(4) { width: 17%; } th:nth-child(6) { width: 26%; }
}

@media (max-width: 680px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 24px; }
  .login-panel { align-self: start; width: calc(100% - 28px); margin-top: 40px; padding: 30px 24px; }
  .app-shell { display: block; padding-bottom: 68px; }
  .sidebar { position: fixed; z-index: 10; inset: auto 0 0; width: auto; height: 64px; flex-direction: row; align-items: center; padding: 7px 10px; }
  .brand, .sidebar-foot { display: none; }
  .sidebar nav { width: 100%; grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .nav-item { min-height: 50px; justify-content: center; flex-direction: column; gap: 2px; padding: 0; font-size: 10px; }
  .nav-item.active { box-shadow: inset 0 -3px var(--green); }
  .nav-icon { line-height: 18px; }
  .main { padding: 22px 14px 32px; }
  .topbar { align-items: flex-start; margin-bottom: 22px; }
  .topbar h1 { font-size: 23px; }
  .top-actions .button { width: 42px; padding: 0; font-size: 0; }
  .top-actions .button span { font-size: 20px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .section-block, .chart { min-width: 0; }
  .chart { gap: 4px; }
  .bar-col span { font-size: 9px; }
  .metric { min-height: 118px; padding: 17px; }
  .metric:first-child { grid-column: 1 / -1; }
  .metric strong { font-size: 29px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar select, .search-wrap { width: 100%; max-width: none; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
  th:nth-child(1) { width: 65%; } th:nth-child(6) { width: 35%; }
  td { padding: 10px 12px; }
  .section-block { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .platform-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  dialog { overflow-x: hidden; }
  dialog form { min-width: 0; padding: 21px; }
}
.ab-settings { min-width: 0; margin: 0; padding: 0; border: 0; }
.ab-settings legend { padding: 0; color: var(--ink); font-size: 14px; font-weight: 650; }
.ab-settings .ab-mode-row { margin: 0 0 16px; border-top: 0; }
.ab-mode-row strong { font-size: 14px; }
.ab-image-preview { margin-top: 12px; }
.ab-image-preview img { display: block; max-width: 100%; max-height: 220px; width: auto; height: auto; margin: 0 auto 8px; }
.ab-image-preview button { min-height: 36px; }
.ab-image-status { margin: 8px 0 0; color: #526068; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.ab-settings input[type="file"] { max-width: 100%; height: auto; min-height: 40px; padding: 8px; }
.ab-settings input[type="file"]::file-selector-button { margin-right: 10px; padding: 4px 8px; border: 1px solid var(--line); background: var(--wash); color: var(--ink); border-radius: 3px; cursor: pointer; }
.ab-row-control { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: #526068; font-size: 12px; }
.ab-row-control .switch { display: grid; align-items: center; min-height: 32px; }
.ab-settings .switch { display: grid; align-items: center; min-height: 44px; }
.qr-mode-setting { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--wash); }
.qr-mode-setting .switch { display: grid; align-items: center; min-height: 44px; }
.switch input:focus-visible + span { outline: 2px solid var(--green-dark); outline-offset: 3px; }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }
.ab-row-control .switch span { width: 34px; height: 20px; }
.ab-row-control .switch span::after { width: 14px; height: 14px; }
.ab-row-control .switch input:checked + span::after { transform: translateX(14px); }
#linkForm button:disabled { cursor: wait; opacity: .65; }
@media (max-width: 680px) {
  .ab-row-control .switch { min-height: 44px; }
}
