/* =========================================================
   pro-control 設計系統
   風格：柔和玻璃面板＋珊瑚橙主色；排版與動效依 iOS 人機介面理念
   ========================================================= */

:root {
  --accent: #ff7a4d;
  --accent-strong: #f5602e;
  --accent-soft: #fff1ea;
  --accent-grad: linear-gradient(165deg, #ff9f73 0%, #ff7a4d 48%, #f45d33 100%);
  --peach: #ffc38f;
  --rose: #f2566b;
  --violet: #6f63e8;
  --indigo: #34387d;
  --sand: #f6d27a;
  --mint: #3cc79a;

  --ink: #1c1f33;
  --ink-2: #474c66;
  --muted: #8d92a8;
  --line: rgba(28, 31, 51, 0.07);
  --line-strong: rgba(28, 31, 51, 0.12);
  --fill: #f2f3f8;
  --fill-2: #e9ebf2;
  --page: #e9ebf2;
  --panel: rgba(255, 255, 255, 0.82);
  --card: #ffffff;
  --white: #ffffff;
  --green: #1fa971;
  --red: #ef4b4b;
  --amber: #e79a12;

  --r-xl: 32px;
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 12px;

  --shadow-1: 0 1px 2px rgba(28, 31, 51, 0.04), 0 6px 20px rgba(28, 31, 51, 0.05);
  --shadow-2: 0 2px 6px rgba(28, 31, 51, 0.05), 0 18px 44px rgba(28, 31, 51, 0.1);
  --shadow-accent: 0 10px 24px rgba(245, 96, 46, 0.3);

  /* iOS 系動效曲線：ios＝系統轉場；spring＝輕回彈 */
  --ios: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: linear(0, 0.063, 0.225, 0.43, 0.628, 0.786, 0.898, 0.968, 1.006, 1.022, 1.024, 1.019, 1.012, 1.006, 1.002, 1);
  --t-fast: 180ms;
  --t-mid: 360ms;
  --t-slow: 620ms;
  --ease: var(--t-mid) var(--ios);

  --font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI",
    "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans TC", sans-serif;

  color: var(--ink);
  background: var(--page);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

html,
body,
#root {
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.02em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgba(255, 122, 77, 0.22);
}

:focus-visible {
  outline: 3px solid rgba(255, 122, 77, 0.45);
  outline-offset: 2px;
}

/* ---------- 按鈕 ---------- */

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--t-fast) var(--spring),
    background-color var(--ease),
    box-shadow var(--ease),
    opacity var(--ease),
    color var(--ease);
}

button svg,
.btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

button:hover,
.btn:hover {
  filter: brightness(1.06);
}

button:active,
.btn:active {
  transform: scale(0.96);
  transition-duration: 90ms;
}

button.primary,
.btn.primary {
  background: var(--accent-grad);
  color: var(--white);
  box-shadow: var(--shadow-accent);
}

button.secondary,
.btn.secondary {
  background: var(--white);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

button.ghost,
.btn.ghost {
  background: var(--fill);
  color: var(--ink);
}

button.ghost:hover,
.btn.ghost:hover {
  background: var(--fill-2);
  filter: none;
}

button:disabled,
button:disabled:active {
  opacity: 0.38;
  cursor: default;
  transform: none;
  filter: none;
  box-shadow: none;
}

.link-btn,
button.link-btn {
  min-height: 0;
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  width: auto;
  cursor: pointer;
  box-shadow: none;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 14px;
  background: var(--white);
  color: var(--ink-2);
  box-shadow: var(--shadow-1);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.round-btn {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  background: #eef1fb;
  color: var(--ink);
}

.round-btn:hover {
  background: #e3e8f8;
  filter: none;
}

/* ---------- 表單（iOS 填充式） ---------- */

input,
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--fill);
  color: var(--ink);
  outline: none;
  transition:
    background-color var(--ease),
    border-color var(--ease),
    box-shadow var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: #a7abbd;
}

input:hover,
select:hover,
textarea:hover {
  background: var(--fill-2);
}

input:focus,
select:focus,
textarea:focus {
  background: var(--white);
  border-color: rgba(255, 122, 77, 0.6);
  box-shadow: 0 0 0 4px rgba(255, 122, 77, 0.14);
}

input:read-only {
  background: var(--fill);
  cursor: default;
}

input:read-only:focus {
  border-color: transparent;
  box-shadow: none;
}

.ui-select {
  position: relative;
  width: 100%;
}

button.ui-select-btn {
  position: relative;
  width: 100%;
  min-height: 42px;
  padding: 10px 36px 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--fill);
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0;
  justify-content: flex-start;
  box-shadow: none;
  filter: none;
}

button.ui-select-btn:hover,
button.ui-select-btn:active,
button.ui-select-opt:active {
  filter: none;
  transform: none;
}

button.ui-select-btn:hover {
  background: var(--fill-2);
}

button.ui-select-btn:focus-visible,
.ui-select.open button.ui-select-btn {
  background: var(--white);
  border-color: rgba(255, 122, 77, 0.6);
  box-shadow: 0 0 0 4px rgba(255, 122, 77, 0.14);
  transform: none;
}

