:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef3ee;
  --text: #17211b;
  --muted: #68746d;
  --line: #dce4de;
  --green: #1e7f5c;
  --green-dark: #126647;
  --amber: #b66d16;
  --red: #b43b3b;
  --blue: #286e9f;
  --shadow: 0 16px 40px rgba(34, 50, 40, 0.12);
}

#resourceView td[data-label="操作"],
#resourceView td[data-label="鎿嶄綔"],
#resourceView tr td:last-child {
  display: block !important;
  width: 100% !important;
}

#resourceView td[data-label="操作"]::before,
#resourceView td[data-label="鎿嶄綔"]::before,
#resourceView tr td:last-child::before {
  display: none !important;
}

#resourceView .row-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 5px !important;
  width: 100% !important;
}

#resourceView .row-actions button {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 36px !important;
  padding: 7px 2px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

.agreement-panel {
  display: flex !important;
  flex-direction: column !important;
  max-height: 92dvh !important;
}

[hidden] {
  display: none !important;
}

.agreement-drawer {
  z-index: 200 !important;
}

[hidden] {
  display: none !important;
}
*** End of File

[hidden] {
  display: none !important;
}

.agreement-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  padding-bottom: 12px !important;
}

.agreement-accept-btn {
  flex: 0 0 auto !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 5 !important;
  margin-top: 12px !important;
  min-height: 46px !important;
}

.agreement-panel {
  display: flex !important;
  flex-direction: column !important;
  max-height: 92dvh !important;
}

.agreement-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  padding-bottom: 12px !important;
}

.agreement-accept-btn {
  flex: 0 0 auto !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 5 !important;
  margin-top: 12px !important;
  min-height: 46px !important;
}

.agreement-panel {
  display: flex !important;
  flex-direction: column !important;
  max-height: 92dvh !important;
}

.agreement-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  padding-bottom: 12px !important;
}

