:root {
  --canvas: #F6F3EB;
  --surface: #FFFDF8;
  --surface-muted: #F0ECE2;
  --ink: #282722;
  --ink-soft: #6C685F;
  --line: #E5E0D5;
  --brand: #FFB51B;
  --brand-soft: #FFF0C6;
  --green: #668f51;
  --green-soft: #e8f2e2;
  --danger: #c45132;
  --danger-soft: #fff0eb;
  --blue: #315d7c;
  --blue-soft: #e9f3f8;
  --shadow: 0 12px 34px rgba(43, 39, 29, 0.08);
  --page-inset: 20px;
  --radius-card: 24px 21px 26px 22px;
  --radius-control: 15px 13px 16px 14px;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { min-width: 280px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(255, 181, 27, 0.38); outline-offset: 2px; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; padding: max(28px, env(safe-area-inset-top)) var(--page-inset) max(28px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% -10%, var(--brand-soft) 0, rgba(255, 240, 198, 0) 42%), var(--canvas); }
.login-shell { display: grid; min-height: calc(100vh - 56px); place-items: center; }
.login-card { width: min(100%, 430px); padding: 38px 24px 28px; border: 1px solid rgba(222, 219, 210, 0.8); border-radius: 30px 24px 32px 26px; background: var(--surface); box-shadow: var(--shadow); }
.brand-mark { display: block; object-fit: contain; }
.login-mark { width: 92px; height: 42px; margin: 0 auto 20px; }
.header-mark { width: 46px; height: 28px; flex: none; }
.eyebrow { margin: 0; color: #946000; text-align: center; font-size: 11px; font-weight: 800; letter-spacing: 0.16em; }
.login-card h1 { margin: 8px 0 0; text-align: center; font-size: 28px; line-height: 1.25; }
.login-note { margin: 12px auto 28px; color: var(--ink-soft); text-align: center; font-size: 14px; line-height: 1.7; }
label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 700; }
.password-field { display: flex; min-height: 52px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-control); background: #fff; }
.password-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 181, 27, 0.17); }
.password-field input { min-width: 0; height: 50px; flex: 1; padding: 0 4px 0 16px; border: 0; outline: 0; background: transparent; font-size: 16px; }
.text-button { min-width: 56px; min-height: 44px; margin-right: 4px; border: 0; background: transparent; color: var(--ink); font-size: 13px; font-weight: 700; }
.primary-button { width: 100%; min-height: 52px; margin-top: 18px; border: 0; border-radius: 999px; color: var(--ink); background: var(--brand); font-size: 16px; font-weight: 750; }
.primary-button:disabled { color: var(--ink-soft); background: var(--line); }
.form-error { margin: 12px 2px 0; color: var(--danger); font-size: 13px; line-height: 1.5; }
.security-note { margin: 20px 0 0; color: var(--ink-soft); text-align: center; font-size: 12px; }
.security-note span { color: var(--brand); }

