/* 套裝軟體共用元件樣式（設計系統 components/bundle.css）。框架無關：Flask/Jinja、Laravel Blade、React 都只要套 class。
   所有值來自 tokens（var(--…)）；白牌只覆寫 --brand、--brand-strong、--brand-tint、--brand-soft。 */

.cc-root, .cc-root * { box-sizing: border-box; }
.cc-root { font-family: var(--font-sans); color: var(--ink); background: var(--surface-page); font-size: 15px; line-height: 24px; }
.cc-root a { color: var(--brand); }
.cc-root :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cc-data { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- AppShell ---------- */
.cc-shell { display: flex; min-height: 100%; background: var(--surface-page); }
.cc-sidebar { flex: 0 0 var(--sidebar-width); background: var(--surface); border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-4); display: flex; flex-direction: column; gap: var(--space-5); }
.cc-sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--space-2); min-height: var(--control-min); }
.cc-sidebar__logo { width: 34px; height: 34px; border-radius: var(--radius-md); background: var(--brand); color: var(--on-brand);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.cc-sidebar__name { display: flex; flex-direction: column; min-width: 0; }
.cc-sidebar__name strong { font-size: 15px; line-height: 20px; color: var(--ink-strong); }
.cc-sidebar__name span { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.cc-nav { display: flex; flex-direction: column; gap: var(--space-1); }
.cc-nav__group { font-size: 12px; font-weight: 500; letter-spacing: 0.02em; color: var(--ink-muted); padding: var(--space-3) var(--space-3) var(--space-1); }
.cc-nav__item { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-min); padding: 0 var(--space-3);
  border-radius: var(--radius-md); color: var(--ink); text-decoration: none; font-size: 15px; }
.cc-root .cc-nav__item { color: var(--ink); }
.cc-nav__item:hover { background: var(--surface-sunken); }
.cc-nav__item svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; }
.cc-nav__item[aria-current="page"] { background: var(--brand-tint); color: var(--brand); font-weight: 700; }
.cc-nav__count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--warning); background: var(--warning-bg);
  border-radius: var(--radius-pill); padding: 0 var(--space-2); }
.cc-sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.cc-user { display: flex; align-items: center; gap: 10px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--surface-sunken); }
.cc-user__avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.cc-user__text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 18px; }
.cc-user__text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-user__text span { color: var(--ink-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-main { flex: 1 1 auto; min-width: 0; padding: var(--space-6) var(--space-7) 48px; }
.cc-main__inner { max-width: var(--content-max); margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-5); }
.cc-pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--space-4); }
.cc-pagehead__crumb { font-size: 13px; color: var(--ink-muted); }
.cc-pagehead h1 { margin: var(--space-1) 0 0; font-size: 28px; line-height: 36px; font-weight: 700; color: var(--ink-strong); text-wrap: balance; }
.cc-pagehead p { margin: var(--space-1) 0 0; font-size: 15px; color: var(--ink-muted); }
@media (max-width: 720px) {
  .cc-shell { flex-direction: column; }
  .cc-sidebar { flex: none; flex-direction: row; align-items: center; padding: var(--space-2) var(--space-4); border-right: none; border-bottom: 1px solid var(--border); }
  .cc-sidebar .cc-nav, .cc-sidebar__foot { display: none; }
  .cc-main { padding: var(--space-5) var(--space-4) 40px; }
  .cc-pagehead h1 { font-size: 22px; line-height: 30px; }
}

/* ---------- AppSwitcher ---------- */
.cc-switcher { position: relative; display: inline-block; }
.cc-switcher__btn { width: var(--control-min); height: var(--control-min); border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); }
.cc-switcher__btn:hover { background: var(--surface-sunken); }
.cc-switcher__btn svg { width: 20px; height: 20px; fill: currentColor; }
.cc-switcher__panel { position: absolute; top: calc(100% + 8px); left: 0; z-index: 40; width: 320px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: var(--space-3);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); }
.cc-switcher__title { grid-column: 1 / -1; font-size: 12px; font-weight: 500; color: var(--ink-muted); padding: var(--space-1) var(--space-2) var(--space-2); }
.cc-switcher__app { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--space-3) var(--space-1); border-radius: var(--radius-md);
  text-decoration: none; color: var(--ink); font-size: 13px; line-height: 18px; text-align: center; }
