:root {
  --bg: #e8f2ff;
  --bg-mid: #f0f7ff;
  --surface: #ffffff;
  --surface-soft: #f4f9ff;
  --text: #0f172a;
  --muted: #5b6f8f;
  --line: #bfdbfe;
  --line-strong: #93c5fd;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.12);
  /* 純色區塊（無漸層） */
  --nav-bar: #1e40af;
  --nav-top-bar: #93c5fd;
  --footer-bg: #1e3a8a;
  --footer-border: rgba(59, 130, 246, 0.38);
  --footer-divider: rgba(147, 197, 253, 0.35);
  --footer-text: #e8f4ff;
  --footer-text-muted: #b4cef0;
  --footer-text-soft: #8eb4e8;
  --footer-link: #dbeafe;
  --footer-link-hover: #ffffff;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 0.22s;
  --dur-med: 0.38s;
}

* {
  box-sizing: border-box;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--bg-mid);
}

body > main.container {
  flex: 1 0 auto;
}

.container {
  width: min(1100px, 94%);
  margin: 22px auto 36px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

nav {
  position: relative;
  flex-shrink: 0;
  background: var(--nav-bar);
  border-bottom: 3px solid #1d4ed8;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  transition: box-shadow var(--dur-med) var(--ease-out);
  box-shadow: 0 8px 24px var(--primary-glow);
}

nav::before {
  content: "";
  display: block;
  height: 3px;
  background: var(--nav-top-bar);
}

nav:hover {
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.22);
}

.nav-inner {
  width: min(1100px, 94%);
  margin: 0 auto;
  min-height: 52px;
  padding: 8px 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* 頁首品牌（取代單一 strong） */
.nav-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(46vw, 360px);
  padding: 4px 10px 4px 0;
  margin-right: 4px;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  transition: background var(--dur-fast) var(--ease-out);
}

.nav-brand:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-brand-title {
  color: #ffffff;
  font-size: clamp(14px, 1.9vw, 17px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.nav-brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.nav-inner > .actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 1 0 auto;
  min-width: min-content;
  margin-left: auto;
  padding-bottom: 2px;
}

.nav-inner > .actions > a {
  flex-shrink: 0;
}

.nav-inner > .actions > a > button {
  padding: 8px 11px;
  font-size: 13px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.nav-auth {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.nav-auth .hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.92);
  max-width: 10.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 6px 22px var(--primary-glow);
  animation: fade-in-up var(--dur-med) var(--ease-out) both;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(37, 99, 235, 0.14);
  border-color: #93c5fd;
}

/* 內含營業項目捲動面板時，取消卡片上浮，避免 sticky／捲動內容與邊框「穿幫」 */
.card:has(.business-items-panel) {
  overflow: visible;
}
.card:has(.business-items-panel):hover {
  transform: none;
  box-shadow: 0 6px 22px var(--primary-glow);
  border-color: var(--line);
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  line-height: 1.45;
  font-weight: 700;
}

h1 {
  font-size: clamp(24px, 2.8vw, 32px);
}

p {
  margin-top: 0;
  line-height: 1.7;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--dur-fast) ease, opacity var(--dur-fast) ease;
}

a:hover {
  color: var(--primary-hover);
}

