:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  --bg: #f5f5f7;
  --surface: #fff;
  --field: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(29, 29, 31, .12);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: #eaf3ff;
  --success: #17804a;
  --success-soft: #edf8f1;
  --warning: #9b6500;
  --warning-soft: #fff8e8;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --shadow: 0 10px 35px rgba(25, 35, 60, .055), 0 1px 3px rgba(25, 35, 60, .04);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(0, 113, 227, .32);
  outline-offset: 2px;
}
input, textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  padding: 10px 13px;
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}
input:hover, textarea:hover { border-color: rgba(0, 113, 227, .32); }
input:focus, textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px rgba(0, 113, 227, .08); outline: 0; }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
textarea { min-height: 132px; max-width: 100%; resize: vertical; }
label { display: block; margin-bottom: 7px; font-size: .9rem; font-weight: 650; }
p { margin: 0; }
code { border-radius: 5px; background: var(--bg); padding: 2px 5px; font-size: .87em; }

.wrap, .site-shell { width: min(100%, 1180px); margin-inline: auto; padding: 26px clamp(16px, 3vw, 36px) 70px; }
.muted, .field-hint, .section-description { color: var(--muted); }
.eyebrow, .section-kicker { margin: 0 0 10px; color: var(--accent); font-size: .73rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.surface, .notice, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.surface { padding: clamp(20px, 3.1vw, 32px); margin-top: 18px; scroll-margin-top: 98px; }
.surface:target { border-color: rgba(0, 113, 227, .38); }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: clamp(1.25rem, 2.2vw, 1.55rem); letter-spacing: -.025em; line-height: 1.23; }
.section-description { margin: -3px 0 22px; line-height: 1.65; max-width: 72ch; font-size: .94rem; }
.field { min-width: 0; }
.field-hint { font-size: .84rem; line-height: 1.55; }
.field + .field { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 18px; align-items: end; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 3px; }
.button, .product-card__primary, .product-card__secondary, .state-panel__retry {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 17px; border-radius: 12px;
  border: 1px solid transparent; font-weight: 650; font-size: .91rem;
  line-height: 1.2; text-align: center; text-decoration: none;
  transition: transform .18s ease, background-color .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.button:hover, .product-card__primary:hover, .product-card__secondary:hover, .state-panel__retry:hover { text-decoration: none; transform: translateY(-1px); }
.button:active, .product-card__primary:active, .product-card__secondary:active, .state-panel__retry:active { transform: translateY(0); }
.button-primary, .product-card__primary { background: var(--accent); color: #fff; box-shadow: 0 5px 14px rgba(0, 113, 227, .18); }
.button-primary:hover, .product-card__primary:hover { background: var(--accent-hover); color: #fff; }
.button-secondary, .product-card__secondary, .state-panel__retry { background: var(--bg); color: var(--text); border-color: var(--line); }
.button-secondary:hover, .product-card__secondary:hover, .state-panel__retry:hover { background: var(--accent-soft); color: var(--accent); border-color: rgba(0, 113, 227, .18); }

/* Landing page */
.landing-shell { max-width: 1120px; }
.landing-hero { position: relative; overflow: hidden; padding: clamp(44px, 8vw, 94px) 0 44px; isolation: isolate; }
.landing-hero::before { content: ""; position: absolute; z-index: -1; top: -90px; right: 4%; width: min(48vw, 480px); height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(160, 204, 255, .36), rgba(236, 244, 255, 0) 70%); pointer-events: none; }
.landing-hero h1 { max-width: 760px; margin: 0 0 18px; font-size: clamp(2.8rem, 6.4vw, 5.3rem); letter-spacing: -.064em; line-height: 1.08; font-weight: 750; }
.landing-hero__intro { max-width: 630px; color: var(--muted); font-size: clamp(1rem, 1.7vw, 1.2rem); line-height: 1.7; }
.privacy-panel { padding: clamp(22px, 3vw, 34px); margin-bottom: 64px; }
.privacy-panel h2 { margin: 0 0 22px; font-size: 1.45rem; letter-spacing: -.025em; }
.privacy-panel__content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px; }
.privacy-panel__content p { color: var(--muted); line-height: 1.75; font-size: .94rem; }
.privacy-panel__contact { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; line-height: 1.6; }
.product-section { padding-bottom: 56px; }
.product-section .section-heading { align-items: end; margin-bottom: 18px; }
.product-section .section-heading h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); letter-spacing: -.04em; }
.section-heading__count { font-size: .88rem; white-space: nowrap; }
.product-grid, .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 18px; }
.product-card { min-height: 260px; padding: 26px; display: flex; flex-direction: column; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.product-card:hover { transform: translateY(-3px); border-color: rgba(0, 113, 227, .22); box-shadow: 0 18px 42px rgba(25, 35, 60, .11); }
.product-card__eyebrow { margin-bottom: 18px; }
.product-card__title { margin: 0 0 25px; font-size: 1.45rem; line-height: 1.28; letter-spacing: -.03em; overflow-wrap: anywhere; }
.product-card__actions { margin-top: auto; display: grid; gap: 10px; }
.product-card__feedback { min-height: 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.product-card__feedback:not(:empty) { margin-top: 12px; }
.section-feedback:empty { display: none; }
.section-feedback:not(:empty) { margin-bottom: 16px; color: var(--danger); }
.state-panel { grid-column: 1 / -1; min-height: 210px; border: 1px dashed var(--line); border-radius: 22px; background: var(--surface); display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 30px; text-align: center; }
.state-panel h3 { margin: 0 0 7px; font-size: 1.25rem; letter-spacing: -.02em; }
.state-panel p { max-width: 42ch; color: var(--muted); font-size: .94rem; }
.state-panel__retry { margin-top: 19px; }
.state-panel--error { border-color: rgba(180, 35, 24, .24); }

/* Admin workbench */
.admin-shell { max-width: 1180px; }
.app-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; letter-spacing: -.02em; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--text); color: var(--surface); font-size: 1.1rem; line-height: 1; }
.connection-pill, .status-pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 7px 11px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.connection-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.status-pill[data-active="true"] { background: var(--success-soft); color: var(--success); border-color: rgba(23, 128, 74, .15); }
.page-intro { padding: clamp(30px, 5vw, 62px) 0 22px; }
.page-intro h1 { max-width: 760px; margin: 0 0 12px; font-size: clamp(2.15rem, 4.2vw, 3.6rem); line-height: 1.12; letter-spacing: -.055em; font-weight: 750; }
.page-intro > p:last-child { color: var(--muted); font-size: 1.04rem; }
.auth-card { margin-top: 14px; }
.login-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.login-form .field { flex: 1 1 330px; max-width: 510px; }
.login-form .button { min-width: 138px; }
.login-form .field-hint { margin: -3px 0 9px; }
.input-with-action { position: relative; }
.input-with-action input { padding-right: 71px; }
.input-action { position: absolute; right: 7px; top: 6px; min-width: 55px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--accent); font-size: .81rem; font-weight: 700; }
.input-action:hover { background: var(--accent-soft); }
.session-bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 13px 15px; border-radius: 14px; background: var(--bg); color: var(--muted); font-size: .89rem; }
.section-nav { position: sticky; top: 12px; z-index: 20; display: flex; align-items: center; gap: 4px; overflow-x: auto; overscroll-behavior-x: contain; margin: 22px 0; padding: 7px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(16px); scrollbar-width: none; }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a { flex: 0 0 auto; padding: 9px 13px; border-radius: 10px; color: var(--muted); font-size: .86rem; font-weight: 650; white-space: nowrap; }
.section-nav a:hover, .section-nav a[aria-current="location"] { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.metric { min-height: 94px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 15px; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; }
.metric strong { font-size: clamp(1.35rem, 2.5vw, 1.85rem); line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.metric span { color: var(--muted); font-size: .8rem; }
.settings-groups { display: grid; gap: 18px; }
.settings-group { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--field); }
.settings-group legend { padding: 0 5px; color: var(--text); font-weight: 700; font-size: .94rem; }
.settings-group .form-grid { align-items: start; }
.settings-group input { background: var(--surface); }
#settings-form .form-actions { margin-top: 20px; }
.product-add-form { align-items: end; }
.product-add-form .field-wide { grid-column: span 2; }
.product-admin-list { display: grid; gap: 12px; margin-top: 20px; }
.product-admin-card { padding: 19px; border-radius: 16px; border: 1px solid var(--line); background: var(--field); }
.product-admin-head, .product-admin-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.product-admin-head { margin-bottom: 12px; }
.product-number { font-size: .82rem; font-weight: 750; color: var(--muted); }
.product-admin-card .form-grid { align-items: start; }
.product-admin-actions { margin-top: 16px; }
.switch-label { display: inline-flex; align-items: center; gap: 9px; margin: 0; font-size: .84rem; color: var(--muted); }
.switch-label input { margin: 0; }
.empty-state { padding: 28px; border: 1px dashed var(--line); border-radius: 16px; text-align: center; color: var(--muted); font-size: .9rem; }
.setup-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 14px; padding: 0; list-style: none; counter-reset: step; }
.setup-steps li { display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 11px 13px; border-radius: 14px; background: var(--field); border: 1px solid var(--line); color: var(--muted); font-size: .83rem; line-height: 1.4; }
.setup-steps li::before { counter-increment: step; content: counter(step); flex: 0 0 25px; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .77rem; font-weight: 750; }
.inline-control { display: flex; gap: 9px; flex-wrap: wrap; }
.inline-control input { flex: 1 1 260px; }
.status-callout { margin: 18px 0 14px; padding: 14px 16px; border-radius: 13px; border: 1px solid var(--line); background: var(--field); color: var(--muted); font-size: .89rem; line-height: 1.6; overflow-wrap: anywhere; }
.status-callout:empty { display: none; }
.status-callout[data-tone="success"] { background: var(--success-soft); border-color: rgba(23, 128, 74, .18); color: var(--success); }
.status-callout[data-tone="warning"] { background: var(--warning-soft); border-color: rgba(155, 101, 0, .17); color: var(--warning); }
.data-columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; margin-top: 24px; }
.data-columns h3 { margin: 0 0 12px; font-size: 1rem; }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: .79rem; white-space: nowrap; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--field); color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.table-empty { color: var(--muted); text-align: center; padding: 28px 13px; }
.app-footer { padding: 38px 0 6px; text-align: center; color: var(--muted); font-size: .79rem; }
.toast { position: fixed; top: 20px; right: 20px; z-index: 100; width: min(420px, calc(100vw - 32px)); padding: 15px 18px; border: 1px solid rgba(0, 113, 227, .2); border-radius: 15px; background: var(--accent-soft); color: var(--text); box-shadow: 0 15px 45px rgba(25, 35, 60, .15); font-size: .9rem; font-weight: 600; line-height: 1.5; }
.toast[data-tone="error"] { border-color: rgba(180, 35, 24, .24); background: var(--danger-soft); color: var(--danger); }

