/* NEXELOGIC Platform v0.1.2 — 後台樣式（覆寫 Django admin 的變數與版面） */

:root {
  --nx-brand: #0F6E74;
  --nx-brand-strong: #0A5459;
  --nx-brand-soft: #E3F1F1;
  --nx-ink: #15232B;
  --nx-ink-2: #4E5F67;
  --nx-ink-3: #7C8B92;
  --nx-surface: #F3F6F6;
  --nx-card: #FFFFFF;
  --nx-line: #D8E1E3;
  --nx-line-2: #E8EEEF;
  --nx-restaurant: #B86E0B;
  --nx-restaurant-soft: #FBF0DF;
  --nx-work: #4A54C4;
  --nx-work-soft: #ECEDFB;
  --nx-ok: #1E7F4F;
  --nx-ok-soft: #E2F3EA;
  --nx-bad: #B3261E;
  --nx-bad-soft: #FBE7E5;
  --nx-idle: #7C8B92;
  --nx-radius: 10px;
  --nx-radius-sm: 6px;

  /* Django admin 變數 */
  --primary: var(--nx-brand);
  --secondary: var(--nx-brand-strong);
  --accent: #F2B544;
  --primary-fg: #fff;
  --body-fg: var(--nx-ink);
  --body-bg: var(--nx-surface);
  --body-quiet-color: var(--nx-ink-2);
  --body-loud-color: var(--nx-ink);
  --header-color: #fff;
  --header-branding-color: #fff;
  --header-bg: var(--nx-brand-strong);
  --header-link-color: #fff;
  --breadcrumbs-fg: var(--nx-ink-2);
  --breadcrumbs-link-fg: var(--nx-brand);
  --breadcrumbs-bg: transparent;
  --link-fg: var(--nx-brand);
  --link-hover-color: var(--nx-brand-strong);
  --link-selected-fg: var(--nx-brand-strong);
  --hairline-color: var(--nx-line-2);
  --border-color: var(--nx-line);
  --error-fg: var(--nx-bad);
  --message-success-bg: var(--nx-ok-soft);
  --message-warning-bg: #FDF3DC;
  --message-error-bg: var(--nx-bad-soft);
  --darkened-bg: var(--nx-surface);
  --selected-bg: #E9F2F2;
  --selected-row: #FFF6DE;
  --button-fg: #fff;
  --button-bg: var(--nx-brand);
  --button-hover-bg: var(--nx-brand-strong);
  --default-button-bg: var(--nx-brand-strong);
  --default-button-hover-bg: #073F43;
  --close-button-bg: var(--nx-ink-3);
  --close-button-hover-bg: var(--nx-ink-2);
  --delete-button-bg: var(--nx-bad);
  --delete-button-hover-bg: #8C1D17;
  --object-tools-fg: #fff;
  --object-tools-bg: var(--nx-brand);
  --object-tools-hover-bg: var(--nx-brand-strong);
  --font-family-primary: "IBM Plex Sans", "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-family-monospace: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nx-brand: #4FB3B8; --nx-brand-strong: #2E8C91; --nx-brand-soft: #173336;
    --nx-ink: #E4ECEE; --nx-ink-2: #A9B8BD; --nx-ink-3: #7F8F95;
    --nx-surface: #0F1A1E; --nx-card: #16242A; --nx-line: #2A3B42; --nx-line-2: #22323A;
    --nx-restaurant: #E9A748; --nx-restaurant-soft: #3A2A12; --nx-work: #9AA2F2; --nx-work-soft: #23264A;
    --nx-ok: #5CC891; --nx-ok-soft: #133524; --nx-bad: #F08A82; --nx-bad-soft: #3F1A18;
    --header-bg: #0B1417; --selected-bg: #1E3338; --selected-row: #33301D;
    --message-success-bg: var(--nx-ok-soft); --message-error-bg: var(--nx-bad-soft); --message-warning-bg: #3A3016;
    --button-fg: #0F1A1E; --default-button-bg: var(--nx-brand); --default-button-hover-bg: #74C7CB;
    --primary-fg: #0F1A1E; --object-tools-fg: #0F1A1E;
  }
}
:root[data-theme="dark"] {
  --nx-brand: #4FB3B8; --nx-brand-strong: #2E8C91; --nx-brand-soft: #173336;
  --nx-ink: #E4ECEE; --nx-ink-2: #A9B8BD; --nx-ink-3: #7F8F95;
  --nx-surface: #0F1A1E; --nx-card: #16242A; --nx-line: #2A3B42; --nx-line-2: #22323A;
  --nx-restaurant: #E9A748; --nx-restaurant-soft: #3A2A12; --nx-work: #9AA2F2; --nx-work-soft: #23264A;
  --nx-ok: #5CC891; --nx-ok-soft: #133524; --nx-bad: #F08A82; --nx-bad-soft: #3F1A18;
  --header-bg: #0B1417; --selected-bg: #1E3338; --selected-row: #33301D;
  --message-success-bg: var(--nx-ok-soft); --message-error-bg: var(--nx-bad-soft); --message-warning-bg: #3A3016;
  --button-fg: #0F1A1E; --default-button-bg: var(--nx-brand); --default-button-hover-bg: #74C7CB;
  --primary-fg: #0F1A1E; --object-tools-fg: #0F1A1E;
}

