:root {
  color: #334155;
  background: #f8fafc;
  font-family: "PingFang TC", "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #273548;
  --muted: #64748b;
  --line: #d8e0e9;
  --line-strong: #bec9d6;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --nav: #273548;
  --nav-soft: #35465c;
  --orange: #c75b12;
  --orange-dark: #9a3f08;
  --orange-soft: #fff4e8;
  --green: #287052;
  --green-soft: #e9f7f0;
  --red: #a92f2f;
  --red-soft: #fff0f0;
  --blue: #2563a9;
  --blue-soft: #edf5ff;
  --shadow: 0 12px 34px rgb(39 53 72 / 9%);
  --radius: 12px;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: #f8fafc; }
body { min-height: 100vh; margin: 0; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #f49a4a; outline-offset: 2px; }
.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; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; border-radius: 8px; color: #fff; background: var(--nav); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(18rem, .85fr) minmax(22rem, 1.15fr); background: var(--surface); }
.login-brand { display: grid; place-content: center; color: #fff; background: linear-gradient(135deg, rgb(39 53 72 / 94%), rgb(39 53 72 / 78%)), repeating-linear-gradient(45deg, transparent 0 24px, rgb(255 255 255 / 5%) 24px 25px); }
.login-brand p { margin: 16px 0 0; color: #cbd5e1; letter-spacing: .14em; text-transform: uppercase; }
.brand-mark { display: grid; width: 92px; height: 92px; place-items: center; border: 2px solid #f49a4a; border-radius: 20px 4px 20px 4px; color: #fff; font-size: 2rem; font-weight: 800; letter-spacing: -.05em; }
.brand-mark-small { width: 36px; height: 36px; border-radius: 9px 2px 9px 2px; font-size: .86rem; }
.login-card { align-self: center; width: min(31rem, calc(100% - 48px)); margin: auto; }
.eyebrow { margin: 0 0 8px; color: var(--orange-dark); font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.login-card h1 { margin: 0; color: var(--ink); font-size: clamp(2rem, 4vw, 3rem); line-height: 1.15; }
.login-intro { margin: 20px 0 28px; color: var(--muted); line-height: 1.75; }
label { display: block; margin: 18px 0 7px; color: var(--ink); font-size: .9rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; }
textarea { min-height: 104px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { color: #64748b; background: #eef2f6; }
.form-note { margin: 18px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.button, .icon-button { min-height: 44px; border: 1px solid transparent; border-radius: 8px; font-weight: 750; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; text-decoration: none; }
.button-primary { color: #fff; background: var(--orange); }
.button-primary:hover { background: var(--orange-dark); }
.button-secondary { color: var(--ink); border-color: var(--line-strong); background: #fff; }
.button-secondary:hover, .button-quiet:hover { background: var(--surface-soft); }
.button-danger { color: #fff; background: var(--red); }
.button-quiet { color: var(--ink); background: transparent; }
.button-block { width: 100%; margin-top: 24px; }
.button:disabled { cursor: not-allowed; opacity: .52; }
.icon-button { display: grid; width: 44px; padding: 0; place-items: center; color: #fff; background: transparent; }
.menu-glyph { display: grid; gap: 4px; width: 20px; }
.menu-glyph > span { display: block; height: 2px; border-radius: 999px; background: currentColor; }

.app-shell { min-height: 100vh; padding: 64px 0 0 248px; }
.topbar { position: fixed; inset: 0 0 auto 0; z-index: 30; height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; color: #fff; background: var(--nav); box-shadow: 0 2px 8px rgb(15 23 42 / 18%); }
.topbar-brand { display: flex; align-items: center; gap: 11px; color: #fff; font-weight: 800; text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user div { display: grid; text-align: right; }
.topbar-user span { color: #cbd5e1; font-size: .75rem; }
.topbar .button-quiet { color: #fff; }
.sidebar { position: fixed; inset: 64px auto 0 0; z-index: 25; width: 248px; display: flex; flex-direction: column; padding: 20px 14px; color: #dbe4ee; background: var(--nav-soft); }
.sidebar-context { display: flex; align-items: center; gap: 8px; padding: 8px 12px 18px; color: #cbd5e1; font-size: .78rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #55c48b; box-shadow: 0 0 0 3px rgb(85 196 139 / 14%); }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 10px 13px; border-radius: 8px; color: #e2e8f0; font-weight: 700; text-decoration: none; }
.nav-link:hover { background: rgb(255 255 255 / 7%); }
.nav-link[aria-current="page"] { color: #fff; background: var(--orange); }
.sidebar-help { margin-top: auto; padding: 15px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 9px; background: rgb(15 23 42 / 14%); }
.sidebar-help strong { color: #fff; font-size: .82rem; }
.sidebar-help p { margin: 7px 0 0; color: #cbd5e1; font-size: .75rem; line-height: 1.65; }
.main-content { width: 100%; max-width: 1500px; min-height: calc(100vh - 64px); padding: 28px clamp(18px, 3vw, 42px) 72px; }
.page-status { min-height: 1px; color: var(--muted); font-size: .85rem; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { margin: 3px 0 0; color: var(--ink); font-size: clamp(1.55rem, 3vw, 2.15rem); line-height: 1.2; }
.page-heading p { margin: 8px 0 0; color: var(--muted); line-height: 1.6; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: .85rem; }
.breadcrumb a { color: var(--blue); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 8px rgb(39 53 72 / 4%); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; color: var(--ink); font-size: 1.02rem; }
.panel-body { padding: 20px; }
.stack { display: grid; gap: 16px; }
.grid-2, .grid-3 { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-span-2 { grid-column: span 2; }
.field-help { margin: 6px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.required-mark { color: var(--red); }
.queue-tabs, .detail-tabs, .setting-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tab-button { min-height: 44px; flex: 0 0 auto; padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-weight: 750; }
.tab-button[aria-selected="true"] { color: var(--orange-dark); border-bottom-color: var(--orange); }
.filters { display: grid; grid-template-columns: minmax(12rem, 2fr) repeat(4, minmax(9rem, 1fr)) auto; gap: 10px; padding: 16px; }
.filters label { margin: 0; }
.filters .filter-label { display: block; margin-bottom: 5px; font-size: .75rem; }
.result-summary { display: flex; justify-content: space-between; gap: 15px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .84rem; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { color: #526174; background: #f7f9fb; font-size: .76rem; letter-spacing: .03em; }
.data-table td { font-size: .88rem; }
.data-table tbody tr:hover { background: #fffaf5; }
.data-table a { color: var(--blue); font-weight: 750; }
.table-wrap { overflow-x: auto; }
.mobile-cards { display: none; }
.equipment-card { display: grid; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.equipment-card:last-child { border-bottom: 0; }
.equipment-card-head { display: flex; justify-content: space-between; gap: 12px; }
.equipment-card strong { color: var(--ink); }
.meta-list { display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--muted); font-size: .82rem; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px; font-size: .74rem; font-weight: 800; white-space: nowrap; }
.badge-neutral { color: #526174; border-color: #d7dee7; background: #f2f5f8; }
.badge-warning { color: #91420d; border-color: #f5c99f; background: var(--orange-soft); }
.badge-success { color: #1f6044; border-color: #a9dbc3; background: var(--green-soft); }
.badge-danger { color: #8c2525; border-color: #efb8b8; background: var(--red-soft); }
.badge-info { color: #1e5791; border-color: #b8d4f2; background: var(--blue-soft); }
.empty-state { padding: 54px 24px; text-align: center; }
.empty-state h2 { margin: 0 0 8px; color: var(--ink); }
.empty-state p { margin: 0 auto 20px; max-width: 34rem; color: var(--muted); line-height: 1.65; }
.loading-grid { display: grid; gap: 12px; }
.skeleton { height: 58px; border-radius: 8px; background: linear-gradient(90deg, #eef2f6, #f8fafc, #eef2f6); background-size: 220% 100%; animation: shimmer 1.2s linear infinite; }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 22px; padding: 0; list-style: none; }
.stepper li { position: relative; display: grid; justify-items: center; gap: 7px; color: var(--muted); font-size: .78rem; text-align: center; }
.stepper li::before { content: ""; position: absolute; top: 17px; right: 50%; left: -50%; height: 2px; background: var(--line); }
.stepper li:first-child::before { display: none; }
.step-number { position: relative; z-index: 1; display: grid; width: 34px; height: 34px; place-items: center; border: 2px solid var(--line-strong); border-radius: 50%; color: var(--muted); background: #fff; font-weight: 800; }
.stepper .is-current, .stepper .is-complete { color: var(--ink); font-weight: 750; }
.stepper .is-current .step-number { color: #fff; border-color: var(--orange); background: var(--orange); }
.stepper .is-complete .step-number { color: #fff; border-color: var(--green); background: var(--green); }
.stepper .is-complete::before, .stepper .is-current::before { background: var(--green); }
.photo-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.photo-group { padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfd; }
.photo-group h3 { margin: 0; color: var(--ink); font-size: .96rem; }
.photo-group > p { margin: 7px 0 13px; min-height: 40px; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.photo-list { display: grid; gap: 9px; margin-bottom: 11px; }
.photo-item { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 9px; min-height: 60px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.photo-thumb { display: grid; width: 54px; height: 44px; place-items: center; overflow: hidden; border-radius: 5px; color: var(--muted); background: var(--surface-soft); font-size: .72rem; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-item-name { min-width: 0; }
.photo-item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.photo-item-actions .button { padding-inline: 8px; }
.photo-item-name strong { display: block; overflow: hidden; color: var(--ink); font-size: .79rem; text-overflow: ellipsis; white-space: nowrap; }
.photo-item-name span { color: var(--muted); font-size: .72rem; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; cursor: pointer; opacity: 0; }
.upload-state { min-height: 20px; margin-top: 7px; color: var(--muted); font-size: .78rem; }
.record-header { display: grid; grid-template-columns: 1fr auto; gap: 18px; margin-bottom: 18px; padding: 20px; border-left: 5px solid var(--orange); }
.record-header h1 { margin: 0; color: var(--ink); font-size: 1.65rem; }
.record-code { margin: 0 0 5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.record-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.definition-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.definition-grid div { min-height: 78px; padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.definition-grid div:nth-child(3n) { border-right: 0; }
.definition-grid dt { margin-bottom: 6px; color: var(--muted); font-size: .76rem; }
.definition-grid dd { margin: 0; color: var(--ink); font-weight: 650; line-height: 1.5; }
.risk-card { padding: 18px; border-left: 4px solid var(--orange); background: var(--orange-soft); }
.risk-card h3 { margin: 0 0 8px; color: var(--ink); }
.settings-grid { display: grid; gap: 20px; }
.settings-list { display: grid; }
.setting-row { display: grid; grid-template-columns: minmax(10rem, 1.2fr) minmax(12rem, 2fr) 7rem 7rem auto; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-code { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; }
.setting-description { color: var(--muted); font-size: .82rem; }
.error-summary { margin: 0 0 18px; padding: 13px 15px; border: 1px solid #e9adad; border-left: 5px solid var(--red); border-radius: 8px; color: #7d2525; background: var(--red-soft); line-height: 1.55; }
.notice { padding: 13px 15px; border: 1px solid #b9d4ef; border-left: 5px solid var(--blue); border-radius: 8px; color: #1c527f; background: var(--blue-soft); line-height: 1.6; }
.notice-warning { color: #81400f; border-color: #efc291; border-left-color: var(--orange); background: var(--orange-soft); }
.dialog { width: min(34rem, calc(100% - 28px)); padding: 0; border: 0; border-radius: 12px; box-shadow: 0 24px 72px rgb(15 23 42 / 24%); }
.dialog::backdrop { background: rgb(15 23 42 / 56%); }
.dialog-heading, #dialog-body, .dialog-actions { padding: 18px 20px; }
.dialog-heading { border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); background: #f8fafc; }
.toast { position: fixed; z-index: 80; right: 20px; bottom: 20px; max-width: min(28rem, calc(100% - 40px)); padding: 13px 16px; border-radius: 8px; color: #fff; background: var(--nav); box-shadow: var(--shadow); }
.mobile-only { display: none; }
@keyframes shimmer { to { background-position: -220% 0; } }
@media (max-width: 1050px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters > :first-child { grid-column: span 2; }
  .photo-groups { grid-template-columns: 1fr; }
  .photo-group > p { min-height: 0; }
}
@media (max-width: 800px) {
  .mobile-only { display: grid; }
  .app-shell { padding-left: 0; }
  .sidebar { transform: translateX(-105%); transition: transform .18s ease; box-shadow: 8px 0 30px rgb(15 23 42 / 22%); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 64px 0 0; z-index: 20; border: 0; background: rgb(15 23 42 / 44%); }
  .topbar { padding: 0 12px; }
  .topbar-brand { margin-right: auto; }
  .topbar-user span { display: none; }
  .main-content { padding-top: 22px; }
  .grid-3, .definition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .definition-grid div:nth-child(3n) { border-right: 1px solid var(--line); }
  .definition-grid div:nth-child(2n) { border-right: 0; }
  .setting-row { grid-template-columns: 1fr auto; }
  .setting-description, .setting-row > .badge:nth-of-type(1) { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-brand { min-height: 190px; }
  .login-brand .brand-mark { width: 66px; height: 66px; font-size: 1.4rem; }
  .login-brand p { font-size: .74rem; }
  .login-card { padding: 34px 0 48px; }
  .topbar-user strong { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .button { padding-inline: 8px; }
  .page-heading, .record-header { grid-template-columns: 1fr; }
  .page-heading { display: grid; }
  .page-actions { justify-content: stretch; }
  .page-actions .button { flex: 1 1 auto; }
  .filters { grid-template-columns: 1fr; }
  .filters > :first-child { grid-column: auto; }
  .desktop-table { display: none; }
  .mobile-cards { display: block; }
  .grid-2, .grid-3, .definition-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .definition-grid div, .definition-grid div:nth-child(2n), .definition-grid div:nth-child(3n) { border-right: 0; }
  .stepper li span:last-child { font-size: .68rem; }
  .stepper li::before { top: 15px; }
  .step-number { width: 30px; height: 30px; }
  .result-summary { display: grid; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
