/* Shared by every FC PayNow portal: ops, merchant, agent, the pay page and sign-in.
   A professional tool used all day: crisp and fast. Motion only where it explains
   something (dialogs, the phone menu) or confirms a press.
   Design rules follow Emil Kowalski's design-engineering skills (emilkowalski/skills). */

/* Brand: FC PayNow blue (logo gradient #2f6bff -> #1238b8) with a cyan spark (#7fe3ff). */
:root {
  --bg: #f4f6fa; --panel: #fff; --text: #111827; --muted: #5f6b7d; --line: #e4e8ef;
  --accent: #1f55e6; --accent-2: #1238b8; --spark: #0ea5c6;
  --green: #138a4f; --amber: #b25e00; --red: #c4321c; --blue: #1f55e6;
  --side: #fff; --side-text: #3b4554; --nav-on: color-mix(in srgb, var(--accent) 10%, transparent);
  --ring: 0 0 0 1px rgb(16 24 40 / 0.07);
  --shadow: var(--ring), 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-pop: 0 0 0 1px rgb(16 24 40 / 0.08), 0 16px 40px rgb(16 24 40 / 0.18);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --radius: 12px;
  --on-accent: #fff;
  --side-w: 248px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1217; --panel: #171b22; --text: #e8eaed; --muted: #9aa3ad; --line: #272d36;
          --accent: #7aa2ff; --accent-2: #4d7cff; --spark: #67e8f9;
          --green: #4cc38a; --amber: #f0a347; --red: #f97066; --blue: #7aa2ff;
          --side: #14181f; --side-text: #c3cad3;
          --ring: 0 0 0 1px rgb(255 255 255 / 0.07);
          --shadow: var(--ring);
          --shadow-pop: 0 0 0 1px rgb(255 255 255 / 0.1), 0 16px 40px rgb(0 0 0 / 0.55);
          --on-accent: #0b1220; }
}

* { box-sizing: border-box; }
html, body { overscroll-behavior-y: none; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang HK", "Noto Sans TC", sans-serif;
  background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

/* --- Logo --- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.logo-mark { width: 32px; height: 32px; flex-shrink: 0; }
.logo-text { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; line-height: 1.15; }
.logo-text b { font-weight: 800; }
.logo-text small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

/* --- Shell: sidebar on desktop, a bottom sheet on phones --- */
.frame { display: flex; min-height: 100vh; min-height: 100dvh; }
.side { width: var(--side-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; background: var(--side); box-shadow: 1px 0 0 var(--line); z-index: 20; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 12px; }
.side-org { margin: 0 12px 6px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--muted) 8%, transparent); }
.side-org label { margin: 0 0 2px; font-size: 11px; }
.side-org select { padding: 4px 6px; font-size: 14px; background: transparent; box-shadow: none; }
.side-org .org-name { font-weight: 600; font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; overscroll-behavior: contain; }
.nav-g { margin: 16px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.nav-i { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--side-text);
  font-size: 14px; font-weight: 500; }
.nav-i span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-i .i { color: var(--muted); }
.nav-i.on { background: var(--nav-on); color: var(--accent); font-weight: 600; }
.nav-i.on .i { color: var(--accent); }
.nav-i.nav-x { margin-top: 10px; box-shadow: 0 -1px 0 var(--line); border-radius: 0 0 8px 8px; padding-top: 12px; }
.side-foot { padding: 12px; box-shadow: 0 -1px 0 var(--line); display: grid; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, #2f6bff, #1238b8); }
.who-t { flex: 1; min-width: 0; display: grid; }
.who-e, .who-r { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.who-r { color: var(--muted); font-size: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); }
.icon-btn .i { width: 20px; height: 20px; }
.page { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); }
.bar-fill { flex: 1; }
.bar-logo, .menu-btn, .sheet-close, .sheet-backdrop { display: none; }
.bar-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Segmented switches: language, live/test */
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: color-mix(in srgb, var(--muted) 12%, transparent); }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgb(16 24 40 / 0.12), var(--ring); }
.seg button.on.test { background: var(--amber); color: #1a1200; }
.side-foot .lang { justify-self: start; }

.badge { display: inline-block; flex-shrink: 0; min-width: 20px; margin-left: 5px; padding: 0 6px; border-radius: 10px;
  font-size: 11px; line-height: 20px; text-align: center; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--text); }
