/*
 * Generated by scripts/extract-tokens.js
 * Source: sources/tokens.js
 * Tokens copied from the public style kit.
 */
:root {
  --viewport-desktop: 1440px;
  --viewport-mobile: 375px;
  --font-base: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --font-heading: "Cairo", sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --line-tight: 1.25;
  --line-base: 1.5;
  --line-relaxed: 1.75;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-1: 0 4px 17px rgba(156, 161, 186, 0.25);
  --white: #ffffff;
  --black: #000000;
  --gray-900: #212529;
  --gray-800: #343A40;
  --gray-700: #495057;
  --gray-600: #6C757D;
  --gray-500: #ADB5BD;
  --gray-400: #CED4DA;
  --gray-300: #DEE2E6;
  --gray-200: #E9ECEF;
  --gray-100: #F8F9FA;
  --primary-100: #EAF3ED;
  --primary-200: #C8E3DB;
  --primary-300: #58BEA5;
  --primary-400: #26A385;
  --primary-500: #167E66;
  --primary-600: #116854;
  --primary-700: #0E5040;
  --primary-800: #343A40;
  --primary-900: #212529;
  --primary-hover: #116854;
  --secondary-100: #fdf0d7;
  --secondary-200: #fbdead;
  --secondary-300: #f8c679;
  --secondary-400: #f3a344;
  --secondary-500: #F0881F;
  --secondary-600: #E16E15;
  --secondary-700: #BB5313;
  --secondary-800: #954217;
  --secondary-900: #783816;
  --info-100: #EAF0F7;
  --info-500: #317191;
  --info-900: #275A74;
  --pending-100: #FFF3E8;
  --pending-500: #FF8610;
  --pending-900: #F16400;
  --success: #1A844A;
  --success-hover: #2B9E5A;
  --danger: #E21D12;
  --danger-hover: #BB2D3B;
  --warning: #FFCC00;
  --warning-soft: #FFEDED;
  --link: #006AF5;
  --analysis: #9850E4;
  --bg-page: #E9ECEF;
  --bg-surface: #ffffff;
  --bg-subtle: #F8F9FA;
  --border: #DEE2E6;
  --border-soft: #E9ECEF;
  --text-main: #343A40;
  --text-muted: #6C757D;
}

/* Public template components. Project-specific layout adjustments follow below. */

:root {
  --color-bg: var(--bg-page);
  --color-surface: var(--bg-surface);
  --color-panel: var(--bg-subtle);
  --color-line: var(--border);
  --color-table-head: var(--primary-100);
  --color-text: var(--text-main);
  --color-muted: var(--text-muted);
  --color-inverse: var(--white);
  --color-teal-50: var(--primary-100);
  --color-teal-100: var(--primary-100);
  --color-teal-200: var(--primary-200);
  --color-teal-700: var(--primary-500);
  --color-teal-800: var(--primary-600);
  --color-primary: var(--primary-500);
  --color-primary-hover: var(--primary-600);
  --color-secondary: var(--secondary-500);
  --color-secondary-hover: var(--secondary-600);
  --color-success: var(--success);
  --color-warning-surface: var(--pending-100);
  --color-warning: var(--pending-900);
  --color-danger: var(--danger);
  --color-danger-surface: var(--warning-soft);
  --shadow-card: var(--shadow-1);
  --sidebar-width: 64px;
  --sidebar-expanded-width: 260px;
  --sidebar-collapsed-width: 64px;
  --current-sidebar-width: var(--sidebar-collapsed-width);
  --topbar-height: 80px;
  --header-gradient-start: #DE580A;
  --header-gradient-end: #FFA06D;
  --header-block-height: 248px;
  --radius-card: var(--radius-md);
  --radius-control: var(--radius-sm);
  --font-base: "Noto Sans TC", ui-sans-serif, system-ui, sans-serif;
  --text-sm: .95rem;
  --text-base: 16px;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: var(--text-base);
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg);
}