.cc-root .cc-switcher__app { color: var(--ink); }
.cc-switcher__app:hover { background: var(--surface-sunken); }
.cc-switcher__app[aria-current="page"] { background: var(--brand-tint); color: var(--brand); font-weight: 700; }
.cc-switcher__foot { grid-column: 1 / -1; border-top: 1px solid var(--border); margin-top: var(--space-2); padding: var(--space-2) var(--space-2) 0; font-size: 13px; }

/* 模組圖示：方塊 + 兩個字，各模組同一套樣式，只換字 */
.cc-appicon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--brand); color: var(--on-brand);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }

/* ---------- Button ---------- */
.cc-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-min);
  padding: 0 var(--space-5); border-radius: var(--radius-button, var(--radius-md)); border: 1.5px solid transparent; font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.cc-btn--primary { background: var(--brand); color: var(--on-brand); }
.cc-btn--primary:hover { background: var(--brand-strong); }
.cc-btn--cta { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-cta); min-height: 48px; padding: 0 28px; font-size: 16px; }
.cc-btn--cta:hover { background: var(--accent-strong); }
.cc-root .cc-btn--cta { color: var(--on-accent); }
.cc-btn--secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.cc-btn--secondary:hover { background: var(--brand-tint); }
.cc-btn--ghost { background: transparent; color: var(--ink); font-weight: 500; }
.cc-btn--ghost:hover { background: var(--surface-sunken); }
.cc-btn--danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.cc-btn--danger:hover { background: var(--danger-bg); }
.cc-btn--sm { min-height: 36px; padding: 0 var(--space-3); font-size: 13px; border-radius: var(--radius-sm); }
.cc-btn:disabled, .cc-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.cc-root .cc-btn--primary { color: var(--on-brand); }

/* ---------- SegmentedControl ---------- */
.cc-segmented { display: inline-flex; gap: var(--space-1); padding: var(--space-1); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.cc-segmented__item { display: inline-flex; align-items: center; min-height: 40px; padding: 0 18px; border-radius: 9px; border: none; background: transparent;
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; text-decoration: none; }
.cc-root .cc-segmented__item { color: var(--ink); }
.cc-segmented__item:hover { background: var(--surface-sunken); }
.cc-segmented__item[aria-current="page"], .cc-segmented__item[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); font-weight: 700; }

/* ---------- ChoicePill（單選的膠囊，例如輸出格式） ---------- */
.cc-choices { border: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-3); }
.cc-choices legend { font-size: 14px; font-weight: 500; color: var(--ink-muted); padding: 0; margin-bottom: var(--space-2); }
.cc-choice { position: relative; display: inline-flex; }
.cc-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cc-choice__pill { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-min); padding: 0 var(--space-4);
  border-radius: var(--radius-pill); border: 1.5px solid var(--border-control); background: var(--surface); color: var(--ink); cursor: pointer; }
.cc-choice__pill strong { font-family: var(--font-mono); font-weight: 500; }
.cc-choice__pill span { font-size: 13px; color: var(--ink-muted); }
.cc-choice:hover .cc-choice__pill { border-color: var(--brand); }
.cc-choice input:checked + .cc-choice__pill { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.cc-choice input:checked + .cc-choice__pill span { color: var(--brand-tint); }
.cc-choice input:focus-visible + .cc-choice__pill { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- DropZone + FileRow ---------- */
.cc-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3);
  padding: 48px var(--space-5); background: var(--surface); border: 2px dashed var(--border-control); border-radius: var(--radius-lg); text-align: center; cursor: pointer; }
.cc-drop:hover, .cc-drop.is-dragover { border-color: var(--brand); background: var(--brand-tint); }
.cc-drop__icon { width: 56px; height: 56px; border-radius: var(--radius-lg); background: var(--brand-tint); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; }
.cc-drop__icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.cc-drop__title { font-size: 18px; line-height: 26px; font-weight: 700; color: var(--ink-strong); }
.cc-drop__hint { font-size: 14px; color: var(--ink-muted); }
.cc-drop__hint u { color: var(--brand); font-weight: 700; }
.cc-drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cc-files { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-1) var(--space-2); }
.cc-file { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); }
.cc-file + .cc-file { border-top: 1px solid var(--border); }
.cc-file__type { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--danger-bg); color: var(--danger); display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.cc-file__name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.cc-file__name strong { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-file__name span { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }
.cc-file__remove { width: var(--control-min); height: var(--control-min); border: none; background: transparent; border-radius: var(--radius-md); color: var(--ink-muted); cursor: pointer; font-size: 16px; }
.cc-file__remove:hover { background: var(--danger-bg); color: var(--danger); }

/* ---------- StatusPill ---------- */
.cc-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.02em;
  border-radius: var(--radius-pill); padding: 4px 10px; white-space: nowrap; }