html, body { background: var(--nx-surface); }
body { font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }

/* ---- 頁首 ---- */
#header { padding: 10px 24px; min-height: 56px; box-sizing: border-box; gap: 16px; }
#branding { display: flex; align-items: center; }
.nx-brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.nx-brand:hover, .nx-brand:focus { color: #fff; text-decoration: none; }
.nx-brand img { width: 32px; height: 32px; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.nx-brand-name { font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.nx-brand-name b { font-weight: 700; }
.nx-version {
  font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #fff; font-variant-numeric: tabular-nums;
}
#user-tools { font-size: 13px; text-transform: none; letter-spacing: 0; }
#user-tools a { border-bottom: none; }
#user-tools a:hover, #user-tools a:focus { text-decoration: underline; }

/* ---- 麵包屑、標題 ---- */
div.breadcrumbs { padding: 14px 24px 0; font-size: 13px; color: var(--nx-ink-2); }
div.breadcrumbs a { color: var(--nx-brand); }
#content { padding: 16px 24px 40px; }
#content h1 { font-size: 24px; font-weight: 600; color: var(--nx-ink); margin: 4px 0 18px; letter-spacing: 0; }
#content h2 { letter-spacing: 0; }

/* ---- 側邊選單 ---- */
#nav-sidebar { background: var(--nx-card); border-right: 1px solid var(--nx-line); }
#nav-sidebar .module caption, #nav-sidebar .module caption a {
  background: transparent; color: var(--nx-ink-3); font-size: 12px; font-weight: 600;
  text-transform: none; letter-spacing: 0; padding: 14px 16px 6px;
}
#nav-sidebar .module th, #nav-sidebar .module td { background: transparent; border-bottom: none; padding: 6px 16px; }
#nav-sidebar .module th a { font-size: 14px; color: var(--nx-ink); }
#nav-sidebar .current-model { background: var(--nx-brand-soft); }
#nav-sidebar .current-model th a { color: var(--nx-brand-strong); font-weight: 600; }
#nav-sidebar .module a.addlink { display: none; }
#nav-filter { border-radius: var(--nx-radius-sm); margin: 12px 16px 4px; width: calc(100% - 32px); }
.toggle-nav-sidebar { background: var(--nx-card); border-color: var(--nx-line); }

/* ---- 模組、表格 ---- */
.module, .inline-group {
  background: var(--nx-card); border: 1px solid var(--nx-line); border-radius: var(--nx-radius); overflow: hidden;
}
.module h2, .module caption, .inline-group h2 {
  background: var(--nx-card); color: var(--nx-ink); font-size: 15px; font-weight: 600; text-transform: none;
  letter-spacing: 0; padding: 14px 16px; border-bottom: 1px solid var(--nx-line-2);
}
.module h2 a, .module caption a.section { color: var(--nx-ink); }
#changelist .results { border: 1px solid var(--nx-line); border-radius: var(--nx-radius); background: var(--nx-card); overflow-x: auto; }
#changelist table thead th, #result_list thead th {
  background: var(--nx-surface); color: var(--nx-ink-2); font-size: 12.5px; font-weight: 600;
  text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--nx-line); padding: 10px 12px;
}
#result_list thead th a, #result_list thead th .text span { color: var(--nx-ink-2); padding: 0; }
#result_list td, #result_list th { padding: 11px 12px; vertical-align: middle; border-bottom: 1px solid var(--nx-line-2); }
#result_list tbody tr:hover td, #result_list tbody tr:hover th { background: var(--selected-bg); }
#result_list tbody tr.selected td, #result_list tbody tr.selected th { background: var(--selected-row); }
#changelist-filter { background: var(--nx-card); border: 1px solid var(--nx-line); border-radius: var(--nx-radius); }
#changelist-filter h2 { background: transparent; color: var(--nx-ink); text-transform: none; letter-spacing: 0; font-size: 15px; }
#changelist-filter h3 { color: var(--nx-ink-3); font-size: 12.5px; font-weight: 600; text-transform: none; }
#changelist-filter li.selected a { color: var(--nx-brand-strong); font-weight: 600; }
#changelist #toolbar { background: transparent; border: none; padding: 0 0 12px; }
#changelist #toolbar #searchbar { border-radius: var(--nx-radius-sm); padding: 8px 12px; min-width: 240px; }
#changelist .actions { background: transparent; border: none; padding: 0 0 12px; color: var(--nx-ink-2); }
#changelist .paginator { border-top: none; color: var(--nx-ink-2); }

/* ---- 按鈕、表單 ---- */
.button, input[type=submit], input[type=button], .submit-row input, a.button {
  border-radius: var(--nx-radius-sm); padding: 9px 16px; font-weight: 600; font-size: 14px; letter-spacing: 0;
}
.submit-row { background: transparent; border: none; padding: 16px 0 0; }
.submit-row a.deletelink { border-radius: var(--nx-radius-sm); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--nx-line); border-radius: var(--nx-radius-sm); padding: 8px 10px; font-size: 14px;
  background: var(--nx-card); color: var(--nx-ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--nx-brand); outline: 2px solid var(--nx-brand-soft); outline-offset: 0; }
