/**
 * Portal（frontend）api-docs 視覺 —— 抽自 /www/wwwroot/api-docs.html 的 inline style（issue #12）。
 *
 * 與原稿差異：
 * - 比照原稿為兩欄（sidebar + content）；程式碼範例內嵌於內容區 .section-card（.code-block），
 *   不另設右側深色 code 欄。
 * - body 直接高度撐滿改為 min-height，避免 Yii debug toolbar 注入時破版。
 */

:root {
  --primary: #E6950A;
  --primary-dark: #B87200;
  --primary-light: #FFF8E1;
  --sidebar-bg: #FFFDE7;
  --sidebar-width: 260px;
  --code-bg: #2b2416;
  --text: #333;
  --muted: #888;
  --border: #FFE082;
  --tag-get: #2196F3;
  --tag-post: #43A047;
  --tag-delete: #e53935;
  --tag-put: #FB8C00;

  /* ── 平台 shell / 設計原型 tokens（合併自 platform.html :root，issue portal-ui）──
     既有變數（--primary/--sidebar-width/--code-bg/--tag-* 等）保留不覆寫；
     以下為 apidocs.css 原本沒有、供 left-nav shell 與 login 使用的新增變數。 */
  /* Brand（--brand* 與 --primary 同色，供設計 class 直接引用其命名） */
  --brand: #E6950A;
  --brand-dark: #B87200;
  --brand-light: #FFF8E1;
  --brand-border: #FFE082;

  /* Platform chrome — Light Nav */
  --shell-bg: #F5F6FA;
  --nav-bg: #FFFFFF;
  --nav-width: 224px;
  --nav-text: #4B5563;
  --nav-text-hover: #111827;
  --nav-active-bg: #FFF8E1;
  --nav-active-text: #B87200;
  --nav-section: #9CA3AF;
  --nav-border: #E8EAF0;

  /* Topbar */
  --topbar-h: 56px;
  --topbar-bg: #FFFFFF;
  --topbar-border: #E8EAF0;

  /* Content */
  --content-bg: #F5F6FA;
  --card-bg: #FFFFFF;
  --card-radius: 10px;
  --card-border: #E8EAF0;
  --card-shadow: 0 1px 4px rgba(0,0,0,.06);

  /* Text（設計語意；與既有 --text/--muted 並存，勿混用） */
  --text-primary: #1A1D23;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;

  /* Status */
  --green: #10B981;
  --red: #EF4444;
  --blue: #3B82F6;
  --yellow: #F59E0B;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #FFF9EF;
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
}

/* ── 全站統一細捲軸 ──
   一次定義，套用於視窗、左側選單、右側內容區與程式碼區塊，確保各處顏色/粗細一致。
   Firefox 走 scrollbar-width/-color；WebKit 走 ::-webkit-scrollbar。 */
html { scrollbar-width: thin; scrollbar-color: #E6DFCE transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #E6DFCE;              /* 淡暖灰米色 */
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #D9C89A; }  /* 滑過時淺卡其 */

/* ── Header ── */
.portal-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 100;
}
.portal-header .logo { display: flex; align-items: center; gap: 10px; }
.portal-header .logo .logo-mark {
  font-size: 20px; font-weight: 800; color: var(--primary);
  letter-spacing: -.02em; text-decoration: none;
  display: flex; align-items: center;
}
.portal-header .logo .logo-img { height: 50px; width: auto; display: block; }
.portal-header .logo .logo-sub {
  font-size: 12px; color: #bbb; margin-left: 12px; padding-left: 12px;
  border-left: 1px solid #eee; line-height: 1.4; white-space: nowrap;
}
.portal-header nav { margin-left: auto; display: flex; gap: 24px; }
.portal-header nav a { font-size: 13px; color: var(--muted); text-decoration: none; }
.portal-header nav a:hover { color: var(--primary-dark); }

/* ── Layout ── */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.portal-sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overscroll-behavior: contain;   /* 側欄滾到底不帶動整頁 */
  flex-shrink: 0;
}
.sidebar-home {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-home-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--primary); color: #fff;
  font-weight: 600; font-size: 13px; cursor: pointer;
  border: none; width: 100%; text-align: left;
  text-decoration: none;
}
.sidebar-home-btn:hover { background: var(--primary-dark); }
.sidebar-empty {
  padding: 16px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}