button {
  border: 1px solid var(--primary-hover);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease, border-color var(--dur-fast) ease;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: #ffffff;
  color: var(--primary-hover);
  border: 1px solid #93c5fd;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

button.secondary:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

button.secondary:active {
  box-shadow: none;
}

button.secondary.ja-danger {
  border-color: #fca5a5;
  color: #b91c1c;
}

button.secondary.ja-danger:hover {
  background: #fef2f2;
  border-color: #f87171;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #ffffff;
  margin-top: 6px;
  margin-bottom: 14px;
  font: inherit;
  color: var(--text);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

select {
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.company-type-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-color: #ffffff;
  background-image: 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='%232563eb' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  font-weight: 600;
  color: #1e3a8a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.company-type-select:hover {
  border-color: var(--primary);
  background-color: var(--primary-soft);
}

.field-note {
  margin: -6px 0 14px;
  line-height: 1.55;
}

.apply-name-check-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 6px 0 12px;
}

.apply-name-check-row .hint {
  margin: 0;
  flex: 1 1 200px;
}

/* 申辦頁：表單 + 設立預查側欄 */
.apply-main-grid {
  display: grid;
  gap: 20px;
  align-items: start;
}

@media (min-width: 960px) {
  .apply-main-grid {
    grid-template-columns: 1fr minmax(280px, 320px);
  }

  .apply-precheck-aside {
    position: sticky;
    top: 14px;
  }
}

.apply-precheck-aside {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px 16px 14px;
  background: var(--surface-soft);
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.08);
}

.apply-precheck-aside h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: #1e3a8a;
  letter-spacing: 0.02em;
}

.apply-precheck-lead {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
}

.apply-precheck-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.apply-precheck-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px 10px;
  padding: 10px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  line-height: 1.45;
}

.apply-precheck-row:last-child {
  border-bottom: none;
}

.apply-precheck-ic {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
}

.apply-precheck-ok .apply-precheck-ic {
  color: #15803d;
}

.apply-precheck-warn .apply-precheck-ic {
  color: #b45309;
}

.apply-precheck-fail .apply-precheck-ic {
  color: #b42318;
}

.apply-precheck-t {
  font-weight: 700;
  color: var(--text);
}

.apply-precheck-d {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}

.apply-precheck-summary {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.apply-precheck-summary--ok {
  background: #ecfdf3;
  color: #14532d;
  border: 1px solid #bbf7d0;
}

.apply-precheck-summary--warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.apply-precheck-summary--fail {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 1px;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 2px;
}

.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}

.company-grid .card {
  background: var(--surface);
  border-top-width: 3px;
  border-top-color: #3b82f6;
  margin-bottom: 0;
  border-radius: 12px;
}

.company-grid .card:nth-child(1) {
  animation-delay: 0.04s;
}
.company-grid .card:nth-child(2) {
  animation-delay: 0.08s;
}
.company-grid .card:nth-child(3) {
  animation-delay: 0.12s;
}
.company-grid .card:nth-child(4) {
  animation-delay: 0.16s;
}
.company-grid .card:nth-child(5) {
  animation-delay: 0.2s;
}
.company-grid .card:nth-child(6) {
  animation-delay: 0.24s;
}

.hint {
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hero {
  display: grid;
  gap: 14px;
}

.hero h1 {
  margin-bottom: 4px;
  color: #1e3a8a;
}

.hero-en {
  display: inline-block;
  font-weight: 600;
  font-size: clamp(16px, 2.4vw, 22px);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.hero-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  animation: fade-in-up var(--dur-med) var(--ease-out) both;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 8px 22px var(--primary-glow);
}

.stat-card .label {
  font-size: 13px;
  color: var(--muted);
}

.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--primary-hover);
}

.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.data-table th {
  background: var(--primary-soft);
  font-weight: 700;
  color: #1e3a8a;
}

.data-table tbody tr {
  transition: background var(--dur-fast) ease;
}

.data-table tbody tr:hover {
  background: var(--primary-soft);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.charter-table .charter-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.55;
}

.judgment-table td {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.55;
  vertical-align: top;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid #3b82f6;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #1e40af;
  background: #eff6ff;
}

.badge-admin {
  margin-left: 6px;
  vertical-align: middle;
  background: var(--primary-hover);
  color: #fff;
  border-color: #1e40af;
  animation: fade-in-up var(--dur-fast) var(--ease-out) both;
}

.notice-callout {
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
}

.notice-callout p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card:hover,
  .stat-card:hover,
  button:hover {
    transform: none;
  }
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.meta-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface);
}