.app-layout.is-sidebar-expanded {
  --current-sidebar-width: var(--sidebar-expanded-width);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  border-right: 1px solid var(--color-line);
  background: var(--color-surface);
  transition: width 0.2s ease, flex-basis 0.2s ease;
}

.sidebar.is-expanded {
  flex-basis: var(--sidebar-expanded-width);
  width: var(--sidebar-expanded-width);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 80px;
  flex: 0 0 auto;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-line);
  font-weight: 800;
  font-size: var(--text-base);
}

.sidebar__brand-main {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sidebar.is-expanded .sidebar__brand {
  justify-content: space-between;
}

.sidebar.is-expanded .sidebar__brand-main {
  display: flex;
}

.sidebar__logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: var(--color-teal-700);
  color: var(--color-inverse);
}

/* 側欄左上角圖片 LOGO */
.sidebar__logo--image {
  width: auto;
  background: transparent;
}

.sidebar__logo--image img {
  display: block;
  height: 28px;
  width: auto;
}

.sidebar__brand-text {
  font-size: 18px;
  font-weight: 700;
}

.sidebar__toggle {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-muted);
}

.sidebar__toggle:hover {
  background: var(--color-panel);
}

.sidebar__nav {
  display: grid;
  gap: 4px;
  padding: 16px 8px;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: var(--text-base);
}

.sidebar__item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 44px;
  min-height: 44px;
  border-radius: 4px;
  padding: 0;
  color: var(--color-text);
  font-weight: 700;
}

.sidebar__item:hover {
  background: var(--color-panel);
}

.sidebar__item.is-active {
  background: var(--color-teal-50);
  color: var(--color-teal-700);
  box-shadow: inset 0 0 0 1px var(--color-teal-100);
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: currentColor;
  flex: 0 0 auto;
}

.icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar__label,
.sidebar__brand-text {
  display: none;
}

.sidebar.is-expanded .sidebar__label,
.sidebar.is-expanded .sidebar__brand-text {
  display: inline;
}

.sidebar.is-expanded .sidebar__nav {
  padding: 16px 8px;
}

.sidebar.is-expanded .sidebar__item {
  justify-content: flex-start;
  gap: 8px;
  width: auto;
  padding: 8px 12px;
}

.app-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to bottom, var(--header-gradient-start) 0, var(--header-gradient-end) var(--header-block-height), var(--color-bg) var(--header-block-height), var(--color-bg) 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: 0 24px;
  color: var(--color-inverse);
  background: linear-gradient(to bottom, var(--header-gradient-start), color-mix(in srgb, var(--header-gradient-end) 32%, var(--header-gradient-start)));
}

.topbar__start {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0;
}

.breadcrumb>span:first-child {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.breadcrumb__sep {
  color: var(--primary-200);
}

.topbar__meta {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 12px;
  color: var(--white);
  font-weight: 400;
  font-size: var(--text-base);
}

.topbar__divider {
  color: var(--primary-200);
  font-weight: 400;
}

.topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-inverse);
  font-weight: 400;
  text-decoration: none;
}

.topbar__title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.mobile-nav-toggle,
.mobile-user-toggle {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-inverse);
}

.mobile-nav-toggle:hover,
.mobile-user-toggle:hover {
  background: color-mix(in srgb, var(--white) 16%, transparent);
}

.sidebar-overlay {
  display: none;
}

.font-size-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.font-size-pill button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 400;
  line-height: 1;
}

.font-size-pill button {
  font-size: var(--text-base);
}

.font-size-pill .is-active {
  background: var(--color-surface);
  color: var(--color-teal-800);
  font-weight: 400;
}

.page {
  display: grid;
  gap: 16px;
  padding: 0 16px 48px;
}

.page-card {
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.page-card--lift {
  margin-top: 0;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--color-line);
}

.title-block {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.section-accent {
  width: 4px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary-400) 0%, var(--primary-500) 100%);
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

.page-title,
.section-title {
  font-size: var(--text-base);
  line-height: 1.35;
  font-weight: 900;
  letter-spacing: 0;
}

.page-desc,
.tag,
.count,
.status {
  font-size: var(--text-sm);
}