.app-header { position: sticky; z-index: 20; top: 0; padding: max(12px, env(safe-area-inset-top)) var(--page-inset) 0; border-bottom: 1px solid rgba(229, 224, 213, 0.8); background: rgba(246, 243, 235, 0.96); backdrop-filter: blur(16px); }
.brand-row { display: flex; max-width: 920px; align-items: center; justify-content: space-between; margin: 0 auto; }
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-lockup p, .detail-header p { margin: 0 0 1px; color: var(--ink-soft); font-size: 11px; }
.brand-lockup h1, .detail-header h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.ghost-button, .back-button, .refresh-button, .small-button { min-height: 44px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; }
.ghost-button { padding: 0 16px; font-size: 13px; }
.tab-nav { display: flex; max-width: 920px; gap: 7px; margin: 12px auto 0; overflow-x: auto; padding: 0 0 10px; scrollbar-width: none; }
.tab-nav::-webkit-scrollbar { display: none; }
.tab-nav button { min-width: max-content; min-height: 44px; padding: 0 17px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-soft); font-size: 14px; font-weight: 700; }
.tab-nav button.active { color: var(--ink); background: var(--brand); }
.content, .detail-content { width: min(100%, 920px); margin: 0 auto; padding: 24px var(--page-inset) calc(44px + env(safe-area-inset-bottom)); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 25px; line-height: 1.25; }
.section-heading p { margin: 6px 0 0; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.refresh-button { flex: none; padding: 0 16px; font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric-card, .data-card, .empty-card, .setting-card, .code-card, .user-summary, .record-card { border: 1px solid rgba(229, 224, 213, 0.8); background: var(--surface); box-shadow: var(--shadow); }
.metric-card { min-height: 116px; padding: 20px; border-radius: var(--radius-card); }
.metric-card.brand { background: var(--brand); }
.metric-card strong { display: block; overflow-wrap: anywhere; font-size: 31px; line-height: 1.1; }
.metric-card span { display: block; margin-top: 12px; color: var(--ink-soft); font-size: 13px; line-height: 1.4; }
.metric-card.brand span { color: rgba(40, 39, 34, 0.7); }
.range-tabs { display: flex; gap: 8px; margin: -2px 0 16px; }
.range-tabs button { min-height: 44px; flex: 1; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 700; }
.range-tabs button.active { border-color: var(--ink); color: var(--surface); background: var(--ink); }
.analytics-note { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; padding: 13px 15px; border-radius: 14px; background: var(--brand-soft); font-size: 12px; line-height: 1.55; }
.analytics-note strong { flex: none; }
.analytics-note span { color: var(--ink-soft); }
.analytics-summary { margin-bottom: 14px; }
.analytics-section { margin-top: 14px; padding: 19px; border: 1px solid rgba(229, 224, 213, 0.8); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); }
.analytics-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.analytics-title h3 { margin: 0; font-size: 17px; line-height: 1.35; }
.analytics-title p { margin: 5px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.funnel-list, .comparison-list { display: grid; gap: 15px; }
.funnel-heading, .comparison-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.funnel-heading strong, .comparison-heading strong { min-width: 0; font-size: 13px; }
.funnel-heading span, .comparison-heading span { flex: none; color: var(--ink-soft); font-size: 11px; }
.funnel-row small { display: block; margin-top: 5px; color: var(--ink-soft); font-size: 10px; text-align: right; }
.funnel-row progress, .comparison-row progress { display: block; width: 100%; height: 9px; margin-top: 8px; overflow: hidden; border: 0; border-radius: 999px; background: var(--surface-muted); appearance: none; }
.funnel-row progress::-webkit-progress-bar, .comparison-row progress::-webkit-progress-bar { border-radius: 999px; background: var(--surface-muted); }
.funnel-row progress::-webkit-progress-value, .comparison-row progress::-webkit-progress-value { border-radius: 999px; background: var(--brand); }
.funnel-row progress::-moz-progress-bar, .comparison-row progress::-moz-progress-bar { border-radius: 999px; background: var(--brand); }
.daily-list { display: grid; grid-template-columns: repeat(7, minmax(68px, 1fr)); gap: 7px; overflow-x: auto; padding-bottom: 3px; }
.daily-list div { min-width: 68px; padding: 11px 8px; border-radius: 12px; background: var(--surface-muted); text-align: center; }
.daily-list strong, .daily-list span, .daily-list small { display: block; }
.daily-list strong { font-size: 13px; }
.daily-list span { margin-top: 7px; font-size: 11px; }
.daily-list small { margin-top: 4px; color: var(--ink-soft); font-size: 9px; line-height: 1.4; }
.analytics-columns { display: grid; grid-template-columns: 1fr; gap: 14px; }
.analytics-columns .analytics-section { margin-top: 14px; }
.analysis-primary { display: block; font-size: 31px; line-height: 1.1; }
.compact-analysis > span, .compact-analysis > small { display: block; }
.compact-analysis > span { margin-top: 10px; font-size: 13px; }
.compact-analysis > small { margin-top: 7px; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.insight-section ul { display: grid; gap: 10px; margin: 0; padding-left: 20px; }
.insight-section li { padding-left: 2px; font-size: 13px; line-height: 1.6; }
.analytics-empty { padding: 18px 12px; border-radius: 12px; color: var(--ink-soft); background: var(--surface-muted); text-align: center; font-size: 12px; }
.analytics-footnote { margin: 15px 4px 0; color: var(--ink-soft); font-size: 10px; line-height: 1.6; text-align: center; }
.data-list { display: grid; gap: 13px; }
.data-card { width: 100%; padding: 19px; border-radius: var(--radius-card); }
button.data-card { min-height: 44px; text-align: left; }
.card-heading, .card-footer, .pro-heading, .record-meta, .record-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.openid-label { color: var(--ink-soft); font-size: 11px; font-weight: 750; letter-spacing: 0.08em; }
.openid { display: block; margin-top: 8px; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.tag { display: inline-flex; min-height: 28px; align-items: center; padding: 0 10px; border-radius: 999px; background: var(--surface-muted); font-size: 11px; font-weight: 750; }
.tag.brand, .tag.pending { background: var(--brand-soft); }
.tag.success { color: var(--green); background: var(--green-soft); }
.tag.danger, .tag.refunded { color: var(--danger); background: var(--danger-soft); }
.tag.blue { color: var(--blue); background: var(--blue-soft); }
.mini-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 18px; }
.mini-metrics div { min-width: 0; padding: 9px 3px; border-radius: 11px; background: var(--surface-muted); text-align: center; }
.mini-metrics strong, .mini-metrics span { display: block; }
.mini-metrics strong { font-size: 17px; }
.mini-metrics span { margin-top: 4px; color: var(--ink-soft); font-size: 9px; line-height: 1.3; }
.card-footer { margin-top: 15px; color: var(--ink-soft); font-size: 11px; }
.card-link { color: var(--ink); font-weight: 750; }
.filter-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-tabs button { min-height: 44px; padding: 0 17px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 700; }
.filter-tabs button.active { border-color: var(--ink); color: var(--surface); background: var(--ink); }
.pro-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.pro-openid { margin: 14px 0 0; overflow-wrap: anywhere; font-size: 13px; }
.pro-time { margin: 11px 0 0; color: var(--ink-soft); font-size: 12px; }
.danger-button { min-height: 44px; padding: 0 15px; border: 0; border-radius: 999px; color: var(--danger); background: var(--danger-soft); font-size: 12px; font-weight: 750; }

.code-card, .setting-card { padding: 21px; border-radius: var(--radius-card); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-group label { color: var(--ink-soft); font-size: 12px; }
.field-group input, .field-group select { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: var(--radius-control); background: #fff; font-size: 16px; }
.duration-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.duration-options button { min-height: 44px; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 700; }
.duration-options button.active { border-color: var(--brand); background: var(--brand-soft); }
.generated-list { display: grid; gap: 9px; margin-top: 18px; }
.generated-code { display: flex; min-height: 50px; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 13px; background: var(--surface-muted); }
.generated-code code { overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.small-button { padding: 0 14px; background: var(--surface); font-size: 12px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-row h3 { margin: 0; font-size: 16px; }
.setting-row p { margin: 6px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: 160ms ease; }
.switch span::after { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.14); content: ""; transition: 160ms ease; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }

.state-card, .error-card, .empty-card { padding: 28px 20px; border-radius: var(--radius-card); text-align: center; font-size: 14px; line-height: 1.6; }
.state-card { color: var(--ink-soft); }
.error-card { color: var(--danger); background: var(--danger-soft); }
.error-card button { display: block; margin: 14px auto 0; }
.empty-card { color: var(--ink-soft); }
.spinner { width: 28px; height: 28px; margin: 0 auto 12px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.detail-view { position: fixed; z-index: 50; inset: 0; overflow-y: auto; background: var(--canvas); }
.detail-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) var(--page-inset) 12px; border-bottom: 1px solid var(--line); background: rgba(246, 243, 235, .96); backdrop-filter: blur(16px); }
.back-button { width: 44px; padding: 0; font-size: 20px; }
.user-summary { margin-bottom: 15px; padding: 19px; border-radius: var(--radius-card); }
.summary-openid { margin: 11px 0 0; overflow-wrap: anywhere; font-size: 13px; }
.summary-total { margin: 10px 0 0; color: var(--ink-soft); font-size: 12px; }
.record-list { display: grid; gap: 13px; }
.record-card { padding: 19px; border-radius: var(--radius-card); }
.record-time { color: var(--ink-soft); font-size: 11px; }
.record-title-row { align-items: baseline; margin-top: 15px; }
.record-title-row h3 { min-width: 0; margin: 0; font-size: 18px; line-height: 1.4; }
.record-title-row span { flex: none; color: var(--ink-soft); font-size: 11px; }
.record-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.record-facts span { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 12px; background: var(--surface-muted); font-size: 13px; }
.record-facts b { color: var(--ink-soft); font-size: 11px; }
.source-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.source-detail { min-width: 0; color: var(--ink-soft); font-size: 11px; overflow-wrap: anywhere; }
.words-label { margin: 18px 0 0; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.words { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.word { padding: 7px 10px; border-radius: 9px; background: var(--surface-muted); font-size: 13px; }
.load-more { display: block; min-height: 46px; margin: 16px auto 0; padding: 0 20px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; }
.toast { position: fixed; z-index: 100; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); left: 18px; width: fit-content; max-width: min(420px, calc(100% - 36px)); margin: auto; padding: 13px 18px; border-radius: 999px; color: white; background: rgba(24, 24, 23, .92); box-shadow: var(--shadow); text-align: center; font-size: 13px; }

@media (min-width: 680px) {
  :root { --page-inset: 28px; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .data-list.users { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-card { padding: 22px; }
}

@media (max-width: 430px) {
  .tab-nav { justify-content: space-between; gap: 2px; }
  .tab-nav button { min-width: 0; padding-right: 5px; padding-left: 5px; font-size: 12px; }
}

@media (max-width: 350px) {
  :root { --page-inset: 13px; }
  .login-card { padding-right: 19px; padding-left: 19px; }
  .mini-metrics { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
}

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