.meta-item .k {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.meta-item .v {
  margin-top: 6px;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.45;
  color: #1e3a8a;
  word-break: break-word;
}

.nav-inner .hint {
  color: rgba(255, 255, 255, 0.88);
}

nav .actions a button {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  background: #ffffff;
  color: var(--primary-hover);
  border: 1px solid #bfdbfe;
}

nav .actions a button:hover {
  background: #ffffff;
  border-color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

nav .actions a button.secondary {
  background: rgba(255, 255, 255, 0.92);
  color: #1e40af;
  border: 1px solid rgba(255, 255, 255, 0.95);
}

nav .actions a button.secondary:hover {
  background: #ffffff;
  border-color: #ffffff;
}

nav .nav-auth button.secondary {
  background: rgba(255, 255, 255, 0.92);
  color: #1e40af;
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

nav .nav-auth button.secondary:hover {
  background: #ffffff;
  border-color: #ffffff;
}

/* —— 營業項目複選面板 —— */
.form-field-label {
  display: block;
  font-weight: 700;
  margin: 14px 0 8px;
  color: #1e3a8a;
}

.business-items-panel {
  max-height: min(480px, 58vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  position: relative;
  isolation: isolate;
  -webkit-overflow-scrolling: touch;
}

.biz-items-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: -6px -6px 12px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.06);
}

.biz-filter-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

.biz-filter-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.biz-filter-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  font: inherit;
}

.biz-selected-summary {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.biz-selected-summary strong {
  color: var(--primary);
  font-size: 16px;
}

.biz-legacy-block {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(37, 99, 235, 0.45);
  background: var(--primary-soft);
}

.biz-cat {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.biz-cat--empty-filter {
  display: none;
}

.biz-cat-summary {
  cursor: pointer;
  padding: 10px 36px 10px 12px;
  font-weight: 700;
  color: #1e40af;
  background: var(--primary-soft);
  list-style: none;
  position: relative;
}

.biz-cat-summary::-webkit-details-marker {
  display: none;
}

.biz-cat-summary::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--muted);
}

.biz-cat[open] > .biz-cat-summary::after {
  content: "▴";
}

.biz-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 6px;
  padding: 10px 10px 12px;
}

.biz-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.biz-check-row:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.biz-check-row--hidden {
  display: none !important;
}

.biz-check-row input.biz-item-check {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.biz-check-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* —— 登記狀態申辦 —— */
.status-actions-card {
  border-top-color: #3b6fb8;
}

.status-actions-gate {
  margin-top: 4px;
  margin-bottom: 0;
}

.status-actions-gate a {
  color: var(--primary);
  font-weight: 700;
}

.register-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 8px 0 14px;
}

.status-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.status-actions-row button {
  min-width: 120px;
}

/* —— 頁尾（與 nav 同藍系、純色） —— */
.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  background: var(--footer-bg);
  color: var(--footer-text);
  border-top: 1px solid var(--footer-border);
  padding: 28px 16px 32px;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: 0 -12px 32px rgba(30, 64, 175, 0.12);
}

.site-footer-inner {
  width: min(1100px, 94%);
  margin: 0 auto;
}

.site-footer-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--footer-divider);
}

.site-footer-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #f8fafc;
}

.site-footer-en {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--footer-text-soft);
}

.site-footer-legal {
  margin: 0 0 8px;
  color: var(--footer-text-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.site-footer-note {
  margin: 0 0 16px;
  color: var(--footer-text-soft);
  font-size: 12px;
  max-width: 52rem;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.site-footer-links a {
  color: var(--footer-link);
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.site-footer-links a:hover {
  color: var(--footer-link-hover);
  text-decoration: underline;
}

.site-footer-sep {
  color: rgba(147, 197, 253, 0.45);
  font-weight: 400;
  user-select: none;
}

@media (max-width: 768px) {
  .nav-brand {
    max-width: min(40vw, 220px);
  }

  .nav-inner > .actions > a > button {
    padding: 7px 9px;
    font-size: 12px;
  }

  .nav-auth .hint {
    max-width: 7.5rem;
  }

  .hero-search {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 14px;
  }
}