button.ui-select-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.ui-select-btn svg {
  position: absolute;
  right: 14px;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--ease);
}

.ui-select.open button.ui-select-btn svg {
  transform: rotate(180deg);
}

.ui-select.disabled button.ui-select-btn {
  opacity: 0.55;
  cursor: default;
}

.ui-select-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow: auto;
  padding: 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 24px 60px rgba(28, 31, 51, 0.16), 0 0 0 1px var(--line);
  animation: pop 280ms var(--spring) both;
}

button.ui-select-opt {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0;
  justify-content: flex-start;
  box-shadow: none;
  filter: none;
}

button.ui-select-opt:hover,
button.ui-select-opt.on {
  background: rgba(255, 122, 77, 0.12);
  color: var(--accent-strong);
  filter: none;
  transform: none;
}

.ui-select-empty {
  margin: 0;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.ui-date {
  position: relative;
  width: 100%;
}

.ui-date-placeholder {
  color: #a7abbd;
}

.ui-date-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  left: 0;
  width: 292px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 24px 60px rgba(28, 31, 51, 0.16), 0 0 0 1px var(--line);
  animation: pop 280ms var(--spring) both;
}

.ui-date-head,
.ui-date-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ui-date-head strong {
  font-size: 14px;
}

button.ui-date-nav,
button.ui-date-day,
button.ui-date-link {
  border: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  filter: none;
  min-height: 0;
  font-weight: 500;
}

button.ui-date-nav {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
}

button.ui-date-nav:hover,
button.ui-date-day:hover,
button.ui-date-link:hover {
  background: var(--fill);
  filter: none;
  transform: none;
}

.ui-date-week,
.ui-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-top: 8px;
  text-align: center;
}

.ui-date-week span {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
}

button.ui-date-day {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  padding: 0;
  border-radius: 10px;
  font-size: 13px;
}

button.ui-date-day.outside {
  color: #c5c8d4;
}

button.ui-date-day.today {
  box-shadow: inset 0 0 0 1px rgba(255, 122, 77, 0.45);
}

button.ui-date-day.on,
button.ui-date-day.on:hover {
  background: var(--accent-grad);
  color: var(--white);
}

button.ui-date-link {
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--accent-strong);
  font-size: 13px;
}

.ui-date-foot {
  margin-top: 8px;
}

button.ui-date-nav:active,
button.ui-date-day:active,
button.ui-date-link:active {
  transform: none;
  filter: none;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

textarea {
  resize: vertical;
}

label {
  display: block;
  font-size: 13px;
  margin-bottom: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-weight: 500;
}

/* ---------- 殼層：背景、浮動導覽膠囊、玻璃舞台 ---------- */

.shell {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  height: 100dvh;
  padding: 18px 18px 18px 0;
  overflow: hidden;
  isolation: isolate;
}

.shell-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(180deg, #f1f2f7 0%, #e7e9f1 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.7;
  animation: drift 22s var(--ios) infinite alternate;
}

.blob-a {
  width: 520px;
  height: 520px;
  right: -140px;
  top: -120px;
  background: radial-gradient(circle, #ffc9b6 0%, #f7b3a4 60%, transparent 70%);
}

.blob-b {
  width: 420px;
  height: 420px;
  right: 18%;
  bottom: -220px;
  background: radial-gradient(circle, #d9dcff 0%, #c9ccf6 60%, transparent 70%);
  animation-delay: -8s;
}

.rail {
  position: relative;
  z-index: 2;
  align-self: center;
  justify-self: center;
  width: 76px;
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 0 16px;
  border-radius: 40px;
  background: var(--accent-grad);
  box-shadow: 0 18px 40px rgba(245, 96, 46, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  animation: rail-in var(--t-slow) var(--spring) both;
}

.rail-brand {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #fff;
}

.brand-mark {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: transparent;
}

.rail-nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.rail-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail-group + .rail-group {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.26);
}

.rail-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 16px rgba(160, 48, 10, 0.22);
  transition:
    transform 520ms var(--spring),
    height 520ms var(--spring),
    opacity var(--ease);
  pointer-events: none;
}

.rail-item {
  position: relative;
  z-index: 1;
  width: 60px;
  height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.86);
  transition:
    color var(--ease),
    transform var(--t-fast) var(--spring),
    background-color var(--ease);
}

.rail-item svg {
  width: 21px;
  height: 21px;
}

.rail-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.rail-item:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
}

.rail-item:active {
  transform: scale(0.92);
}

.rail-item.active {
  color: var(--accent-strong);
  background: transparent;
}

.rail-logout {
  margin-top: auto;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--white);
}

.rail-logout svg {
  width: 19px;
  height: 19px;
}

