:root {
  --canvas: #f5f5f7;
  --canvas-deep: #eceef2;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-soft: #f8f9fb;
  --ink: #1d1d1f;
  --ink-soft: #3a3a3c;
  --muted: #71717a;
  --muted-light: #a1a1aa;
  --line: rgba(29, 29, 31, 0.1);
  --line-strong: rgba(29, 29, 31, 0.16);
  --blue: #0066cc;
  --blue-bright: #0077ed;
  --blue-soft: #eaf4ff;
  --green: #138a58;
  --green-soft: #eaf8f1;
  --orange: #b85c00;
  --orange-soft: #fff4e5;
  --red: #c62828;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.03), 0 16px 48px rgba(31, 35, 48, 0.07);
  --shadow-float: 0 24px 80px rgba(31, 35, 48, 0.16);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% -8%, rgba(0, 119, 237, 0.09), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(93, 150, 255, 0.06), transparent 28%),
    linear-gradient(180deg, #fafafd 0, var(--canvas) 340px, var(--canvas) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1;
}

button, input, select, textarea { font: inherit; }
button, select, input[type="date"] { -webkit-tap-highlight-color: transparent; }

button {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s, background .18s;
}

button:hover { border-color: rgba(0, 102, 204, .35); background: #fff; box-shadow: 0 6px 18px rgba(0, 55, 110, .08); }
button:active { transform: scale(.98); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid rgba(0, 119, 237, .2); outline-offset: 2px; }
button:disabled { opacity: .58; cursor: wait; transform: none; }

h1, h2, h3, p { margin: 0; }
h1 { letter-spacing: -.035em; }
h2, h3 { letter-spacing: -.018em; }
a { color: inherit; }

.hidden { display: none !important; }
.srOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { display: block; color: var(--blue); font-size: 11px; font-weight: 760; letter-spacing: .16em; line-height: 1.4; }

.loginGate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 18% 14%, rgba(0, 119, 237, .16), transparent 30%),
    radial-gradient(circle at 84% 80%, rgba(87, 148, 255, .12), transparent 32%),
    #f4f6fa;
}

.loginGate::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .3;
  background-image: linear-gradient(rgba(0,0,0,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

.loginCard {
  position: relative;
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, .92);
  border-radius: 28px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
}

.loginBrand { display: flex; align-items: center; gap: 16px; }
.loginBrand h1 { margin-top: 4px; font-size: 24px; line-height: 1.2; }
.brandMark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; color: #fff; background: linear-gradient(145deg, #1687f8, #0057b8); box-shadow: inset 0 1px rgba(255,255,255,.45), 0 10px 24px rgba(0, 102, 204, .25); font-weight: 800; font-size: 21px; }
.loginLead { margin: 24px 0 22px; color: var(--muted); line-height: 1.65; }
.fieldLabel { display: grid; gap: 8px; }
.fieldLabel > span { color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.loginButton { width: 100%; margin-top: 14px; }
.loginError { min-height: 21px; margin-top: 8px; color: var(--red); font-size: 13px; }
.loginFooter { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.loginFooter a { color: var(--blue); text-decoration: none; }

.shell { width: min(1440px, calc(100% - 44px)); margin: 0 auto; padding: 18px 0 max(40px, env(safe-area-inset-bottom)); }

.topbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 9px 12px 9px 14px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 19px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 10px 40px rgba(24, 34, 54, .07);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 14px; letter-spacing: -.01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .045em; }
.brandMarkSmall { width: 40px; height: 40px; border-radius: 12px; font-size: 16px; box-shadow: inset 0 1px rgba(255,255,255,.45), 0 6px 16px rgba(0,102,204,.2); }
.topbarActions { display: flex; align-items: center; gap: 8px; }
.health { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); background: rgba(248,249,251,.8); font-size: 12px; white-space: nowrap; }
.health i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(19,138,88,.1); }
.textButton { min-height: 36px; padding: 0 13px; border-color: transparent; color: var(--muted); background: transparent; font-size: 13px; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; padding: 58px 18px 34px; }
.heroCopy { max-width: 720px; }
.heroCopy h1 { margin-top: 8px; font-size: clamp(31px, 4.2vw, 52px); line-height: 1.08; }
.heroCopy p { max-width: 620px; margin-top: 15px; color: var(--muted); font-size: 16px; line-height: 1.7; }