.field label,
table {
  font-size: var(--text-base);
}

.page-desc {
  margin-top: 4px;
  color: var(--color-muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--color-teal-50);
  color: var(--color-teal-700);
  padding: 4px 8px;
  font-weight: 800;
  white-space: nowrap;
}

.filter {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
}

.field label {
  color: var(--color-text);
  font-weight: 800;
}

.field.is-required label::after {
  content: " *";
  color: var(--color-danger);
}

.field-error {
  margin: 0;
  color: var(--color-danger);
  font-size: var(--text-sm);
}

.control.is-invalid {
  border-color: var(--color-danger);
}

.control {
  width: 100%;
  height: 40px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0 12px;
  outline: none;
}

textarea.control {
  min-height: 104px;
  padding: 8px 12px;
  resize: vertical;
}

.control:focus {
  border-color: var(--color-teal-200);
  box-shadow: 0 0 0 3px var(--primary-200);
}

.select-like {
  appearance: none;
  display: grid;
  grid-template-columns: 1fr 40px;
  align-items: stretch;
  overflow: hidden;
  width: 100%;
  height: 40px;
  border: 1px solid var(--gray-500);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-muted);
  padding: 0;
  text-align: left;
}

.select-like__value {
  display: flex;
  align-items: center;
  padding: 0 12px;
}

.select-like__arrow {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--gray-400);
  background: var(--bg-subtle);
  color: var(--color-text);
}

.filter-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: 8px 10px;
  max-height: 36px;
  font-weight: 400;
  white-space: nowrap;
}

.button--primary {
  background: var(--color-teal-700);
  color: var(--color-inverse);
}

.button--primary:hover {
  background: var(--color-teal-800);
}

.button--secondary {
  background: var(--color-secondary);
  color: var(--color-inverse);
}

.button--secondary:hover {
  background: var(--color-secondary-hover);
}

.button--small {
  gap: 4px;
  padding: 6px 8px;
  max-height: 32px;
  font-size: var(--text-sm);
}

.button--gray {
  background: var(--gray-600);
  color: var(--color-inverse);
}

.button--gray:hover {
  background: var(--gray-700);
}

.button--outline {
  border-color: var(--color-teal-700);
  background: transparent;
  color: var(--color-teal-700);
}

.button--outline:hover {
  background: var(--color-teal-100);
}

.button--outline-gray {
  border-color: var(--gray-500);
  background: transparent;
  color: var(--gray-700);
}

.button--outline-gray:hover {
  background: var(--gray-100);
}

.button--danger {
  background: var(--danger);
  color: var(--color-inverse);
}

.button--danger:hover {
  background: var(--danger-hover);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 16px 0;
}

.toolbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-line);
  padding: 16px 16px 0;
  font-weight: 700;
}

.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-text);
  padding: 0 0 8px;
  font-weight: 400;
}

.tab.is-active {
  border-bottom-color: var(--color-teal-700);
  color: var(--color-teal-700);
}

.count {
  margin-left: 4px;
  border-radius: 999px;
  background: var(--color-panel);
  color: var(--color-muted);
  padding: 2px 8px;
  font-weight: 800;
}

.category-tabs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  overflow-x: auto;
}

.category-tab {
  height: 40px;
  border: 1px solid var(--primary-600);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: var(--primary-600);
  color: var(--color-inverse);
  padding: 0 24px;
  font-weight: 400;
  white-space: nowrap;
}

.category-tab:not(.is-active):hover {
  border-color: var(--primary-700);
  background: var(--primary-700);
}

.category-tab.is-active {
  height: 48px;
  border-color: var(--secondary-500);
  border-bottom: 4px solid var(--secondary-600);
  background: var(--secondary-500);
  color: var(--color-inverse);
  font-weight: 700;
}

.filter-card {
  border-top-left-radius: 0;
}

/* 頁籤與下方資料區塊相接、左上角無圓角 */
.page > .category-tabs + .page-card,
.page > .master-tabs + .page-card,
.page > .crossyear-tabs + .page-card {
  margin-top: -16px;
  border-top-left-radius: 0;
}