.rail-logout:hover {
  background: rgba(255, 255, 255, 0.3);
  filter: none;
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-radius: var(--r-xl);
  background: var(--panel);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  box-shadow: 0 30px 80px rgba(28, 31, 51, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
  animation: stage-in var(--t-slow) var(--ios) both;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px 8px;
  position: relative;
  z-index: 20;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flavor-chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef1fb;
  color: var(--indigo);
  font-size: 12px;
  font-weight: 600;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px 32px 36px;
  scroll-behavior: smooth;
}

/* 換頁轉場：淡入＋微位移＋微縮放，並令頁內一級區塊依序浮現 */
.page-enter {
  animation: page-in var(--t-slow) var(--ios) both;
}

.main .page-enter > :not(.ov) > * {
  animation: rise var(--t-slow) var(--ios) backwards;
}

.main .page-enter > :not(.ov) > :nth-child(2) {
  animation-delay: 40ms;
}
.main .page-enter > :not(.ov) > :nth-child(3) {
  animation-delay: 80ms;
}
.main .page-enter > :not(.ov) > :nth-child(4) {
  animation-delay: 120ms;
}
.main .page-enter > :not(.ov) > :nth-child(5) {
  animation-delay: 160ms;
}
.main .page-enter > :not(.ov) > :nth-child(n + 6) {
  animation-delay: 200ms;
}

.rise {
  animation: rise var(--t-slow) var(--ios) backwards;
  animation-delay: calc(var(--i, 0) * 55ms);
}

/* ---------- 頭像、帳號選單、提醒 ---------- */

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3d4288, #6f63e8);
  color: var(--white);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}

.avatar.lg {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.avatar-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 3px;
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-1);
}

.avatar-btn .avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
}

.user-menu,
.bell {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  min-width: 240px;
  padding: 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 24px 60px rgba(28, 31, 51, 0.18), 0 0 0 1px var(--line);
  transform-origin: top right;
  animation: pop 320ms var(--spring) both;
}

.popover-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 10px 10px;
}

.popover-empty {
  margin: 0;
  padding: 10px 12px 14px;
}

.user-popover-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.side-user-name {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
}

.side-user-role {
  font-size: 12px;
  color: var(--muted);
}

.menu-item {
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  background: transparent;
  color: var(--ink);
  border-radius: 12px;
  font-weight: 500;
}

.menu-item:hover {
  background: var(--fill);
  filter: none;
}

.menu-item.danger {
  color: var(--red);
}

.bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--rose);
  color: var(--white);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  box-shadow: 0 0 0 2px var(--white);
  animation: badge-in 480ms var(--spring) both;
}

.bell-popover {
  width: 320px;
  max-height: 420px;
  overflow: auto;
}

.notice-item {
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
  border-radius: 14px;
  text-align: left;
  font-weight: 500;
}

.notice-item:hover {
  background: var(--fill);
  filter: none;
}

.notice-dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.notice-dot.warn {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 122, 77, 0.16);
}

.notice-dot.info {
  background: var(--violet);
  box-shadow: 0 0 0 4px rgba(111, 99, 232, 0.14);
}

.notice-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.notice-title {
  font-weight: 650;
}

/* ---------- 頂部快速搜尋 ---------- */

.top-search {
  position: relative;
  width: min(440px, 100%);
}

.top-search input {
  margin: 0;
  height: 42px;
  padding: 10px 78px 10px 42px;
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-1);
}

.top-search input:focus {
  box-shadow: 0 0 0 4px rgba(255, 122, 77, 0.14), var(--shadow-1);
}

.top-search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.top-search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--fill);
  border-radius: 7px;
  padding: 3px 7px;
  pointer-events: none;
}

.top-search-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 340px;
  overflow: auto;
  padding: 6px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 24px 60px rgba(28, 31, 51, 0.18), 0 0 0 1px var(--line);
  transform-origin: top center;
  animation: pop 320ms var(--spring) both;
}

.top-search-item {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  background: none;
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 500;
}

.top-search-item:hover {
  background: var(--fill);
  filter: none;
}

.top-search-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.top-search-item-name {
  font-weight: 650;
}

.top-search-item-meta {
  font-size: 12px;
}

.top-search-item-phase {
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.top-search-item-phase.phase-active {
  color: var(--green);
}
.top-search-item-phase.phase-expiring {
  color: var(--accent-strong);
}
.top-search-item-phase.phase-expired {
  color: var(--red);
}
.top-search-item-phase.phase-none {
  color: var(--muted);
}

.top-search-empty {
  margin: 0;
  padding: 12px;
}

/* ---------- 分段控制（iOS Segmented Control，滑動拇指） ---------- */

.seg {
  position: relative;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border-radius: 12px;
  background: rgba(118, 118, 128, 0.12);
  isolation: isolate;
}

.seg-thumb {
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--seg-count, 2));
  border-radius: 9px;
  background: var(--white);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transform: translateX(calc(var(--seg-index, 0) * 100%));
  transition: transform 460ms var(--spring);
}

.seg-item {
  min-height: 32px;
  padding: 6px 16px;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-shadow: none;
  transition: color var(--ease), transform var(--t-fast) var(--spring);
}

.seg-item:hover {
  filter: none;
}

.seg-item.on {
  color: var(--ink);
}

.seg-tabs {
  margin: 0 0 20px;
}

/* ---------- 版面通用 ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  margin: 0 0 4px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.page-sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--ease), transform var(--ease);
}

.card.dark {
  background: linear-gradient(160deg, #2d3170, #3f3b93);
  color: var(--white);
}

.card.dark .muted,
.card.dark .page-sub {
  color: rgba(255, 255, 255, 0.6);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* 同事帳戶新增表單：每欄自包 label＋input 一條 flex 直欄，左緣必然對齊；
   唔共用 .row 嘅 auto-fit grid，避免欄寬受無關 grid item 影響 */