.workflow { min-width: 410px; display: flex; align-items: center; padding: 14px 17px; border: 1px solid rgba(255,255,255,.8); border-radius: 18px; background: rgba(255,255,255,.54); box-shadow: 0 10px 32px rgba(24,34,54,.045); }
.workflowItem { display: flex; align-items: center; gap: 9px; }
.workflowItem > span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--muted); background: #fff; font-size: 12px; font-weight: 700; }
.workflowItem div { display: grid; white-space: nowrap; }
.workflowItem strong { font-size: 12px; }
.workflowItem small { margin-top: 2px; color: var(--muted-light); font-size: 10px; }
.workflowItem.active > span { border-color: var(--blue); color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(0,102,204,.22); }
.workflowLine { width: 26px; height: 1px; margin: 0 9px; background: var(--line-strong); }

.layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr); align-items: start; gap: 18px; }
.panel { border: 1px solid rgba(255,255,255,.95); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-card); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.inputPanel { padding: 26px; }
.resultPanel { position: sticky; top: 92px; padding: 26px; }
.panelTitle, .resultHeader { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.panelTitle > div:first-child, .resultHeader > div:first-child, .adminContent .panelTitle > div { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.panelTitle h2, .resultHeader h2 { font-size: 21px; }
.panelTitle p { grid-column: 2; margin-top: 4px; color: var(--muted); font-size: 13px; }
.sectionIndex { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; }

.segmented { display: inline-grid; grid-auto-flow: column; padding: 3px; border-radius: 11px; background: #eceef2; box-shadow: inset 0 0 0 1px rgba(0,0,0,.035); }
.segmented button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; box-shadow: none; font-size: 13px; font-weight: 650; }
.segmented button:hover { color: var(--ink); background: rgba(255,255,255,.45); box-shadow: none; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.11); }
.segmented.small button { min-height: 30px; padding: 0 11px; font-size: 12px; }

.formSection { padding: 22px 0 10px; border-top: 1px solid var(--line); }
.formSection:first-of-type { padding-top: 0; border-top: 0; }
.sectionHeading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sectionHeading > div, .draftHeader > div, .adminSummary > span { display: flex; align-items: center; gap: 10px; }
.sectionHeading h3 { font-size: 15px; }
.sectionHeading > span { color: var(--muted-light); font-size: 11px; }
.sectionIcon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--blue); background: var(--blue-soft); font-size: 13px; font-weight: 750; }
.sectionIcon.dark { color: #fff; background: var(--ink); }

.grid, .adminGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
.compact { grid-template-columns: repeat(2, minmax(150px, 220px)); }
label { display: grid; gap: 7px; margin-bottom: 14px; }
label > span { color: var(--ink-soft); font-size: 13px; font-weight: 560; }
label small { min-height: 16px; color: var(--muted-light); font-size: 11px; line-height: 1.4; }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  outline: 0;
  color: var(--ink);
  background: rgba(255,255,255,.84);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.015);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input::placeholder, textarea::placeholder { color: #a9a9b2; }
input:hover, select:hover, textarea:hover { border-color: rgba(29,29,31,.25); }
input:focus, select:focus, textarea:focus { border-color: rgba(0,102,204,.6); background: #fff; box-shadow: 0 0 0 4px rgba(0,119,237,.1); }
input[readonly] { color: var(--ink-soft); background: #f3f4f6; }
textarea { resize: vertical; line-height: 1.55; }
.inquiryField { margin-bottom: 10px; }
.inquiryField textarea { min-height: 132px; padding: 15px; border-color: rgba(0,102,204,.18); background: linear-gradient(180deg, #fbfdff, #fff); font-size: 14px; }
.inlineAction { min-height: 36px; padding: 0 13px; border: 0; color: var(--blue); background: var(--blue-soft); font-size: 12px; font-weight: 650; }
.inlineAction:hover { border: 0; background: #dceeff; box-shadow: none; }

button.primary { border-color: var(--blue); color: #fff; background: linear-gradient(180deg, var(--blue-bright), var(--blue)); box-shadow: inset 0 1px rgba(255,255,255,.25), 0 8px 20px rgba(0,102,204,.2); font-weight: 700; }
button.primary:hover { border-color: var(--blue); background: linear-gradient(180deg, #1185f8, #0061c4); box-shadow: inset 0 1px rgba(255,255,255,.25), 0 11px 26px rgba(0,102,204,.25); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 8px; }
.actionPrimary, .aiButton { min-height: 50px; }
.actionPrimary { display: flex; align-items: center; justify-content: space-between; padding-left: 20px; }
.actionPrimary b { font-size: 19px; font-weight: 400; }
.aiButton { border-color: rgba(0,102,204,.2); color: var(--blue); background: linear-gradient(180deg, #f8fbff, #edf6ff); font-weight: 700; }
.aiButton:hover { background: #e6f3ff; }

.statusBadge { display: inline-flex; align-items: center; min-height: 30px; padding: 0 11px; border-radius: 999px; color: var(--muted); background: #f0f1f3; font-size: 11px; font-weight: 650; white-space: nowrap; }
.statusBadge::before { content: ""; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: currentColor; opacity: .7; }
.statusWarn { color: var(--orange) !important; background: var(--orange-soft) !important; }
.statusOk { color: var(--green) !important; background: var(--green-soft) !important; }

.buttonSpinner { width: 15px; height: 15px; display: inline-block; margin-right: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 22px; }
.metrics > div { min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, #fbfbfc, #f6f7f9); }
.metrics > div.metricPrimary { border-color: rgba(0,102,204,.14); background: linear-gradient(145deg, #f3f8ff, #eaf4ff); }
.metrics span { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .035em; }
.metrics strong { min-height: 29px; margin: 9px 0 5px; overflow-wrap: anywhere; color: var(--ink); font-size: 20px; line-height: 1.25; letter-spacing: -.02em; }
.metricPrimary strong { color: var(--blue); }
.metrics small { color: var(--muted-light); font-size: 10px; }

.draftHeader { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 11px; }
.draftHeader h3 { font-size: 15px; }
.draftHeader p { margin-top: 2px; color: var(--muted-light); font-size: 10px; }
.copyButton { min-height: 34px; padding: 0 12px; border-color: transparent; color: var(--blue); background: var(--blue-soft); font-size: 12px; font-weight: 650; }
.copyButton:hover { border-color: transparent; background: #dceeff; box-shadow: none; }
.draft { min-height: 425px; padding: 18px; border-color: var(--line); border-radius: 16px; background: #fff; color: var(--ink-soft); font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", monospace; font-size: 13px; line-height: 1.65; }
.reviewNote { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; padding: 12px 13px; border-radius: 13px; color: var(--muted); background: #f7f7f8; font-size: 11px; line-height: 1.55; }
.reviewNote > span { width: 20px; height: 20px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-soft); font-size: 11px; font-weight: 800; }
.reviewNote strong { display: block; margin-bottom: 1px; color: var(--ink-soft); }

.debugDisclosure { margin-top: 12px; border-top: 1px solid var(--line); }
.debugDisclosure summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 2px 4px; color: var(--muted); cursor: pointer; list-style: none; font-size: 12px; }
.debugDisclosure summary::-webkit-details-marker, .adminSummary::-webkit-details-marker { display: none; }
.debugDisclosure summary::after { content: "+"; color: var(--muted-light); font-size: 18px; font-weight: 300; }
.debugDisclosure[open] summary::after { content: "−"; }
.debugDisclosure summary small { color: var(--muted-light); font-size: 10px; }
#debug { max-height: 220px; overflow: auto; margin: 10px 0 0; padding: 14px; border: 1px solid rgba(255,255,255,.08); border-radius: 13px; color: #d8e5f4; background: #171c26; font-size: 11px; line-height: 1.55; white-space: pre-wrap; }

.adminPanel { margin-top: 18px; overflow: hidden; }
.adminSummary { display: flex; align-items: center; justify-content: space-between; padding: 19px 24px; cursor: pointer; list-style: none; }
.adminSummary b { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); background: #f0f1f3; font-size: 14px; }
.adminSummary strong, .adminSummary small { display: block; }
.adminSummary strong { font-size: 14px; }
.adminSummary small { margin-top: 3px; color: var(--muted-light); font-size: 10px; font-weight: 400; }
.adminSummary i { color: var(--muted-light); font-style: normal; transition: transform .2s var(--ease); }
.adminPanel[open] .adminSummary i { transform: rotate(180deg); }
.adminContent { padding: 4px 24px 24px; border-top: 1px solid var(--line); }
.adminContent .panelTitle { padding-top: 20px; }
.adminGrid { grid-template-columns: minmax(170px, 1fr) auto minmax(210px, 1.2fr) auto auto; align-items: end; gap: 10px; }
.jsonMaintenance { margin-top: 10px; }
.jsonMaintenance summary { padding: 10px 0; color: var(--muted); cursor: pointer; font-size: 12px; }
.jsonMaintenance textarea { margin-bottom: 10px; font-family: ui-monospace, monospace; font-size: 12px; }

.siteFooter { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 30px 8px 8px; color: var(--muted); font-size: 11px; }
.siteFooter > div { display: grid; gap: 3px; }
.siteFooter strong { color: var(--ink-soft); font-size: 12px; }
.siteFooter nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 16px; }
.siteFooter a { color: var(--muted); text-decoration: none; }
.siteFooter a:hover { color: var(--blue); }

@media (max-width: 1180px) {
  .hero { align-items: flex-start; flex-direction: column; gap: 24px; }
  .workflow { min-width: 0; width: 100%; justify-content: center; }
  .layout { grid-template-columns: minmax(0, 1fr) minmax(380px, .85fr); }
  .adminGrid { grid-template-columns: 1fr auto 1fr auto; }
  #downloadTemplateBtn { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 920px) {
  .shell { width: min(100% - 24px, 760px); padding-top: 12px; }
  .hero { padding: 44px 8px 26px; }
  .layout { grid-template-columns: 1fr; }
  .resultPanel { position: static; }
  .draft { min-height: 360px; }
  .adminGrid { grid-template-columns: 1fr 1fr; }
  #downloadTemplateBtn { grid-column: auto; justify-self: stretch; }
}

@media (max-width: 620px) {
  body { background: var(--canvas); }
  .shell { width: 100%; padding: 0 10px max(28px, env(safe-area-inset-bottom)); }
  .topbar { top: 6px; min-height: 56px; gap: 8px; border-radius: 16px; }
  .brand { min-width: 0; flex: 1 1 auto; }
  .brand strong { font-size: 12px; }
  .brand small { display: none; }
  .brandMarkSmall { width: 36px; height: 36px; border-radius: 11px; }
  .topbarActions { flex: 0 0 auto; gap: 2px; }
  .health { padding: 7px 9px; }
  .health span { max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
  .textButton { flex: 0 0 auto; padding: 0 7px; white-space: nowrap; }
  .hero { padding: 38px 8px 22px; }
  .heroCopy h1 { font-size: 32px; }
  .heroCopy p { font-size: 14px; }
  .workflow { justify-content: flex-start; overflow-x: auto; padding: 12px; scrollbar-width: none; }
  .workflow::-webkit-scrollbar { display: none; }
  .workflowLine { width: 16px; margin: 0 7px; }
  .panel { border-radius: 20px; }
  .inputPanel, .resultPanel { padding: 19px 16px; }
  .panelTitle { align-items: stretch; flex-direction: column; }
  .panelTitle .segmented { width: 100%; }
  .panelTitle .segmented button { width: 100%; }
  .grid, .compact, .adminGrid { grid-template-columns: 1fr; }
  .sectionHeading.dataHeading { align-items: flex-start; flex-direction: column; }
  .sectionHeading.dataHeading .segmented { width: 100%; }
  .sectionHeading.dataHeading button { width: 100%; }
  .actions { grid-template-columns: 1fr; }
  .actionPrimary, .aiButton { min-height: 52px; }
  .metrics { gap: 8px; }
  .metrics > div { min-height: 100px; padding: 14px; }
  .metrics strong { font-size: 17px; }
  .draft { min-height: 390px; font-size: 12px; }
  .adminSummary { padding: 17px 16px; }
  .adminContent { padding: 4px 16px 18px; }
  .siteFooter { align-items: flex-start; flex-direction: column; padding-inline: 8px; }
  .siteFooter nav { justify-content: flex-start; }
  .loginCard { padding: 26px 22px; border-radius: 24px; }
  .loginBrand h1 { font-size: 21px; }
}

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