:root{
  font-family:Inter,"Noto Sans TC","Microsoft JhengHei",system-ui,sans-serif;
  color:#f8fafc;background:#0b1118;line-height:1.55;
  --bg:#0b1118;--surface:#111923;--surface-2:#17212d;--surface-3:#1d2937;
  --line:#2b3949;--muted:#91a0b2;--text:#f8fafc;--accent:#65a7ff;--accent-2:#2f77d0;
  --success:#3fa36c;--danger:#c94b43;--warning:#d89932;--shadow:0 18px 50px rgba(0,0,0,.28)
}
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:radial-gradient(circle at top,#132332 0,#0b1118 38%,#080d12 100%);color:var(--text)}button,input,select,textarea{font:inherit}button{cursor:pointer}a{color:inherit;text-decoration:none}.hidden{display:none!important}.muted{color:var(--muted)}

.portal-shell{width:min(920px,calc(100% - 28px));margin:0 auto;padding:48px 0 34px;min-height:100vh}.brand-header{display:flex;align-items:center;justify-content:center;gap:18px;text-align:left;margin:0 auto 28px}.brand-header h1{font-size:clamp(30px,5vw,48px);line-height:1.1;margin:4px 0}.brand-subtitle{margin:0;color:var(--muted)}.brand-mark{width:52px;height:52px;border-radius:16px;background:linear-gradient(135deg,#6db3ff,#2e68b6);display:grid;place-items:center;font-weight:900;letter-spacing:.08em;box-shadow:0 10px 30px rgba(61,126,219,.32)}.brand-mark.large{width:68px;height:68px;border-radius:20px;margin:0 auto 16px;font-size:22px}.eyebrow,.section-kicker{margin:0;color:#7db7ff;font-size:12px;font-weight:900;letter-spacing:.18em}.card{background:linear-gradient(180deg,rgba(20,29,40,.98),rgba(13,20,29,.98));border:1px solid var(--line);border-radius:22px;padding:28px;box-shadow:var(--shadow)}.portal-card{margin:18px 0}.card-title-row{display:flex;gap:14px;align-items:center;margin-bottom:22px}.card-title-row h2,.section-heading h2{margin:2px 0 0;font-size:22px}.step-badge{width:46px;height:46px;border-radius:14px;background:rgba(101,167,255,.14);color:#8dc0ff;border:1px solid rgba(101,167,255,.32);display:grid;place-items:center;font-weight:900}.grid{display:grid;gap:16px}.grid.two{grid-template-columns:1fr 1fr}.grid.four{grid-template-columns:repeat(4,minmax(0,1fr))}.full{grid-column:1/-1}label{display:block;font-size:14px;font-weight:800;margin:12px 0 7px;color:#dce6f2}input,select,textarea{width:100%;padding:13px 15px;border:1px solid #354557;border-radius:12px;background:#0f1720;color:#fff;outline:none;transition:.2s}textarea{min-height:76px;resize:vertical}input:focus,select:focus,textarea:focus{border-color:#69a9ff;box-shadow:0 0 0 4px rgba(101,167,255,.12)}input::placeholder,textarea::placeholder{color:#657386}.field-help{display:block;font-size:12px;color:var(--muted);margin-top:6px}.license-options{display:flex;align-items:center;justify-content:space-between;gap:12px}.check-row{display:flex;align-items:center;gap:8px;font-weight:700;margin:10px 0}.check-row input,.backup-check{width:auto;margin:0}.text-button{width:auto;border:0;background:transparent;color:#8dbfff;padding:4px;margin:0;font-weight:800}.primary-action,.secondary-action,button{border:0;border-radius:12px;background:linear-gradient(135deg,#4d8fe3,#2c67b2);color:#fff;font-weight:900;padding:13px 18px}.primary-action,.secondary-action{width:100%;margin-top:18px}.secondary-action,.secondary{background:#445263}.danger{background:#b9433d!important}.small{width:auto;margin:0;padding:8px 12px;font-size:13px}.tiny{width:auto!important;margin:0 0 0 6px!important;padding:4px 7px!important;font-size:11px!important}.notice{margin:18px 0 0;padding:15px 16px;border-radius:14px;background:rgba(216,153,50,.12);border:1px solid rgba(216,153,50,.36);display:flex;flex-direction:column}.license-status{margin:16px 0 0;padding-top:14px;border-top:1px solid var(--line);overflow-wrap:anywhere}.success-card{text-align:center}.success-icon{width:68px;height:68px;margin:0 auto 12px;border-radius:22px;display:grid;place-items:center;background:linear-gradient(135deg,#4cad78,#287a51);font-size:38px;font-weight:900}.success-card h2{font-size:30px;margin:4px 0 18px}.success-card dl{display:grid;grid-template-columns:1fr 1fr;gap:12px;text-align:left}.success-card dl div{background:var(--surface-2);padding:15px;border-radius:14px;border:1px solid rgba(255,255,255,.04)}.success-card dt{font-size:12px;color:var(--muted)}.success-card dd{margin:3px 0 0;font-weight:900;font-size:18px}.important{font-weight:900;color:#ff9b72}.portal-footer{text-align:center;color:#637083;font-size:12px;margin-top:26px}
.toast{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);width:max-content;max-width:min(520px,calc(100vw - 36px));padding:17px 24px;border-radius:14px;background:#243143;color:#fff;box-shadow:0 20px 60px rgba(0,0,0,.48);z-index:9999;text-align:center;font-weight:900;word-break:break-word}.toast.error{background:#9e382f}.toast.success{background:#2f754f}

.admin-login-screen{min-height:100vh;display:grid;place-items:center;padding:24px}.login-panel{width:min(440px,100%);padding:36px;background:rgba(16,24,34,.98);border:1px solid var(--line);border-radius:24px;box-shadow:var(--shadow);text-align:center}.login-panel h1{font-size:34px;margin:4px 0}.login-panel label{text-align:left}.admin-layout{display:grid;grid-template-columns:250px minmax(0,1fr);min-height:100vh}.admin-sidebar{position:sticky;top:0;height:100vh;padding:24px 18px;background:#0a1119;border-right:1px solid #253241;display:flex;flex-direction:column}.sidebar-brand{display:flex;align-items:center;gap:12px;padding:2px 6px 26px}.sidebar-brand strong{display:block}.sidebar-brand small{display:block;color:var(--muted)}.sidebar-nav{display:grid;gap:7px}.sidebar-nav a{padding:12px 14px;border-radius:11px;color:#aebac8;font-weight:800}.sidebar-nav a:hover,.sidebar-nav a.active{background:rgba(101,167,255,.12);color:#90c2ff}.sidebar-logout{margin-top:auto;width:100%;background:#2a3543}.admin-main{min-width:0;padding:30px clamp(18px,3vw,42px) 70px}.admin-topbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:24px}.admin-topbar h1{margin:2px 0;font-size:32px}.status-pill{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:999px;background:rgba(63,163,108,.12);color:#81d5a5;border:1px solid rgba(63,163,108,.28);font-size:13px;font-weight:800}.status-pill span{width:8px;height:8px;border-radius:50%;background:#57c986;box-shadow:0 0 0 5px rgba(87,201,134,.1)}.dashboard-section,.admin-card{scroll-margin-top:22px;margin-bottom:20px}.section-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:18px}.stats-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.stat-card{padding:20px;border-radius:18px;background:linear-gradient(180deg,#172331,#111a25);border:1px solid var(--line)}.stat-card span{display:block;color:var(--muted);font-size:13px}.stat-card strong{display:block;font-size:30px;margin-top:6px}.admin-card{padding:24px}.duration-row,.search-row,.actions,.batch-toolbar,.new-key{display:flex;gap:9px;align-items:center}.duration-row input{flex:1}.duration-row select{width:120px}.search-row{margin:12px 0 16px}.search-row input{min-width:180px;max-width:520px}.search-row button{flex:0 0 auto}.table-wrap{overflow:auto;border:1px solid var(--line);border-radius:14px}table{width:100%;border-collapse:collapse;min-width:990px}th,td{text-align:left;padding:12px 10px;border-bottom:1px solid #293746;font-size:13px;vertical-align:middle}th{background:#18222d;color:#aebaca;position:sticky;top:0;z-index:1}tbody tr:hover{background:rgba(101,167,255,.035)}.action-cell{white-space:nowrap;width:1%}.actions{flex-wrap:nowrap}.actions button{width:auto;margin:0;padding:7px 10px;font-size:12px}.note-cell{white-space:normal;overflow-wrap:anywhere;word-break:break-word;min-width:250px;max-width:440px}.note-display{display:flex;align-items:flex-start;gap:8px}.note-display span{flex:1;white-space:pre-wrap}.note-editor{display:grid;gap:8px}.note-editor textarea{min-width:240px}.note-editor-actions{display:flex;gap:6px}.note-editor-actions button{margin:0;width:auto;padding:6px 9px;font-size:12px}.new-key{justify-content:space-between;margin-top:16px;padding:16px;background:rgba(63,163,108,.12);border:1px solid rgba(63,163,108,.35);border-radius:14px;font-size:17px;font-weight:800;word-break:break-all}.batch-toolbar{flex-wrap:wrap;margin:12px 0 16px}.backup-group{border:1px solid var(--line);border-radius:14px;margin:10px 0;overflow:hidden;background:#101923}.backup-group-head{width:100%;margin:0;border-radius:0;background:#18232f;color:#fff;text-align:left;display:flex;align-items:center;gap:10px}.backup-group-head small{margin-left:auto;color:#9cabbc}.backup-group-body{padding:0 8px 8px}.backup-group-body table{min-width:980px}
@media(max-width:1050px){.grid.four,.stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.admin-layout{grid-template-columns:210px minmax(0,1fr)}}
@media(max-width:760px){.portal-shell{padding-top:24px}.brand-header{align-items:flex-start;justify-content:flex-start}.brand-header .brand-mark{display:none}.brand-header h1{font-size:31px}.card{padding:20px;border-radius:18px}.grid.two,.grid.four,.stats-grid{grid-template-columns:1fr}.success-card dl{grid-template-columns:1fr}.admin-layout{display:block}.admin-sidebar{position:relative;width:100%;height:auto;padding:14px}.sidebar-brand{padding-bottom:12px}.sidebar-nav{grid-template-columns:repeat(4,1fr);overflow:auto}.sidebar-nav a{text-align:center;font-size:12px;padding:9px}.sidebar-logout{margin-top:12px}.admin-main{padding:20px 12px 60px}.admin-topbar{align-items:flex-start}.status-pill{display:none}.search-row,.duration-row,.new-key{align-items:stretch;flex-direction:column}.duration-row select{width:100%}.search-row input{max-width:none}.search-row button,.new-key button{width:100%}.batch-toolbar{align-items:stretch;flex-direction:column}.batch-toolbar button{width:100%}.note-cell{min-width:220px;max-width:280px}.action-cell{position:static;background:transparent}}

/* v1.0.1 前台 App 式圖文教學 */
.tutorial-panel{margin:0 0 22px;border:1px solid rgba(101,167,255,.28);border-radius:16px;overflow:hidden;background:rgba(101,167,255,.055)}
.return-tutorial-panel{margin:22px 0 2px;text-align:left}
.tutorial-toggle{width:100%;margin:0;padding:15px 17px;border-radius:0;background:transparent;display:flex;align-items:center;justify-content:space-between;gap:16px;text-align:left;color:var(--text)}
.tutorial-toggle:hover{background:rgba(101,167,255,.08)}
.tutorial-toggle span:first-child{display:grid;gap:2px}
.tutorial-toggle strong{font-size:15px}
.tutorial-toggle small{font-size:12px;color:var(--muted);font-weight:700}
.tutorial-toggle-icon{display:grid;place-items:center;flex:0 0 34px;width:34px;height:34px;border-radius:11px;background:rgba(101,167,255,.13);color:#8ec0ff;font-size:22px;line-height:1}
.tutorial-content{border-top:1px solid rgba(101,167,255,.22);padding:18px}
.tutorial-app{display:grid;gap:16px}
.tutorial-progress{display:flex;align-items:center;gap:12px;color:#a9b7c6;font-size:12px;font-weight:900;letter-spacing:.06em}
.tutorial-progress>div{height:6px;flex:1;background:#233143;border-radius:999px;overflow:hidden}
.tutorial-progress i{display:block;height:100%;width:0;background:linear-gradient(90deg,#65a7ff,#70d3c3);border-radius:inherit;transition:width .25s ease}
.tutorial-stage{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(230px,.55fr);gap:18px;align-items:center}
.tutorial-image-wrap{position:relative;overflow:hidden;border-radius:15px;border:1px solid #34465a;background:#060a0f;box-shadow:0 18px 38px rgba(0,0,0,.28)}
.tutorial-image-wrap img{display:block;width:100%;height:auto;max-height:520px;object-fit:contain;background:#05090d;cursor:zoom-in}
.tutorial-callout{position:absolute;border:4px solid #ff544d;border-radius:14px;box-shadow:0 0 0 9999px rgba(0,0,0,.20),0 0 24px rgba(255,84,77,.85);pointer-events:none;animation:tutorialPulse 1.6s ease-in-out infinite}
.tutorial-callout::after{content:"";position:absolute;left:50%;bottom:-24px;transform:translateX(-50%);border-left:12px solid transparent;border-right:12px solid transparent;border-top:18px solid #ff544d;filter:drop-shadow(0 3px 3px rgba(0,0,0,.35))}
.tutorial-callout span{position:absolute;left:50%;bottom:-54px;transform:translateX(-50%);white-space:nowrap;padding:6px 10px;border-radius:9px;background:#d93f39;color:#fff;font-size:12px;font-weight:900;box-shadow:0 8px 20px rgba(0,0,0,.32)}
@keyframes tutorialPulse{0%,100%{box-shadow:0 0 0 9999px rgba(0,0,0,.20),0 0 16px rgba(255,84,77,.55)}50%{box-shadow:0 0 0 9999px rgba(0,0,0,.20),0 0 31px rgba(255,84,77,1)}}
.tutorial-copy{padding:8px 4px}
.tutorial-step-label{margin:0 0 5px;color:#7db7ff;font-size:12px;font-weight:900;letter-spacing:.18em}
.tutorial-copy h3{margin:0 0 10px;font-size:clamp(20px,3vw,27px);line-height:1.3}
.tutorial-copy p:last-child{margin:0;color:#b9c5d2;line-height:1.75}
.tutorial-nav{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.tutorial-nav-button{width:100%;margin:0;padding:11px 14px}
.tutorial-nav-button:disabled{opacity:.38;cursor:not-allowed}
.tutorial-dots{display:flex;justify-content:center;gap:8px}
.tutorial-dots button{width:9px;height:9px;min-width:9px;padding:0;border-radius:50%;background:#415063;transition:.2s}
.tutorial-dots button.active{width:26px;border-radius:999px;background:#65a7ff}

@media(max-width:760px){
  .tutorial-content{padding:12px}
  .tutorial-stage{grid-template-columns:1fr;gap:12px}
  .tutorial-image-wrap img{max-height:none}
  .tutorial-copy{padding:3px 2px 0}
  .tutorial-copy h3{font-size:21px}
  .tutorial-callout{border-width:3px;border-radius:10px}
  .tutorial-callout span{font-size:10px;bottom:-46px;padding:5px 8px}
  .tutorial-callout::after{bottom:-20px;border-left-width:9px;border-right-width:9px;border-top-width:14px}
}


/* v1.0.2 教學標示修正與圖片燈箱 */
.tutorial-callout.label-above::after{top:-22px;bottom:auto;border-top:18px solid #ff544d;border-bottom:0}
.tutorial-callout.label-above span{top:-55px;bottom:auto}
body.lightbox-open{overflow:hidden}
.tutorial-lightbox{position:fixed;inset:0;z-index:12000;display:grid;place-items:center;padding:28px;background:rgba(0,0,0,.88);backdrop-filter:blur(8px)}
.tutorial-lightbox.hidden{display:none}
.tutorial-lightbox-stage{position:relative;max-width:min(96vw,1500px);max-height:92vh;overflow:visible;border:1px solid #536579;border-radius:16px;background:#05090d;box-shadow:0 30px 100px rgba(0,0,0,.75)}
.tutorial-lightbox-stage img{display:block;max-width:96vw;max-height:92vh;width:auto;height:auto;object-fit:contain;border-radius:15px;cursor:zoom-out}
.tutorial-lightbox-close{position:fixed;top:18px;right:22px;z-index:1;width:46px;height:46px;min-width:46px;margin:0;padding:0;border-radius:50%;background:#253548;color:#fff;font-size:30px;line-height:1;box-shadow:0 12px 30px rgba(0,0,0,.45)}
.tutorial-lightbox-callout{z-index:2}
@media(max-width:760px){
  .tutorial-callout.label-above::after{top:-18px;border-left-width:9px;border-right-width:9px;border-top-width:14px}
  .tutorial-callout.label-above span{top:-47px;bottom:auto}
  .tutorial-lightbox{padding:12px}
  .tutorial-lightbox-stage img{max-width:96vw;max-height:88vh}
  .tutorial-lightbox-close{top:10px;right:10px;width:40px;height:40px;min-width:40px;font-size:26px}
}


/* v1.0.3 教學標籤穩定定位 */
.tutorial-callout.label-above::after{top:-19px;bottom:auto;border-left:11px solid transparent;border-right:11px solid transparent;border-top:16px solid #ff544d}
.tutorial-callout.label-above span{top:-48px;bottom:auto;max-width:min(260px,70vw);overflow:hidden;text-overflow:ellipsis}
@media(max-width:760px){
  .tutorial-callout.label-above::after{top:-15px;border-left-width:8px;border-right-width:8px;border-top-width:12px}
  .tutorial-callout.label-above span{top:-40px;bottom:auto;max-width:68vw}
}


/* v1.0.4：放大教學圖片改用內嵌標示圖，避免紅框漂移 */
.tutorial-lightbox-stage{overflow:hidden}
.tutorial-lightbox-stage img{display:block;max-width:96vw;max-height:92vh;width:auto;height:auto;object-fit:contain}


/* v1.0.5：燈箱直接顯示原圖，標示依圖片比例同步定位 */
.tutorial-lightbox-stage{
  position:relative;
  display:inline-block;
  width:auto;
  height:auto;
  max-width:96vw;
  max-height:92vh;
  overflow:visible;
  line-height:0;
  background:#05090d;
}
.tutorial-lightbox-stage img{
  display:block;
  width:auto;
  height:auto;
  max-width:96vw;
  max-height:92vh;
  object-fit:contain;
}
.tutorial-lightbox-callout{
  z-index:3;
  line-height:1.25;
  box-shadow:0 0 0 2px rgba(255,255,255,.18),0 0 28px rgba(255,84,77,.95);
  animation:tutorialLightboxPulse 1.6s ease-in-out infinite;
}
.tutorial-lightbox-callout span{
  font-size:clamp(14px,1.55vw,24px);
  padding:8px 14px;
  border-radius:11px;
}
@keyframes tutorialLightboxPulse{
  0%,100%{box-shadow:0 0 0 2px rgba(255,255,255,.14),0 0 18px rgba(255,84,77,.65)}
  50%{box-shadow:0 0 0 2px rgba(255,255,255,.22),0 0 34px rgba(255,84,77,1)}
}
@media(max-width:760px){
  .tutorial-lightbox-stage,.tutorial-lightbox-stage img{max-width:96vw;max-height:88vh}
  .tutorial-lightbox-callout span{font-size:clamp(12px,3.6vw,18px);padding:6px 9px}
}


/* v1.1.0 詢問碼綁定歷史與再次綁定審核 */
body.modal-open{overflow:hidden}
.history-modal{position:fixed;inset:0;z-index:11000;display:grid;place-items:center;padding:24px}
.history-modal.hidden{display:none}
.history-modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.78);backdrop-filter:blur(6px)}
.history-modal-panel{position:relative;width:min(820px,96vw);max-height:88vh;overflow:auto;padding:24px;border:1px solid var(--line);border-radius:20px;background:#101923;box-shadow:0 30px 100px rgba(0,0,0,.7)}
.history-modal-panel>header{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:18px}
.history-modal-panel h2{margin:2px 0 0}
.history-modal-panel header button{width:auto;margin:0}
.history-warning{padding:16px;margin-bottom:18px;border:1px solid rgba(255,92,83,.48);border-radius:15px;background:rgba(255,92,83,.1)}
.history-warning>strong{color:#ff958f;font-size:16px}.history-warning>p{margin:6px 0 12px;color:#c7d1dc}
.history-warning article{display:flex;justify-content:space-between;align-items:center;gap:14px;padding:12px;margin-top:8px;border-radius:12px;background:#172331}
.history-warning article small{display:block;color:var(--muted);margin-top:4px}.history-warning .actions{flex-wrap:wrap}
.history-timeline{position:relative;display:grid;gap:0;padding-left:22px}
.history-timeline::before{content:"";position:absolute;left:7px;top:8px;bottom:8px;width:2px;background:#34465a}
.history-event{position:relative;padding:0 0 20px 18px}.history-event:last-child{padding-bottom:0}
.history-dot{position:absolute;left:-21px;top:5px;width:13px;height:13px;border-radius:50%;background:#65a7ff;border:3px solid #101923;box-shadow:0 0 0 2px #65a7ff}
.history-event.unbound .history-dot,.history-event.rebin_rejected .history-dot{background:#ff6d65;box-shadow:0 0 0 2px #ff6d65}
.history-event.rebound .history-dot,.history-event.rebin_approved .history-dot{background:#70d3a0;box-shadow:0 0 0 2px #70d3a0}
.history-event>div{padding:13px 15px;border-radius:13px;background:#172331;border:1px solid #263648}
.history-event-head{display:flex;justify-content:space-between;gap:12px}.history-event time{color:var(--muted);font-size:12px}
.history-event p{margin:8px 0 3px}.history-event small{color:var(--muted)}
@media(max-width:760px){.history-modal{padding:10px}.history-modal-panel{padding:17px;max-height:94vh}.history-warning article,.history-event-head{align-items:stretch;flex-direction:column}.history-warning .actions button{width:100%}}

/* v1.1.1 — license status and one-click filters */
.license-filter-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:12px 0 18px}
.license-filter-bar>span{color:var(--muted);font-size:13px;font-weight:900;margin-right:4px}
.status-filter{background:#283545;border:1px solid #3b4c60;color:#cbd7e5}
.status-filter.active{background:linear-gradient(135deg,#4d8fe3,#2c67b2);border-color:#69a9ff;color:#fff;box-shadow:0 0 0 3px rgba(101,167,255,.11)}
.license-status-badge{display:inline-flex;align-items:center;justify-content:center;min-width:66px;padding:5px 9px;border-radius:999px;font-size:12px;font-weight:900;border:1px solid transparent;white-space:nowrap}
.license-status-badge.active{color:#8ee0b1;background:rgba(63,163,108,.14);border-color:rgba(63,163,108,.38)}
.license-status-badge.expired{color:#ffd08a;background:rgba(216,153,50,.14);border-color:rgba(216,153,50,.42)}
.license-status-badge.disabled{color:#ffaaa5;background:rgba(201,75,67,.13);border-color:rgba(201,75,67,.40)}
.empty-table-cell{text-align:center;color:var(--muted);padding:30px!important}
@media(max-width:640px){.license-filter-bar{align-items:stretch}.license-filter-bar>span{width:100%}.status-filter{flex:1;min-width:72px}}