.badge.hot { background: var(--amber); color: #fff; }
.test-bar { background: var(--amber); color: #1a1200; text-align: center; font-weight: 600; padding: 6px 12px; font-size: 13px; position: relative; z-index: 30; }

/* --- Sign-in and notice pages --- */
body.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, #2f6bff 22%, transparent), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #7fe3ff 22%, transparent), transparent 60%), var(--bg); }
.auth-wrap { width: 100%; max-width: 420px; display: grid; gap: 18px; padding: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; }
.auth-brand .logo-mark { width: 40px; height: 40px; }
.auth-brand .logo-text { font-size: 22px; }
.auth-card { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 28px; }
.auth-card h1 { font-size: 22px; margin: 0 0 8px; }
.auth-foot { display: flex; justify-content: center; }
button.block, .btn.block { display: block; width: 100%; padding: 11px 14px; font-weight: 600; text-align: center; }

/* --- Layout and surfaces --- */
main { padding: 8px 24px 40px; width: 100%; max-width: 1240px; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 4px 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 16px; margin: 18px 0 10px; }
.panel > h2:first-child, .panel > form > h2:first-child { margin-top: 0; }
.panel { background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel > :last-child { margin-bottom: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); padding: 14px 16px; display: block;
  color: var(--text); min-width: 0; }
.tile .n { font-size: clamp(18px, 1.7vw, 26px); font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 13px; display: inline; }
.tile .tip { margin-top: -2px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }

/* --- API guide (rendered Markdown) --- */
.guide { line-height: 1.6; overflow-wrap: anywhere; }
.guide h2 { font-size: 18px; margin-top: 24px; }
.guide h3 { font-size: 16px; margin-top: 18px; }
.guide code { font-size: 13px; background: color-mix(in srgb, var(--muted) 14%, transparent); padding: 1px 4px; border-radius: 4px; }
.guide pre { overflow-x: auto; padding: 12px; border-radius: 8px; background: color-mix(in srgb, var(--muted) 12%, transparent); }
.guide pre code { background: none; padding: 0; }
.guide table { margin: 8px 0; }

/* --- Tables --- */
.tablewrap { overflow-x: auto; box-shadow: var(--shadow); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.muted td { color: var(--muted); }
tr.click { cursor: pointer; }

/* --- Pills, messages, definition lists --- */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-grey { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.pill-blue { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }
.pill-green { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.pill-amber { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.pill-red { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.msg.success { background: color-mix(in srgb, var(--green) 14%, transparent); }
.msg.error { background: color-mix(in srgb, var(--red) 14%, transparent); }
dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.outcome { padding: 10px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, transparent); margin: 12px 0; }
.outcome.danger { background: color-mix(in srgb, var(--amber) 16%, transparent); }
.errorlist { color: var(--red); margin: 2px 0; padding-left: 16px; font-size: 13px; }

/* --- Forms and buttons --- */
form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
label .tip { margin: -2px 0 0 2px; }
form p { margin: 0 0 12px; }
input[type=checkbox], input[type=radio] { width: auto; padding: 0; box-shadow: none; accent-color: var(--accent); vertical-align: middle; margin: 0 6px 0 0; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 0; box-shadow: inset 0 0 0 1px var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); font: inherit; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
  user-select: none; touch-action: manipulation;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease; }
/* Every press is confirmed at once, on pointer-down. */
button:active:not(:disabled), .btn:active { transform: scale(0.97); }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.danger { background: var(--red); border-color: var(--red); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Hover only where there is a real pointer, so taps never leave a stuck state. */
@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled):not(.primary):not(.danger):not(.on) { background: color-mix(in srgb, var(--text) 5%, var(--panel)); }
  button.primary:hover, .btn.primary:hover { background: color-mix(in srgb, #000 10%, var(--accent)); }
  a.tile { transition: box-shadow 150ms ease; }
  a.tile:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent), 0 1px 2px rgb(16 24 40 / 0.04); }
  tr.click:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
  .nav-i:not(.on):hover { background: color-mix(in srgb, var(--muted) 10%, transparent); color: var(--text); }
}

/* --- Confirm dialog (money actions): occasional, so it may animate, briefly --- */
dialog { border: 0; box-shadow: var(--shadow-pop); border-radius: 12px; padding: 0; max-width: 560px;
  width: calc(100% - 32px); background: var(--panel); color: var(--text);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
dialog[open] { opacity: 1; transform: scale(1); }
@starting-style { dialog[open] { opacity: 0; transform: scale(0.96); } }
dialog::backdrop { background: rgb(0 0 0 / 0.4); transition: opacity 200ms ease; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }
dialog .body { padding: 16px; }
dialog.wide { max-width: 980px; }

@media (prefers-reduced-motion: reduce) {
  dialog { transition: opacity 150ms ease; }
  @starting-style { dialog[open] { transform: none; } }
  button:active:not(:disabled), .btn:active { transform: none; }
}

/* --- Phones: the sidebar becomes a bottom sheet opened from the top bar --- */
@media (max-width: 860px) {
  .frame { display: block; }
  .bar { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); gap: 6px; }
  .menu-btn, .bar-logo, .sheet-close { display: inline-grid; }
  .bar-logo { display: inline-flex; gap: 8px; min-width: 0; }
  .bar-logo .logo-mark { width: 28px; height: 28px; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: auto; max-height: 86dvh;
    border-radius: 18px 18px 0 0; box-shadow: var(--shadow-pop); z-index: 40; padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(102%); visibility: hidden;
    transition: transform 260ms var(--ease-out), visibility 0s linear 260ms; }
  .side::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px;
    background: var(--line); }
  .side-head { padding: 16px 12px 6px 16px; }
  .side-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; align-content: start; }
  .side-nav .nav-g { grid-column: 1 / -1; margin: 12px 10px 2px; }
  .nav-i { padding: 10px; }
  .nav-i.nav-x { grid-column: 1 / -1; }
  .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / 0.4);
    opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
  body.menu-open .side { transform: none; visibility: visible; transition: transform 260ms var(--ease-out); }
  body.menu-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }
  main { padding: 4px 12px 32px; }
  h1 { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  th, td { padding: 9px 8px; }
  /* Tables scroll sideways rather than squeezing words into columns. */
  .tablewrap th, .tablewrap td { white-space: nowrap; }
  .tablewrap td.wrap { white-space: normal; min-width: 200px; }
  .help-ctl .btn, .help-ctl button { padding: 6px 10px; font-size: 13px; }
  .seg button { padding: 4px 8px; }
  /* 16px stops iOS zooming into a field on focus. */
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .side, body.menu-open .side { transition: none; }
}

/* --- Help: ⓘ tooltips and page tours (core/static/core/help.js) --- */
.tip { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  min-height: 0; padding: 0; margin: 0 2px; border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  font-size: 13px; line-height: 1; vertical-align: middle; cursor: help; box-shadow: none; }
.tip::before { content: ""; position: absolute; width: 36px; height: 36px; }  /* a finger-sized hit area */
.tip { position: relative; }
.tip:hover, .tip[aria-expanded="true"] { color: var(--accent); }
.tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tip-pop { position: fixed; z-index: 60; max-width: min(320px, calc(100vw - 16px)); padding: 8px 10px; border-radius: 8px;
  background: var(--text); color: var(--bg); font-size: 13px; line-height: 1.45; box-shadow: var(--shadow-pop); white-space: pre-line; }
.tour-layer { position: fixed; inset: 0; z-index: 50; background: transparent; }
.tour-ring { position: fixed; z-index: 51; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgb(0 0 0 / 0.45); transition: all 200ms var(--ease-out); }
.tour-bubble { position: fixed; z-index: 52; width: min(380px, calc(100vw - 16px)); padding: 14px 16px; border-radius: 12px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-pop); }
.tour-bubble.center { left: 50% !important; top: 30% !important; transform: translateX(-50%); }
.tour-bubble h2 { font-size: 16px; margin: 2px 0 6px; }
.tour-bubble p { margin: 0 0 12px; white-space: pre-line; }
.tour-count { font-size: 12px; color: var(--muted); }
.tour-nav { display: flex; gap: 8px; align-items: center; }
.tour-nav span { flex: 1; }
.tour-off { display: flex; gap: 6px; align-items: center; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.tour-off input { width: auto; }
.help-btn { white-space: nowrap; }
@media (max-width: 760px) {
  .tour-bubble:not(.center) { left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; }
}
@media (prefers-reduced-motion: reduce) { .tour-ring { transition: none; } }
.guide-shot { display: block; width: 100%; max-width: 900px; height: auto; margin: 12px 0; border-radius: 8px; box-shadow: var(--ring); }
.guide-page ol { padding-left: 20px; } .guide-page li { margin-bottom: 6px; }
.help-ctl { flex-wrap: nowrap; gap: 6px; }