.user-add {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.user-add label {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.user-add label span {
  margin: 0;
}

.user-add-action {
  flex: 0 0 auto;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.remote-support-code {
  font-size: 32px;
  letter-spacing: 0.2em;
  font-weight: 650;
  margin: 8px 0;
}

.remote-support-entry {
  font-size: 20px;
  letter-spacing: 0.2em;
  width: 8em;
  margin-right: 8px;
}

.remote-support-screen {
  margin-top: 12px;
  min-height: 240px;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
}

.remote-support-screen:focus {
  outline: 2px solid var(--accent, #3d6b4f);
}

.error {
  color: var(--red);
  font-weight: 500;
}

.ok {
  color: var(--green);
  font-weight: 500;
}

.test-school-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  vertical-align: middle;
}

.page-title .test-school-toggle,
.page-title .chip {
  margin-left: 12px;
}

.test-school-toggle input {
  width: auto;
  margin: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  margin-right: 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.card.dark .chip {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
}

.update-tag {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.internal-note,
.internal-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #efedff;
  color: #4d43a8;
  font-size: 11px;
  font-weight: 600;
}

.internal-note {
  display: block;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
}

.skeleton {
  border-radius: var(--r-lg);
  height: 112px;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.5) 20%, rgba(255, 255, 255, 0.95) 40%, rgba(255, 255, 255, 0.5) 60%) #eceef5;
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.state-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 24px;
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-1);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 12px;
  color: var(--muted);
  text-align: center;
}

.empty p {
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

tbody tr {
  transition: background-color var(--ease);
}

tbody tr:hover {
  background: rgba(242, 243, 248, 0.7);
}

/* 統一分頁列 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.pager-btns {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.is-unavailable {
  opacity: 0.5;
  filter: grayscale(0.85);
}

button.app-pick.is-unavailable,
button.app-pick:disabled {
  cursor: not-allowed;
}

.unavailable-reason {
  margin-top: 4px;
  color: #7a6f86;
  font-size: 12px;
}

.card.dark .unavailable-reason {
  color: #d2cce0;
}

/* =========================================================
   總覽（仿截圖：左卡堆、中列表、下摘要、右聯絡欄）
   ========================================================= */

.ov {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
}

.ov-main {
  min-width: 0;
}

.ov-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.ov-head .page-sub {
  margin-bottom: 22px;
}

.ov-top {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.hero-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
  padding: 16px 18px;
  border-radius: 22px;
  color: var(--white);
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 16px 34px rgba(28, 31, 51, 0.16);
  transition:
    transform 480ms var(--spring),
    box-shadow var(--ease);
}

.hero-card:hover {
  transform: translateY(-4px) rotate(-0.6deg);
  box-shadow: 0 24px 44px rgba(28, 31, 51, 0.2);
}

.hero-card:active {
  transform: scale(0.97);
  transition-duration: 120ms;
}

.hero-peach {
  background: linear-gradient(150deg, #ffcf8a 0%, #ffab70 45%, #f47a4c 100%);
}

.hero-indigo {
  background: linear-gradient(150deg, #2f3372 0%, #3b3f8e 55%, #4b4aa6 100%);
}

.hero-art {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.hero-peach .hero-art {
  background:
    radial-gradient(120px 90px at 88% 18%, rgba(255, 255, 255, 0.38), transparent 70%),
    radial-gradient(160px 120px at 30% 110%, rgba(244, 93, 51, 0.55), transparent 70%);
}

.hero-indigo .hero-art {
  background:
    radial-gradient(90px 90px at 42% 72%, rgba(242, 86, 107, 0.85), transparent 70%),
    conic-gradient(from 210deg at 78% 40%, rgba(201, 180, 255, 0.55), rgba(201, 180, 255, 0) 30%);
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-pill {
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
  position: relative;
}

.hero-pill::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--white);
}

.hero-caption {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.92;
}

.hero-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero-value small {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.8;
  letter-spacing: 0;
}

.hero-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.hero-foot em {
  display: block;
  font-style: normal;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.75;
}

.add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 116px;
  border-radius: 22px;
  border: 1.5px dashed #b9c3de;
  background: rgba(220, 228, 247, 0.55);
  color: #6b7597;
  font-size: 13px;
  font-weight: 600;
  transition:
    background-color var(--ease),
    border-color var(--ease),
    transform 420ms var(--spring);
}

.add-card svg {
  width: 20px;
  height: 20px;
}

.add-card:hover {
  background: rgba(220, 228, 247, 0.85);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.add-card:active {
  transform: scale(0.97);
}

.panel {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h3,
.section-head h3,
.side-head h3 {
  margin: 0 0 2px;
  font-size: 19px;
  font-weight: 700;
}

.round-pager {
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 16px 0 14px;
}

.summary-total {
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-coin {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
}

.summary-amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.summary-unit {
  color: var(--muted);
  font-weight: 600;
}

.summary-stats {
  display: flex;
  gap: 18px;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat svg {
  width: 15px;
  height: 15px;
}

.stat em {
  font-style: normal;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
}

.stat.up svg {
  color: var(--green);
}

.stat.down svg {
  color: var(--rose);
}

.svc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.svc-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1.4fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 70px;
  padding: 12px 14px;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
  transition:
    background-color var(--ease),
    box-shadow var(--ease),
    transform 420ms var(--spring);
}

.svc-row:hover {
  background: var(--white);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  filter: none;
}

.svc-row:active {
  transform: scale(0.985);
}

.svc-tile,
.contact-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  color: var(--white);
  font-weight: 700;
  font-size: 16px;
  flex: 0 0 auto;
}

.tone-a {
  background: linear-gradient(145deg, #ff9f73, #f45d33);
}
.tone-b {
  background: linear-gradient(145deg, #7d73f0, #4b44b8);
}
.tone-c {
  background: linear-gradient(145deg, #41d1a0, #1fa971);
}
.tone-d {
  background: linear-gradient(145deg, #ffcf6e, #f0a020);
}
.tone-e {
  background: linear-gradient(145deg, #ff7b8d, #e04158);
}

.svc-main,
.svc-amount,
.contact-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.svc-name {
  font-weight: 700;
  font-size: 14.5px;
}

.svc-sub,
.svc-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svc-amount {
  align-items: flex-end;
  text-align: right;
}

.svc-amount strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.svc-amount .muted {
  font-size: 11.5px;
  white-space: nowrap;
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--fill);
  color: var(--muted);
}

.phase-pill.phase-active {
  background: rgba(31, 169, 113, 0.12);
  color: var(--green);
}

.phase-pill.phase-expiring {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.phase-pill.phase-expired {
  background: rgba(239, 75, 75, 0.1);
  color: var(--red);
}

.summary-section {
  margin-top: 30px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.mini-card {
  display: flex;
  flex-direction: column;
  min-height: 190px;
  padding: 16px 16px 12px;
  border-radius: 22px;
  background: var(--white);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition:
    transform 480ms var(--spring),
    box-shadow var(--ease);
}

.mini-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-2);
}

.mini-card:active {
  transform: scale(0.97);
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.mini-go {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow-1);
  color: var(--green);
  transition: transform 420ms var(--spring);
}

.mini-go svg {
  width: 14px;
  height: 14px;
}

.mini-card:hover .mini-go {
  transform: translate(2px, -2px);
}

.mini-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.mini-unit {
  margin-top: 4px;
  color: #c4c7d4;
  font-size: 12px;
  font-weight: 600;
}

.mini-legend {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-empty {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: auto;
  overflow: visible;
}

.chart-stroke {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1200ms var(--ios) 250ms forwards;
}

.chart-line .chart-stroke {
  stroke: var(--rose);
  opacity: 0.8;
}

.chart-fill {
  opacity: 0;
  animation: fade 900ms var(--ios) 500ms forwards;
}

.chart-dot circle {
  fill: var(--white);
  stroke: var(--rose);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0);
  animation: dot-in 520ms var(--spring) forwards;
  animation-delay: calc(500ms + var(--i, 0) * 90ms);
}

.chart-bar {
  fill: var(--accent);
  transform-box: fill-box;
  transform-origin: bottom;
  transform: scaleY(0);
  animation: grow 760ms var(--spring) forwards;
  animation-delay: calc(260ms + var(--i, 0) * 70ms);
}

.chart-bar.alt {
  fill: var(--peach);
}

.donut-card {
  align-items: stretch;
}

.donut-wrap {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 10px auto 4px;
}

.chart-donut {
  width: 104px;
  height: 104px;
  transform: rotate(0deg);
}

.donut-track {
  fill: none;
  stroke: var(--fill);
  stroke-width: 6;
}

.donut-seg {
  fill: none;
  stroke-width: 6;
  stroke-linecap: butt;
  opacity: 0;
  transform-box: view-box;
  transform-origin: center;
  animation: donut-in 900ms var(--spring) forwards;
  animation-delay: calc(300ms + var(--i, 0) * 110ms);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.donut-center strong {
  font-size: 22px;
  line-height: 1;
}

.donut-center em {
  font-style: normal;
  color: var(--muted);
  font-size: 11px;
}

.donut-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
}

.donut-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ov-side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100dvh - 160px);
  padding: 18px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), var(--shadow-1);
}

.ov-side .seg {
  display: grid;
  width: 100%;
}

.ov-side-skeleton {
  height: 560px;
}

.side-panel {
  animation: rise 420ms var(--ios) backwards;
}

.side-head {
  margin-bottom: 12px;
}

.side-head .muted {
  font-size: 12px;
}

.side-empty {
  margin: 8px 0;
}

.side-filters {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.contact-list,
.app-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact,
.app-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 16px;
  transition:
    background-color var(--ease),
    transform 420ms var(--spring);
}

.contact:hover {
  background: var(--white);
  transform: translateX(3px);
}

.contact:active {
  transform: scale(0.98);
}

.contact .contact-avatar,
.app-row .contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 15px;
}

.contact-body strong {
  font-size: 13.5px;
}

.contact-body .muted {
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-row .contact-body {
  flex: 1;
}

.reminder {
  position: relative;
  margin-top: auto;
  padding: 18px 18px 20px;
  border-radius: 22px;
  background:
    radial-gradient(180px 140px at 100% 100%, rgba(255, 176, 150, 0.7), transparent 70%),
    rgba(255, 255, 255, 0.85);
  overflow: hidden;
}

.reminder-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  color: var(--violet);
  animation: ring 2.8s var(--ios) 1.2s infinite;
  transform-origin: 50% 10%;
}

.reminder-icon svg {
  width: 26px;
  height: 26px;
}

.reminder strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
  padding-right: 44px;
}

.reminder p {
  margin: 4px 0 0;
  padding-right: 44px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}

.reminder-go {
  position: absolute;
  right: 16px;
  bottom: 18px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--white);
  box-shadow: 0 0 0 6px rgba(255, 122, 77, 0.18), var(--shadow-accent);
  transition: transform 420ms var(--spring);
}

.reminder-go svg {
  width: 16px;
  height: 16px;
}

.reminder-go:hover {
  transform: translateX(3px);
}

.reminder-go:active {
  transform: scale(0.9);
}

/* =========================================================
   客戶與合約
   ========================================================= */

.roster-filters {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(120px, 0.6fr) minmax(140px, 0.7fr);
  gap: 8px;
  margin: 0 0 12px;
}

.school-card {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr auto;
  gap: 12px 16px;
  align-items: start;
  margin: 0 -12px;
  padding: 14px 12px;
  border-radius: 18px;
  cursor: pointer;
  transition:
    background-color var(--ease),
    box-shadow var(--ease);
}

.school-card:hover {
  background: #fafbfd;
  box-shadow: inset 0 0 0 1px var(--line);
}

.school-card.is-test {
  background: var(--accent-soft);
}

.school-card.is-test:hover {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(245, 96, 46, 0.22);
}

.school-card + .school-card {
  border-top: 1px solid var(--line);
}

.school-card:hover + .school-card {
  border-top-color: transparent;
}

.school-card strong {
  font-size: 15px;
  transition: color var(--ease);
}

.school-card:hover strong {
  color: var(--accent-strong);
}

.school-card-actions {
  display: flex;
  justify-content: flex-end;
}

.school-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.phase-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 0;
  margin-top: 6px;
  font-size: 12px;
}

.phase-arrow {
  margin: 0 5px;
  color: #c4c7d4;
}

.phase-off {
  color: #b3b7c8;
}

.phase-on {
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}

.phase-hint.phase-active .phase-on {
  color: var(--green);
  background: rgba(31, 169, 113, 0.12);
}

.phase-hint.phase-expiring .phase-on {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.phase-hint.phase-expired .phase-on {
  color: var(--red);
  background: rgba(239, 75, 75, 0.1);
}

.phase-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 0;
}

.phase-line .phase-hint {
  margin-top: 0;
}

/* =========================================================
   學校詳情
   ========================================================= */

.detail-page > p:first-child a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 13px;
  transition: transform var(--t-fast) var(--spring);
}

.detail-page > p:first-child a:hover {
  transform: translateX(-3px);
}

.detail-page h2 {
  margin-bottom: 8px;
}

.detail-page.is-test .card {
  background: var(--accent-soft);
}

.detail-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.detail-summary .phase-hint {
  margin-top: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 4px 24px;
  margin-bottom: 8px;
}

.detail-grid h4 {
  margin-bottom: 4px;
}

.contract-row {
  border-top: 1px solid var(--line);
}

.contract-row:first-of-type {
  border-top: 0;
}

.contract-head {
  display: grid;
  grid-template-columns: 16px minmax(120px, 0.9fr) minmax(200px, 1.3fr) minmax(90px, 0.6fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 0;
  margin: 0 -10px;
  width: calc(100% + 20px);
  padding: 14px 10px;
  border-radius: 14px;
  background: none;
  color: inherit;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.contract-head:hover {
  background: var(--fill);
  filter: none;
}

.contract-head:active {
  transform: scale(0.995);
}

.contract-caret {
  color: var(--accent);
  transition: transform var(--ease);
}

.contract-name {
  font-weight: 650;
}

.contract-meta,
.contract-apps {
  color: var(--muted);
  font-size: 13px;
}

.contract-tools {
  display: flex;
  gap: 8px;
  padding: 0 0 12px 26px;
}

.contract-tools:empty {
  display: none;
}

.contract-body {
  padding: 0 0 16px 26px;
  animation: rise 420ms var(--ios) backwards;
}

.contract-block {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.contract-block:first-of-type {
  border-top: 0;
  padding-top: 4px;
}

.contract-block strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.contract-block p {
  margin: 4px 0;
}

.contract-block h4 {
  margin: 16px 0 8px;
  font-size: 14px;
}

.handover-edit label {
  display: block;
  margin: 10px 0;
}

.handover-edit textarea {
  min-height: 76px;
}

.handover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 8px 0 14px;
}

.person-block {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--fill);
}

.token-list {
  display: grid;
  gap: 10px;
}

.token-list strong {
  word-break: break-all;
}

.token-list .person-block button {
  margin-top: 6px;
}

.person-block strong,
.person-block p {
  margin: 0 0 4px;
}

/* 出場與授權 */
.app-block {
  padding: 14px 0;
}

.app-block + .app-block {
  border-top: 1px solid var(--line);
}

.app-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.grant-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 6px 0;
}

.grant-row.secondary {
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  opacity: 0.85;
}

.grant-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13px;
}