.table-wrap {
  margin: 12px;
  overflow-x: auto;
  border: 1px solid var(--color-line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

thead {
  background: var(--color-table-head);
}

th,
td {
  border-bottom: 1px solid var(--color-line);
  padding: 12px;
  vertical-align: middle;
}

th {
  color: var(--color-text);
  font-weight: 900;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: var(--color-panel);
}

tbody tr:hover {
  background: var(--color-teal-100);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.link {
  color: var(--color-teal-700);
  font-weight: 800;
}

.table-action-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-action-icon {
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-teal-700);
  padding: 6px 8px;
  max-height: 32px;
  line-height: 1;
  font-size: var(--text-sm);
  font-weight: 400;
  cursor: pointer;
}

.table-action-icon:hover {
  background: var(--color-teal-100);
}

.table-action-icon--danger {
  color: var(--danger);
}

.table-action-icon--danger:hover {
  background: var(--warning-soft);
}

.table-action-icon:disabled {
  opacity: .5;
  cursor: default;
}

.table-action-icon:disabled:hover {
  background: transparent;
}

.table-action-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-teal-200);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-teal-700);
  padding: 6px 8px;
  font-weight: 400;
  white-space: nowrap;
}

.table-action-text:hover {
  background: var(--color-teal-100);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 800;
  white-space: nowrap;
}

.status--success {
  background: var(--color-teal-50);
  color: var(--color-success);
}

.status--warning {
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.status--neutral {
  background: var(--color-panel);
  color: var(--color-muted);
  box-shadow: inset 0 0 0 1px var(--color-line);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--color-line);
  margin-top: 16px;
  padding: 16px;
  font-weight: 400;
}

.pager {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--color-muted);
}

.pager button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: inherit;
  font-weight: 400;
}

.pager button:hover {
  background: var(--color-panel);
}

.pager .is-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--color-teal-700);
  color: var(--color-inverse);
}

.pagination__size {
  width: auto;
  height: 32px;
}

.info-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
}

.info-card,
.stat-card {
  border: 1px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-surface);
  padding: 16px;
}

.info-card__label,
.stat-card__label {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

.info-card__value,
.stat-card__value {
  margin-top: 8px;
  font-size: var(--text-base);
  font-weight: 900;
}

.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: var(--current-sidebar-width);
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--color-line);
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
  padding: 16px max(16px, env(safe-area-inset-bottom));
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--gray-900) 44%, transparent);
}

