:root {
  --line-green: #06c755;
  --line-green-dark: #05a648;
  --bg: #f6f7f9;
  --text: #1a1a1a;
  --text-muted: #767676;
  --danger: #e0433d;
  --border: #e5e5e5;
  --card-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
}

.page {
  padding: 16px 16px 40px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 4px;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 0;
}

.home-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 20px;
}

/* 登入後首頁專用：讓「我的行程」清單自動撐滿剩餘空間，避免行程筆數
   很少時，畫面最下面（公司資訊之後）留一大片空白背景——改成把多出來
   的空間讓「我的行程」清單去撐，公司資訊永遠貼齊畫面最下方，不會有
   突兀的留白。行程筆數夠多、內容本來就會撐滿或超過畫面時，這個設定
   不會有任何影響，頁面照樣正常往下捲動。 */
.home-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.home-page .trip-list {
  flex: 1;
}

/* 首頁區塊之間的分隔線（跟公司資訊上方那條線同樣的樣式，用來
   把「我的轉帳帳號」／「輸入兌換碼」這排按鈕跟上面的「我的行程」
   清單做視覺區隔）。 */
.section-divider {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* 讓裡面的按鈕並排、平分寬度（例如首頁「我的轉帳帳號」＋「輸入兌換碼」）。 */
.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row .btn {
  flex: 1;
}

/* 首頁「轉帳帳號／兌換碼」按鈕列，緊接在公司資訊區塊（.home-footer）
   之前的情況：讓按鈕下緣到下面那條線的距離，跟上面那條線到按鈕上緣
   的距離（.section-divider的padding-top，16px）一致，兩邊間距對稱，
   不會看起來下面留白特別多。只有在這個特定情境（緊接在section-divider
   後面）才調整，不影響.home-footer在其他畫面（例如選擇登入方式畫面）
   單獨使用時原本的間距。 */
.section-divider + .home-footer {
  margin-top: 16px;
}

.home-footer {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

.home-footer p {
  margin: 4px 0;
}

.home-footer a {
  color: var(--line-green-dark);
  text-decoration: none;
}

.home-footer .build-info {
  margin-top: 10px;
  font-size: 11px;
  opacity: 0.7;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--text);
}

.demo-banner {
  background: #fff6e0;
  border: 1px solid #ffe1a6;
  color: #7a5b00;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.loading, .empty-hint {
  color: var(--text-muted);
  text-align: center;
  padding: 24px 8px;
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: #eee;
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--line-green);
  color: #fff;
}
.btn-primary:active {
  background: var(--line-green-dark);
}
.btn-primary:disabled {
  opacity: 0.6;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--line-green);
  color: var(--line-green-dark);
}
.btn-outline:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-danger-outline {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:active {
  opacity: 0.85;
}
.btn-danger:disabled {
  opacity: 0.6;
}

.btn-small {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 0;
  cursor: pointer;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 12px;
}

.input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
  background: #fff;
  color: var(--text);
}

.input-small {
  padding: 8px 10px;
  font-size: 14px;
  max-width: 120px;
}

.trip-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trip-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.trip-card-name {
  font-weight: 600;
}

.trip-card-arrow {
  color: var(--text-muted);
}

.trip-header {
  margin-bottom: 8px;
}

.trip-title-row {
  display: flex;
  align-items: center;
  gap: 1em; /* 一個中文字的間距 */
}

.trip-title-row .page-title {
  margin: 4px 0;
}

.btn-edit-trip-name {
  /* 外框樣式改用共用的.icon-circle-btn（見js/ui.js的呼叫處），這裡只留
     這顆按鈕自己需要的細節。 */
  flex-shrink: 0;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.member-avatars {
  display: flex;
}

.member-row-actions {
  display: flex;
  gap: 6px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--line-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-right: -8px;
  border: 2px solid var(--bg);
}

.avatar.is-virtual {
  background: #9aa0a6;
  border: 2px dashed #9aa0a6;
}

.viewing-as-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff3cd;
  border: 1px solid #ffe08a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.switch-user-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.switch-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.switch-user-row.current {
  border-color: var(--line-green);
  background: #f0fbf4;
}