a:focus-visible, button:focus-visible, .button:focus-visible { outline: 2px solid var(--nx-brand); outline-offset: 2px; }
.object-tools a, .object-tools a:link, .object-tools a:visited {
  border-radius: var(--nx-radius-sm); text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 600;
  padding: 8px 14px;
}
ul.messagelist li { border-radius: var(--nx-radius-sm); margin-bottom: 8px; padding: 12px 16px 12px 40px; font-size: 14px; }
.errornote { border-radius: var(--nx-radius-sm); }
.help, p.help, form .help { color: var(--nx-ink-3); }

#footer { padding: 16px 24px 28px; color: var(--nx-ink-3); font-size: 12.5px; }

/* ---- 共用元件 ---- */
.nx-muted { color: var(--nx-ink-3); }
.nx-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.nx-badge--restaurant { background: var(--nx-restaurant-soft); color: var(--nx-restaurant); }
.nx-badge--work { background: var(--nx-work-soft); color: var(--nx-work); }
.nx-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.nx-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--nx-idle); }
.nx-status--unused::before { background: var(--nx-brand); }
.nx-status--redeemed::before, .nx-status--ok::before { background: var(--nx-ok); }
.nx-status--void::before, .nx-status--fail::before { background: var(--nx-bad); }
.nx-code {
  font-family: var(--font-family-monospace); font-size: 14.5px; font-weight: 500; letter-spacing: .04em;
  user-select: all; -webkit-user-select: all; color: var(--nx-ink); white-space: nowrap;
}
.nx-copy {
  margin-left: 8px; padding: 3px 10px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--nx-brand); background: var(--nx-brand-soft); border: none; border-radius: 999px;
}
.nx-copy:hover { background: var(--nx-brand); color: #fff; }
.nx-copy.is-done { background: var(--nx-ok); color: #fff; }

/* ---- 總覽首頁 ---- */
.nx-dash { display: grid; gap: 20px; max-width: 1180px; }
.nx-products { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.nx-product {
  background: var(--nx-card); border: 1px solid var(--nx-line); border-radius: var(--nx-radius);
  border-top: 4px solid var(--nx-product, var(--nx-brand)); padding: 18px 20px 20px;
}
.nx-product--restaurant { --nx-product: var(--nx-restaurant); }
.nx-product--work { --nx-product: var(--nx-work); }
.nx-product-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.nx-product-head h2 { margin: 0; font-size: 18px; font-weight: 600; color: var(--nx-ink); }
.nx-product-head small { color: var(--nx-ink-3); font-size: 12.5px; }
.nx-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--nx-line-2);
  border: 1px solid var(--nx-line-2); border-radius: var(--nx-radius-sm); overflow: hidden; margin: 0 0 16px; }
.nx-stat { background: var(--nx-card); padding: 12px 14px; }
.nx-stat dt { font-size: 12.5px; color: var(--nx-ink-2); }
.nx-stat dd { margin: 2px 0 0; font-size: 26px; font-weight: 600; color: var(--nx-ink); font-variant-numeric: tabular-nums; line-height: 1.2; }
.nx-stat dd.is-alert { color: var(--nx-bad); }
.nx-stat a { color: inherit; }
.nx-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nx-actions a { display: inline-flex; align-items: center; padding: 8px 14px; border-radius: var(--nx-radius-sm);
  font-weight: 600; font-size: 13.5px; text-decoration: none; border: 1px solid var(--nx-line); color: var(--nx-ink); }
.nx-actions a.is-primary { background: var(--nx-product, var(--nx-brand)); border-color: transparent; color: #fff; }
.nx-actions a:hover { border-color: var(--nx-product, var(--nx-brand)); text-decoration: none; }
.nx-actions a.is-primary:hover { filter: brightness(.92); }
.nx-panel { background: var(--nx-card); border: 1px solid var(--nx-line); border-radius: var(--nx-radius); }
.nx-panel > h2 { margin: 0; padding: 14px 18px; font-size: 15px; font-weight: 600; color: var(--nx-ink);
  border-bottom: 1px solid var(--nx-line-2); }
.nx-panel > p { margin: 0; padding: 12px 18px; color: var(--nx-ink-2); }
.nx-table { width: 100%; border-collapse: collapse; }
.nx-table th, .nx-table td { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--nx-line-2); font-size: 13.5px; vertical-align: top; }
.nx-table th { color: var(--nx-ink-2); font-weight: 600; font-size: 12.5px; background: transparent; }
.nx-table tr:last-child td { border-bottom: none; }
.nx-table .nx-key { font-family: var(--font-family-monospace); font-size: 13px; white-space: nowrap; }
.nx-empty { padding: 18px; color: var(--nx-ink-3); }
.nx-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
.nx-shortcuts { list-style: none; margin: 0; padding: 6px 0; }
.nx-shortcuts li { padding: 0; list-style: none; }
.nx-shortcuts li::before { content: none; }
.nx-shortcuts a { display: block; padding: 10px 18px; color: var(--nx-ink); }
.nx-shortcuts a:hover { background: var(--selected-bg); text-decoration: none; }
.nx-shortcuts small { display: block; color: var(--nx-ink-3); font-size: 12.5px; }

/* ---- 批次產生、批次結果 ---- */
.nx-form { max-width: 640px; background: var(--nx-card); border: 1px solid var(--nx-line); border-radius: var(--nx-radius); padding: 22px 24px; }
.nx-field { margin-bottom: 18px; }
.nx-field > label, .nx-field > .nx-label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--nx-ink); }
.nx-field input[type=text], .nx-field input[type=number], .nx-field select { width: 100%; box-sizing: border-box; max-width: 420px; }
.nx-field .errorlist { margin: 6px 0 0; padding: 0; list-style: none; color: var(--nx-bad); }
.nx-seg { display: inline-flex; border: 1px solid var(--nx-line); border-radius: var(--nx-radius-sm); overflow: hidden; }
.nx-seg label { display: flex; align-items: center; gap: 8px; padding: 9px 16px; cursor: pointer; font-weight: 600; margin: 0; }
.nx-seg label + label { border-left: 1px solid var(--nx-line); }
.nx-seg input { margin: 0; accent-color: var(--nx-brand); }
.nx-seg label:has(input:checked) { background: var(--nx-brand-soft); color: var(--nx-brand-strong); }
.nx-note { color: var(--nx-ink-2); margin: 4px 0 18px; }
.nx-batch-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.nx-batch-head p { margin: 0; color: var(--nx-ink-2); }
.nx-codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1px;
  background: var(--nx-line-2); border: 1px solid var(--nx-line); border-radius: var(--nx-radius); overflow: hidden; }