.modal-container {
  width: min(560px, 100%);
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 16px;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-header {
  border-bottom: 1px solid var(--color-line);
}

.modal-title {
  font-size: var(--text-base);
  font-weight: 900;
  color: var(--color-teal-700);
  line-height: 1.25;
}

.modal-close {
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  max-height: 32px;
  background: transparent;
  color: var(--color-muted);
  padding: 6px 8px;
}

.modal-close:hover {
  background: var(--color-panel);
  color: var(--color-text);
}

.modal-body {
  display: grid;
  gap: 16px;
}

.modal-footer {
  border-top: 1px solid var(--color-line);
  justify-content: flex-end;
}

.chart-panel {
  min-height: 220px;
  border: 1px dashed var(--color-line);
  border-radius: 12px;
  background: var(--color-panel);
  padding: 16px;
}

@media (max-width: 768px) {
  .app-layout {
    display: block;
  }

  .sidebar,
  .sidebar.is-expanded {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: min(280px, calc(100vw - 48px));
    height: 100vh;
    min-height: 0;
    border-right: 1px solid var(--color-line);
    border-bottom: 0;
    box-shadow: var(--shadow-card);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .app-layout.is-mobile-drawer-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__brand,
  .sidebar.is-expanded .sidebar__brand {
    min-height: 56px;
    padding: 0 12px;
    border-bottom: 1px solid var(--color-line);
  }

  .sidebar__nav,
  .sidebar.is-expanded .sidebar__nav {
    display: grid;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 8px;
  }

  .sidebar__item,
  .sidebar.is-expanded .sidebar__item {
    justify-content: flex-start;
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
  }

  .sidebar__label,
  .sidebar__brand-text,
  .sidebar.is-expanded .sidebar__label,
  .sidebar.is-expanded .sidebar__brand-text {
    display: inline;
  }

  .sidebar__brand-main,
  .sidebar.is-expanded .sidebar__brand-main {
    display: flex;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    border: 0;
    background: color-mix(in srgb, var(--gray-900) 44%, transparent);
  }

  .sidebar-overlay.is-visible {
    display: block;
  }

  .app-main {
    --header-block-height: 296px;
    background: linear-gradient(to bottom, var(--header-gradient-start) 0, var(--header-gradient-end) var(--header-block-height), var(--color-bg) var(--header-block-height), var(--color-bg) 100%);
  }

  .topbar {
    background: linear-gradient(to bottom, var(--header-gradient-start), color-mix(in srgb, var(--header-gradient-end) 50%, var(--header-gradient-start)));
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    min-height: 0;
    padding: 12px 16px;
  }

  .mobile-nav-toggle,
  .mobile-user-toggle {
    display: grid;
  }

  .mobile-nav-toggle {
    grid-column: 1;
  }

  .mobile-user-toggle {
    grid-column: 3;
  }

  .topbar__start {
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    margin: 8px 0;
  }

  .topbar__context {
    display: block;
    flex: 0 0 auto;
  }

  .topbar__title {
    text-align: left;
  }

  .breadcrumb {
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    width: auto;
    margin-left: auto;
    text-align: right;
  }

  .topbar__meta {
    position: absolute;
    top: 56px;
    right: 16px;
    z-index: 40;
    display: none;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    min-width: 176px;
    margin-left: 0;
    border: 1px solid var(--color-line);
    border-radius: 8px;
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    color: var(--color-text);
    font-size: var(--text-sm);
    padding: 12px;
  }

  .topbar__meta.is-open {
    display: flex;
  }

  .topbar__meta .topbar__user,
  .topbar__divider {
    display: none;
  }

  .topbar__link {
    color: var(--color-text);
  }

  .topbar__meta .font-size-pill {
    color: var(--color-text);
  }

  .page>*,
  .page-card {
    min-width: 0;
  }

  .filter-grid,
  .info-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    justify-content: flex-start;
  }

  .category-tabs {
    overflow-x: auto;
  }

  .table-wrap {
    max-width: 100%;
  }

  table {
    min-width: 720px;
  }

  .pagination {
    gap: 8px;
  }

  .action-bar {
    left: 0;
  }
}

/* User-selected project theme: 預算版本與歷程管理_公版樣式.html. */
:root {
  --gray-800: #2B2B2B;
  --gray-200: #F2F2F2;
  --gray-100: #F7F7F7;
  --primary-100: #FBEDE4;
  --primary-200: #F5D2BE;
  --primary-300: #F39A6B;
  --primary-400: #EE7A3F;
  --primary-500: #B5440F;
  --primary-600: #9A3A0C;
  --primary-700: #7F300A;
  --primary-hover: #9A3A0C;
  --secondary-500: #E8591F;
  --secondary-600: #D14D17;
  --success-100: #E5F3EB;
  --bg-page: #F2F2F2;
  --bg-subtle: #F7F7F7;
  --text-main: #2B2B2B;
  --font-base: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", ui-sans-serif, system-ui, sans-serif;
}

/* Workflow layouts and current public-template contract corrections. */
[hidden] {
  display: none !important;
}

.sidebar__item {
  border: 0;
  background: transparent;
  font-weight: 400;
}

.sidebar__label {
  text-align: left;
}

.topbar {
  gap: 16px;
  padding: 0 16px;
}

.topbar__start {
  flex: 1;
  flex-wrap: wrap;
}

.topbar__context {
  min-width: 0;
}

.topbar__title {
  line-height: 1.25;
}

.topbar__meta {
  flex: 0 0 auto;
  white-space: nowrap;
}

.topbar__link,
.breadcrumb-home {
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
}

.breadcrumb-home {
  display: inline-flex;
}

.breadcrumb {
  min-width: 0;
  flex-wrap: wrap;
}

.breadcrumb__sep,
.topbar__divider {
  color: var(--primary-200);
}

.topbar__meta {
  color: var(--white);
}

.page {
  padding-top: 0;
}

.page.has-action-bar {
  padding-bottom: 120px;
}

.page>*,
#main-form,
.page-card {
  min-width: 0;
}

#main-form {
  display: grid;
  gap: 16px;
}