.switch-user-row .su-name {
  flex: 1;
  font-size: 14.5px;
}

/* .btn-delete-virtual的外框樣式改用共用的.icon-circle-btn（見js/ui.js的
   呼叫處）；.su-name本身有flex:1，會自動把這顆按鈕推到最右邊，這裡
   不用再另外定義樣式。 */

/* ---------------- 贊助兌換碼機制 ---------------- */

.sponsor-badge {
  background: #fff8e1;
  color: #8a6d00;
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
}

/* 首頁「哈囉，OOO！」跟贊助者小標籤疊在一起的欄位（用來跟右邊的
   登出按鈕同一列並排，整體高度盡量跟登出按鈕差不多）。 */
.home-user-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sponsor-badge-inline {
  display: inline-block;
  background: #fff8e1;
  color: #8a6d00;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* 鎖住的按鈕：左上角一個小鎖頭圖示 */
.locked-btn {
  position: relative;
  opacity: 0.85;
}
.lock-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

/* 表單欄位旁邊的小鎖頭（例如「這筆花費的幣別」標籤旁邊） */
.lock-inline-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  vertical-align: middle;
  padding: 0 2px;
}
/* 小鎖頭旁邊的說明小字（例如「小額贊助解鎖更多幣別」） */
.lock-inline-hint {
  font-size: 12px;
  font-weight: normal;
  color: var(--text-muted);
  vertical-align: middle;
}

/* 管理頁面：密碼驗證／登入畫面 */
.admin-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 24px;
  text-align: center;
}
.admin-gate h1 {
  font-size: 20px;
  margin-bottom: 6px;
}
.admin-gate p.hint-text {
  margin-bottom: 20px;
}
.admin-gate .input {
  max-width: 260px;
  text-align: center;
}
.admin-gate .btn {
  max-width: 260px;
  margin-top: 12px;
}

/* 管理頁面：使用統計 */
.stat-controls {
  margin-bottom: 14px;
}
.type-select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23767676" stroke-width="2.5"><polyline points="6 9 12 15 18 9"/></svg>') no-repeat right 14px center;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  margin-bottom: 10px;
  font-family: inherit;
}
.range-tabs {
  display: flex;
  gap: 6px;
}
.range-tab {
  flex: 1;
  text-align: center;
  padding: 8px 2px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: #ececec;
  cursor: pointer;
  user-select: none;
}
.range-tab.active {
  background: var(--line-green);
  color: #fff;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 14px;
  text-align: center;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.stat-number {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.stat-number .unit-letter {
  font-size: 19px;
  font-weight: 700;
}
.stat-exact {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 管理頁面：代碼清單 */
.code-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}
.code-table th,
.code-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.code-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}
.code-mono {
  font-family: monospace;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.code-copyable {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.code-copyable:active {
  opacity: 0.6;
}
.code-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
}
.code-badge-unused {
  background: #e6f4ea;
  color: #1a7f37;
}
.code-badge-used {
  background: #eef0f3;
  color: #666;
}
.code-badge-expired {
  background: #fdecea;
  color: #c62828;
}
.code-note {
  color: var(--text-muted);
  font-size: 12px;
}
.btn-copy-inline {
  background: none;
  border: none;
  color: var(--line-green);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  padding: 0 0 0 6px;
}
/* .btn-delete-code的外框樣式改用共用的.icon-circle-btn（見js/ui.js的
   呼叫處），這裡不用再重複定義。 */

.tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 12px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  position: relative;
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab-update-dot {
  position: absolute;
  top: 6px;
  right: 26%;
  width: 8px;
  height: 8px;
  background: #e53935;
  border-radius: 50%;
}

.tab-btn.active {
  color: var(--line-green-dark);
  border-bottom-color: var(--line-green);
}

.feature-panel {
  margin: 32px 4px 0;
  padding: 30px 20px;
  border-radius: 14px;
  text-align: center;
}
.feature-panel-locked {
  background: #f7f5ee;
  border: 1px solid #ecdfb8;
}
.feature-panel-soon {
  background: #eef7f0;
  border: 1px solid #cfe9d6;
}
.feature-panel-icon {
  font-size: 34px;
  margin-bottom: 12px;
}
.feature-panel-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.feature-panel-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 16px;
}
.feature-panel .btn {
  max-width: 220px;
  margin: 0 auto;
}

.itin-toolbar {
  display: flex;
  gap: 10px;
}
.itin-toolbar .itin-toolbar-add {
  flex: 2;
}
.itin-toolbar .itin-toolbar-import {
  flex: 1;
  white-space: nowrap;
  padding-left: 8px;
  padding-right: 8px;
}

.itin-day-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin: 20px 0 8px;
}

