:root {
  --ink: #10383c;
  --muted: #668083;
  --green: #138b71;
  --deep: #073f43;
  --mint: #e7f5f1;
  --line: #cfe2df;
  --paper: #ffffff;
  --bg: #f2f9f7;
  --amber: #f4b62f;
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% 10%, #fff 0, var(--bg) 55%, #e6f3ef 100%); }
button, input { font: inherit; }
button { cursor: pointer; }

.brand-header {
  min-height: 92px;
  padding: 14px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #fff;
  background: linear-gradient(120deg, #083d40, #0a5352);
}
.brand-lockup { display: flex; align-items: center; min-width: 0; gap: 14px; }
.brand-lockup img { width: 62px; height: 62px; border-radius: 18px; object-fit: cover; }
.brand-lockup div { display: grid; gap: 3px; }
.brand-lockup strong { font-size: clamp(19px, 2.2vw, 29px); white-space: nowrap; }
.brand-lockup span { color: #bfe0d7; font-size: 14px; }
.portal-page .brand-lockup div { display: flex; align-items: center; gap: 12px; }
.portal-page .brand-lockup span { font-size: 12px; white-space: nowrap; }
.login-page .brand-header { min-height: 60px; padding-block: 6px; }
.login-page .brand-lockup img { width: 44px; height: 44px; border-radius: 13px; }
.login-page .brand-lockup div { display: flex; align-items: center; gap: 12px; }
.login-page .brand-lockup strong { font-size: 22px; }
.login-page .brand-lockup span { font-size: 11px; white-space: nowrap; }
.login-page .system-pill { padding: 6px 11px; font-size: 12px; }
.system-pill, .face-verified {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.3); border-radius: 999px; white-space: nowrap;
}
.system-pill i { width: 10px; height: 10px; border-radius: 50%; background: #4ee0ac; box-shadow: 0 0 0 5px rgba(78,224,172,.15); }

.login-layout { width: min(1120px, calc(100% - 32px)); margin: 34px auto; display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 24px; align-items: start; }
.face-card, .qr-card, .welcome-card, .app-card {
  background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: 0 18px 50px rgba(5,63,66,.08);
}
.face-card { padding: clamp(24px, 4vw, 46px); text-align: center; }
.face-card h1, .qr-card h2, .welcome-card h1, .section-heading h2 { margin: 8px 0; }
.face-card h1 { font-size: clamp(30px, 4vw, 46px); }
.face-card > p { color: var(--muted); font-size: 17px; }
.eyebrow { color: var(--green); font-size: 14px; font-weight: 800; letter-spacing: .08em; }

.camera-shell {
  position: relative; width: min(390px, 78vw); aspect-ratio: 1; margin: 28px auto 18px;
  overflow: hidden; border-radius: 50%; background: #082e31;
  border: 7px solid transparent;
  background-image: linear-gradient(#082e31, #082e31), conic-gradient(#53e0bb, #56c9ff, #bc87ff, #ff91c7, #ffd56b, #53e0bb);
  background-origin: border-box; background-clip: padding-box, border-box;
  box-shadow: 0 0 0 5px rgba(52,202,168,.08), 0 20px 46px rgba(5,63,66,.16);
}
.camera-shell video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; color: #cde3df; background: #0a3538; }
.camera-placeholder[hidden] { display: none; }
.camera-shell.is-success { width: min(210px, 55vw); background-image: linear-gradient(#e4f8ef, #e4f8ef), conic-gradient(#53e0bb, #56c9ff, #bc87ff, #ff91c7, #ffd56b, #53e0bb); }
.camera-shell.is-success video, .camera-shell.is-success .scan-line { display: none; }
.camera-shell.is-success .camera-placeholder { color: #087257; background: linear-gradient(145deg, #effbf7, #d7f4e8); }
.camera-shell.is-success .camera-placeholder strong { font-size: 22px; }
.success-symbol { width: 82px; height: 82px; display: grid; place-items: center; margin: 0 auto 8px; border-radius: 50%; color: #fff; background: var(--green); font-size: 54px; font-weight: 900; line-height: 1; }
.face-symbol { font-size: 76px; font-weight: 200; color: #73d9c1; }
.scan-line { position: absolute; left: 15%; right: 15%; top: 50%; height: 3px; background: linear-gradient(90deg, transparent, #8ee8ff, #fff, #66e9b4, transparent); box-shadow: 0 0 12px #7ee7da; animation: scan 2.8s ease-in-out infinite; }
@keyframes scan { 0%,100% { transform: translateY(-85px); opacity: .5; } 50% { transform: translateY(85px); opacity: 1; } }

.status-message { min-height: 50px; width: min(520px, 100%); margin: 0 auto 14px; padding: 12px 18px; border-radius: 16px; background: var(--mint); font-size: 18px; font-weight: 750; }
.status-message[data-kind="success"] { color: #087257; background: #dcf6ea; }
.status-message[data-kind="error"] { color: #9b382f; background: #fff0ed; }
.primary-button, .secondary-button, .outline-button, .header-button { border-radius: 14px; font-weight: 800; }
.primary-button { width: min(420px, 100%); padding: 16px; color: #fff; background: var(--deep); border: 0; font-size: 20px; }
.primary-button:disabled { opacity: .7; cursor: wait; }
.privacy-note { font-size: 13px !important; }
.text-button { display: block; margin: 18px auto 0; border: 0; background: transparent; color: #567578; text-decoration: underline; }
.password-panel { width: min(420px, 100%); margin: 16px auto 0; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 12px; text-align: left; }
.password-panel[hidden] { display: none; }
.password-panel label { display: grid; gap: 6px; font-weight: 700; }
.password-panel input { width: 100%; padding: 13px; border: 1px solid #aac5c1; border-radius: 12px; }
.secondary-button { border: 0; color: #fff; background: var(--green); padding: 13px; }
.form-error { color: #a3342d !important; margin: 0; }

.qr-card { padding: 32px; text-align: center; }
.qr-card p { color: var(--muted); line-height: 1.65; }
.qr-card .text-button { display: block; margin: 18px auto 0; }
.qr-card .password-panel { text-align: left; }
.desktop-qr-login .login-layout { grid-template-columns: minmax(360px, 540px); justify-content: center; }
.desktop-qr-login .qr-card { width: 100%; }
.qr-frame { width: 250px; height: 250px; margin: 20px auto 12px; border: 1px solid var(--line); border-radius: 24px; display: grid; place-items: center; background: #fff; }
.qr-frame img { width: 220px; height: 220px; }
.qr-status { font-weight: 750; min-height: 44px; }
.outline-button { padding: 10px 18px; color: var(--deep); background: #fff; border: 1px solid #96bab6; }
.qr-card small { display: block; color: var(--muted); margin-top: 16px; }

.portal-main { width: min(1120px, calc(100% - 32px)); margin: 32px auto 60px; }
.pilot-banner { margin-bottom: 18px; padding: 14px 18px; display: flex; gap: 12px; align-items: center; border: 1px solid #efcf79; border-radius: 16px; color: #654b0b; background: #fff8dd; }
.pilot-banner strong { white-space: nowrap; }
.pilot-banner[hidden] { display: none; }
.welcome-card { padding: 28px 32px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.welcome-card h1 { font-size: clamp(26px, 4vw, 40px); }
.face-verified { color: #096d5b; border-color: #abd8cc; background: #ecf8f5; }
.reverify-notice { margin-top: 8px; color: #8a5700; font-size: 13px; font-weight: 700; text-align: right; }
.device-share { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 4px; color: var(--muted); font-size: 14px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 34px 8px 18px; gap: 20px; }
.muted { color: var(--muted); }
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.app-card { width: 100%; min-height: 126px; padding: 20px; display: grid; grid-template-columns: 54px 1fr auto; gap: 14px; align-items: center; color: inherit; text-align: left; text-decoration: none; }
button.app-card { border: 1px solid var(--line); }
button.app-card:hover, button.app-card:focus-visible { transform: translateY(-2px); border-color: #8fc4bb; box-shadow: 0 20px 52px rgba(5,63,66,.13); outline: none; }
.app-card strong { display: block; font-size: 20px; }
.app-card small { display: block; color: var(--muted); margin-top: 6px; }
.app-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; color: #fff; background: linear-gradient(140deg, var(--green), var(--deep)); font-size: 22px; font-weight: 850; }
.app-state { color: var(--green); font-weight: 750; white-space: nowrap; }
.app-state[data-health="online"]::before, .app-state[data-health="offline"]::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; vertical-align: 1px; background: #3bc89a; box-shadow: 0 0 0 4px rgba(59,200,154,.13); }
.app-state[data-health="offline"] { color: #9a5b14; }
.app-state[data-health="offline"]::before { background: #e7a242; box-shadow: 0 0 0 4px rgba(231,162,66,.14); }
.app-card.is-pending { opacity: .72; }
.portal-main[hidden], .embedded-workspace[hidden] { display: none; }
.workspace-open { overflow: hidden; }
.workspace-open .brand-header { height: 60px; min-height: 60px; padding-block: 6px; position: relative; }
.workspace-open .brand-lockup img { width: 44px; height: 44px; border-radius: 13px; }
.workspace-open .brand-lockup strong { font-size: 22px; }
.workspace-open .brand-lockup span { display: inline; font-size: 11px; }
.workspace-open .header-button { padding: 7px 12px; font-size: 14px; }
.header-workspace-title { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; line-height: 1.15; }
.workspace-current { display: grid; justify-items: center; gap: 1px; }
.workspace-current[hidden] { display: none; }
.header-workspace-title:has(.workspace-current[hidden]) { grid-template-columns: auto auto; }
.header-workspace-title:has(.workspace-current[hidden]) .workspace-fullscreen { grid-column: 2; }
.header-workspace-title[hidden] { display: none; }
.header-workspace-title span { color: #bfe0d7; font-size: 12px; font-weight: 750; letter-spacing: .08em; }
.header-workspace-title strong { color: #fff; font-size: 19px; white-space: nowrap; }
.embedded-workspace { height: calc(100dvh - 60px); display: flex; flex-direction: column; background: #edf6f4; }
.workspace-toolbar { min-height: 46px; padding: 4px max(12px, calc((100vw - 1120px) / 2)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: #fff; box-shadow: 0 3px 12px rgba(5,63,66,.07); z-index: 2; }
.workspace-mobile-title { display: none; }
.workspace-home { justify-self: start; }
.workspace-fullscreen { grid-column: 3; justify-self: end; }
.workspace-home, .workspace-fullscreen { padding: 7px 11px; border: 1px solid rgba(255,255,255,.4); border-radius: 9px; color: #fff; background: rgba(255,255,255,.1); font-size: 14px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.workspace-frame-wrap { position: relative; flex: 1; min-height: 0; }
.workspace-frame-wrap iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.workspace-loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; color: var(--muted); background: #f4faf8; font-size: 18px; font-weight: 800; }
.workspace-loading[hidden] { display: none; }
.header-button { color: #fff; padding: 10px 17px; border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.1); }
.header-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions [hidden] { display: none; }

.access-main { width: min(1320px, calc(100% - 32px)); margin: 30px auto 60px; }
.access-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.access-intro h1 { margin: 6px 0 0; font-size: clamp(28px, 4vw, 40px); }
.access-intro p { color: var(--muted); }
.admin-panel { margin-top: 20px; padding: 24px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 16px 44px rgba(5,63,66,.07); }
.panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 18px; }
.panel-heading h2 { margin: 5px 0 0; }
.panel-note { margin: -6px 0 18px; color: var(--muted); }
.compact { width: auto; padding: 10px 16px; }
.app-config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.app-config-card { display: grid; gap: 10px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: #f8fcfb; }
.app-config-head, .app-config-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-config-head strong { font-size: 19px; }
.app-config-card > label, .credential-fields > label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }
.app-config-card input, .credential-fields input { width: 100%; padding: 11px 12px; border: 1px solid #aac5c1; border-radius: 11px; background: #fff; }
.role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.role-card { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: #f8fcfb; }
.role-card h3 { margin: 0 0 14px; }
.permission-check { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; cursor: pointer; }
.permission-check input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--green); }
.permission-check span { min-width: 0; }
.permission-check strong, .permission-check small { display: block; }
.permission-check small { margin-top: 2px; color: var(--muted); }
.search-field { display: grid; gap: 6px; min-width: min(340px, 100%); color: var(--muted); font-weight: 700; }
.search-field input, .identity-fields input, .identity-fields select { width: 100%; padding: 11px 12px; border: 1px solid #aac5c1; border-radius: 11px; background: #fff; }
.employee-list { display: grid; gap: 16px; }
.employee-access-card { padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: #fff; }
.employee-access-card[hidden] { display: none; }
.employee-summary { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.employee-summary h3 { margin: 8px 0; font-size: 24px; }
.pair-badge, .face-chip { display: inline-flex; align-items: center; border-radius: 999px; font-weight: 750; }
.pair-badge { padding: 5px 10px; font-size: 13px; }
.pair-badge.paired { color: #087257; background: #dcf6ea; }
.pair-badge.waiting { color: #825e0a; background: #fff3cb; }
.face-list { display: flex; flex-wrap: wrap; gap: 7px; }
.face-chip { padding: 5px 9px; color: #315e60; background: #edf7f5; font-size: 13px; }
.identity-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.identity-fields label { display: grid; align-content: center; gap: 6px; color: var(--muted); font-weight: 700; }
.switch-label { display: flex !important; grid-auto-flow: column; justify-content: start; align-items: center; gap: 8px !important; }
.switch-label input, .inherit-row input { width: 19px; height: 19px; accent-color: var(--green); }
.credential-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; margin: 0 0 16px; padding: 14px; border: 1px dashed #bdd2cf; border-radius: 14px; background: #fbfdfd; }
.inherit-row { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; }
.employee-permissions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; margin-top: 10px; padding: 12px 16px; border-radius: 14px; background: #f6fbfa; }
.employee-permissions.is-inherited { opacity: .65; }
.save-status { min-height: 22px; margin: 10px 0 0; font-weight: 750; }
.save-status[data-kind="success"] { color: #087257; }
.save-status[data-kind="error"] { color: #a3342d; }
.audit-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.audit-row { display: grid; grid-template-columns: 170px 160px 190px 1fr; gap: 12px; align-items: center; padding: 11px 14px; background: #fff; border-bottom: 1px solid #e4eeec; }
.audit-row:last-child { border-bottom: 0; }
.audit-row time, .audit-row small { color: var(--muted); }
.audit-row small { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .login-page .brand-lockup div { gap: 7px; }
  .login-page .brand-lockup strong { font-size: 18px; }
  .login-page .brand-lockup span { font-size: 10px; }
  .portal-page .brand-lockup div { gap: 7px; }
  .portal-page .brand-lockup span { font-size: 10px; }
  .login-layout { grid-template-columns: 1fr; }
  .qr-card { max-width: 540px; width: 100%; margin: 0 auto; }
  .app-grid { grid-template-columns: repeat(2, 1fr); }
  .role-grid { grid-template-columns: 1fr; }
  .identity-fields, .credential-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-row { grid-template-columns: 150px 1fr 1fr; }
  .audit-row small { grid-column: 1 / -1; }
  .workspace-open .brand-header { height: 94px; min-height: 94px; align-items: start; padding-block: 5px; }
  .workspace-open .brand-lockup img { width: 36px; height: 36px; }
  .workspace-open .brand-lockup strong { font-size: 18px; }
  .header-workspace-title { top: auto; bottom: 5px; transform: translateX(-50%); gap: 14px; }
  .workspace-current span { display: none; }
  .header-workspace-title strong { font-size: 16px; }
  .embedded-workspace { height: calc(100dvh - 94px); }
  .workspace-mobile-title { display: grid; justify-items: center; gap: 0; line-height: 1.1; }
  .workspace-mobile-title .eyebrow { display: none; }
  .workspace-mobile-title strong { font-size: 15px; white-space: nowrap; }
}
@media (max-width: 620px) {
  .login-page .brand-header { min-height: 56px; padding: 6px 12px; }
  .login-page .brand-lockup img { width: 40px; height: 40px; }
  .login-page .brand-lockup strong { font-size: 18px; }
  .brand-header { min-height: 84px; padding: 12px 16px; }
  .brand-lockup img { width: 54px; height: 54px; }
  .brand-lockup span, .system-pill { display: none; }
  .login-layout { width: min(100% - 20px, 560px); margin: 18px auto; }
  .face-card { border-radius: 22px; padding: 24px 16px; }
  .camera-shell { width: min(330px, 82vw); }
  .portal-main { width: min(100% - 20px, 560px); margin-top: 18px; }
  .pilot-banner { display: grid; gap: 5px; }
  .welcome-card { display: block; padding: 22px; }
  .face-verified { margin-top: 16px; }
  .section-heading { align-items: start; }
  .app-grid { grid-template-columns: 1fr; }
  .app-card { grid-template-columns: 50px 1fr; }
  .app-state { grid-column: 2; }
  .access-main { width: min(100% - 20px, 620px); margin-top: 18px; }
  .access-intro, .panel-heading, .employee-summary { align-items: stretch; flex-direction: column; }
  .admin-panel { padding: 18px 14px; }
  .app-config-grid, .identity-fields, .credential-fields, .employee-permissions { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 1fr; gap: 4px; }
  .audit-row small { grid-column: auto; }
  .header-actions { gap: 6px; }
  .header-button { padding: 9px 11px; }
  .workspace-open .brand-header { height: 88px; min-height: 88px; padding: 5px 10px; gap: 6px; }
  .workspace-open .brand-lockup { gap: 6px; }
  .workspace-open .brand-lockup img { width: 32px; height: 32px; }
  .workspace-open .brand-lockup strong { font-size: 15px; }
  .portal-page .brand-lockup span, .workspace-open .brand-lockup span { display: none; }
  .workspace-open .header-button { padding: 6px 7px; font-size: 12px; }
  .embedded-workspace { height: calc(100dvh - 88px); }
  .workspace-toolbar { min-height: 48px; grid-template-columns: 1fr auto 1fr; gap: 6px; padding: 4px 8px; }
  .workspace-mobile-title { display: grid; justify-items: center; gap: 0; line-height: 1.1; }
  .workspace-mobile-title .eyebrow { display: none; }
  .workspace-mobile-title strong { font-size: 15px; white-space: nowrap; }
  .workspace-home, .workspace-fullscreen { padding: 7px 9px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) { .scan-line { animation: none; } }

/* Compact signed-in platform bar. */
.portal-page .brand-header { position: relative; height: 44px; min-height: 44px; padding: 4px 20px; gap: 10px; }
.portal-page .brand-lockup { gap: 8px; }
.portal-page .brand-lockup img { width: 34px; height: 34px; border-radius: 10px; }
.portal-page .brand-lockup strong { font-size: 18px; }
.portal-page .brand-lockup span { font-size: 10px; }
.portal-page .header-button { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.portal-page.workspace-open .brand-header { height: 34px; min-height: 34px; padding-block: 3px; }
.portal-page.workspace-open .brand-lockup img { width: 28px; height: 28px; border-radius: 8px; }
.portal-page.workspace-open .brand-lockup strong { font-size: 16px; }
.portal-page.workspace-open .brand-lockup span { font-size: 9px; }
.portal-page .header-workspace-title { gap: 12px; }
.portal-page .workspace-current span { display: none; }
.portal-page .header-workspace-title strong { font-size: 15px; }
.portal-page .workspace-home, .portal-page .workspace-fullscreen { padding: 4px 8px; font-size: 12px; border-radius: 7px; }
.portal-page .embedded-workspace { height: calc(100dvh - 34px); }
@media (max-width: 1100px) {
  .portal-page .brand-lockup span { display: none; }
}
@media (max-width: 900px) {
  .portal-page .brand-header { height: 68px; min-height: 68px; align-items: start; }
  .portal-page.workspace-open .brand-header { height: 58px; min-height: 58px; align-items: start; }
  .portal-page .header-workspace-title { bottom: 3px; }
  .portal-page .embedded-workspace { height: calc(100dvh - 58px); }
}
@media (max-width: 620px) {
  .portal-page .brand-header { padding-inline: 8px; }
  .portal-page .brand-lockup strong { font-size: 14px; }
  .portal-page.workspace-open .brand-lockup strong { font-size: 14px; }
  .portal-page .header-actions { gap: 4px; }
  .portal-page .header-button { padding: 4px 6px; font-size: 11px; }
}