.page-navigation {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.function-tabs {
  flex-wrap: nowrap;
}

.function-tabs .category-tab {
  flex: 0 0 auto;
}

.context-grid {
  display: grid;
  grid-template-columns: 100px 150px 100px minmax(220px, 1fr);
  gap: 12px;
  padding-bottom: 16px;
}

.context-grid--accounting {
  grid-template-columns: 100px 150px;
}

.context-grid--fund {
  grid-template-columns: 100px 150px minmax(180px, 280px);
}

/* 側欄大項右側展開／收合箭頭 */
.sidebar__chev {
  display: none;
}

.sidebar.is-expanded .sidebar__chev {
  display: inline-grid;
  margin-left: auto;
  transition: transform .2s;
}

.sidebar__item.is-open .sidebar__chev {
  transform: rotate(180deg);
}

.sidebar__modules {
  display: none;
}

.sidebar.is-expanded .sidebar__modules {
  display: grid;
  gap: 4px;
  margin: 4px 0;
}

.sidebar.is-expanded .sidebar__item {
  width: 100%;
}

.sidebar__module {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-main);
  padding: 8px 12px 8px 36px;
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.5;
}

.sidebar__module:hover {
  background: var(--gray-200);
}

.sidebar__module.is-active {
  background: var(--primary-100);
  color: var(--primary-700);
}

.sidebar__workgroups {
  display: grid;
  gap: 2px;
  margin: 0 0 4px;
}

.sidebar__workgroup {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-main);
  padding: 8px 12px 8px 54px;
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sidebar__workgroup:hover {
  background: var(--gray-200);
}

.sidebar__workgroup.is-active {
  background: var(--primary-100);
  color: var(--primary-700);
}

.sidebar__module:focus-visible,
.sidebar__workgroup:focus-visible {
  outline-offset: -2px;
}

.filter-grid {
  gap: 12px;
}

.filter .control {
  border-color: var(--gray-500);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
}

.modal-body .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
}

.modal-body form {
  display: grid;
  gap: 16px;
}

.field {
  font-weight: 400;
}

.field label {
  font-weight: 400;
}

.field:has(textarea) {
  grid-column: 1 / -1;
}

textarea.control {
  min-height: 104px;
  height: auto;
  padding: 10px 12px;
}

.control[readonly],
.control:disabled {
  background: var(--gray-100);
  color: var(--gray-700);
}

.control:focus-visible {
  border-color: var(--primary-500);
  outline: 2px solid var(--primary-200);
  box-shadow: none;
}

.button {
  font-size: var(--text-base);
  line-height: 1;
}

.button--small {
  font-size: var(--text-sm);
}

.button:disabled,
.pager button:disabled {
  cursor: default;
  opacity: .5;
}

button:focus-visible,
.button:focus-visible {
  outline: 2px solid var(--secondary-500);
  outline-offset: 2px;
}