.nx-codes li { background: var(--nx-card); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nx-codes li.is-used .nx-code { color: var(--nx-ink-3); text-decoration: line-through; }

/* ---- 帳號安全 ---- */
.nx-security { max-width: 640px; }
.nx-qr { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; margin: 12px 0 18px; }
.nx-qr-box { background: #fff; padding: 10px; border-radius: var(--nx-radius-sm); border: 1px solid var(--nx-line); width: 180px; height: 180px; }
.nx-secret { font-family: var(--font-family-monospace); font-size: 15px; letter-spacing: .06em; user-select: all; }
.nx-inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.nx-inline-form input[type=text] { width: 140px; font-family: var(--font-family-monospace); font-size: 18px; letter-spacing: .2em; text-align: center; }

/* ---- 登入頁 ---- */
body.login { background: var(--nx-surface); }
body.login #container { background: transparent; border: none; box-shadow: none; max-width: 400px; width: calc(100% - 32px); margin: 8vh auto 0; }
body.login #header { background: transparent; color: var(--nx-ink); padding: 0 0 20px; justify-content: center; min-height: 0; }
body.login #header #branding { justify-content: center; width: 100%; }
body.login #header .nx-brand { flex-direction: column; gap: 12px; color: var(--nx-ink); text-align: center; }
body.login #header .nx-brand img { width: 64px; height: 64px; border-radius: 16px; box-shadow: none; }
body.login #header .nx-brand-name { font-size: 22px; }
body.login #header .nx-version { background: var(--nx-brand-soft); color: var(--nx-brand-strong); }
body.login #content { background: var(--nx-card); border: 1px solid var(--nx-line); border-radius: 14px; padding: 24px 24px 20px; min-height: 0; }
body.login #content-main { width: 100%; }
body.login .form-row { padding: 0 0 14px; border: none; }
body.login .form-row label small { font-weight: 400; color: var(--nx-ink-3); margin-left: 4px; }
body.login .form-row label { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; float: none; width: auto; color: var(--nx-ink); }
body.login .form-row input { width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 15px; }
body.login .submit-row { padding: 6px 0 0; margin: 0; }
body.login .submit-row input { width: 100%; padding: 11px; font-size: 15px; }
body.login .nx-login-foot { text-align: center; color: var(--nx-ink-3); font-size: 12.5px; margin-top: 18px; }
body.login #footer { display: none; }

/* ---- 開機動畫：兩個環扣合成 N ---- */
#nx-boot {
  position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; background: var(--nx-surface);
  animation: nx-boot-out .35s ease 1.15s forwards;
}
.nx-booted #nx-boot { display: none; }
#nx-boot svg { width: 88px; height: 88px; overflow: visible; }
#nx-boot .nx-tile { fill: var(--nx-brand); transform-origin: 32px 32px; animation: nx-tile .5s cubic-bezier(.2,.8,.2,1) both; }
#nx-boot .nx-link { fill: none; stroke: #fff; stroke-width: 4.5; }
#nx-boot .nx-link--l { animation: nx-link-l .45s cubic-bezier(.3,1.4,.5,1) .18s both; }
#nx-boot .nx-link--r { animation: nx-link-r .45s cubic-bezier(.3,1.4,.5,1) .18s both; }
#nx-boot .nx-bar { fill: none; stroke: #fff; stroke-width: 4.5; stroke-linecap: round; stroke-dasharray: 36; stroke-dashoffset: 36;
  animation: nx-bar .32s ease-out .58s forwards; }