.itin-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.itin-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-left: 2px solid var(--border);
  margin-left: 6px;
  padding-left: 16px;
  position: relative;
}

.itin-row::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-green);
}

.itin-time {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--line-green-dark);
  width: 40px;
  flex-shrink: 0;
}

.itin-main {
  flex: 1;
  min-width: 0;
}

.itin-title {
  font-size: 14px;
  font-weight: 600;
}

.itin-place {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.itin-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.itin-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* 圖示按鈕的共用外框樣式：白底圓形＋細框。行程頁籤的地圖／編輯／刪除，
 * 還有其他頁面裡功能相同（編輯或刪除某一筆資料）的小圖示按鈕，都套用
 * 這個共用樣式，維持整站視覺一致（配合<a>或<button>都能用）。 */
.icon-circle-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  color: var(--text-muted);
}

.icon-circle-btn:hover {
  opacity: 0.75;
}

.itin-map-btn-disabled {
  opacity: 0.35;
  cursor: default;
}
.itin-map-btn-disabled:hover {
  opacity: 0.35;
}

.expense-filter-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 14px;
}

.expense-filter-select {
  flex: 2;
  width: auto;
}

.expense-filter-row .btn {
  flex: 1;
  min-width: 0;
  padding: 6px 6px;
  font-size: 12.5px;
  line-height: 1.25;
  white-space: normal;
  text-align: center;
}

.expense-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.expense-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.expense-main {
  flex: 1;
  min-width: 0;
}

.expense-desc {
  font-weight: 600;
  font-size: 14.5px;
}

.expense-cat {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.expense-meta {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 3px;
}

.expense-original-currency {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 2px;
}

.expense-amount {
  font-weight: 700;
  white-space: nowrap;
}

/* .btn-edit-expense／.btn-delete-expense的外框樣式改用共用的
   .icon-circle-btn（見js/ui.js的呼叫處），這裡不用再重複定義。 */

.balance-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.balance-row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  font-size: 14.5px;
}

.balance-amount.positive {
  color: var(--line-green-dark);
  font-weight: 700;
}
.balance-amount.negative {
  color: var(--danger);
  font-weight: 700;
}
.balance-amount.neutral {
  color: var(--text-muted);
}

.settle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.settle-row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.settle-row > div:first-child {
  flex: 1;
}

.settle-amount {
  font-weight: 700;
  white-space: nowrap;
}

.settle-row-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settle-status {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.settle-status-pending {
  color: var(--text-muted);
}

.settle-status-paid {
  color: var(--line-green-dark);
}

.settle-bank-info {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.settle-bank-info span {
  overflow-wrap: anywhere;
}

.settle-bank-multi {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.settle-bank-selected-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.settle-bank-selected-row .settle-bank-selected-text {
  overflow-wrap: anywhere;
}

.bank-account-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}

.bank-account-row:first-child {
  margin-top: 4px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.overlay-panel {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 28px;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.overlay-header h2 {
  font-size: 18px;
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
}

.split-type-row {
  display: flex;
  gap: 14px;
  font-size: 14px;
  margin-top: 8px;
}

.split-panel {
  background: #fafafa;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
}

.split-panel.hidden {
  display: none;
}

.hidden {
  display: none;
}

.hint-text {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.hint-text-success {
  color: #1a7f37;
}

.hint-text-warning {
  color: #b45309;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 5px 0;
}

.split-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}