.help-text {
  padding: 12px 16px 16px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.help-inline {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.modal-body .help-text {
  padding: 0;
}

.section-title {
  font-size: var(--text-base);
  font-weight: 700;
}

.category-tabs {
  gap: 8px;
}

.numeric {
  display: block;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table {
  min-width: 720px;
}

th {
  height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-weight: 700;
}

td {
  height: 48px;
}

tbody tr:hover {
  background: var(--gray-200);
}

td .field {
  min-width: 140px;
}

td .field label {
  font-size: var(--text-sm);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px;
}

.pagination {
  margin-top: 0;
}

.pager-current {
  padding: 0 8px;
  white-space: nowrap;
}

.pagination__jump {
  width: 64px;
  height: 32px;
}

.tabs {
  flex-wrap: wrap;
}

.info-grid {
  gap: 16px;
}

.info-card {
  box-shadow: none;
  background: var(--gray-100);
}

.info-card__value {
  margin-top: 4px;
  font-weight: 700;
}

.status {
  font-weight: 400;
}

.status--success {
  background: var(--success-100);
}

.action-bar {
  padding: 16px;
}

.modal-overlay {
  z-index: 100;
  background: var(--gray-900);
  background: color-mix(in srgb, var(--gray-900) 44%, transparent);
}

.modal-container {
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.modal-container--wide {
  width: min(1000px, 100%);
}

.modal-header {
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  background: var(--white);
}

.has-modal {
  overflow: hidden;
}

.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  max-width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--primary-200);
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--primary-100);
  color: var(--primary-700);
  box-shadow: var(--shadow-1);
  font-size: var(--text-sm);
}

.toast--warning {
  background: var(--pending-100);
  border-color: var(--secondary-300);
  color: var(--pending-900);
}

.font-large {
  --text-sm: 16px;
  --text-base: 16px;
}

.font-small {
  --text-sm: 14px;
  --text-base: 14px;
}

.topbar__meta {
  font-size: 16px;
}

.breadcrumb {
  font-size: 14px;
}

@media (min-width: 769px) and (max-width: 1200px) {
  .context-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .app-main {
    padding-top: 148px;
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    height: 148px;
    grid-template-rows: 40px minmax(0, 1fr);
    padding: 8px 16px;
  }

  .topbar__start {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-self: start;
    align-items: start;
    gap: 8px;
    margin: 4px 0;
  }

  .topbar__context {
    min-width: 0;
  }

  .topbar__title {
    font-size: 24px;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .breadcrumb {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    margin-left: 0;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 14px;
    text-align: left;
  }

  .breadcrumb>* {
    flex: 0 0 auto;
  }

  .topbar__meta {
    font-size: 16px;
  }

  .topbar__meta .topbar__link {
    color: var(--text-main);
  }

  .page {
    padding-top: 16px;
  }

  .context-grid,
  .form-grid,
  .modal-body .form-grid {
    grid-template-columns: 1fr;
  }

  .context-grid> :last-child {
    grid-column: auto;
  }

  .filter-actions {
    justify-content: flex-end;
  }

  .category-tabs {
    gap: 8px;
  }

  .function-tabs {
    flex-wrap: nowrap;
  }

  .category-tab {
    flex: 0 0 auto;
  }

  .sidebar__item {
    gap: 8px;
  }

  .sidebar .sidebar__modules {
    display: grid;
    gap: 4px;
    margin: 4px 0;
  }

  .modal-container {
    max-height: calc(100dvh - 32px);
  }

  .pagination {
    gap: 8px;
  }
}

@media print {

  .sidebar,
  .topbar__meta,
  .category-tabs,
  .page-navigation,
  .context-grid,
  .filter-actions,
  .toolbar__actions,
  .pagination,
  .action-bar,
  .modal-overlay,
  .toast,
  .mobile-nav-toggle,
  .mobile-user-toggle {
    display: none !important;
  }

  .app-layout,
  .app-main {
    display: block;
    background: var(--white);
    padding: 0;
  }

  .topbar {
    position: static;
    min-height: 0;
    padding: 12px 0;
    color: var(--text-main);
    background: var(--white);
  }

  .page {
    display: block;
    padding: 0;
  }

  .page-card {
    box-shadow: none;
    margin-bottom: 16px;
    break-inside: avoid;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 12px;
  }

  th,
  td {
    padding: 6px;
    height: auto;
    white-space: normal;
  }

  .has-modal .app-layout {
    display: none !important;
  }

  .has-modal .modal-overlay {
    display: block !important;
    position: static;
    background: var(--white);
    padding: 0;
  }

  .has-modal .modal-container {
    width: auto;
    max-height: none;
    overflow: visible;
    box-shadow: none;
  }

  .has-modal .modal-header,
  .has-modal .modal-footer {
    display: none;
  }
}

/* Shared file actions, row operations and a separate history tab. */
.toolbar__files {
  order: 10;
  margin-left: auto;
}

.table-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions-cell {
  min-width: 120px;
}

.table-history-cell {
  width: 72px;
  min-width: 72px;
  text-align: center;
  white-space: nowrap;
}

.table-history-cell .table-actions {
  justify-content: center;
}

.table-actions .table-action-group {
  gap: 8px;
}

.category-tab--history {
  margin-left: auto;
}

.file-choices {
  display: grid;
  gap: 16px;
}

.file-choice {
  display: grid;
  gap: 8px;
}

.file-choice>.button {
  justify-content: flex-start;
  width: 100%;
  max-height: none;
  min-height: 36px;
  white-space: normal;
  text-align: left;
}

.file-choice>p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.modal-container--export {
  width: min(960px, 100%);
}

.modal-container--export .modal-title {
  color: var(--color-text);
}

.modal-container--export .modal-body {
  padding: 24px;
}

.export-formats {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.export-formats legend {
  margin-bottom: 16px;
  padding: 0;
  font-size: var(--text-base);
}

.export-format-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.export-format-option {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
}

.export-format-option input {
  margin: 2px 0 0;
}

.export-format-option span {
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .category-tab--history {
    margin-left: 24px;
  }

  .toolbar__files {
    width: 100%;
  }
}

@media print {

  .toolbar__files,
  .table-actions,
  .file-choices {
    display: none !important;
  }
}

.crossyear-tabs {
  min-width: 0;
}

@media print {
  .crossyear-tabs {
    display: none !important;
  }
}

/* Shared master-data and cross-year pages reuse the public category tabs. */
.master-tabs {
  min-width: 0;
}

.master-tabs .category-tab--history {
  margin-left: 0;
}

@media print {
  .master-tabs {
    display: none !important;
  }
}

@media print {
  .voucher-print-sheet+.voucher-print-sheet {
    break-before: page;
  }
}
/* 下拉選單：自訂箭頭，距右側邊緣 12px */
:root {
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23495057' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

select.control {
  appearance: none;
  padding-right: 36px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

select.control:disabled,
select.control[readonly] {
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

/* 列表：勾選欄與工具列刪除按鈕 */
.button--outline-danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.button--outline-danger:hover:not(:disabled) {
  background: var(--warning-soft);
}

.list-select-cell {
  width: 40px;
  min-width: 40px;
  text-align: center;
}

.list-select-cell input {
  accent-color: var(--primary-500);
}

/* 預算編製的歷程頁籤緊接在預算編製頁籤右側 */
.category-tab--history[data-id="F01-009"],
.category-tab--history[data-id="F01-018"] {
  margin-left: 0;
}

/* 沒有頁籤的頁面，查詢區塊維持完整圓角 */
.page > .filter-card:first-child {
  border-top-left-radius: var(--radius-card);
}

/* 情境列（年度、機關…）：標籤與選單同一行，並以底色區別一般篩選欄位 */
.page-navigation .context-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  background: var(--color-panel);
}

.context-grid .field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.context-grid .field label {
  color: var(--color-muted);
  white-space: nowrap;
}

.context-grid .field .control {
  width: auto;
  min-width: 100px;
}

/* 燈箱：捲動只發生在內容區，頁首與頁腳固定，出現卷軸時四個圓角維持完整 */
.modal-container {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header,
.modal-footer {
  position: static;
  flex: 0 0 auto;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

@media print {
  .modal-body {
    overflow: visible;
  }
}

/* 08 系統管理（獨立模組）：頁籤與下方區塊相接、左上角無圓角 */
.page > .category-tabs + #yongyiMount {
  --yy-first-radius: 0;
  margin-top: -16px;
}

/* 全系統統一的核取方塊、單選鈕 */
input[type="checkbox"],
input[type="radio"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary-500);
  vertical-align: middle;
  cursor: pointer;
}

input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  opacity: .5;
  cursor: not-allowed;
}