.grant-status {
  font-weight: 650;
}

.grant-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.grant-actions button.link-btn:disabled {
  background: none;
}

.grant-hint {
  flex-basis: 100%;
  margin: 0;
}

.grant-hint a {
  margin-left: 8px;
  color: var(--accent-strong);
  font-weight: 650;
}

.app-head-action {
  margin-left: auto;
}

.update-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(28, 31, 51, 0.04);
}

.update-box-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.update-box-head .ok,
.update-box-head .unavailable-reason {
  margin: 0;
}

.update-box code {
  font-size: 12px;
}

.vault-strip,
.release-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--fill);
}

.vault-strip-line,
.vault-strip-form,
.release-strip form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.release-strip form {
  align-items: flex-end;
}

.release-strip label {
  flex: 1;
  min-width: 220px;
  margin: 0;
}

.vault-strip input[type="password"],
.release-strip input {
  min-width: 220px;
  margin: 0;
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.inline-label input[type="number"] {
  width: 72px;
  margin: 0;
}

.pack-progress {
  margin-bottom: 12px;
}

.pack-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 13px;
}

.pack-progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
}

.pack-progress-track > div {
  height: 100%;
  border-radius: inherit;
  background: var(--accent-grad);
  transition: width 0.25s ease;
}

.pack-progress-track > div.is-error {
  background: var(--red);
}

