/* ============================================================
   創施系統 (Trust Accounting) — 共用品牌樣式 v2（2026-07 設計升級）
   品牌青藍：#50B4C8（主），#2396A8（深），輔以中性灰底
   原則：專業、視覺舒適；所有舊 class 名照用，純視覺升級
   ============================================================ */

:root {
  --brand: #50B4C8;
  --brand-dark: #2396A8;
  --brand-darker: #1b7585;
  --brand-soft: #e8f6f9;
  --brand-grad: linear-gradient(135deg, #2396A8 0%, #3aa9bd 55%, #50B4C8 100%);
  --ink: #1f2d33;
  --ink-strong: #14232a;
  --muted: #6b7c84;
  --line: #e3e9ec;
  --line-soft: #ecf1f3;
  --bg: #f3f6f8;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(20, 35, 42, .05), 0 4px 14px rgba(20, 35, 42, .05);
  --shadow-hover: 0 2px 4px rgba(20, 35, 42, .06), 0 10px 28px rgba(20, 35, 42, .10);
  --radius: 14px;
  --ok: #2c8a5b;
  --ok-soft: #e9f6ef;
  --warn: #c47e16;
  --warn-soft: #fdf3e3;
  --danger: #c0392b;
  --danger-soft: #fbecec;
}

body {
  background: var(--bg) !important;
  background-image: linear-gradient(180deg, #ebf2f5 0%, var(--bg) 260px) !important;
  background-repeat: no-repeat !important;
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 內容區：原本 body.container 太貼邊，加返呼吸位 */
body.container,
body.container-fluid {
  padding-bottom: 48px;
}

/* ---------- 頂部導航列（半透明玻璃感） ---------- */
.tru-nav {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(227, 233, 236, .9);
  box-shadow: 0 1px 12px rgba(20, 35, 42, .05);
  margin-bottom: 24px;
}
.tru-nav__inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  flex-wrap: wrap;
}
/* 全站統一返回鍵（2026-07-25 Kelvin：每頁要清晰返回；手機 PWA 冇瀏覽器返回掣） */
.tru-nav__back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 7px 14px;
  border: 1.5px solid var(--brand, #2396A8);
  border-radius: 20px;
  color: var(--brand-dark, #17707e);
  background: #fff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s;
}
.tru-nav__back:hover { background: var(--brand-soft, #e8f5f7); color: var(--brand-dark, #17707e); }
@media (max-width: 576px) {
  .tru-nav__back span { display: none; }        /* 手機淨出箭嘴，慳位 */
  .tru-nav__back { padding: 7px 10px; }
}
.tru-nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-right: 12px;
}
.tru-nav__brand img { height: 42px; width: auto; display: block; }
.tru-nav__zh { font-size: .8em; font-weight: 500; letter-spacing: 0; opacity: .75; white-space: nowrap; }
@media (max-width: 820px) { .tru-nav__zh { display: none; } }
.tru-nav__brand span {
  font-weight: 700;
  color: var(--brand-dark);
  font-size: 18px;
  letter-spacing: .5px;
  white-space: nowrap;
}
.tru-nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}
.tru-nav__links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 10px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tru-nav__links a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.tru-nav__links a.active {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 2px 8px rgba(35, 150, 168, .35);
}
.tru-nav__spacer { flex: 1; }
.tru-nav__revenue {
  background: var(--brand-dark) !important;
  color: #fff !important;
}
.tru-nav__revenue:hover { background: var(--brand-darker) !important; }

@media (max-width: 720px) {
  .tru-nav__inner { padding: 8px 12px; }
  .tru-nav__links { gap: 2px; }
  .tru-nav__links a { padding: 7px 10px; font-size: 13.5px; }
  .tru-nav__brand span { display: none; }
}

/* ---------- 標題（層級：h1 深墨色重磅、h2/h3 品牌深青） ---------- */
h1 { color: var(--ink-strong); font-weight: 800; letter-spacing: -.015em; }
h2, h3 { color: var(--brand-dark); font-weight: 700; letter-spacing: -.01em; }
hr { border-color: var(--line); opacity: 1; }

/* ---------- 卡片 ---------- */
.tru-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

/* details 卡：summary 統一手感 */
details.tru-card > summary { list-style: none; user-select: none; }
details.tru-card > summary::-webkit-details-marker { display: none; }
details.tru-card > summary::before {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-right: 2px solid var(--brand-dark); border-bottom: 2px solid var(--brand-dark);
  transform: rotate(-45deg); margin: 0 9px 1px 2px; transition: transform .15s;
}
details.tru-card[open] > summary::before { transform: rotate(45deg); }

/* 統計卡片網格（財務數字＝等寬數字，睇數企理） */
.tru-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.tru-stat {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-left: 5px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  transition: box-shadow .15s, transform .15s;
}
.tru-stat:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.tru-stat__label {
  color: var(--muted); font-size: 12.5px; font-weight: 700;
  letter-spacing: .04em; margin-bottom: 6px;
}
.tru-stat__value {
  color: var(--ink-strong); font-size: 27px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tru-stat--warn { border-left-color: #e8a13a; background: linear-gradient(135deg, var(--warn-soft) 0%, #fff 45%); }
.tru-stat--warn .tru-stat__value { color: var(--warn); }
.tru-stat--good { border-left-color: #3fb27a; background: linear-gradient(135deg, var(--ok-soft) 0%, #fff 45%); }
.tru-stat--good .tru-stat__value { color: var(--ok); }

/* ---------- 按鈕 ---------- */
.btn { border-radius: 10px; }
.btn-brand,
.btn[style*="#50B4C8"] {
  background: var(--brand-grad) !important;
  border: none !important;
  color: #fff !important;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(35, 150, 168, .30);
  transition: box-shadow .15s, transform .12s, filter .15s;
}
.btn-brand:hover,
.btn[style*="#50B4C8"]:hover {
  filter: brightness(.94);
  box-shadow: 0 4px 14px rgba(35, 150, 168, .40);
  transform: translateY(-1px);
}
.btn-brand:active { transform: translateY(0); box-shadow: 0 1px 4px rgba(35, 150, 168, .30); }
.btn-outline-secondary {
  --bs-btn-color: #46565e;
  --bs-btn-border-color: #cfdade;
  --bs-btn-hover-bg: var(--brand-soft);
  --bs-btn-hover-color: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-soft);
  --bs-btn-active-color: var(--brand-dark);
  --bs-btn-active-border-color: var(--brand);
  background: #fff;
}
.btn:focus-visible, .form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(80, 180, 200, .22);
}
.form-control, .form-select { border-radius: 9px; border-color: #d6e0e4; }

/* ---------- 表格（螢幕先生效；列印文件唔引用此檔） ---------- */
@media screen {
  .table { background: var(--card); border-radius: var(--radius); overflow: hidden; }
  .table thead th {
    background: #f2f8fa;
    color: var(--brand-darker);
    font-weight: 700;
    font-size: .92em;
    letter-spacing: .03em;
    border-bottom: 2px solid var(--brand);
    border-top: none;
    position: sticky;
    top: 0;
    white-space: nowrap;
  }
  .table tbody td { border-color: var(--line-soft); }
  .table tbody tr:hover { background: #f0f8fa; }
  .table .text-end { font-variant-numeric: tabular-nums; }
  .table-responsive { border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
}

/* 表格搜尋／篩選列 */
.tru-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.tru-toolbar .form-control,
.tru-toolbar .form-select { max-width: 240px; border-radius: 9px; }

/* 模組分流大按鈕（主頁／入口頁） */
.tru-entry {
  display: inline-block;
  background: var(--brand-grad);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 14px 0;
  border-radius: 11px;
  box-shadow: var(--shadow);
  transition: background .15s, box-shadow .15s, transform .15s;
}
.tru-entry:hover { color: #fff; box-shadow: var(--shadow-hover); transform: translateY(-2px); }

/* 浮動返回掣（用緊過程中喺左下角，唔阻住） */
.tru-back-float{
  position:fixed; left:14px; bottom:18px; z-index:1080;
  width:46px; height:46px; border-radius:50%;
  background:var(--brand); color:#fff; border:none;
  display:flex; align-items:center; justify-content:center;
  font-size:22px; line-height:1; text-decoration:none;
  box-shadow:0 3px 10px rgba(0,0,0,.28); cursor:pointer;
  transition:transform .12s, background .12s;
}
.tru-back-float:hover{ background:var(--brand-dark); color:#fff; transform:translateY(-2px); }
@media print{ .tru-back-float{ display:none!important; } }

/* ---------- 版塊子導覽（第二層） ---------- */
.tru-subnav {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 6px 18px 10px;
}
.tru-subnav__label {
  font-size: 13px; font-weight: 700; color: var(--brand-dark);
  background: var(--brand-soft); border-radius: 8px; padding: 5px 10px; margin-right: 4px;
}
.tru-subnav a {
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 5px 12px; border-radius: 8px; white-space: nowrap;
}
.tru-subnav a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.tru-subnav a.active { background: var(--brand); color: #fff; }

/* ---------- 通知小紅點 ---------- */
.tru-nav__badge {
  background: #e24b4a; color: #fff; border-radius: 10px;
  font-size: 12px; font-weight: 700; padding: 1px 6px; margin-left: 3px; display: inline-block;
}

/* ---------- 提示訊息 ---------- */
.alert { border-radius: 12px; border: none; box-shadow: var(--shadow); }

/* ---------- 手機底部導覽（員工 iPad/手機操作端） ---------- */
.tru-bottomnav { display: none; }
@media (max-width: 820px) {
  .tru-bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
    display: flex;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(31,45,51,.08);
  }
  .tru-bottomnav a {
    flex: 1; text-align: center; text-decoration: none;
    padding: 7px 0 calc(7px + env(safe-area-inset-bottom, 0px));
    font-size: 12px; color: var(--muted); line-height: 1.25; font-weight: 600;
  }
  .tru-bottomnav a .ico { display: block; font-size: 20px; }
  .tru-bottomnav a.active { color: var(--brand-dark); }
  body { padding-bottom: 72px !important; }
}
@media print { .tru-bottomnav, .tru-subnav, .tru-nav { display: none !important; } }

/* ---------- Trust Accounting 專用 ---------- */
/* 頂欄遊出 body 限寬（full-bleed），永遠一行、放唔落就橫掃 —— 唔會再摺幾行 */
body { overflow-x: hidden; }
.tru-nav {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}
.tru-nav__inner { flex-wrap: nowrap; max-width: 1280px; }
.tru-nav__links {
  flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tru-nav__links::-webkit-scrollbar { display: none; }
.tru-nav__brand img { height: 34px; }
.tru-nav__sep {
  width: 1px; height: 20px; background: var(--line);
  margin: 0 6px; flex: 0 0 auto; align-self: center;
}
.tru-nav__user {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 20px;
  white-space: nowrap; text-decoration: none;
}
.tru-nav__user:hover { background: var(--brand); color: #fff; }
.tru-nav__logout {
  text-decoration: none; color: var(--muted); font-size: 13.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.tru-nav__logout:hover { background: var(--danger-soft); color: var(--danger); }
.tru-bottomnav a .ico svg { width: 22px; height: 22px; display: block; margin: 0 auto 1px; }

@media (max-width: 820px) {
  /* 手機：頂欄唔迫餅 —— links 收起，行底部導覽＋工作台入口卡 */
  .tru-nav__links, .tru-nav__sep { display: none; }
  .tru-nav__user { font-size: 12.5px; padding: 4px 10px; margin-left: auto; }
  .tru-nav__user svg { display: none; }
  .tru-nav__brand img { height: 28px; }
  .tru-nav__brand span { display: inline; font-size: 15px; }
  h1 { font-size: 22px; }
  .tru-card { padding: 16px; }
  .table { font-size: 13.5px; }
}

/* ---------- 工作台（首頁） ---------- */
.tru-board { max-width: 1100px; margin: 0 auto; text-align: left; }
.tru-board h5 { font-weight: 800; color: var(--ink); margin: 22px 0 10px; }
.tru-blockcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tru-blockcard {
  position: relative;
  display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 16px 16px 14px; box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tru-blockcard::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--brand-grad); opacity: 0; transition: opacity .12s;
}
.tru-blockcard:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: rgba(80, 180, 200, .5);
}
.tru-blockcard:hover::before { opacity: 1; }
.tru-blockcard b { display: block; color: var(--brand-dark); font-size: 17px; margin-bottom: 4px; }
.tru-blockcard span { color: var(--muted); font-size: 12.5px; line-height: 1.4; display: block; }
.tru-blockcard--internal b { color: #b3541e; }
.tru-mycard {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 10px;
}

/* ---------- 徽章／進度共通 ---------- */
.badge { font-variant-numeric: tabular-nums; }

/* ---------- 手機：寬表格橫向捲動＋觸控目標（2026-07-22） ---------- */
/* body 有 overflow-x: hidden，寬表格若無 .table-responsive 包住，溢出部分會直接被裁走
   （唔係無捲動條，係完全按唔到）。包咗之後仲要撐開表身闊度，否則表格被壓縮至容器闊度，
   一樣無得橫向捲動。故此兩者必須同時做。 */
@media (max-width: 820px) {
  .tru-wide-table { min-width: 960px; }
  .tru-wide-table--xl { min-width: 1400px; }

  /* 觸控目標：細按鈕放大至約 40px 高。多處細按鈕寫死 inline padding／font-size，
     故此處須 !important 先覆蓋得到。 */
  .btn-sm, .btn-group-sm > .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
  }

  /* iOS：輸入框字體小於 16px，focus 時整頁自動放大（開發鐵律 12） */
  .form-control, .form-select,
  .form-control-sm, .form-select-sm { font-size: 16px !important; }
}