.cc-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cc-status--done { color: var(--success); background: var(--success-bg); }
.cc-status--running { color: var(--brand); background: var(--brand-tint); }
.cc-status--review { color: var(--warning); background: var(--warning-bg); }
.cc-status--failed { color: var(--danger); background: var(--danger-bg); }
.cc-status--neutral { color: var(--ink-muted); background: var(--surface-sunken); }
.cc-status--running::before { animation: cc-pulse 1.4s ease-in-out infinite; }
@keyframes cc-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .cc-status--running::before { animation: none; } }

/* ---------- Card ---------- */
.cc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.cc-card__title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; color: var(--ink-strong); }

/* ---------- DataTable ---------- */
.cc-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; }
.cc-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.cc-table th { text-align: left; font-size: 12px; font-weight: 500; letter-spacing: 0.02em; color: var(--ink-muted); background: var(--surface-sunken);
  padding: 10px var(--space-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.cc-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.cc-table tr:last-child td { border-bottom: none; }
.cc-table tbody tr:hover { background: var(--surface-sunken); }
.cc-table .is-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.cc-table .is-sub { display: block; font-size: 12px; color: var(--ink-muted); }

/* ---------- Alert ---------- */
.cc-alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: 14px; line-height: 22px; }
.cc-alert strong { font-weight: 700; }
.cc-alert--info { background: var(--info-bg); color: var(--info); }
.cc-alert--success { background: var(--success-bg); color: var(--success); }
.cc-alert--warning { background: var(--warning-bg); color: var(--warning); }
.cc-alert--danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- Progress ---------- */
.cc-progress { display: flex; flex-direction: column; gap: 6px; }
.cc-progress__row { display: flex; justify-content: space-between; font-size: 14px; }
.cc-progress__row span:last-child { font-family: var(--font-mono); color: var(--brand); }
.cc-progress__track { height: 6px; border-radius: var(--radius-pill); background: var(--brand-tint); overflow: hidden; }
.cc-progress__bar { height: 100%; border-radius: var(--radius-pill); background: var(--brand); }
.cc-progress__note { font-size: 13px; color: var(--ink-muted); }

/* ---------- Field ---------- */
.cc-field { display: flex; flex-direction: column; gap: 6px; }
.cc-field label { font-size: 14px; font-weight: 500; color: var(--ink); }
.cc-field input, .cc-field select, .cc-field textarea { min-height: var(--control-min); padding: 0 var(--space-3); border: 1.5px solid var(--border-control);
  border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font: inherit; }
.cc-field textarea { padding: 10px var(--space-3); min-height: 96px; }
.cc-field input:focus-visible, .cc-field select:focus-visible, .cc-field textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--brand); }
.cc-field__help { font-size: 13px; color: var(--ink-muted); }
.cc-field.is-invalid input { border-color: var(--danger); }
.cc-field.is-invalid .cc-field__help { color: var(--danger); }

/* ---------- JobItem ---------- */
.cc-jobs { display: flex; flex-direction: column; }
.cc-job { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: 10px var(--space-1); }
.cc-job + .cc-job { border-top: 1px solid var(--border); }
.cc-job__what { display: flex; flex-direction: column; min-width: 0; }
.cc-job__what strong { font-size: 14px; }
.cc-job__meta { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }
.cc-job--active { flex-direction: column; align-items: stretch; background: var(--surface-sunken); border-radius: 12px; padding: var(--space-3); }
.cc-job--active + .cc-job { border-top: none; }

/* ---------- ModuleCard（Hub 首頁） ---------- */
.cc-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.cc-module { display: flex; flex-direction: column; gap: 10px; padding: var(--space-5); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); text-decoration: none; color: var(--ink); min-height: 188px; }
.cc-root .cc-module { color: var(--ink); }
.cc-module:hover { border-color: var(--brand); box-shadow: var(--shadow-card); }
.cc-module__name { font-size: 17px; line-height: 24px; font-weight: 700; color: var(--ink-strong); }
.cc-module__desc { font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.cc-module__foot { margin-top: auto; font-size: 13px; font-weight: 500; color: var(--brand); }

/* ---------- SectionHeading（色盤可在 ::before 加記號） ---------- */
.cc-sechead { margin: 0; font-size: 22px; line-height: 32px; font-weight: 700; color: var(--ink-strong); }