.pack-modal {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--fill);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pack-modal p {
  margin: 0;
}

.pack-modal-actions,
.pack-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pack-choice strong {
  min-width: 8em;
}

/* 標籤變長（格式化後帶序號與容量）時，下拉要縮窄並省略，不可把「重新掃描」擠到下一行。 */
.card-head:has(.usb-picker) h3 {
  flex: 0 0 auto;
}

.usb-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
  flex: 1 1 auto;
}

.usb-picker .ui-select {
  flex: 1 1 280px;
  width: auto;
  min-width: 0;
  max-width: 460px;
  margin: 0;
}

.usb-picker > button {
  flex: 0 0 auto;
}

.usb-picker button.ui-select-btn {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.usb-picker button.ui-select-btn span {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usb-picker button,
.grant-actions button {
  white-space: nowrap;
}

.gate-board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-basis: 100%;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--fill);
}

.gate-item {
  display: grid;
  grid-template-columns: 16px auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  margin: 0;
  padding: 4px 0;
}

.gate-note {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.45;
}

.gate-item.onsite {
  cursor: pointer;
}

.gate-item.onsite.disabled {
  cursor: default;
  opacity: 0.55;
}

.gate-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--green);
}

.gate-lamp,
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c7cad6;
  display: inline-block;
  transition: background-color var(--ease), box-shadow var(--ease);
}