#nx-boot .nx-boot-name { margin-top: 16px; font-weight: 600; letter-spacing: .02em; color: var(--nx-ink-2); text-align: center;
  animation: nx-fade .3s ease .6s both; }
@keyframes nx-tile { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes nx-link-l { from { transform: translateX(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nx-link-r { from { transform: translateX(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nx-bar { to { stroke-dashoffset: 0; } }
@keyframes nx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nx-boot-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  #nx-boot { display: none; }
}

/* ---- 窄螢幕（平板直向、手機） ---- */
@media (max-width: 1024px) {
  .nx-split { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  #header { padding: 10px 16px; }
  .nx-brand-name { font-size: 15px; }
  #content { padding: 12px 16px 32px; }
  div.breadcrumbs { padding: 12px 16px 0; }
  .nx-products { grid-template-columns: 1fr; }
  .nx-stat dd { font-size: 22px; }
  .nx-form { padding: 18px 16px; }
  .nx-table th, .nx-table td { padding: 10px 14px; }
  #changelist #toolbar #searchbar { min-width: 0; width: 100%; }
}

/* ---- v0.1.2 修正：側邊選單、下拉選單、搜尋列 ---- */
#nav-sidebar { background: transparent; border-right: 1px solid var(--nx-line); }
#nav-sidebar .module { background: transparent; border: none; border-radius: 0; margin-bottom: 4px; }
#nav-sidebar .module caption, #nav-sidebar .current-app .section:link, #nav-sidebar .current-app .section:visited,
#nav-sidebar .module caption a.section:link, #nav-sidebar .module caption a.section:visited { color: var(--nx-ink-3); }
#nav-sidebar .current-app caption a.section { color: var(--nx-brand-strong); }
#nav-sidebar .module tr { border-radius: var(--nx-radius-sm); }
#nav-sidebar .current-model th { border-radius: var(--nx-radius-sm) 0 0 var(--nx-radius-sm); }
select { height: auto; min-height: 38px; line-height: 1.3; }
#changelist .actions select { min-height: 34px; padding: 4px 8px; }
#changelist #toolbar form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#changelist #toolbar form input[type=submit] { padding: 8px 16px; background: var(--nx-brand); color: #fff; border: none; }
#changelist .actions .button { padding: 6px 14px; }
#result_list td.field-code_copy { white-space: nowrap; }
#changelist-filter ul { padding-left: 0; }
#changelist-filter li { list-style: none; }
.dashboard #content { width: auto; max-width: 1180px; }
.dashboard #content-main { float: none; }
#result_list td, #result_list th { padding: 10px 10px; }
#result_list td.field-merchant_link, #result_list td.field-created_display, #result_list td.field-plan { white-space: nowrap; }
.nx-copy { margin-left: 6px; }
#header { height: auto; }
.nx-panel { overflow: hidden; }
@media (max-width: 1024px) {
  #header { flex-wrap: wrap; align-items: center; justify-content: space-between; padding-top: 10px; padding-bottom: 10px; }
  #header #user-tools { margin: 0; text-align: left; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nx-actions a.is-primary { color: #0F1A1E; }
}
:root[data-theme="dark"] .nx-actions a.is-primary { color: #0F1A1E; }
.object-tools a.addlink, .object-tools a.addlink:link, .object-tools a.addlink:visited { background-image: none; padding-right: 14px; }
.object-tools a.addlink::before { content: "+"; margin-right: 6px; font-weight: 700; }
#result_list td.field-name, #result_list th.field-name, #result_list td.field-key { white-space: nowrap; }
@media (max-width: 1100px) {
  #nav-sidebar, #toggle-nav-sidebar { display: none; }
  .main.shifted > #nav-sidebar + .content, .main > #nav-sidebar + .content { max-width: 100%; }
  #changelist { flex-direction: column; }
  #changelist-filter { order: -1; width: auto; margin: 0 0 16px; position: static; }
  #changelist-filter details { display: inline-block; vertical-align: top; margin-right: 24px; }
  #changelist-filter h2, #changelist-filter #changelist-filter-extra-actions { display: none; }
}
@media (max-width: 1100px) {
  #changelist-filter { height: auto; min-height: 0; padding: 4px 16px 8px; }
}
.nx-qr-box svg { width: 100%; height: 100%; display: block; }

/* ---- 手機／平板：漢堡選單 ---- */
.nx-menu-btn, .nx-drawer, .nx-drawer-backdrop { display: none; }
@media (max-width: 1100px) {
  #header { flex-wrap: nowrap; }
  #branding { flex: 1; justify-content: space-between; gap: 12px; }
  #header #user-tools { display: none; }
  .nx-menu-btn {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 44px; height: 44px; padding: 0 11px; margin-right: -8px; box-sizing: border-box;
    background: transparent; border: none; border-radius: var(--nx-radius-sm); cursor: pointer;
  }
  .nx-menu-btn span { display: block; height: 2px; border-radius: 2px; background: #fff; transition: transform .2s ease, opacity .2s ease; }
  .nx-menu-btn:hover, .nx-menu-btn:focus-visible { background: rgba(255,255,255,.12); }
  .nx-menu-open .nx-menu-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nx-menu-open .nx-menu-btn span:nth-child(2) { opacity: 0; }
  .nx-menu-open .nx-menu-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .nx-drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 900; background: rgba(10, 20, 24, .45);
    opacity: 0; transition: opacity .2s ease;
  }
  .nx-drawer {
    display: flex; flex-direction: column; position: fixed; top: 0; right: 0; bottom: 0; z-index: 901;
    width: min(320px, 86vw); background: var(--nx-card); color: var(--nx-ink); overflow-y: auto;
    box-shadow: -8px 0 24px rgba(10, 20, 24, .18); transform: translateX(100%); transition: transform .22s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nx-drawer[hidden], .nx-drawer-backdrop[hidden] { display: none; }
  .nx-menu-open .nx-drawer { transform: none; }
  .nx-menu-open .nx-drawer-backdrop { opacity: 1; }
  .nx-menu-open, .nx-menu-open body { overflow: hidden; }

  .nx-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 10px 20px;
    border-bottom: 1px solid var(--nx-line-2); }
  .nx-drawer-user { font-weight: 600; font-size: 15px; }
  .nx-drawer-close { width: 40px; height: 40px; font-size: 26px; line-height: 1; color: var(--nx-ink-2);
    background: transparent; border: none; border-radius: var(--nx-radius-sm); cursor: pointer; }
  .nx-drawer-close:hover { background: var(--selected-bg); }
  .nx-drawer-group { margin: 16px 20px 4px; font-size: 12.5px; font-weight: 600; color: var(--nx-ink-3); }
  .nx-drawer-list { list-style: none; margin: 0; padding: 0 8px; }
  .nx-drawer-list li { list-style: none; padding: 0; }
  .nx-drawer-list li::before { content: none; }
  .nx-drawer-list a, .nx-drawer-list button {
    display: block; width: 100%; box-sizing: border-box; padding: 11px 12px; text-align: left;
    font: inherit; font-size: 15px; color: var(--nx-ink); background: transparent; border: none;
    border-radius: var(--nx-radius-sm); cursor: pointer; text-decoration: none;
  }
  .nx-drawer-list a:hover, .nx-drawer-list button:hover { background: var(--selected-bg); text-decoration: none; }
  .nx-drawer-list a[aria-current="page"] { background: var(--nx-brand-soft); color: var(--nx-brand-strong); font-weight: 600; }
  .nx-drawer-list form { margin: 0; }
  .nx-drawer-logout { color: var(--nx-bad) !important; }
  .nx-drawer-foot { margin: auto 0 0; padding: 20px; font-size: 12.5px; color: var(--nx-ink-3); }
}
@media (prefers-reduced-motion: reduce) {
  .nx-drawer, .nx-drawer-backdrop, .nx-menu-btn span { transition: none; }
}
@media (max-width: 1100px) {
  #header .nx-drawer, #header .nx-drawer a:link, #header .nx-drawer a:visited,
  #header .nx-drawer button { color: var(--nx-ink); }
  #header .nx-drawer a[aria-current="page"] { color: var(--nx-brand-strong); }
  #header .nx-drawer .nx-drawer-logout { color: var(--nx-bad) !important; }
  #changelist-filter { max-height: none; overflow: visible; }
}
@media (max-width: 767px) {
  #changelist-filter details { display: block; margin: 0 0 4px; }
  #header { padding-left: 16px; padding-right: 12px; }
}
@media (max-width: 1100px) {
  #changelist-filter { flex: 0 0 auto; }
}
@media (max-width: 1100px) {
  #header { flex-direction: row; align-items: center; }
  #branding { width: 100%; }
}
.nx-status--warn::before { background: #C77C02; }

/* ---- 點餐系統營運看板 ---- */
.nx-ops-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.nx-ops-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.nx-ops-tag--danger { background: var(--nx-bad-soft); color: var(--nx-bad); }
.nx-ops-tag--warn { background: #FDF0D5; color: #8A5300; }
.nx-ops-tag--muted { background: var(--darkened-bg); color: var(--nx-ink-3); }
.nx-ops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.nx-dash .nx-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.nx-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- 收款、信件 ---- */
.nx-money { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 16px 20px; }
.nx-money h2 { margin: 0 0 2px; padding: 0; border: none; font-size: 15px; font-weight: 600; color: var(--nx-ink); }
.nx-money p { margin: 0; padding: 0; }
.nx-money strong { font-size: 26px; font-weight: 600; color: var(--nx-ink); font-variant-numeric: tabular-nums; }
.nx-check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.nx-check input { accent-color: var(--nx-brand); width: 18px; height: 18px; margin: 0; }
.nx-field input[type=email], .nx-field textarea { width: 100%; box-sizing: border-box; max-width: 520px; }
.nx-template-tools { padding-top: 8px; gap: 8px; }
iframe.nx-mail-preview { width: 100%; max-width: 640px; height: 520px; border: 1px solid var(--nx-line); border-radius: var(--nx-radius-sm); background: #F3F6F6; }
.field-body textarea { font-size: 14.5px; line-height: 1.6; }

/* 收據（螢幕與列印共用） */
.nx-receipt { max-width: 720px; background: #fff; color: #15232B; border: 1px solid var(--nx-line); border-radius: var(--nx-radius);
  padding: 28px 32px; position: relative; box-sizing: border-box; }
.nx-receipt.is-void::after { content: "已作廢"; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-14deg);
  font-size: 72px; font-weight: 700; color: rgba(179, 38, 30, .22); border: 6px solid rgba(179, 38, 30, .22); padding: 0 24px; border-radius: 12px; }
.nx-receipt-head { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; padding-bottom: 18px; border-bottom: 2px solid #0A5459; }
.nx-receipt-head img { border-radius: 10px; }
.nx-receipt-head h2 { margin: 0 0 4px; padding: 0; border: none; font-size: 18px; color: #15232B; background: none; }
.nx-receipt-head p { margin: 0; color: #4E5F67; font-size: 12.5px; }
.nx-receipt-title { text-align: right; }
.nx-receipt-title strong { display: block; font-size: 24px; letter-spacing: .3em; color: #0A5459; }
.nx-receipt-title span { font-family: var(--font-family-monospace); font-size: 13px; color: #4E5F67; }
.nx-receipt-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; margin: 18px 0; }
.nx-receipt-meta div { display: flex; gap: 10px; }
.nx-receipt-meta dt { color: #7C8B92; min-width: 64px; }
.nx-receipt-meta dd { margin: 0; font-weight: 500; }
.nx-receipt-items { width: 100%; border-collapse: collapse; margin: 6px 0 18px; }
.nx-receipt-items th, .nx-receipt-items td { padding: 10px 8px; border-bottom: 1px solid #E8EEEF; text-align: left; font-size: 14px; background: none; color: #15232B; }
.nx-receipt-items thead th { color: #4E5F67; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid #D8E1E3; }
.nx-receipt-items tfoot th, .nx-receipt-items tfoot td { border-bottom: none; font-size: 15px; }
.nx-receipt-items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nx-receipt-code { border: 1px dashed #0F6E74; border-radius: 10px; padding: 14px 16px; text-align: center; margin-bottom: 18px; }
.nx-receipt-code p { margin: 0; color: #4E5F67; font-size: 12.5px; }
.nx-receipt-code strong { display: block; margin: 4px 0 6px; font-family: var(--font-family-monospace); font-size: 22px; letter-spacing: .06em; color: #0A5459; }
.nx-receipt-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; color: #4E5F67; font-size: 12.5px; }
.nx-receipt-foot p { margin: 0; }
.nx-sign { white-space: nowrap; font-size: 14px; color: #15232B; }
@media (max-width: 600px) {
  .nx-receipt { padding: 20px 16px; }
  .nx-receipt-head { grid-template-columns: auto 1fr; }
  .nx-receipt-title { grid-column: 1 / -1; text-align: left; }
  .nx-receipt-meta { grid-template-columns: 1fr; }
}
@media print {
  @page { size: A5 portrait; margin: 10mm; }
  html, body { background: #fff !important; }
  #header, #nav-sidebar, #toggle-nav-sidebar, .breadcrumbs, #footer, .nx-no-print, .messagelist, #content h1,
  .nx-drawer, .nx-drawer-backdrop, #nx-boot { display: none !important; }
  #content, .main, #main, #container { padding: 0 !important; margin: 0 !important; display: block !important; }
  .nx-receipt { border: none; padding: 0; max-width: none; }
}
.field-subject input[type=text] { width: 100%; max-width: 640px; box-sizing: border-box; }
.field-body textarea { width: 100%; max-width: 640px; box-sizing: border-box; }
iframe.nx-mail-preview { height: 640px; }

/* ---- 更新內容介紹 ---- */
.nx-wn-backdrop { position: fixed; inset: 0; z-index: 9000; background: rgba(10, 20, 24, .5); }
.nx-wn { position: fixed; z-index: 9001; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--nx-card); color: var(--nx-ink); border-radius: 16px; box-shadow: 0 20px 48px rgba(10, 20, 24, .28);
  animation: nx-wn-in .28s cubic-bezier(.2,.8,.2,1) both; animation-delay: 1.2s; }
.nx-booted .nx-wn { animation-delay: 0s; }
@keyframes nx-wn-in { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@media (prefers-reduced-motion: reduce) { .nx-wn { animation: none; } }
.nx-wn-kicker { margin: 0; padding: 22px 24px 0; color: var(--nx-brand-strong); font-size: 13.5px; }
.nx-wn h2 { margin: 4px 0 0; padding: 0 24px 14px; font-size: 21px; font-weight: 700; color: var(--nx-ink); background: none; border: none; }
.nx-wn-body { overflow-y: auto; padding: 0 24px; border-top: 1px solid var(--nx-line-2); }
.nx-wn-ver { margin: 18px 0 0; font-size: 14px; color: var(--nx-ink-2); }
.nx-wn-list { list-style: none; margin: 0; padding: 6px 0 10px; }
.nx-wn-list li { list-style: none; padding: 12px 0 12px 22px; position: relative; border-bottom: 1px solid var(--nx-line-2); font-size: 14.5px; }
.nx-wn-list li:last-child { border-bottom: none; }
.nx-wn-list li::before { content: ""; position: absolute; left: 2px; top: 20px; width: 8px; height: 8px; border-radius: 50%; background: var(--nx-brand); }
.nx-wn-list strong { display: block; color: var(--nx-ink); margin-bottom: 2px; }
.nx-wn-list span { color: var(--nx-ink-2); line-height: 1.6; }
.nx-wn-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px 20px;
  border-top: 1px solid var(--nx-line-2); }
.nx-wn-actions .button { padding: 10px 22px; }
.nx-releases { display: grid; gap: 16px; max-width: 760px; }
.nx-release h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.nx-release .nx-wn-list { padding: 4px 18px 12px; }
.nx-version-tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--nx-brand-soft); color: var(--nx-brand-strong); }
#footer a { color: var(--nx-brand); }

/* ---- 分頁籤、使用者總覽、方案比較、產品更新（v0.4.0） ---- */
.nx-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.nx-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--nx-line);
  background: var(--nx-card); color: var(--nx-ink-2); font-weight: 600; font-size: 13.5px; text-decoration: none; }
.nx-tabs a[aria-current=page] { background: var(--nx-brand); border-color: var(--nx-brand); color: #fff; }
.nx-tabs a small { font-weight: 500; opacity: .8; }
.nx-users-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.nx-users-bar .nx-tabs { margin: 0; }
.nx-users-search { display: flex; gap: 6px; }
.nx-users-search input[type=search] { min-width: 220px; padding: 8px 10px; }
.nx-users-note { margin: 6px 0 14px; }
.nx-linkbtn { background: none; border: none; padding: 0; color: var(--nx-brand); cursor: pointer; font: inherit; text-decoration: underline; }
.nx-users .nx-panel, .nx-plans .nx-panel, .nx-updates .nx-panel { margin-bottom: 16px; }
.nx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nx-chips a.nx-badge { text-decoration: none; }
.nx-badge--nexelogic { background: var(--nx-brand-soft); color: var(--nx-brand-strong); }
.nx-pager { text-align: center; }
.nx-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 24px; margin: 0; padding: 16px 18px; }
.nx-kv dt { color: var(--nx-ink-3); font-size: 12.5px; }
.nx-kv dd { margin: 2px 0 0; font-size: 14.5px; word-break: break-all; }
.nx-assist { padding: 14px 18px 16px; }
.nx-assist-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.nx-assist-actions form { margin: 0; }
.nx-assist-actions .button { padding: 9px 14px; }
.nx-danger { color: var(--nx-bad) !important; border-color: var(--nx-bad) !important; background: transparent !important; }
.nx-reset-body { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; padding: 16px 18px; }
.nx-reset-body > div:last-child { flex: 1 1 260px; }
.nx-reset-url code { display: block; padding: 8px 10px; background: var(--nx-surface); border-radius: 8px; word-break: break-all; font-size: 13px; }
.nx-confirm { max-width: 460px; }
.nx-confirm-form { padding: 16px 18px; }
.nx-confirm-form .form-row { padding: 0 0 12px; border: none; }
.nx-confirm-form label { display: block; font-weight: 600; margin-bottom: 6px; float: none; width: auto; padding: 0; }
.nx-confirm-form input[type=password], .nx-confirm-form input[type=text] { width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 15px; }
.nx-compare th, .nx-compare td { text-align: center; white-space: nowrap; }
.nx-compare th:first-child, .nx-compare td:first-child { text-align: left; white-space: normal; min-width: 180px; }
.nx-compare .nx-yes { color: var(--nx-ok); font-weight: 700; }
.nx-compare .nx-no { color: var(--nx-ink-3); }
.nx-compare thead small { display: block; font-weight: 500; color: var(--nx-ink-3); }
.nx-release { padding: 12px 18px 14px; border-top: 1px solid var(--nx-line-2); }
.nx-release:first-of-type { border-top: none; }
.nx-release h3 { margin: 0 0 6px; font-size: 14.5px; }
.nx-release h3 small { color: var(--nx-ink-3); font-weight: 500; margin-left: 6px; }
.nx-release ul { margin: 0; padding-left: 1.2em; }
.nx-release li { margin: 3px 0; color: var(--nx-ink-2); }
.nx-release li strong { color: var(--nx-ink); }
.nx-version-line { font-size: 12.5px; color: var(--nx-ink-3); }
@media (max-width: 767px) {
  .nx-users-search { width: 100%; }
  .nx-users-search input[type=search] { min-width: 0; flex: 1; }
}
.nx-table th { text-transform: none; letter-spacing: 0; }
.nx-loglist { list-style: none; margin: 0; padding: 6px 18px 12px; }
.nx-loglist li { padding: 8px 0; border-bottom: 1px solid var(--nx-line-2); font-size: 13.5px; }
.nx-loglist li:last-child { border-bottom: none; }
.nx-loglist small { display: block; color: var(--nx-ink-3); }
.nx-danger { border: 1px solid var(--nx-bad) !important; }