@media (max-width: 950px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .data-columns { grid-template-columns: 1fr; }
  .product-add-form .field-wide { grid-column: auto; }
}

@media (max-width: 700px) {
  .wrap, .site-shell { padding: 14px 16px 56px; }
  .landing-hero { padding: 45px 0 32px; }
  .landing-hero h1 { font-size: clamp(2rem, 8.7vw, 2.4rem); letter-spacing: -.045em; }
  .privacy-panel { margin-bottom: 38px; }
  .privacy-panel__content { grid-template-columns: 1fr; gap: 13px; }
  .product-grid { grid-template-columns: 1fr; }
  .app-header { min-height: 44px; }
  .page-intro { padding: 38px 0 12px; }
  .page-intro h1 { font-size: clamp(2.05rem, 7.5vw, 2.7rem); }
  .surface { border-radius: 20px; padding: 20px; scroll-margin-top: 80px; }
  .section-nav { top: 6px; margin: 17px 0; border-radius: 13px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-steps { grid-template-columns: 1fr; }
  .login-form .field { flex-basis: 100%; max-width: none; }
  .login-form .button { width: 100%; }
  .session-bar { flex-wrap: wrap; }
  .inline-control input { flex-basis: 100%; }
  .inline-control .button { flex: 1 1 130px; }
  .product-admin-actions { flex-wrap: wrap; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111216;
    --surface: #1d1f24;
    --field: #25272e;
    --text: #f5f5f7;
    --muted: #b4b5bc;
    --line: rgba(255, 255, 255, .13);
    --accent: #2997ff;
    --accent-hover: #51aaff;
    --accent-soft: #172e47;
    --success: #52cb86;
    --success-soft: #173528;
    --warning: #f4c16d;
    --warning-soft: #3c2f17;
    --danger: #ff8a82;
    --danger-soft: #3f2425;
    --shadow: 0 10px 35px rgba(0, 0, 0, .15);
  }
  .landing-hero::before { background: radial-gradient(circle, rgba(35, 83, 142, .33), rgba(17, 18, 22, 0) 70%); }
  .brand-mark { background: #f5f5f7; color: #1d1d1f; }
  .button-primary, .product-card__primary { color: #071422; }
  .button-primary:hover, .product-card__primary:hover { color: #071422; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