.module-group { border-bottom: 1px solid var(--border); }
.module-header {
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
  background: transparent;
}
.module-header:hover { background: #FFF9C4; }
.module-header .module-title { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.module-header .module-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.module-header .arrow { font-size: 10px; color: var(--muted); transition: transform .2s; }
.module-header.open .arrow { transform: rotate(90deg); }
.api-list { display: none; }
.api-list.open { display: block; }
.api-item {
  padding: 9px 16px 9px 24px;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 12.5px; color: var(--text);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.api-item:hover { background: #FFF8E1; }
.api-item.active { background: var(--primary-light); border-left-color: var(--primary); color: var(--primary); font-weight: 600; }
.method-tag {
  font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 3px;
  color: #fff; flex-shrink: 0;
}
.tag-post { background: var(--tag-post); }
.tag-get { background: var(--tag-get); }
.tag-delete { background: var(--tag-delete); }
.tag-put { background: var(--tag-put); }
.tag-doc { background: #6366F1; } /* 總覽/說明類項目徽章（對齊設計原型 DOC 標記） */

/* ── Main Content ── */
.portal-main {
  flex: 1;
  overflow-y: auto;
  background: #f0f5f5;
}
.content-wrap {
  min-width: 860px;
  width: 80%;
  padding: 32px 36px;
}

/* ── Intro / cards ── */
.home-intro {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.home-intro h2 { font-size: 20px; color: var(--primary); margin-bottom: 12px; }
.home-intro p { font-size: 14px; line-height: 1.8; color: #555; }

/* ── 服務架構流程圖（首頁）── */
.home-flow {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.home-flow h2 { font-size: 18px; color: var(--primary); margin-bottom: 24px; font-weight: 700; }
.flow-diagram { overflow-x: auto;padding: 24px; }
.flow-diagram svg { min-width: 640px; }

.module-cards {
  display: grid;
  /* auto-fit（非 auto-fill）：空軌道會塌陷，卡片一律撐滿整列寬，避免單張卡窄縮＋右側大片留白。 */
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 24px;
}
.module-card {
  background: #fff;
  /* 中性卡邊（設計為白底灰邊）；hover 才轉品牌色，勿用 --border（琥珀黃） */
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 16px 18px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  /* 對齊設計原型模組卡：左圖示 + 右內容（標題/說明/連結） */
  display: flex; align-items: flex-start; gap: 12px;
  text-decoration: none;
}
.module-card:hover { box-shadow: 0 4px 16px rgba(230,149,10,.18); border-color: var(--primary); }
.module-card .mc-ico { font-size: 22px; line-height: 1; flex-shrink: 0; margin-top: 1px; }
.module-card .mc-body { min-width: 0; }
.module-card h4 { font-size: 14px; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.module-card p { font-size: 12px; color: var(--muted); line-height: 1.5; }
.module-card .mc-link { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--primary); }
.module-card .card-arrow { color: var(--primary); font-size: 16px; flex-shrink: 0; margin-top: 2px; }

/* ── Page header（api-header 樣式）── */
.api-header {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 20px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}
.api-header .breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.api-header .breadcrumb span { color: var(--primary); }
.api-header .breadcrumb a { color: var(--muted); text-decoration: none; }
.api-header .breadcrumb a:hover { color: var(--primary-dark); }
.api-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.api-header .endpoint {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--primary-light); padding: 8px 14px; border-radius: 6px;
  font-size: 13px;
}
.api-header .endpoint .method { font-weight: 700; color: var(--primary); font-size: 13px; }
.api-header .endpoint .url { font-family: monospace; color: var(--text); }
.api-header .desc { margin-top: 14px; font-size: 14px; line-height: 1.7; color: #555; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  color: var(--muted); border: none; background: none;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Section card ── */
.section-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.section-card h3 {
  font-size: 13px; font-weight: 700;
  padding: 12px 18px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
  text-transform: uppercase; letter-spacing: .04em;
}

/* ── Param table ── */
.section-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.section-card th { background: var(--shell-bg); padding: 10px 16px; text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.section-card td { padding: 10px 16px; border-top: 1px solid var(--card-border); vertical-align: top; }
.section-card tr:first-child td { border-top: none; }
.param-name { font-family: monospace; color: var(--primary-dark); font-weight: 600; }
.required { color: #e53935; font-size: 11px; font-weight: 700; }
.optional { color: var(--muted); font-size: 11px; }
.type-badge { font-size: 11px; background: #eee; padding: 2px 6px; border-radius: 3px; font-family: monospace; }
.error-code { font-family: monospace; font-weight: 700; color: #e53935; }

/* ── Code block（深色 code panel 內容）── */
.code-block {
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  margin: 0;
}
.code-block-header {
  background: #3a2e10;
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.code-block-header .lang { font-size: 11px; color: #FFD54F; font-weight: 600; text-transform: uppercase; }
.code-block-header .copy-btn {
  font-size: 11px; color: #FFCC80; background: none; border: 1px solid #5D4E20;
  border-radius: 4px; padding: 2px 8px; cursor: pointer;
}
.code-block-header .copy-btn:hover { color: #fff; border-color: var(--primary); }
.code-block pre {
  padding: 16px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  color: #FFF8E1;
  font-family: "Fira Code", "Cascadia Code", monospace;
}
.code-block pre .k { color: #FFD54F; }
.code-block pre .s { color: #A5D6A7; }
.code-block pre .n { color: #FFCC80; }
.code-block pre .c { color: #8D7B4A; font-style: italic; }

/* section-card 內文比照 api-docs 原稿：表格 / code-block 齊邊，段落與 notice 補內距。 */
.section-card > table { margin: 0; }
/* 欄位說明小標題（MD `### 子標題`）：獨立標題原本只是有色粗體文字，貼在內容之間不夠
   明顯。改為滿版淡色底帶（--primary-light）＋上下分隔線，讓每個欄位說明小節與上方
   內容明確區隔。margin 橫向歸零、以 padding 撐內距，配合 .section-card 的 overflow:hidden
   即為齊卡片邊的標題帶。 */
.section-card > h4 {
  font-size: 13px; font-weight: 700;
  margin: 16px 0 10px;
  padding: 8px 18px;
  background: var(--primary-light);
  border-top: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
  color: var(--primary-dark);
}
/* 標記 #54：回應分頁一張 section-card 內以「表格 → h4 子標題 → 表格」交錯堆疊多個
   巢狀欄位小節（如 city_districts / districts / job_types 項目欄位）。標題帶本身已有
   上緣分隔線與底色，緊跟表格時僅再加大上緣留白拉開距離即可（分隔線由標題帶自帶）。 */
.section-card > table + h4 {
  margin-top: 24px;
  margin-bottom: 0;
}
.section-card > p { margin: 14px 18px; font-size: 14px; line-height: 1.7; color: #555; }
/* 清單比照段落的字級 / 行高 / 顏色；左內距容納項目符號並與段落文字左緣對齊。 */
.section-card > ul,
.section-card > ol { margin: 14px 18px; padding-left: 22px; font-size: 14px; line-height: 1.7; color: #555; }
.section-card > ul { list-style: disc; }
.section-card > ol { list-style: decimal; }
.section-card > ul li,
.section-card > ol li { margin: 4px 0; }
.section-card > .notice { margin: 14px 18px; }
/* team/invite 專用：表單直接作為卡片子元素時比照段落慣例補左右 + 下內距，避免
   input/select/按鈕貼齊卡片邊框。限定 .invite-form-card 這個 invite 頁自身容器，
   不用通用的 .section-card > form（其他頁面如 profile / support / api-keys 亦有
   卡片內表單，但其表格 / 版面各異，全域套用會造成表單與同卡片內表格對不齊）。 */
.section-card.invite-form-card > form { padding: 4px 18px 18px; }
/* 標記 #11：多個 Portal 表單（api-keys/apply、support/create、profile 等）的 form
   直接掛在 .section-card 下、無左右內距，內容貼齊卡片邊框太擠。比照 invite 慣例補
   18px 左右 + 下內距，讓欄位/label/輸入框與卡片邊有呼吸空隙。以 .form-card 修飾類
   逐頁掛載（不用通用 .section-card > form），避免波及已自行補內距的頁面（如
   security / webhooks 其 form 內元素已各自帶 18px，全域套用會雙重內距）。 */
.section-card.form-card > form { padding: 4px 18px 18px; }
.section-card .code-block { border-radius: 0; }
.section-card .code-block + .code-block { border-top: 1px solid #3a2e10; }

/* ── Notice box ── */
.notice {
  background: #fff8e1; border: 1px solid #ffe082;
  border-radius: 8px; padding: 12px 16px;
  font-size: 13px; color: #5d4037; line-height: 1.6;
  margin-bottom: 16px;
}
.notice::before { content: "⚠️ "; }
/* 多段引言（空白 `>` 行分隔）併入同一 notice 時，各段成 <p>；抹掉瀏覽器預設 margin，
   段間留 8px、末段不留，讓多則提示清楚分行又不撐高整框。 */
.notice > p { margin: 0 0 8px; }
.notice > p:last-child { margin-bottom: 0; }
/* 多段時 ⚠️ 位置修正：容器 ::before 屬行內內容，遇 block 的 <p> 會被擠到獨立一行；
   故有 <p> 子節點時抑制容器 ⚠️，改由第一段 <p> 帶行內 ⚠️（單行 notice 無 <p>，不受影響）。 */
.notice:has(> p)::before { content: none; }
.notice > p:first-child::before { content: "⚠️ "; }

/* ── 前端表單校驗的就地錯誤（form-validate.js 插入）──
   與 .notice 的「區塊式」提示區隔：此處為緊貼欄位的單行文字，不加底色與外框，
   以免每個欄位都掛一個色塊而讓表單看起來雜亂。沿用同一組琥珀警示語意
   （⚠️ 圖標 + 琥珀色文字 #F59E0B，與品牌色 --brand #E6950A 同色系）。 */
.field-error {
  /* inline：與標籤文字同一行（標籤多為 display:block，錯誤若成塊級會被擠到下一行）。 */
  display: inline;
  margin-left: 8px;
  font-size: 12px; font-weight: 400; line-height: 1.6;
  color: #F59E0B;
  /* 標籤本身可能設了 letter-spacing / text-transform，此處歸零避免繼承後變形。 */
  letter-spacing: 0; text-transform: none;
}
.field-error::before { content: "⚠️ "; }

/* ── Footer ── */
.portal-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Header 帳號區（已登入）── */
.portal-header .header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}
.portal-header .header-user .account-name {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
}
a.account-name:hover { color: var(--primary); text-decoration: underline; }
.portal-header .header-user .logout-link {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  transition: color .15s, border-color .15s, background .15s;
}
.portal-header .header-user .logout-link:hover {
  color: var(--primary-dark);
  border-color: var(--primary);
  background: var(--primary-light);
}
/* header 同時有 nav 與 header-user 時，nav 不再吃 margin-left:auto */
.portal-header nav.has-user { margin-left: 32px; }

/* ══════════════════════════════════════════════════════════════
   PLATFORM SHELL —— 已登入 left-nav 兩欄外框（設計原型 platform.html）。
   flex shell 行為限縮於 body.portal-shell，勿套全域 body（會壞 login/guest）。
   ══════════════════════════════════════════════════════════════ */
body.portal-shell {
  display: flex;
  flex-direction: row;   /* 覆寫共用 body 的 column */
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--shell-bg);
  color: var(--text-primary);
}

/* ── LEFT NAV ── */
.platform-nav {
  width: var(--nav-width);
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  box-shadow: 2px 0 8px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
}
.platform-nav::-webkit-scrollbar { width: 4px; }
.platform-nav::-webkit-scrollbar-thumb { background: #E8EAF0; border-radius: 2px; }

/* Logo area */
.nav-logo {
  padding: 0 16px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--nav-border);
  background: #fff;
  flex-shrink: 0;
}
.nav-logo img { height: 28px; width: auto; display: block; }
.nav-logo .nav-logo-sub {
  font-size: 10px; color: var(--nav-section);
  margin-left: 10px; padding-left: 10px;
  border-left: 1px solid var(--nav-border);
  line-height: 1.4; white-space: nowrap;
}

/* Partner badge */
.nav-partner {
  margin: 12px 12px 0;
  padding: 10px 12px;
  background: var(--brand-light);
  border-radius: 8px;
  border: 1px solid var(--brand-border);
  display: flex; align-items: center; justify-content: space-between;
  transition: background .15s;
  color: inherit; text-decoration: none;
}
a.nav-partner { cursor: pointer; }
a.nav-partner:hover { background: #FFE082; }
.nav-partner-info .label { font-size: 10px; color: var(--brand-dark); letter-spacing: .04em; text-transform: uppercase; font-weight: 700; }
.nav-partner-info .value { font-size: 12.5px; color: #111827; font-weight: 700; margin-top: 2px; }
.nav-partner-arrow { color: var(--brand-dark); font-size: 10px; }

/* Status dot */
.nav-status {
  margin: 10px 12px;
  padding: 8px 12px;
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  border-radius: 6px;
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: #065F46;
}
.nav-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(16,185,129,.6);
  animation: navpulse 2s infinite;
}
@keyframes navpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* Section label */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--nav-section);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 16px 18px 5px;
}

/* Nav item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 13px;
  color: var(--nav-text);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: color .12s, background .12s;
  user-select: none;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--nav-text-hover);
  background: #F9FAFB;
}
.nav-item.active {
  color: var(--nav-active-text);
  background: var(--nav-active-bg);
  border-left-color: var(--brand);
  font-weight: 700;
}
/* 佔位：計費管理暫不開放（灰、不可點） */
.nav-item.disabled {
  color: var(--nav-section);
  cursor: default;
  opacity: .7;
}
.nav-item.disabled:hover { background: transparent; color: var(--nav-section); }
.nav-item .nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-label { flex: 1; }
.nav-item .nav-badge {
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  background: var(--brand); color: #fff;
}
.nav-item .nav-badge.new { background: #10B981; }
.nav-item .nav-badge.soon { background: #E5E7EB; color: #6B7280; }

/* Nav divider */
.nav-divider {
  margin: 8px 18px;
  border: none;
  border-top: 1px solid var(--nav-border);
}

/* Nav footer */
.nav-footer {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--nav-border);
  background: #FAFAFA;
}
.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
}
.nav-user:hover { background: #F3F4F6; }
.nav-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, #FFB300 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.nav-user-info { min-width: 0; }
.nav-user-info .name { font-size: 12px; font-weight: 600; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user-info .role { font-size: 10px; color: var(--text-secondary); }
.nav-user .nav-user-gear { margin-left: auto; font-size: 10px; color: #6B7280; }

/* ── RIGHT BODY ── */
.platform-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top bar */
.platform-topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 100;
}
.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-secondary);
}
.topbar-breadcrumb .sep { color: var(--card-border); }
.topbar-breadcrumb .current { font-weight: 600; color: var(--text-primary); }
/* 麵包屑可點節點（根節點「Worky 開放平台」與中間可點分層），對齊設計原型 crumb-link。 */
.topbar-breadcrumb .crumb-link {
  color: var(--text-secondary); text-decoration: none; cursor: pointer;
  padding: 2px 6px; border-radius: 4px;
  transition: color .12s, background .12s;
}
.topbar-breadcrumb .crumb-link:hover { color: var(--brand-dark); background: var(--brand-light); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-logout-btn {
  height: 32px; padding: 0 14px;
  border-radius: 6px; border: 1px solid var(--card-border);
  background: #fff; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
  transition: border-color .12s, color .12s;
}
.topbar-logout-btn:hover { border-color: var(--brand); color: var(--brand-dark); }

/* Page container */
.platform-page {
  flex: 1;
  overflow-y: auto;
  background: var(--content-bg);
  padding: 24px 28px;
}
.platform-page::-webkit-scrollbar { width: 6px; }
.platform-page::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════
   Login 登入頁（issue #22 + portal-ui 對齊設計原型）—— 置中卡片。
   使用設計 class（login-screen / login-card / login-* / tagline）。
   ══════════════════════════════════════════════════════════════ */
body.login-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: auto;
  background: #F5F6FA;
}
.login-screen-wrap {
  position: relative;
  flex: 1;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}
.login-bg-pattern {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.login-bg-pattern::before {
  content: '';
  position: absolute; top: -200px; left: -200px;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(230,149,10,.08) 0%, transparent 70%);
}
.login-bg-pattern::after {
  content: '';
  position: absolute; bottom: -150px; right: -150px;
  width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.06) 0%, transparent 70%);
}
.login-card {
  background: #FFFFFF;
  border: 1px solid #E8EAF0;
  border-radius: 16px;
  padding: 40px 44px;
  width: 100%;
  max-width: 420px;
  position: relative; z-index: 1;
  box-shadow: 0 8px 32px rgba(0,0,0,.08);
}
/* 較寬卡片（合作夥伴申請頁，對齊設計 register-screen 520px）。 */
.login-card.wide {
  width: 520px;
  max-width: 92vw;
  max-height: 90vh;
  overflow: auto;
}
.login-logo-wrap {
  text-align: center; margin-bottom: 32px;
}
.login-logo-wrap img { height: 36px; width: auto; }
.login-logo-wrap .tagline {
  font-size: 12px; color: #9CA3AF; margin-top: 8px; letter-spacing: .04em;
}
.login-title {
  font-size: 18px; font-weight: 700; color: #111827; margin-bottom: 6px;
}
.login-sub { font-size: 13px; color: #6B7280; margin-bottom: 28px; }
.login-field { margin-bottom: 18px; }
.login-field label {
  display: block; font-size: 12px; font-weight: 600;
  color: #374151; margin-bottom: 7px; letter-spacing: .03em;
}
.login-field input,
.login-field textarea {
  width: 100%; padding: 11px 14px;
  background: #F9FAFB; border: 1px solid #E5E7EB;
  border-radius: 8px; color: #111827; font-size: 14px;
  font-family: inherit; line-height: 1.5;
  outline: none; transition: border-color .15s;
}
/* 下拉欄位（如邀請成員頁「角色」）：沿用 input 外觀，補 cursor 提示可點選。 */
.login-field select {
  width: 100%; padding: 11px 14px;
  background: #F9FAFB; border: 1px solid #E5E7EB;
  border-radius: 8px; color: #111827; font-size: 14px;
  font-family: inherit; outline: none; cursor: pointer;
}
.login-field select:focus { border-color: var(--brand); }
/* 業務簡述等多行欄位：沿用 input 外觀，僅補多行專屬（避免瀏覽器預設等寬字/過窄）。 */
.login-field textarea { resize: vertical; min-height: 96px; }
.login-field input:focus,
.login-field textarea:focus { border-color: var(--brand); }
.login-field input::placeholder,
.login-field textarea::placeholder { color: #9CA3AF; }
.login-field .error { color: #DC2626; font-size: 12px; margin-top: 6px; }
.login-field.field-has-error input,
.login-field.field-has-error textarea { border-color: #EF4444; }
.login-field .captcha-image { margin-bottom: 8px; }
.login-field-row {
  display: flex; justify-content: space-between; align-items: center;
}
.login-remember { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: #374151; cursor: pointer; }
.login-remember input { width: auto; }
.login-forgot { font-size: 12px; color: var(--brand); cursor: pointer; text-decoration: none; }
.login-forgot:hover { text-decoration: underline; }
.login-btn {
  width: 100%; padding: 12px;
  background: var(--brand); border: none; border-radius: 8px;
  color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
  margin-top: 8px; transition: background .15s;
}
.login-btn:hover { background: var(--brand-dark); }
.login-footer-note {
  text-align: center; margin-top: 24px;
  font-size: 11.5px; color: #6B7280;
}
.login-footer-note a { color: var(--brand); text-decoration: none; }
.login-error {
  background: #FEF2F2; border: 1px solid #FECACA;
  border-radius: 7px; padding: 10px 14px;
  font-size: 12.5px; color: #DC2626; margin-bottom: 16px;
}
/* Yii errorSummary 單一橫幅（與 .login-error 同款；顯示/隱藏由 Yii 內聯 style 控管，故此處不設 display）。 */
.login-error-summary {
  background: #FEF2F2; border: 1px solid #FECACA;
  border-radius: 7px; padding: 10px 14px;
  font-size: 12.5px; color: #DC2626; margin-bottom: 16px;
}
.login-error-summary p { margin: 0 0 4px; font-weight: 600; }
.login-error-summary ul { margin: 0; padding-left: 18px; }
.login-error-summary li { margin: 2px 0; }
.login-env {
  text-align: center; color: #9CA3AF; font-size: 11px; margin-top: 18px;
}
/* 忘記密碼「已寄出」成功態（issue #49）：綠色提示 + 返回登入/重發郵件雙鈕（append-only）。 */
.login-success {
  background: #ECFDF5; border: 1px solid #A7F3D0;
  border-radius: 7px; padding: 12px 14px;
  font-size: 12.5px; color: #047857; line-height: 1.6; margin-bottom: 16px;
}
.login-success strong { color: #065F46; }
.login-success-warn {
  background: #FFFBEB; border: 1px solid #FDE68A;
  border-radius: 7px; padding: 10px 14px;
  font-size: 12px; color: #B45309; line-height: 1.6; margin-bottom: 16px;
}
/* 次要全寬按鈕（外框式），與 .login-btn 尺寸對齊，供「返回登入」用。 */
.login-btn-ghost {
  display: block; width: 100%; padding: 12px; box-sizing: border-box;
  background: #fff; border: 1px solid var(--card-border); border-radius: 8px;
  color: var(--text-secondary); font-size: 14px; font-weight: 700;
  text-align: center; text-decoration: none; cursor: pointer;
  margin-top: 10px; transition: border-color .15s, color .15s;
}
.login-btn-ghost:hover { border-color: var(--brand); color: var(--brand-dark); }

/* ══════════════════════════════════════════════════════════════
   通用篩選列（logs 等頁篩選區共用）—— 對齊設計 token，取代拼湊 inline style。
   ══════════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 16px 18px;
}
/* logs 頁專屬：對齊設計原型 #section-logs 無標籤篩選列（標記 #22）。
   欄位不帶 label，故各欄垂直置中對齊、間距加大呼吸感；不影響 webhooks 頁的帶標籤版型。 */
.filter-bar--logs {
  gap: 14px;
  align-items: center;
  padding: 18px 20px 20px;
}
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-field label {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  letter-spacing: .02em;
}
.filter-field input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: #F9FAFB;
  outline: none;
  transition: border-color .15s;
}
.filter-field input:focus { border-color: var(--brand); }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.filter-btn {
  height: 38px;
  padding: 0 22px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.filter-btn.primary {
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
}
.filter-btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.filter-btn.secondary {
  background: #fff; color: var(--text-secondary); border: 1px solid var(--card-border);
}
.filter-btn.secondary:hover { border-color: var(--brand); color: var(--brand-dark); }

/* filter-field 也支援 select（方法 / 狀態 / 每頁筆數下拉），外觀與 input 對齊。 */
.filter-field select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: #F9FAFB;
  outline: none;
  transition: border-color .15s;
}
.filter-field select:focus { border-color: var(--brand); }

/* webhooks 近期推播紀錄：關鍵字搜尋框內嵌放大鏡圖示（對齊 PM 參考設計圖 markup #57）。 */
.filter-field.wh-search { position: relative; }
.filter-field.wh-search .wh-search-icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: #9CA3AF; pointer-events: none;
}
.filter-field.wh-search input { padding-left: 34px; }

/* logs 頁「最近 API 呼叫」資料表：對齊設計原型 .billing-table（標記 #65）。
   儲存格 12px 14px 呼吸感、淡灰列分隔線（非琥珀黃 --border）、末列去底線、
   表頭淡灰底小字大寫。取代舊 inline 的 10px 6px 擠壓內距。 */
.logs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.logs-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .05em;
  background: #F9FAFB;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}
.logs-table td {
  padding: 12px 14px; border-bottom: 1px solid #F3F4F6;
  color: var(--text-primary);
}
.logs-table tr:last-child td { border-bottom: none; }

/* logs 頁分頁列：對齊原型 footer（padding 14px 20px、上緣分隔線、左筆數選單／右頁碼）。
   取代舊「margin-top + padding 0 6px」貼邊寫法，讓分頁組件不再貼卡片邊框。 */
.logs-pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--card-border);
}
.logs-pager .logs-pager-perpage {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-secondary);
}
.logs-pager .logs-pager-perpage select {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--card-border); border-radius: 6px;
  font-size: 12.5px; color: var(--text); background: #F9FAFB; outline: none;
}
.logs-pager .logs-pager-nav {
  display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.logs-pager .logs-pager-range { color: var(--text-muted); font-size: 12.5px; }

/* ══════════════════════════════════════════════════════════════
   Portal 純樣式對齊（apply-key / team / logs / contact-review）—— 對齊 PM 設計原型。
   僅新增，不改既有 class；沿用既有 --brand / --card-border 等 token。
   ══════════════════════════════════════════════════════════════ */

/* 通用主 / 次按鈕（若既有 filter-btn/login-btn 不適用時的一般場景，如卡頭動作鈕）。 */
.btn-primary {
  background: var(--brand); color: #fff; border: none;
  border-radius: 8px; padding: 8px 16px;
  font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-block; font-size: 13px;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary {
  background: #fff; color: var(--text-secondary);
  border: 1px solid var(--card-border);
  border-radius: 8px; padding: 8px 16px;
  font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-block; font-size: 13px;
}
.btn-secondary:hover { border-color: var(--brand); color: var(--brand-dark); }

/* apply-key：成對欄位兩欄並排（窄螢幕退回單欄）。 */
.login-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 520px) { .login-field-grid { grid-template-columns: 1fr; } }

/* team：卡頭附動作鈕（標題左、按鈕右）。 */
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
}
.card-head h3 {
  font-size: 13px; font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 0; background: none; border: none;
}

/* team：角色彩色圓角徽章。 */
.role-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.role-badge.admin  { background: #D1FAE5; color: #065F46; }
.role-badge.dev    { background: #FEF3C7; color: #92400E; }
.role-badge.viewer { background: #E5E7EB; color: #374151; }

/* logs：狀態色底膠囊。 */
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
}
.status-pill.ok    { background: #D1FAE5; color: #065F46; }
.status-pill.err   { background: #FEE2E2; color: #991B1B; }
.status-pill.other { background: #E5E7EB; color: #374151; }

/* logs：方法欄字色（POST 綠 / GET 藍）。 */
.method-get  { color: var(--blue);  font-weight: 600; }
.method-post { color: var(--green); font-weight: 600; }

/* dashboard 快捷操作（標記 #64）：對齊 PM 設計原型 platform.html 的 .quick-actions /
   .qa-btn —— 兩欄網格、圖示置頂置中的直式卡片（現況為圖示置左的橫式 .module-card，
   與設計不符）。沿用既有 --card-border / --brand / --text-primary / --text-muted token，
   不新造色票。hover 走品牌色細陰影，與 module-card 一致但更輕。 */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa-btn {
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .12s, box-shadow .12s;
}
.qa-btn:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(230,149,10,.12); }
/* markup #107 追問：臨時合作方儀表板快捷操作，僅「API 文檔」可點，其餘置灰（可見不可點）。
   沿用與選單 .nav-item.disabled 同一套視覺語言（降透明度 + 不可點游標 + 抑制 hover 反饋）。 */
.qa-btn.disabled { opacity: .5; cursor: default; }
.qa-btn.disabled:hover { border-color: var(--card-border); box-shadow: none; }
.qa-btn .qa-icon  {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin: 0 auto 8px;
  border-radius: 50%;
  font-size: 18px; line-height: 1;
}
.qa-btn .qa-label { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.qa-btn .qa-sub   { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

/* qa-icon 圓形色底（PM 補件：對齊設計原型每卡圖示帶語意色圓底，非裸放）。
   複用 dashboard KPI 卡已用過的 rgba 淡色底手法與既有色相 token
   （--blue/--green/--yellow/--brand），4 色相輪替、不新造色票。 */
.qa-icon.blue   { background: rgba(59,130,246,.12); }
.qa-icon.green  { background: rgba(16,185,129,.12); }
.qa-icon.yellow { background: rgba(245,158,11,.12); }
.qa-icon.brand  { background: rgba(230,149,10,.12); }

/* ── API 詳情頁「調試」分頁（issue #44）───────────────────────────────
   沿用 .section-card 外框與 portal token（--primary/--border/--card-border 等），
   不引入 Bootstrap；表單控件為原生 input/select，僅補間距與狀態色。 */
/* 調試分頁頂部增加呼吸間隙（markup #19 第 1 點）：此分頁首張卡片直接貼在 tab bar
   下方 20px 處，較其他分頁擁擠；補 padding-top 讓輸入區與頁籤列拉開，不影響其他分頁
   （僅作用於 #tab-debug）。*/
#tab-debug { padding-top: 12px; }
.api-debug .section-card { padding: 0 0 18px; }

/* markup #21：「輸入」卡片內文兩欄——左為表單輸入區，右為輸入 JSON 即時預覽。
   窄螢幕（<900px）自動改為上下堆疊，避免右欄擠壓輸入控件。 */
.api-debug-body { display: flex; gap: 20px; align-items: flex-start; }
.api-debug-inputs { flex: 1 1 60%; min-width: 0; }
.api-debug-json {
  flex: 0 0 38%; min-width: 0; align-self: stretch;
  margin: 14px 18px 0 0;
  border: 1px solid var(--card-border); border-radius: 8px;
  background: var(--code-bg, #1e1e1e); overflow: hidden;
  display: flex; flex-direction: column;
}
.api-debug-json-head {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 14px; border-bottom: 1px solid #3a2e10;
}
.api-debug-json-title { color: #e6e6e6; font-size: 13px; font-weight: 700; }
.api-debug-json-hint { color: #9aa0a6; font-size: 11px; line-height: 1.5; }
.api-debug-json-body {
  margin: 0; padding: 14px 16px; flex: 1 1 auto;
  overflow-x: auto;
}
/* markup #24：三段（header / query / body）——各段一個灰字小標 + 一個內容 <pre>。 */
.api-debug-json-seg + .api-debug-json-seg { margin-top: 14px; }
.api-debug-json-seg-label {
  color: #9aa0a6; font-family: monospace; font-size: 12px; font-weight: 700;
  letter-spacing: .04em; margin-bottom: 4px;
}
.api-debug-json-seg-body {
  margin: 0; color: #e6e6e6; font-family: monospace; font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-all;
}
@media (max-width: 900px) {
  .api-debug-body { flex-direction: column; }
  .api-debug-inputs, .api-debug-json { flex: 1 1 auto; width: auto; }
  .api-debug-json { margin: 14px 18px 0; }
}
.api-debug-endpoint {
  display: flex; align-items: center; gap: 10px;
  /* markup #20：endpoint pill 原 margin-top 4px 貼「輸入」標題分隔線太緊，
     比照卡片內文 .section-card > p 的 14px 上緣慣例補一點呼吸間隙。 */
  margin: 14px 18px 16px; padding: 8px 14px;
  background: var(--primary-light); border-radius: 6px; width: fit-content;
}
.api-debug-endpoint .method { font-weight: 700; font-size: 13px; }
.api-debug-endpoint .url { font-family: monospace; font-size: 13px; color: var(--text-secondary); }

.api-debug-group { margin: 0 18px 8px; }
.api-debug-group > h4 {
  font-size: 13px; font-weight: 700; margin: 16px 0 10px;
  color: var(--primary-dark); border-bottom: 1px solid var(--card-border); padding-bottom: 6px;
}
.api-debug-field { margin-bottom: 14px; }
.api-debug-field > label {
  display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 13px;
}
.api-debug-field > label code {
  font-family: monospace; color: var(--primary-dark); font-weight: 700; font-size: 13px;
}
.api-debug-field > label .type { color: var(--text-secondary); font-size: 12px; }
.api-debug-field > label .required {
  background: #FEE2E2; color: #991B1B; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px;
}
.api-debug-field input[type="text"],
.api-debug-field input[type="number"],
.api-debug-field input[type="file"],
.api-debug-field select {
  width: 100%; box-sizing: border-box; padding: 8px 11px;
  border: 1px solid var(--card-border); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text, #1f2937);
}
.api-debug-field input:focus,
.api-debug-field select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(230,149,10,.15);
}
/* markup #25：送出測試前必填驗證——缺項欄位以紅框標示（沿用站點錯誤色 --red / #EF4444）。 */
.api-debug-field.field-invalid input[type="text"],
.api-debug-field.field-invalid input[type="number"],
.api-debug-field.field-invalid input[type="file"],
.api-debug-field.field-invalid select {
  border-color: var(--red, #EF4444);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .15);
}
.api-debug-field .field-desc { margin: 5px 0 0; font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.api-debug-field .hint { display: block; margin-top: 4px; font-size: 12px; color: var(--text-secondary); }

.api-debug-actions {
  display: flex; gap: 10px; margin: 18px 18px 0; padding-top: 16px;
  border-top: 1px solid var(--card-border);
}
.api-debug-actions button {
  padding: 9px 18px; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; font-family: inherit;
}
.api-debug-actions .btn-send { background: var(--primary); color: #fff; }
.api-debug-actions .btn-send:hover { background: var(--primary-dark); }
.api-debug-actions .btn-send:disabled { opacity: .6; cursor: not-allowed; }
.api-debug-actions .btn-reset { background: #fff; color: var(--text-secondary); border-color: var(--card-border); }
.api-debug-actions .btn-reset:hover { border-color: var(--primary); color: var(--primary); }

.api-debug-output { margin: 14px 18px 0; }
.api-debug-output .output-empty,
.api-debug-output .output-loading { color: var(--text-secondary); font-size: 13px; padding: 12px 0; }
.api-debug-output .output-status {
  display: inline-block; padding: 3px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 700; margin-bottom: 10px;
}
.api-debug-output .output-ok   { background: #D1FAE5; color: #065F46; }
.api-debug-output .output-err  { background: #FEE2E2; color: #991B1B; }
.api-debug-output .output-warn { background: #FEF3C7; color: #92400E; }
.api-debug-output .output-note { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.api-debug-output .output-body {
  background: var(--code-bg, #1e1e1e); color: #e6e6e6;
  padding: 14px 16px; border-radius: 8px; font-family: monospace; font-size: 13px;
  line-height: 1.6; overflow-x: auto; white-space: pre; margin: 0;
}

/* 欄位說明的跨文件連結（[文字](檔名.md) → 詳情頁）。 */
.api-debug-field .field-desc a { color: var(--primary-dark); text-decoration: underline; }
.api-debug-field .field-desc a:hover { color: var(--primary); }

/* 關聯欄位選項載入狀態列（需求 1）。 */
.option-load-status {
  margin: 0 18px 14px; padding: 7px 12px; border-radius: 6px;
  font-size: 12px; line-height: 1.6;
}
.option-load-status.info { background: var(--primary-light); color: var(--primary-dark); }
.option-load-status.ok   { background: #D1FAE5; color: #065F46; }
.option-load-status.warn { background: #FEF3C7; color: #92400E; }
.option-load-status.err  { background: #FEE2E2; color: #991B1B; }

/* 圖片網址欄位：文字框＋右側上傳按鈕（需求 2）。 */
.api-debug-input-row { display: flex; gap: 8px; align-items: stretch; }
.api-debug-input-row input[type="text"] { flex: 1; min-width: 0; }
.api-debug-input-row .btn-upload {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  background: #fff; color: var(--primary); border: 1px solid var(--primary);
}
.api-debug-input-row .btn-upload:hover { background: var(--primary); color: #fff; }
.api-debug-input-row .btn-upload:hover .type-tag { color: #fff; border-color: rgba(255,255,255,.6); }
.api-debug-input-row .btn-upload:disabled { opacity: .6; cursor: not-allowed; }
.api-debug-input-row .btn-upload .type-tag {
  font-family: monospace; font-size: 11px; font-weight: 500;
  color: var(--text-secondary); border: 1px solid var(--card-border);
  border-radius: 4px; padding: 1px 5px;
}
.upload-status { display: block; margin-top: 5px; font-size: 12px; line-height: 1.6; }
.upload-status.info { color: var(--text-secondary); }
.upload-status.ok   { color: #065F46; }
.upload-status.warn { color: #92400E; }
.upload-status.err  { color: #991B1B; }

/* ── 獨立 002 file 欄位：可貼上型取圖區（issue #93）─────────────────────
   點擊選檔／聚焦後 Ctrl+V 貼上／拖放，選定後就地顯示縮圖預覽。沿用 portal token。 */
.api-debug-filepick {
  border: 1px dashed var(--card-border); border-radius: 8px;
  padding: 16px; background: #F9FAFB; cursor: pointer;
  transition: border-color .12s, background .12s; outline: none;
}
.api-debug-filepick:hover,
.api-debug-filepick:focus,
.api-debug-filepick.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
/* 懸停即貼（issue #102）：滑鼠移入期間的高亮，提示「現在按 Ctrl+V 會進這裡」。
   沿用 dragover 的實心主色邊框語彙，較純 :hover 更明顯，以區別「可貼上」的作用態。 */
.api-debug-filepick.hover-paste {
  border-style: solid; border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(230, 149, 10, .18);
}
.api-debug-filepick .filepick-empty:not([hidden]) {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.6;
}
.api-debug-filepick .filepick-plus {
  font-size: 20px; color: var(--primary); font-weight: 700; line-height: 1;
}
.api-debug-filepick kbd {
  font-family: monospace; font-size: 11px; background: #fff;
  border: 1px solid var(--card-border); border-radius: 4px; padding: 0 5px;
}
.api-debug-filepick .filepick-error { color: var(--red, #EF4444); }
/* 用 :not([hidden]) 讓 hidden 屬性能真正隱藏——類選擇器特異度(0,2,0)否則會壓過 UA 的 [hidden]{display:none}，
   導致未選圖時空 src 的 .filepick-thumb 露出破圖（issue #93 修後回報） */
.api-debug-filepick .filepick-preview:not([hidden]) { display: flex; align-items: center; gap: 12px; }
.api-debug-filepick .filepick-thumb {
  width: 56px; height: 56px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--card-border); background: #fff; flex-shrink: 0;
}
.api-debug-filepick .filepick-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text, #1f2937); word-break: break-all; }
.api-debug-filepick .filepick-clear {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--card-border); background: #fff; color: var(--text-secondary);
  cursor: pointer; font-size: 12px; line-height: 1;
}
.api-debug-filepick .filepick-clear:hover { border-color: var(--red, #EF4444); color: var(--red, #EF4444); }
.api-debug-field.field-invalid .api-debug-filepick {
  border-color: var(--red, #EF4444); box-shadow: 0 0 0 3px rgba(239, 68, 68, .15);
}

/* ── 取圖小視窗 modal（issue #93）——101/202「上傳」鈕點開，選檔＋貼上＋預覽＋確認 ── */
.img-pick-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(17, 24, 39, .5);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.img-pick-overlay.open { display: flex; }
.img-pick-modal {
  width: 100%; max-width: 440px; background: #fff; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.24); overflow: hidden;
  display: flex; flex-direction: column;
}
.img-pick-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--card-border);
}
.img-pick-title { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.img-pick-x {
  border: none; background: none; cursor: pointer; font-size: 15px;
  color: var(--text-secondary); line-height: 1;
}
.img-pick-x:hover { color: var(--primary); }
.img-pick-drop {
  margin: 18px; border: 1px dashed var(--card-border); border-radius: 8px;
  padding: 22px 16px; background: #F9FAFB; cursor: pointer; text-align: center;
  transition: border-color .12s, background .12s; outline: none;
}
.img-pick-drop:hover, .img-pick-drop:focus, .img-pick-drop.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.img-pick-drop-empty:not([hidden]) {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.7;
}
.img-pick-plus { font-size: 26px; color: var(--primary); font-weight: 700; line-height: 1; }
.img-pick-drop kbd {
  font-family: monospace; font-size: 11px; background: #fff;
  border: 1px solid var(--card-border); border-radius: 4px; padding: 0 5px;
}
/* :not([hidden]) 同 .filepick-preview 修法（issue #93 跟進）：.img-pick-preview 特異度(0,1,0)
   與 UA [hidden]{display:none} 同級、靠來源順序勝出 → 未選圖時 hidden 失效、空 src 的
   .img-pick-thumb 露破圖。改 :not([hidden]) 讓 hidden 屬性真正生效。 */
.img-pick-preview:not([hidden]) { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.img-pick-thumb {
  max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 6px;
  border: 1px solid var(--card-border); background: #fff;
}
.img-pick-name { font-size: 12px; color: var(--text-secondary); word-break: break-all; }
/* 多選（photos 等陣列欄位）縮圖清單：每張一格帶縮圖、檔名與移除鈕，可捲動。 */
.img-pick-list:not([hidden]) {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  max-height: 240px; overflow-y: auto;
}
.img-pick-list-item {
  display: flex; align-items: center; gap: 10px; padding: 6px;
  background: #fff; border: 1px solid var(--card-border); border-radius: 6px;
}
.img-pick-list-thumb {
  width: 44px; height: 44px; flex: none; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--card-border);
}
.img-pick-list-name {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-secondary);
  word-break: break-all; line-height: 1.5;
}
.img-pick-list-rm {
  flex: none; width: 24px; height: 24px; border-radius: 4px; cursor: pointer;
  background: #fff; border: 1px solid var(--card-border);
  color: var(--text-secondary); font-size: 12px; line-height: 1; font-family: inherit;
}
.img-pick-list-rm:hover { border-color: #991B1B; color: #991B1B; }
.img-pick-list-add {
  font-size: 12px; color: var(--primary); text-align: center;
  padding: 4px; line-height: 1.6;
}
.img-pick-msg { margin: 0 18px; font-size: 12px; line-height: 1.6; }
.img-pick-msg.ok { color: #166534; }
.img-pick-msg.err { color: #991B1B; }
.img-pick-msg.warn { color: #92400E; }
.img-pick-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--card-border); margin-top: 6px;
}
.img-pick-actions button {
  padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; font-family: inherit;
}
.img-pick-cancel { background: #fff; color: var(--text-secondary); border-color: var(--card-border); }
.img-pick-cancel:hover { border-color: var(--primary); color: var(--primary); }
.img-pick-ok { background: var(--primary); color: #fff; }
.img-pick-ok:hover { background: var(--primary-dark); }
.img-pick-ok:disabled { opacity: .5; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════
   API 文檔雙側欄佈局（issue #46）—— 於外層 platform shell 之內，
   再嵌一層文檔側欄（搜尋框 ＋ 模組分組可折疊樹 ＋ 當前端點高亮）。
   僅 apidocs 相關頁（my-api / api-doc）套用；沿用既有 .module-group /
   .api-item / .method-tag（見上方 Sidebar 區塊），不另立外殼樣式。
   ══════════════════════════════════════════════════════════════ */

/* topbar 之下切成兩欄：左文檔側欄 + 右內容（維持 .platform-page 捲動行為）。 */
.apidoc-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
/* 文檔側欄外框：白底、右框線、獨立捲動（overscroll 收斂，滾到底不帶動內容區）。 */
.apidoc-doc-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--nav-border);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}
.apidoc-doc-sidebar::-webkit-scrollbar { width: 4px; }
.apidoc-doc-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
/* 側欄內套用文檔側欄時，內容區改由此欄承接捲動；.platform-page 自身仍捲動右側。 */
.apidoc-body > .platform-page { flex: 1; min-width: 0; }

/* 頂部搜尋框（icon + input），對齊設計原型 apidocs section 的 apidoc-search。 */
.apidoc-search-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px;
  background: #fff;
  border-bottom: 1px solid var(--nav-border);
}
.apidoc-search-wrap .apidoc-search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}
.apidoc-search {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: #F9FAFB;
  border: 1px solid var(--nav-border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.apidoc-search:focus { border-color: var(--primary); background: #fff; }

/* 群組全被搜尋濾掉時的提示。 */
.sidebar-no-result {
  padding: 16px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

/* ── 二級選單 L1 分區標籤（issue #53）─────────────────────────────
   對齊設計原型 platform.html 的 .apidoc-nav-section：L1 模組分類作為灰字
   小標，其下承接可折疊的 .module-group（L2 子分類）。沿用既有 --nav-section
   色票，不另立新視覺語彙。 */
.apidoc-nav-block:not(:first-of-type) { margin-top: 4px; }
.apidoc-nav-section {
  padding: 12px 16px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--nav-section);
}

/* ════════════════════════════════════════
   API 金鑰列表（已派發金鑰）——嚴格對齊設計原型 platform.html
   的 .apikey-row 卡列版型（狀態點＋名稱＋狀態徽章＋遮罩金鑰＋單行 meta＋操作）。
   取代先前 6 欄表格；沿用 portal token（--green/--red/--yellow/--card-border 等）。
   標記 #28。
════════════════════════════════════════ */
.apikey-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid #F3F4F6;
}
.apikey-row:first-of-type { border-top: none; }
.apikey-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; align-self: flex-start; margin-top: 6px;
}
.apikey-status-dot.active { background: var(--green); }
.apikey-status-dot.pending { background: var(--yellow); }
.apikey-status-dot.rejected { background: var(--red); }
.apikey-status-dot.disabled { background: #D1D5DB; }
.apikey-info { flex: 1; min-width: 0; }
.apikey-info .ak-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.apikey-info .ak-name .tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 700; margin-left: 8px;
}
.apikey-info .ak-name .tag.paid { background: rgba(16,185,129,.1); color: var(--green); }
.apikey-info .ak-name .tag.pending { background: rgba(245,158,11,.1); color: var(--yellow); }
.apikey-info .ak-name .tag.failed { background: rgba(239,68,68,.1); color: var(--red); }
.apikey-info .ak-name .tag.disabled { background: #F3F4F6; color: var(--text-muted); }
.apikey-info .ak-key {
  font-family: monospace; font-size: 12px; color: var(--text-muted);
  margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.apikey-info .ak-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.apikey-actions { display: flex; gap: 8px; flex-shrink: 0; align-self: flex-start; }
.ak-btn {
  padding: 5px 12px; font-size: 11px; font-weight: 600;
  border-radius: 5px; cursor: pointer; border: 1px solid var(--card-border);
  background: #fff; color: var(--text-secondary); text-decoration: none;
  display: inline-block; line-height: 1.4;
}
.ak-btn:hover { border-color: var(--primary); color: var(--primary-dark); }
.ak-btn[disabled] { opacity: .6; cursor: not-allowed; }
.ak-btn[disabled]:hover { border-color: var(--card-border); color: var(--text-secondary); }
/* 標記 #63：推播端點列表操作鈕對齊 PM 設計原型 apikey-row 的 .copy（中性外框）/ .revoke（紅底）分組。 */
.ak-btn.copy { border-color: var(--card-border); background: #fff; color: var(--text-secondary); }
.ak-btn.copy:hover { border-color: var(--primary); color: var(--primary-dark); }
.ak-btn.revoke { border-color: #FECACA; background: #FEF2F2; color: var(--red); }
.ak-btn.revoke:hover { background: #FEE2E2; border-color: #FCA5A5; color: var(--red); }

/* ════════ 帳號資料抽屜（右側 slide-over；markup #68 追問：改右側抽屜） ══════
   對齊 PM 設計原型 platform.html 的 .profile-overlay / .profile-panel：
   點左下角「個人帳號」→ 從右側滑出 380px 抽屜。內容＝自助個資維護表單
   （顯示名稱 / Email / 電話可改；登入帳號唯讀）。付費方案依 #68 不放。
   全部復用既有 CSS token（--card-border / --brand / --text-* 等），不自造色。 */
.profile-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.45);
  display: none; align-items: flex-start; justify-content: flex-end;
}
.profile-overlay.open { display: flex; }
.profile-panel {
  width: 380px; max-width: 100%; height: 100vh;
  background: #fff;
  box-shadow: -8px 0 32px rgba(0,0,0,.15);
  overflow-y: auto;
  display: flex; flex-direction: column;
  animation: profile-slide-in .18s ease-out;
}
@keyframes profile-slide-in {
  from { transform: translateX(24px); opacity: .4; }
  to   { transform: translateX(0);    opacity: 1; }
}
.profile-panel-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: space-between;
}
.profile-panel-header h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); margin: 0; }
.profile-close-btn {
  width: 30px; height: 30px; border-radius: 6px;
  background: #F3F4F6; border: none; cursor: pointer;
  font-size: 16px; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.profile-close-btn:hover { background: #E5E7EB; }
.profile-avatar-wrap {
  padding: 24px;
  background: linear-gradient(135deg, #1A1D23 0%, #2D3748 100%);
  display: flex; align-items: center; gap: 16px;
}
.profile-avatar-big {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, #FFB300 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.profile-avatar-info .name { font-size: 16px; font-weight: 700; color: #fff; }
.profile-avatar-info .role { font-size: 12px; color: #9CA3AF; margin-top: 2px; }
.profile-avatar-info .partner { font-size: 11px; color: var(--brand); margin-top: 4px; }
.profile-section { padding: 20px 24px; border-bottom: 1px solid var(--card-border); }
.profile-section:last-child { border-bottom: none; }
.profile-section h4 {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  letter-spacing: .08em; text-transform: uppercase; margin: 0 0 14px;
}
.profile-field { margin-bottom: 14px; }
.profile-field label { display: block; font-size: 11.5px; color: var(--text-secondary); margin-bottom: 5px; }
.profile-field .val { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.profile-field .val .locked-hint { font-size: 11px; color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.profile-field input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--card-border); border-radius: 7px;
  font-size: 13.5px; color: var(--text-primary); outline: none;
  transition: border-color .12s;
}
.profile-field input:focus { border-color: var(--brand); }
.profile-field .field-error { font-size: 11.5px; color: var(--red); margin-top: 5px; }
.profile-save-btn {
  width: 100%; margin-top: 4px; padding: 10px;
  border-radius: 7px; border: none;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background .12s;
}
.profile-save-btn:hover { background: var(--brand-dark); }
.profile-flash {
  margin: 16px 24px 0; padding: 10px 14px; border-radius: 7px;
  font-size: 12.5px; line-height: 1.5;
}
.profile-flash.success { background: rgba(16,185,129,.1); color: #059669; border: 1px solid rgba(16,185,129,.25); }
.profile-flash.danger  { background: #FEF2F2; color: var(--red); border: 1px solid #FECACA; }

/* ── SweetAlert2 彈窗主題（團隊頁的編輯 / 權限 / 重設密碼 / 停用確認）──
   SweetAlert2 預設為藍色系與 16px 大圓角，與 Portal 的琥珀主色（--brand #E6950A）
   及卡片語彙（--card-radius 10px、--card-border）不符，故於此覆寫。
   按鈕底色由 JS 以 confirmButtonColor 帶入（取自 CSS 變數，見 team-modal.js），
   此處只管形狀 / 字級 / 邊框 / 表單元素，避免色碼在兩處各寫一份而漂移。 */
.portal-swal {
  border-radius: var(--card-radius);
  border: 1px solid var(--card-border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .12);
  font-family: inherit;
}
.portal-swal .swal2-title {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary);
  padding: 20px 24px 4px;
}
.portal-swal .swal2-html-container {
  font-size: 13px; line-height: 1.7;
  color: var(--text-secondary);
  margin: 10px 24px 0;
  text-align: left;
}
/* 確認鈕：形狀對齊 .btn-primary（底色由 JS 帶入 --brand / --tag-delete）。 */
.portal-swal .portal-swal-confirm {
  border-radius: 8px; padding: 9px 22px;
  font-size: 13px; font-weight: 600;
  box-shadow: none;
}
/* 取消鈕：白底灰字細框，比照 .btn-secondary，不用 Swal 預設的灰色實心。 */
.portal-swal .portal-swal-cancel {
  border-radius: 8px; padding: 9px 22px;
  font-size: 13px; font-weight: 600;
  background: #fff !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--card-border) !important;
  box-shadow: none;
}
.portal-swal .portal-swal-cancel:hover { background: var(--shell-bg) !important; }
.portal-swal .swal2-actions { margin-top: 20px; gap: 10px; }
/* 彈窗內的表單元素：對齊 .login-field 的輸入框外觀（灰底細框、focus 轉主色）。 */
.portal-swal .swal2-html-container input[type="text"],
.portal-swal .swal2-html-container input[type="email"],
.portal-swal .swal2-html-container input[type="password"] {
  background: #F9FAFB; border: 1px solid #E5E7EB; border-radius: 8px;
  font-family: inherit; outline: none; transition: border-color .15s;
}
.portal-swal .swal2-html-container input:focus { border-color: var(--brand); }
.portal-swal .swal2-html-container input[type="checkbox"] { accent-color: var(--brand); }
/* 權限勾選框彈窗較寬，內容左對齊並留出捲動空間。 */
.portal-swal .swal2-html-container label { cursor: pointer; }