.dot {
  width: 8px;
  height: 8px;
}

.gate-lamp.green,
.dot.on {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(31, 169, 113, 0.14);
}

.gate-lamp.red {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(239, 75, 75, 0.12);
}

.gate-lamp.gray {
  background: #c7cad6;
}

/* =========================================================
   開約表單
   ========================================================= */

.aftercare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  align-items: end;
}

.aftercare-grid label {
  min-width: 0;
  margin-bottom: 0;
}

.aftercare-grid label span {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 1.5em;
}

.aftercare-heading {
  margin: 20px 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.person-group {
  margin: 14px 0 18px;
}

.person-group h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
}

.time-module {
  padding: 14px 14px 6px;
  border-radius: 16px;
  background: var(--fill);
}

.time-module input,
.time-module button.ui-select-btn {
  background: var(--white);
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field-tag {
  display: inline-block;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.field-tag.req {
  color: var(--accent-strong);
}

.accordion {
  margin: 10px 0 14px;
  padding: 4px 16px 10px;
  border-radius: 18px;
  background: var(--fill);
}

.accordion summary {
  cursor: pointer;
  padding: 12px 0;
  font-weight: 650;
  list-style: none;
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion summary::before {
  content: "›";
  display: inline-block;
  margin-right: 8px;
  color: var(--accent);
  font-weight: 700;
  transition: transform var(--ease);
}

.accordion[open] summary::before {
  transform: rotate(90deg);
}

.accordion[open] > :not(summary) {
  animation: rise 380ms var(--ios) backwards;
}

.choice-row {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(118, 118, 128, 0.12);
}

button.choice {
  flex: 1;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  box-shadow: none;
}

button.choice:hover {
  filter: none;
  background: rgba(255, 255, 255, 0.5);
}

button.choice.on {
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
}

.app-pick-field {
  display: block;
  font-size: 13px;
  margin-bottom: 10px;
}

.app-pick-field > span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-weight: 500;
}

.app-picks {
  display: grid;
  gap: 8px;
}

.app-pick-wrap {
  display: grid;
  gap: 6px;
}

.app-gift-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.app-gift-toggle input {
  width: auto;
  margin: 0;
}

button.app-pick {
  width: 100%;
  justify-content: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--white);
  color: var(--ink);
  font-weight: 400;
  text-align: left;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

button.app-pick:hover {
  filter: none;
  box-shadow: inset 0 0 0 1px rgba(255, 122, 77, 0.4);
}

button.app-pick.on {
  background: linear-gradient(180deg, #fff5f0 0%, var(--white) 80%);
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 10px 26px rgba(245, 96, 46, 0.12);
}

.app-pick-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(255, 122, 77, 0.18);
  flex: 0 0 auto;
}

.app-pick-body {
  flex: 1;
  min-width: 0;
}

.app-pick-body strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
}

.app-pick-body small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.app-pick-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--white);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex: 0 0 auto;
  animation: badge-in 420ms var(--spring) both;
}