.agreement-accept-btn {
  flex: 0 0 auto !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 5 !important;
  margin-top: 12px !important;
  min-height: 46px !important;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

body:not(.logged-in) .app-shell {
  display: none;
}

body.logged-in .login-screen {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(120deg, rgba(30, 127, 92, 0.12), rgba(40, 110, 159, 0.1)),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
}

.login-brand .brand-title {
  color: var(--text);
}

.login-brand .brand-subtitle {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.register-form {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.register-notice {
  padding: 12px;
  border-radius: 8px;
  background: #fff8e9;
  color: var(--amber);
  line-height: 1.5;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input,
.login-form button {
  min-height: 44px;
}

.demo-accounts {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f8f6;
  color: var(--muted);
  font-size: 13px;
}

.demo-accounts strong {
  color: var(--text);
}

.sidebar {
  background: #17211b;
  color: #f7fbf8;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #e0f1e8;
  color: #126647;
  border-radius: 8px;
  font-weight: 800;
  font-size: 20px;
}

.brand-title {
  font-weight: 800;
  font-size: 17px;
}

.brand-subtitle,
.account-box span,
.mini-label,
.eyebrow {
  color: #aab8af;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 13px 14px;
  text-align: left;
  background: transparent;
  color: #dbe7df;
}

.nav-item.active,
.nav-item:hover {
  background: #24342b;
  color: #ffffff;
}

.account-box {
  display: none;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

p {
  color: var(--muted);
}

.top-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.compact-toolbar {
  margin-bottom: 14px;
}

.portal-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #e8eee9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.portal-tab {
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.portal-tab.active {
  background: #fff;
  color: var(--green-dark);
  box-shadow: 0 1px 4px rgba(34, 50, 40, 0.1);
}

.role-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.current-user {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 127, 92, 0.12);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.unlock-btn,
.dial-btn,
.copy-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-btn {
  background: var(--green);
  color: #fff;
}

.primary-btn:hover {
  background: var(--green-dark);
}

.ghost-btn {
  background: var(--surface-2);
  color: var(--text);
}

.danger-btn {
  background: #faeaea;
  color: var(--red);
}

.unlock-btn {
  background: #fff0d8;
  color: var(--amber);
}

.unlock-btn:hover {
  background: #ffe1ad;
}

.dial-btn {
  background: var(--green);
  color: #fff;
}

.dial-btn:hover {
  background: var(--green-dark);
}

.copy-btn {
  background: #e8f1ff;
  color: #1d4f91;
}

.copy-btn:hover {
  background: #d7e8ff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric span,
.metric small,
td small {
  color: var(--muted);
}

.metric strong {
  font-size: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workbench,
.boss-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.boss-risk-panel {
  display: none;
}

.panel-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.task-list,
.staff-list,
.risk-list,
.stage-bars {
  display: grid;
  gap: 10px;
}

.task-item,
.staff-item,
.risk-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: grid;
  gap: 6px;
  background: #fbfdfb;
}

.task-item {
  text-align: left;
}

.task-item strong,
.staff-item strong,
.risk-item strong {
  font-size: 15px;
}

.account-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.company-open-panel {
  margin-bottom: 14px;
}

.company-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  gap: 10px;
}

.company-form button {
  min-height: 42px;
}

.account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.quota-actions {
  display: grid;
  grid-template-columns: 110px auto auto;
  gap: 8px;
  align-items: center;
}

.quota-actions input {
  width: 110px;
}

.platform-metrics {
  margin-bottom: 16px;
}

.data-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.insight-card {
  min-height: 132px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.insight-card span {
  color: var(--muted);
  font-size: 13px;
}

.insight-card strong {
  font-size: 25px;
  color: var(--green-dark);
}

.insight-card small {
  color: var(--muted);
  line-height: 1.5;
}

.flow-step {
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfb;
  display: grid;
  gap: 8px;
  align-content: start;
}

.flow-step span {
  color: var(--muted);
  font-size: 13px;
}

.task-meta,
.staff-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.stage-row {
  display: grid;
  gap: 7px;
}

.stage-line {
  height: 9px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.stage-fill {
  height: 100%;
  background: var(--green);
}

.toolbar {
  margin-bottom: 14px;
}

.search-box {
  flex: 1 1 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding-left: 12px;
}

.search-box span {
  color: var(--muted);
}

.search-box input {
  flex: 1;
  border: 0;
  box-shadow: none;
  min-width: 160px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #f8faf8;
  color: var(--muted);
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.customer-name {
  display: grid;
  gap: 4px;
}

.mobile-pairs,
.always-hidden {
  display: none;
}

.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-2);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 68px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status.locked {
  background: #fff3db;
  color: var(--amber);
}

.status.unlocked {
  background: #e7f5ed;
  color: var(--green-dark);
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.boss-account-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  width: min(360px, 100%);
}

.boss-account-actions button {
  min-width: 0;
  width: 100%;
  padding-inline: 8px;
}

#resourceView .row-actions {
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: flex-start;
}

#resourceView .row-actions button {
  flex: 0 0 auto;
  width: auto;
  min-height: 34px;
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
}

#resourceView td[data-label="操作"],
#resourceView td[data-label="鎿嶄綔"] {
  display: block;
}

#resourceView td[data-label="操作"]::before,
#resourceView td[data-label="鎿嶄綔"]::before {
  display: none;
}

.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.customer-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-facts {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.level-control {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.level-control select {
  min-height: 38px;
}

.level-select {
  min-width: 86px;
  padding: 8px 10px;
}

.detail-level-control {
  max-width: 220px;
}

.recharge-list {
  display: grid;
  gap: 12px;
}

.recharge-help {
  padding: 12px;
  border-radius: 8px;
  background: #fff8e9;
  color: var(--amber);
  display: grid;
  gap: 4px;
  line-height: 1.5;
}

.gift-panel {
  width: min(420px, 100%);
}

.gift-body {
  display: grid;
  gap: 12px;
}

.gift-body strong {
  font-size: 20px;
  color: var(--green-dark);
}

.agreement-drawer {
  z-index: 90;
}

.agreement-panel {
  width: min(620px, 100%);
}

.agreement-body {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding-right: 4px;
}

.agreement-body section {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.agreement-body section:last-child {
  border-bottom: 0;
}

.agreement-body h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.agreement-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.agreement-accept-btn {
  width: 100%;
  margin-top: 16px;
}

.recharge-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfb;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.recharge-card strong {
  display: block;
  font-size: 22px;
}

.recharge-card span,
.recharge-card small {
  display: block;
  color: var(--muted);
}

.pay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pay-wechat {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
  color: #fff;
}

.pay-wechat {
  background: #1aad19;
}

.qr-pay-box {
  display: grid;
  gap: 12px;
}

.qr-pay-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: #f8faf8;
}

.qr-pay-card img {
  width: min(240px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.qr-pay-card strong,
.qr-pay-card span,
.qr-pay-card small {
  display: block;
}

.rebate-highlight {
  display: inline !important;
  color: #d82727;
  font-weight: 800;
}

.drawer-query-actions,
.query-button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.drawer-query-actions {
  margin-top: 12px;
}

.drawer-query-result {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.drawer-query-result h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.mini-table-wrap {
  overflow-x: auto;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mini-table th,
.mini-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.record-query-panel {
  margin-top: 14px;
}

.upload-proof {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.upload-proof input {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.proof-thumb {
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  background: #fff;
}

.proof-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.audit-amount-input {
  width: 96px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #fff7ed;
  color: #c2410c;
}

.status-pill.approved {
  background: #ecfdf5;
  color: #047857;
}

.status-pill.rejected {
  background: #fef2f2;
  color: #b91c1c;
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 22, 18, 0.42);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100%);
  height: 100%;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
  overflow: auto;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.contact-btn {
  width: 44px;
  min-width: 44px;
  min-height: 38px;
  padding: 0;
  display: inline-block;
  background: var(--surface-2) url("assets/contact-phone-icon.jpg") center / 22px 22px no-repeat;
}

.contact-qr-card {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.contact-qr-card img {
  width: min(280px, 88vw);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
}

.contact-qr-card small {
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.detail-body {
  display: grid;
  gap: 16px;
}

.detail-section {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.detail-section:last-child {
  border-bottom: 0;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.fact {
  display: grid;
  gap: 4px;
  background: #f8faf8;
  border-radius: 8px;
  padding: 12px;
}

.fact span {
  color: var(--muted);
  font-size: 12px;
}

.follow-form {
  display: grid;
  gap: 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--green);
  padding: 4px 0 4px 12px;
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

.company-detail-list {
  display: grid;
  gap: 14px;
}

.employee-unlock-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  overflow: hidden;
}

.employee-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #eef4ef;
  color: var(--green-dark);
}

.employee-title span {
  color: var(--muted);
  font-size: 13px;
}

.unlock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 12px;
  padding: 13px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.unlock-facts {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-size: 13px;
}

.unlock-facts span {
  color: var(--text);
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(30px);
  opacity: 0;
  pointer-events: none;
  background: #17211b;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: 0.2s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
    padding: 10px 8px;
  }

  .account-box {
    display: none;
  }

  .summary-grid,
  .workbench,
  .boss-layout {
    grid-template-columns: 1fr 1fr;
  }

  .wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  body {
    background: #eef3ef;
  }

  .main {
    padding: 14px;
  }

  .sidebar {
    gap: 12px;
    padding: 12px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .brand-title {
    font-size: 15px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 14px;
    gap: 12px;
  }

  .top-actions,
  .role-switch {
    width: 100%;
  }

  .portal-switch {
    width: 100%;
  }

  .portal-tab {
    flex: 1;
  }

  .role-switch select,
  .primary-btn {
    flex: 1;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 23px;
  }

  .workbench,
  .boss-layout {
    grid-template-columns: 1fr;
  }

  .nav {
    overflow-x: auto;
    grid-auto-flow: column;
    grid-auto-columns: 92px;
    grid-template-columns: none;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    min-height: 42px;
    padding: 9px 8px;
    white-space: nowrap;
  }

  .brand-subtitle {
    display: none;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 17px;
  }

  .panel,
  .customer-card {
    padding: 14px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .search-box {
    grid-column: 1 / -1;
    flex-basis: auto;
  }

  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    line-height: 28px;
  }

  td[colspan] {
    display: block;
  }

  td[colspan]::before {
    display: none;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .row-actions button {
    min-height: 40px;
  }

  .customer-grid {
    grid-template-columns: 1fr;
  }

  .drawer-panel {
    width: 100%;
    padding: 18px;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }

  .account-form,
  .company-form,
  .insight-grid,
  .data-flow {
    grid-template-columns: 1fr;
  }

  .account-row {
    align-items: stretch;
    flex-direction: column;
  }

  .recharge-card {
    align-items: stretch;
    flex-direction: column;
  }

  .pay-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .unlock-row {
    grid-template-columns: 1fr;
  }

  .unlock-facts {
    justify-items: start;
  }

  .quota-actions {
    grid-template-columns: 1fr 1fr;
  }

  .quota-actions input {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 760px) {
  body.logged-in {
    background: #f3f6f4;
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .main {
    padding: 12px 12px calc(92px + env(safe-area-inset-bottom));
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 18;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 28px rgba(34, 50, 40, 0.14);
    color: var(--text);
  }

  .sidebar .brand {
    display: none;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    grid-auto-flow: initial;
    grid-auto-columns: initial;
    gap: 4px;
    overflow: visible;
    padding: 0;
    scroll-snap-type: none;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    min-width: 0;
    min-height: 48px;
    padding: 7px 4px;
    border-radius: 8px;
    background: #f4f7f5;
    color: var(--muted);
    text-align: center;
    scroll-snap-align: none;
    white-space: normal;
    line-height: 1.15;
    font-size: 11px;
  }

  .nav-item.active,
  .nav-item:hover {
    background: var(--green);
    color: #fff;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin: -12px -12px 12px;
    padding: 12px;
    background: rgba(243, 246, 244, 0.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(220, 228, 222, 0.72);
  }

  .topbar > div:first-child {
    flex: 1;
    min-width: 120px;
  }

  .topbar h1 {
    font-size: 21px;
    line-height: 1.25;
    white-space: nowrap;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 11px;
    white-space: nowrap;
  }

  .top-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    align-items: stretch;
    flex: 0 0 auto;
  }

  .portal-switch,
  .current-user {
    display: none;
  }

  #contactBtn,
  #rechargeBtn,
  #logoutBtn {
    flex: 0 0 48px;
    width: 48px;
    min-height: 38px;
    padding: 8px 10px;
    text-align: center;
  }

  #contactBtn,
  #rechargeBtn {
    background: var(--surface-2);
    color: var(--text);
  }

  #contactBtn.contact-btn,
  .top-actions #contactBtn.contact-btn.ghost-btn {
    background: var(--surface-2) url("assets/contact-phone-icon.jpg") center / 22px 22px no-repeat;
  }

  .summary-grid,
  .platform-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .metric {
    min-height: 92px;
    padding: 12px;
    gap: 5px;
  }

  .metric strong {
    font-size: 22px;
    line-height: 1.1;
  }

  .metric span,
  .metric small {
    font-size: 12px;
    line-height: 1.35;
  }

  .panel {
    padding: 12px;
  }

  .panel-head,
  .section-head {
    display: grid;
    gap: 10px;
  }

  .panel-head h2,
  .section-head h2 {
    font-size: 16px;
  }

  .panel-head p,
  .section-head p {
    margin-bottom: 0;
    font-size: 12px;
    line-height: 1.5;
  }

  .section-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .section-actions button,
  .section-actions select,
  .section-actions input {
    width: 100%;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  .toolbar .search-box {
    grid-column: 1 / -1;
  }

  .toolbar select,
  .toolbar input,
  .search-box {
    min-height: 42px;
    width: 100%;
  }

  .search-box input {
    min-width: 0;
  }

  .table-wrap {
    border: 0;
    background: transparent;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    border-collapse: separate;
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 14px rgba(34, 50, 40, 0.05);
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    align-items: start;
    font-size: 14px;
    word-break: break-word;
  }

  tr td:first-child {
    display: block;
    padding: 16px 16px 14px;
  }

  tr td:first-child::before {
    display: none;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    line-height: 22px;
  }

  td:last-child {
    border-bottom: 0;
  }

  td[data-label="操作"],
  td[data-label="鎿嶄綔"] {
    grid-template-columns: 1fr;
  }

  td[data-label="操作"]::before,
  td[data-label="鎿嶄綔"]::before {
    display: none;
  }

  .mobile-hide {
    display: none;
  }

  .mobile-pairs {
    display: grid;
    gap: 9px;
    margin-top: 10px;
  }

  .mobile-pairs div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 18px;
    row-gap: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
  }

  .mobile-pairs span {
    display: inline-flex;
    gap: 4px;
    min-width: 0;
  }

  .mobile-pairs b {
    color: var(--green-dark);
    font-weight: 800;
  }

  #clientsView td {
    padding-top: 11px;
    padding-bottom: 11px;
  }

  #clientsView tr td:first-child {
    padding-top: 14px;
    padding-bottom: 12px;
  }

  #clientsView .customer-name {
    gap: 9px;
  }

  #clientsView .mobile-pairs {
    gap: 9px;
    margin-top: 10px;
  }

  #clientsView .mobile-pairs div {
    line-height: 1.7;
  }

  td[colspan] {
    display: block;
  }

  td[colspan]::before {
    display: none;
  }

  .customer-name {
    min-width: 0;
    gap: 9px;
  }

  .customer-name strong,
  .staff-item strong,
  .task-item strong,
  .risk-item strong {
    font-size: 15px;
    line-height: 1.35;
  }

  .tag-list,
  .staff-meta,
  .task-meta {
    gap: 5px;
  }

  .tag,
  .status,
  .status-pill {
    min-height: 26px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .row-actions,
  .quota-actions,
  .pay-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .row-actions button,
  .quota-actions button,
  .pay-actions button,
  .primary-btn,
  .ghost-btn,
  .danger-btn,
  .unlock-btn,
  .dial-btn,
  .copy-btn {
    min-height: 42px;
    padding: 10px 11px;
    white-space: normal;
    line-height: 1.25;
    font-size: 14px;
  }

  .quota-actions input {
    grid-column: 1 / -1;
    width: 100%;
  }

  .account-form,
  .company-form,
  .insight-grid,
  .data-flow,
  .fact-grid {
    grid-template-columns: 1fr;
  }

  .account-row,
  .employee-title,
  .unlock-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .drawer-panel {
    top: auto;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(92dvh, 760px);
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
  }

  .drawer-head {
    position: sticky;
    top: -14px;
    z-index: 2;
    margin: -14px -14px 12px;
    padding: 14px;
    background: #fff;
  }

  .detail-body {
    gap: 12px;
  }

  .recharge-card {
    padding: 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .qr-pay-card img {
    justify-self: center;
    width: min(260px, 86vw);
  }

  .proof-thumb {
    width: 54px;
    height: 54px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    transform: translateY(24px);
    text-align: center;
  }

  .toast.show {
    transform: translateY(0);
  }

  body.logged-in .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 80;
    transform: translateZ(0);
  }

  body.logged-in .main {
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
  }

  .topbar > div:first-child {
    min-width: 0;
    overflow: hidden;
  }

  .topbar h1,
  .eyebrow {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top-actions {
    display: inline-flex;
    width: auto;
    flex: none;
    gap: 6px;
  }

  #contactBtn,
  #rechargeBtn,
  #logoutBtn,
  .top-actions #contactBtn.ghost-btn,
  .top-actions #rechargeBtn.primary-btn,
  .top-actions #logoutBtn.ghost-btn {
    flex: none;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    min-height: 36px;
    padding: 7px 0;
    font-size: 13px;
    line-height: 1;
  }

  tr {
    margin-bottom: 14px;
  }

  td {
    padding-top: 11px;
    padding-bottom: 11px;
  }

  tr td:first-child {
    padding-top: 14px;
    padding-bottom: 12px;
  }

  .mobile-pairs,
  #clientsView .mobile-pairs {
    gap: 7px;
    margin-top: 8px;
  }

  .mobile-pairs div,
  #clientsView .mobile-pairs div {
    line-height: 1.55;
  }

  .customer-name,
  #clientsView .customer-name {
    gap: 7px;
  }
}

#resourceView td[data-label="操作"],
#resourceView td[data-label="鎿嶄綔"] {
  display: block !important;
  width: 100% !important;
}

#resourceView td[data-label="操作"]::before,
#resourceView td[data-label="鎿嶄綔"]::before {
  display: none !important;
}

#resourceView .row-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 5px !important;
  width: 100% !important;
}

#resourceView .row-actions button {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 36px !important;
  padding: 7px 2px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

.agreement-panel {
  display: flex !important;
  flex-direction: column !important;
  max-height: 92dvh !important;
}

.agreement-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  padding-bottom: 12px !important;
}

.agreement-accept-btn {
  flex: 0 0 auto !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 5 !important;
  margin-top: 12px !important;
  min-height: 46px !important;
}

.agreement-drawer {
  z-index: 200 !important;
}

[hidden] {
  display: none !important;
}

#contactBtn.contact-btn,
.top-actions #contactBtn.contact-btn.ghost-btn {
  background: var(--surface-2) url("assets/contact-phone-icon.jpg") center / 22px 22px no-repeat !important;
}

#companiesView td {
  padding-top: 10px;
  padding-bottom: 10px;
}
