:root {
      color-scheme: light;
      --bg: #f3f0ea;
      --ink: #1c1f1a;
      --muted: #6f6a63;
      --line: #e4dfd6;
      --card: #fffcf8;
      --accent: #8a3f22;
      --sidebar: #1c1f1a;
      --side-text: #e8e4dc;
      --side-dim: #b7b1a7;
    }

    * { box-sizing: border-box; }

    html, body { margin: 0; min-height: 100%; }

    body {
      font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
      color: var(--ink);
      background: var(--bg);
      font-size: 14px;
      line-height: 1.5;
      -webkit-font-smoothing: antialiased;
    }

    button, input { font: inherit; color: inherit; }

    :focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    ::selection { background: #f0ddd3; }

    .app {
      display: grid;
      grid-template-columns: 232px minmax(0, 1fr);
      min-height: 100vh;
    }

    .sidebar {
      position: sticky;
      top: 0;
      height: 100vh;
      display: flex;
      flex-direction: column;
      background: var(--sidebar);
      color: var(--side-text);
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 26px 20px 18px;
    }

    .brand svg { display: block; flex: none; }

    .brand-name {
      font-family: Didot, "Bodoni 72", "Bodoni MT", "Times New Roman", serif;
      font-size: 24px;
      letter-spacing: 0.04em;
      line-height: 1;
    }

    .brand-sub {
      margin-top: 5px;
      color: var(--side-dim);
      font-size: 11px;
      letter-spacing: 0.16em;
      text-transform: uppercase;
    }

    .nav { padding: 8px 0 24px; overflow: auto; }

    .nav-group + .nav-group { margin-top: 18px; }

    .nav-label {
      margin: 0 20px 8px;
      color: var(--side-dim);
      font-size: 12px;
    }

    .nav-btn {
      display: block;
      width: calc(100% - 20px);
      margin: 2px 10px;
      padding: 9px 12px;
      border: 0;
      border-radius: 8px;
      background: transparent;
      color: #ddd8d0;
      text-align: left;
      cursor: pointer;
    }

    .nav-btn:hover { background: rgba(255, 255, 255, 0.05); }

    .nav-btn[aria-current="page"] {
      background: rgba(255, 255, 255, 0.08);
      color: #fff;
      box-shadow: inset 2px 0 0 #c96a45;
    }

    .main { min-width: 0; }

    .top {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 16px;
      padding: 28px 32px 16px;
    }

    .eyebrow {
      margin: 0;
      color: var(--accent);
      font-size: 13px;
    }

    h1 {
      margin: 4px 0 0;
      font-size: 26px;
      font-weight: 600;
      letter-spacing: -0.02em;
    }

    .count {
      margin: 0;
      color: var(--muted);
      font-size: 13px;
      text-align: right;
    }

    .head-side {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 8px;
    }

    .tools {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .search {
      width: 240px;
      height: 34px;
      padding: 0 12px;
      border: 1px solid #e3ddd4;
      border-radius: 8px;
      background: #fff;
    }

    .search-field { width: 132px; }
    .search-field[hidden] { display: none; }
    .search-field .picker-btn { height: 34px; padding: 0 10px; font-size: 13px; }

    .filters {
      display: flex;
      align-items: center;
      gap: 10px;
      margin: 0 32px 14px;
    }

    .filters[hidden] { display: none; }

    .filter-label { color: var(--muted); font-size: 13px; }

    .chips { display: flex; flex-wrap: wrap; gap: 6px; }

    .chip {
      height: 28px;
      padding: 0 10px;
      border: 1px solid #e3ddd4;
      border-radius: 999px;
      background: #fff;
      color: #5e5a54;
      cursor: pointer;
    }

    .chip.is-on {
      border-color: var(--ink);
      background: var(--ink);
      color: #f4f1eb;
    }

    .summary {
      margin: 0;
      padding: 10px 16px;
      background: #e7f2ea;
      color: #2f6b4f;
      font-size: 13px;
    }

    .summary[hidden] { display: none; }

    .summary span { margin-right: 14px; }

    .empty {
      padding: 28px 16px;
      color: var(--muted);
      text-align: center;
    }

    .card {
      margin: 0 32px 32px;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 16px;
      overflow: auto;
    }

    table {
      width: 100%;
      min-width: 1040px;
      border-collapse: collapse;
    }

    table.is-wide { min-width: 1240px; }
    table.is-goods { min-width: 1320px; }

    .time {
      color: #5e5a54;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }

    th {
      padding: 12px 16px;
      background: #f7f4ee;
      color: var(--muted);
      font-size: 12px;
      font-weight: 600;
      text-align: left;
      letter-spacing: 0.04em;
    }

    td {
      padding: 14px 16px;
      border-top: 1px solid var(--line);
      vertical-align: middle;
    }

    tbody tr:hover td { background: #faf8f4; }

    .name { font-weight: 600; }

    .domain {
      font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
      font-size: 12.5px;
      color: #5e5a54;
      word-break: break-all;
    }

    .clip {
      max-width: 168px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      word-break: normal;
    }

    .thumb {
      display: block;
      width: 44px;
      height: 44px;
      border-radius: 6px;
      background: #efeae2;
      object-fit: cover;
    }

    .jump-product {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 168px;
    }

    .jump-product .name { font-size: 13px; white-space: nowrap; }

    .sku {
      font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
      font-size: 12.5px;
      color: #5e5a54;
    }

    .price { font-variant-numeric: tabular-nums; white-space: nowrap; }

    .url-cell { max-width: 220px; }

    .url-cell a {
      color: #5e5a54;
      text-decoration: none;
    }

    .url-cell a:hover { color: var(--accent); text-decoration: underline; }

    .type {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 999px;
      background: #f3efe8;
      font-size: 12px;
    }

    .status {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
    }

    .status i {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: currentColor;
    }

    .is-on { color: #2f6b4f; }
    .is-off { color: #9a6b24; }
    .is-bad { color: #a33b32; }
    .is-muted { color: #6e675f; }

    .ops {
      display: flex;
      flex-wrap: wrap;
      gap: 6px 12px;
    }

    .ops button,
    .ops a {
      padding: 0;
      border: 0;
      background: transparent;
      color: var(--accent);
      cursor: pointer;
      text-decoration: none;
    }

    .ops button:hover,
    .ops a:hover { text-decoration: underline; }
    .ops button.is-danger { color: #a33b32; }

    .note-cell {
      max-width: 240px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .id-col {
      color: #5e5a54;
      font-variant-numeric: tabular-nums;
    }

    .rule-panel { display: flex; flex-direction: column; gap: 14px; }

    .rule-list { display: flex; flex-direction: column; gap: 10px; }

    .rule-card {
      padding: 12px 14px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #fff;
    }

    .rule-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .rule-head button {
      padding: 0;
      border: 0;
      background: transparent;
      color: var(--accent);
      cursor: pointer;
    }

    .rule-head button:hover { text-decoration: underline; }

    .rule-title {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .rule-countries {
      margin: 8px 0 0;
      color: #5e5a54;
      font-size: 13px;
    }

    .rule-form {
      display: flex;
      flex-direction: column;
      gap: 12px;
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #faf8f4;
    }

    .rule-form[hidden] { display: none; }

    .rule-form .block {
      display: flex;
      flex-direction: column;
      gap: 6px;
      font-size: 13px;
    }

    .picker { position: relative; }

    .picker-btn {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      height: 36px;
      padding: 0 12px;
      border: 1px solid #e3ddd4;
      border-radius: 6px;
      background: #fff;
      text-align: left;
      cursor: pointer;
    }

    .picker-btn.is-placeholder { color: #b0aaa2; }

    .picker-btn::after {
      content: "";
      width: 7px;
      height: 7px;
      margin-top: -3px;
      border-right: 1.5px solid #6f6a63;
      border-bottom: 1.5px solid #6f6a63;
      transform: rotate(45deg);
      flex: none;
    }

    .picker.is-open .picker-btn {
      border-color: #c4b8aa;
      box-shadow: 0 0 0 3px rgba(184, 92, 56, 0.12);
    }

    .picker-menu {
      position: fixed;
      z-index: 30;
      max-height: 220px;
      overflow: auto;
      padding: 4px;
      border: 1px solid #e3ddd4;
      border-radius: 8px;
      background: #fff;
      box-shadow: 0 10px 28px rgba(28, 31, 26, 0.12);
    }

    .picker-menu[hidden] { display: none; }

    .picker-option {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      padding: 8px 10px;
      border: 0;
      border-radius: 6px;
      background: transparent;
      text-align: left;
      cursor: pointer;
    }

    .picker-option:hover { background: #f7f4ee; }

    .picker-option.is-on {
      background: #f3efe8;
      font-weight: 600;
    }

    .picker-option.is-on::after {
      content: "✓";
      color: var(--accent);
      font-weight: 600;
    }

    .country-box {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px 10px;
      max-height: 168px;
      overflow: auto;
      padding: 10px;
      border: 1px solid #e3ddd4;
      border-radius: 8px;
      background: #fff;
    }

    .country-box label {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
    }

    .rule-actions { display: flex; justify-content: flex-end; gap: 8px; }

    .mask,
    .drawer { position: fixed; }

    .mask {
      inset: 0;
      z-index: 1;
      background: rgba(28, 31, 26, 0.35);
    }

    .drawer {
      top: 0;
      right: 0;
      z-index: 2;
      width: min(440px, 100%);
      height: 100vh;
      display: flex;
      flex-direction: column;
      background: var(--card);
      border-left: 1px solid var(--line);
    }

    .drawer.wide { width: min(640px, 100%); }
    .drawer.wider { width: min(1120px, 100%); }

    .mask[hidden],
    .drawer[hidden] { display: none; }

    .modal {
      position: fixed;
      z-index: 2;
      left: 50%;
      top: 50%;
      width: min(460px, calc(100% - 32px));
      max-height: min(520px, calc(100vh - 48px));
      display: flex;
      flex-direction: column;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 16px;
      box-shadow: 0 18px 50px rgba(28, 31, 26, 0.16);
      transform: translate(-50%, -50%);
    }

    .modal[hidden] { display: none; }

    .form-modal {
      width: min(680px, calc(100% - 32px));
      max-height: min(860px, calc(100vh - 40px));
      overflow: hidden;
    }

    .form-modal .form-body {
      min-height: 0;
      flex: 1;
    }

    .form-body { display: flex; flex-direction: column; gap: 14px; }

    .field {
      display: grid;
      grid-template-columns: 108px minmax(0, 1fr);
      gap: 8px 12px;
      align-items: start;
    }

    .field[hidden] { display: none; }

    .field-label {
      margin: 0;
      padding-top: 8px;
      text-align: right;
    }

    .req { color: #c4473a; margin-right: 2px; }

    .control input {
      width: 100%;
      height: 36px;
      padding: 0 10px;
      border: 1px solid #e3ddd4;
      border-radius: 6px;
      background: #fff;
    }

    .field.invalid input,
    .field.invalid .picker-btn { border-color: #c4473a; }

    .hint {
      margin: 8px 0 0;
      padding: 8px 12px;
      border-radius: 6px;
      background: #f4f2ee;
      color: #8a847c;
      font-size: 12px;
    }

    .static {
      margin: 0;
      padding-top: 8px;
      color: #5e5a54;
    }

    .field-error {
      margin: 6px 0 0;
      color: #c4473a;
      font-size: 12px;
    }

    .switch-row {
      display: flex;
      align-items: center;
      gap: 8px;
      min-height: 36px;
    }

    .switch {
      position: relative;
      width: 40px;
      height: 22px;
      padding: 0;
      border: 0;
      border-radius: 999px;
      background: #d9d3c9;
      cursor: pointer;
    }

    .switch::after {
      content: "";
      position: absolute;
      top: 2px;
      left: 2px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #fff;
    }

    .switch.is-on { background: #3cba6e; }
    .switch.is-on::after { transform: translateX(18px); }

    .switch-text { color: #8a847c; }
    .switch-text.is-active { color: #1f8f4e; font-weight: 600; }

    .count-col { text-align: right; font-variant-numeric: tabular-nums; }

    .drawer-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      padding: 22px 24px 0;
    }

    .drawer-kicker {
      margin: 0;
      color: var(--muted);
      font-size: 13px;
    }

    .drawer-head h2 {
      margin: 4px 0 0;
      font-size: 20px;
      font-weight: 600;
    }

    .icon-btn {
      width: 32px;
      height: 32px;
      border: 0;
      border-radius: 8px;
      background: transparent;
      cursor: pointer;
      font-size: 20px;
      line-height: 1;
    }

    .icon-btn:hover { background: #f3efe8; }

    .drawer-body {
      padding: 20px 24px;
      overflow: auto;
    }

    .kv {
      display: grid;
      grid-template-columns: 88px 1fr;
      gap: 12px 12px;
      margin: 0;
    }

    .kv dt { color: var(--muted); }
    .kv dd { margin: 0; }

    .mini {
      width: 100%;
      min-width: 0;
      border-collapse: collapse;
    }

    .drawer .mini { min-width: 1040px; }

    .mini th,
    .mini td {
      padding: 10px 8px;
      font-size: 13px;
    }

    .mini th { background: transparent; border-bottom: 1px solid var(--line); }

    .note {
      margin: 16px 0 0;
      color: var(--muted);
      font-size: 12px;
    }

    .drawer-foot {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      margin-top: auto;
      padding: 16px 24px 22px;
      border-top: 1px solid var(--line);
    }

    .btn {
      height: 34px;
      padding: 0 14px;
      border: 1px solid #d9d3c9;
      border-radius: 8px;
      background: #fff;
      cursor: pointer;
    }

    .btn:hover { background: #f7f4ee; }

    .btn.primary {
      background: var(--ink);
      border-color: var(--ink);
      color: #f4f1eb;
    }

    .btn.primary:hover { background: #2a2e28; }

    .btn.danger {
      background: #a33b32;
      border-color: #a33b32;
      color: #fff;
    }

    .btn.danger:hover { background: #8c322b; }

    .toast {
      position: fixed;
      left: 50%;
      bottom: 24px;
      z-index: 3;
      padding: 10px 16px;
      border-radius: 999px;
      background: var(--ink);
      color: #f4f1eb;
      font-size: 13px;
      opacity: 0;
      transform: translateX(-50%) translateY(8px);
      pointer-events: none;
      transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .toast.show {
      opacity: 1;
      transform: translateX(-50%);
    }

    @media (max-width: 860px) {
      .app { grid-template-columns: 1fr; }
      .sidebar { position: relative; height: auto; }
      .top, .card { margin-left: 16px; margin-right: 16px; }
      .top { padding-left: 0; padding-right: 0; flex-wrap: wrap; }
      .search { width: 180px; }
      .field { grid-template-columns: 1fr; }
      .field-label { text-align: left; padding-top: 0; }
    }

    @media (prefers-reduced-motion: reduce) {
      .toast { transition: none; }
    }

    a.nav-btn { text-decoration: none; }

    a.btn, label.btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      text-decoration: none;
      color: inherit;
      font: inherit;
    }

    a.btn.primary, a.btn.danger { color: #f4f1eb; }

    a.chip {
      display: inline-flex;
      align-items: center;
      text-decoration: none;
    }

    .control select, .search-field select {
      width: 100%;
      height: 36px;
      padding: 0 10px;
      border: 1px solid #e3ddd4;
      border-radius: 8px;
      background: #fff;
    }

    .search-field select { height: 34px; width: 132px; }

    .sidebar-foot {
      margin-top: auto;
      padding: 16px 20px 22px;
      color: var(--side-dim);
      font-size: 12px;
    }

    .sidebar-foot a { color: var(--side-text); text-decoration: none; }
    .sidebar-foot a:hover { text-decoration: underline; }

    .ops form { display: inline; }

    .login-page {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 24px;
    }

    .login-card {
      width: min(420px, 100%);
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 16px;
      padding: 28px 28px 22px;
    }

    .login-card h1 { margin: 8px 0 18px; font-size: 26px; }

    .login-card .stack { display: flex; flex-direction: column; gap: 12px; }

    .login-card input {
      width: 100%;
      height: 40px;
      padding: 0 12px;
      border: 1px solid #e3ddd4;
      border-radius: 8px;
      background: #fff;
    }

    .hint code, .api-box {
      font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
      font-size: 12px;
    }

    .api-box {
      margin: 0;
      padding: 14px 16px;
      overflow: auto;
      white-space: pre-wrap;
      background: #1c1f1a;
      color: #f4f1eb;
      border-radius: 12px;
    }

    .doc {
      margin: 0 32px 32px;
      padding: 18px 20px;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 16px;
    }

    .doc h2 { margin: 0 0 8px; font-size: 16px; }
    .doc p { margin: 0 0 10px; color: #5e5a54; }
    .doc + .doc { margin-top: -16px; }