/* 舊版篩選列（深色卡內） */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.card.dark input,
.card.dark button.ui-select-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.card.dark button.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

/* =========================================================
   登入／改密／啟動
   ========================================================= */

.auth-shell {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 24px;
  isolation: isolate;
  background:
    radial-gradient(520px 420px at 85% 10%, rgba(255, 184, 156, 0.85), transparent 70%),
    radial-gradient(460px 380px at 10% 90%, rgba(201, 204, 246, 0.9), transparent 70%),
    linear-gradient(180deg, #f1f2f7, #e7e9f1);
}

.login {
  width: min(420px, 100%);
  margin: 0;
  padding: 30px 30px 26px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(30px) saturate(170%);
  -webkit-backdrop-filter: blur(30px) saturate(170%);
  box-shadow: 0 30px 80px rgba(28, 31, 51, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: sheet-in var(--t-slow) var(--spring) both;
}

.login form button[type="submit"] {
  width: 100%;
  min-height: 46px;
  margin-top: 6px;
  font-size: 15px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 15px;
  font-weight: 700;
}

.auth-brand .brand-mark {
  width: 48px;
  height: 48px;
}

.boot {
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff6ea;
}

.boot-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255, 122, 77, 0) 0deg, var(--accent) 300deg, rgba(255, 122, 77, 0) 360deg);
  -webkit-mask: radial-gradient(circle, transparent 9px, #000 10px);
  mask: radial-gradient(circle, transparent 9px, #000 10px);
  animation: spin 800ms linear infinite;
}

/* =========================================================
   關鍵影格
   ========================================================= */

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rail-in {
  from {
    opacity: 0;
    transform: translateX(-24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes stage-in {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes badge-in {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes fade {
  to {
    opacity: 1;
  }
}

@keyframes grow {
  to {
    transform: scaleY(1);
  }
}

@keyframes dot-in {
  to {
    transform: scale(1);
  }
}

@keyframes donut-in {
  from {
    opacity: 0;
    transform: rotate(-40deg) scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes drift {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-40px, 30px) scale(1.08);
  }
}

@keyframes ring {
  0%,
  70%,
  100% {
    transform: rotate(0);
  }
  74% {
    transform: rotate(14deg);
  }
  80% {
    transform: rotate(-12deg);
  }
  86% {
    transform: rotate(8deg);
  }
  92% {
    transform: rotate(-4deg);
  }
}

/* =========================================================
   響應式
   ========================================================= */

@media (max-width: 1380px) {
  .mini-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1240px) {
  .ov {
    grid-template-columns: minmax(0, 1fr);
  }

  .ov-side {
    position: static;
    min-height: 0;
  }
}

@media (max-width: 980px) {
  .ov-top {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .svc-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .svc-amount {
    display: none;
  }
}

@media (max-width: 900px) {
  .contract-head {
    grid-template-columns: 16px 1fr;
  }

  .contract-meta,
  .contract-apps {
    grid-column: 2;
  }

  .contract-body {
    padding-left: 0;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 80px minmax(0, 1fr);
    padding: 10px 10px 10px 0;
  }

  .rail {
    width: 66px;
  }

  .rail-item,
  .rail-indicator {
    width: 54px;
  }

  .main,
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .flavor-chip {
    display: none;
  }

  .roster-filters,
  .school-card {
    grid-template-columns: 1fr;
  }

  .hero-stack,
  .mini-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .blob,
  .reminder-icon {
    animation: none !important;
  }
}

.boot-offline {
  margin: 18px 0 0;
  color: var(--muted, #6b6b6b);
  font-size: 14px;
  text-align: center;
}

.boot:has(.boot-offline) {
  align-content: center;
}

.db-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 500;
}

.db-banner.is-down {
  background: #fdecec;
  color: var(--red);
  border: 1px solid var(--red);
}

.db-banner.is-ok {
  background: #e9f7ee;
  color: var(--green);
  border: 1px solid var(--green);
}

.guard-notice {
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff7e0;
  border: 1px solid #e0b64a;
}

.guard-notice p {
  margin: 0;
}

.guard-unconfirmed {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--red);
  font-weight: 500;
}

.pack-unplug-warning {
  margin: 6px 0 0;
  color: var(--red);
  font-weight: 600;
}

.pack-write-stats {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 13px;
}

.pack-write-stall {
  margin: 4px 0 0;
  font-weight: 600;
}

.end-date-missing {
  color: var(--red);
  font-weight: 600;
}
