/* BANFULY 统一界面规范 v1（全浅色简洁），与 styles.css、design/banfuly-tokens.css 保持一致 */
:root {
  --ink: #1d1d1f; --ink-soft: #424245; --action: #0071e3; --action-hover: #0077ed; --action-soft: #e8f1fd; --canvas: #f5f5f7; --surface: #fff;
  --fill: #f5f5f7; --fill-hover: #ebebf0; --border: rgba(0,0,0,.08); --border-strong: #d2d2d7; --muted: #6e6e73; --hint: #86868b;
  --primary: #1d1d1f; --primary-hover: #333336; --success: #1e8e3e; --success-bg: #e8f6ec; --danger: #d70015; --danger-bg: #fff1f2;
  --radius-control: 10px; --radius-panel: 18px; --radius-pill: 999px; --header-height: 60px; --shadow: 0 18px 48px rgba(0,0,0,.12);
  --shadow-card: 0 1px 2px rgba(0,0,0,.04); --ease: cubic-bezier(.25,.1,.25,1);
}
* { box-sizing: border-box; }
html { min-width: 0; background: var(--canvas); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Noto Sans SC", "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
body { min-width: 0; margin: 0; font-size: 15px; line-height: 1.5; }
button, input { font: inherit; }
button, a, label { touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(0,113,227,.35); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 16px; min-height: 44px; padding: 0 16px; display: flex; align-items: center; border-radius: var(--radius-control); background: var(--ink); color: #fff; text-decoration: none; transform: translateY(-140%); transition: transform .18s ease; }
.skip-link:focus { transform: translateY(0); }

.topbar { position: sticky; z-index: 20; top: 0; height: var(--header-height); border-bottom: 1px solid var(--border); background: rgba(255,255,255,.82); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.topbar-inner { width: min(100%,1312px); height: 100%; margin: 0 auto; padding: 0 32px; display: flex; align-items: center; gap: 24px; }
.brand { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; font-weight: 600; letter-spacing: .06em; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; position: relative; border-radius: 7px; background: var(--ink); }
.brand-mark::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 6px; height: 6px; border-radius: 2px; background: #fff; }
.primary-navigation { display: flex; align-items: center; gap: 4px; }
.primary-navigation a { min-height: 36px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: var(--radius-pill); color: var(--ink-soft); font-size: 14px; font-weight: 500; text-decoration: none; }
.primary-navigation a:hover { background: var(--fill); color: var(--ink); }
.primary-navigation a[aria-current="page"] { background: var(--fill); color: var(--ink); }
.top-actions { min-width: 0; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.account-label { max-width: 240px; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

.button, .icon-button { min-height: 44px; padding: 0 20px; border: 1px solid transparent; border-radius: var(--radius-pill); cursor: pointer; font-size: 14px; font-weight: 500; transition: background-color .18s ease,border-color .18s ease,color .18s ease,opacity .18s ease; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; text-decoration: none; }
.button-primary:hover:not(:disabled) { background: var(--primary-hover); }
.button-secondary { border-color: var(--border-strong); background: var(--surface); color: var(--ink); }
.button-secondary:hover:not(:disabled), .button-quiet:hover:not(:disabled) { background: var(--fill); color: var(--ink); }
.button-quiet { background: transparent; color: var(--ink-soft); }
.icon-button { width: 44px; padding: 0; background: var(--fill); color: var(--ink); font-size: 20px; }
.icon-button:hover { background: var(--fill-hover); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.state-panel { min-height: calc(100vh - var(--header-height)); display: grid; place-content: center; justify-items: center; color: var(--muted); }
.loading-mark { width: 22px; height: 22px; border: 2px solid var(--fill-hover); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
.state-panel p { margin: 12px 0 0; }
.blocked-panel { width: min(420px,calc(100% - 32px)); margin: 12vh auto 0; padding: 36px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: 0 12px 32px rgba(0,0,0,.08); }
.blocked-panel h1 { margin: 0 0 8px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.blocked-panel p { margin: 0 0 24px; color: var(--muted); }

.admin-main { width: min(100%,1312px); margin: 0 auto; padding: 48px 32px 64px; }
.page-heading { margin-bottom: 24px; }
.page-heading h1 { margin: 0 0 6px; font-size: 32px; font-weight: 600; line-height: 1.2; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--muted); }
.admin-layout { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 20px; align-items: start; }
.accounts-panel, .permission-panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--surface); box-shadow: var(--shadow-card); }
.accounts-panel { position: sticky; top: calc(var(--header-height) + 20px); overflow: hidden; }
.panel-heading { min-height: 68px; padding: 12px 16px 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; font-size: 17px; font-weight: 600; }
.search-field { padding: 14px 16px 10px; display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.search-field input, .create-grid input, .settings-grid input, .reason-field input { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid transparent; border-radius: 12px; background: var(--fill); color: var(--ink); outline: none; transition: background-color .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease); }
.search-field input:focus, .create-grid input:focus, .settings-grid input:focus, .reason-field input:focus { border-color: var(--action); background: #fff; box-shadow: 0 0 0 4px rgba(0,113,227,.14); }
.account-list { max-height: calc(100vh - 260px); padding: 6px 8px 10px; display: grid; gap: 4px; overflow: auto; }
.account-item { width: 100%; min-height: 64px; padding: 10px 12px; display: grid; grid-template-columns: 38px minmax(0,1fr) 10px; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; color: var(--ink); cursor: pointer; text-align: left; }
.account-item:hover { background: var(--fill); }
.account-item.selected { border-color: transparent; background: var(--action-soft); }
.account-avatar, .avatar { display: grid; place-items: center; border-radius: 50%; background: var(--fill); color: var(--ink-soft); font-weight: 600; }
.account-avatar { width: 38px; height: 38px; }
.account-item > span:nth-child(2) { min-width: 0; display: grid; }
.account-item strong, .account-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-item small { color: var(--muted); font-weight: 400; }
.active-dot, .inactive-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.inactive-dot { background: var(--border-strong); }
.list-empty { padding: 22px 12px; color: var(--muted); text-align: center; }

.permission-panel { overflow: hidden; }
.empty-selection { min-height: 360px; padding: 28px; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-selection > span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: var(--action-soft); color: var(--action); font-weight: 600; }
.empty-selection > span svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.75; }
.empty-selection h2 { margin: 14px 0 4px; font-size: 19px; font-weight: 600; }
.empty-selection p { margin: 0; color: var(--muted); }
.editor-header { min-height: 104px; padding: 20px 24px; display: grid; grid-template-columns: 52px minmax(0,1fr) auto; align-items: center; gap: 14px; border-bottom: 1px solid var(--border); }
.avatar { width: 52px; height: 52px; font-size: 18px; }
.editor-title { min-width: 0; }
.editor-title p { margin: 0; color: var(--muted); font-size: 13px; }
.editor-title h2 { margin: 1px 0 5px; overflow: hidden; font-size: 21px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { padding: 3px 10px; border-radius: 99px; background: var(--success-bg); color: var(--success); font-size: 12px; font-weight: 500; }
.status-pill.disabled { background: var(--fill); color: var(--hint); }
.editor-meta { display: none; }
.editor-meta strong { color: var(--ink); }
.mobile-account-back { display: none; }

.account-settings, .systems-section, .detail-section, .change-section, .audit-section, .create-panel { padding: 24px; border-bottom: 1px solid var(--border); }
.section-heading { margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading h2, .section-heading h3 { margin: 0; font-size: 17px; font-weight: 600; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.settings-grid, .create-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.settings-grid > label, .create-grid > label, .reason-field { display: grid; gap: 7px; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.wide { grid-column: 1/-1; }
.toggle-row { min-height: 64px; padding: 10px 12px; display: grid !important; grid-template-columns: minmax(0,1fr) 44px; align-items: center; column-gap: 12px; border: 0; border-radius: 12px; background: var(--fill); cursor: pointer; }
.toggle-row input { appearance: none; width: 44px; height: 24px; min-height: 24px; padding: 0; grid-column: 2; grid-row: 1/3; border: 0; border-radius: 99px; background-color: var(--border-strong); background-image: radial-gradient(circle at 12px 12px,#fff 0 9px,transparent 9.5px); cursor: pointer; transition: background-color .18s ease,background-position .18s ease; }
.toggle-row > span, .toggle-row > small { grid-column: 1; }
.toggle-row input:checked { background-color: var(--success); background-image: radial-gradient(circle at 32px 12px,#fff 0 9px,transparent 9.5px); }
.toggle-row small { color: var(--muted); font-weight: 400; }

.system-grid { display: grid; gap: 0; border-top: 1px solid var(--border); }
.system-card { min-height: 72px; padding: 10px 0; display: grid; grid-template-columns: minmax(0,1fr) auto 44px; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.system-heading { min-width: 0; display: grid; grid-template-columns: 38px minmax(0,1fr); align-items: center; gap: 11px; }
.system-heading > i { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--action-soft); color: var(--action); font-style: normal; font-weight: 600; }
.system-heading > i svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.system-heading > span { min-width: 0; display: grid; }
.system-heading small { overflow: hidden; color: var(--muted); font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.system-card > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch { width: 44px; height: 24px; padding: 3px; border-radius: 99px; background: var(--border-strong); transition: background .18s ease; }
.switch::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .18s ease; }
.system-card > input:checked + .switch { background: var(--success); }
.system-card > input:checked + .switch::after { transform: translateX(20px); }
.system-card > input:focus-visible + .switch { outline: 3px solid rgba(0,113,227,.35); outline-offset: 2px; }

.policy-boundary, .detail-disabled-message { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; background: var(--action-soft); color: var(--ink-soft); font-size: 13px; }
.detail-disabled-message { background: var(--danger-bg); color: var(--danger); }
.detail-section.disabled { background: #fbfbfd; }
.capability-groups { display: grid; gap: 18px; }
.capability-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.capability-group legend { width: 100%; margin-bottom: 8px; display: grid; }
.capability-group legend strong { font-size: 14px; }
.capability-group legend small { color: var(--muted); }
.capability-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); border-top: 1px solid var(--border); }
.capability-card { min-height: 58px; padding: 9px 8px 9px 0; display: grid; grid-template-columns: 22px minmax(0,1fr); align-items: center; gap: 9px; border-bottom: 1px solid var(--border); cursor: pointer; }
.capability-card:nth-child(odd) { margin-right: 16px; }
.capability-card input, .mini-grant-grid input { appearance: none; width: 20px; height: 20px; display: grid; place-items: center; border: 1.5px solid var(--border-strong); border-radius: 6px; background: #fff; cursor: pointer; }
.capability-card input:checked, .mini-grant-grid input:checked { border-color: var(--action); background: var(--action); }
.capability-card input:checked::after, .mini-grant-grid input:checked::after { content: ""; width: 8px; height: 4px; border-bottom: 2px solid #fff; border-left: 2px solid #fff; transform: rotate(-45deg) translate(1px,-1px); }
.capability-card > span { display: grid; }
.capability-card small { color: var(--muted); font-size: 12px; font-weight: 400; }
.capability-group.action-group .capability-card strong { color: #b25000; }
.capability-group:disabled { opacity: .55; }

.change-summary { min-height: 48px; margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; background: var(--fill); color: var(--ink-soft); font-size: 13px; }
.change-summary ul { margin: 0; padding-left: 20px; }
.reason-field { margin-bottom: 16px; }
.audit-section { border-bottom: 0; }
.audit-list { display: grid; border-top: 1px solid var(--border); }
.audit-list article { padding: 13px 0; border-bottom: 1px solid var(--border); }
.audit-list article > div { display: flex; justify-content: space-between; gap: 16px; }
.audit-list time, .audit-list small { color: var(--muted); font-size: 12px; }
.audit-list p { margin: 4px 0; color: var(--ink-soft); }
.mini-grant-grid { margin-top: 8px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.mini-grant-grid label { min-height: 44px; display: flex; align-items: center; gap: 9px; cursor: pointer; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: 420px; padding: 14px 20px; border-radius: 14px; background: rgba(29,29,31,.92); color: #fff; font-size: 14px; box-shadow: var(--shadow); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.toast.error { background: var(--danger); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1023px) {
  .topbar-inner, .admin-main { padding-left: 24px; padding-right: 24px; }
  .admin-layout { grid-template-columns: 240px minmax(0,1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  :root { --header-height: 56px; }
  .topbar-inner { padding: 0 16px; gap: 8px; }
  .primary-navigation, .account-label { display: none; }
  .admin-main { padding: 28px 16px 40px; }
  .page-heading h1 { font-size: 24px; }
  .admin-layout { grid-template-columns: minmax(0,1fr); }
  .accounts-panel { position: static; }
  .permission-panel { display: none; }
  .admin-layout.editing .accounts-panel { display: none; }
  .admin-layout.editing .permission-panel { display: block; }
  .account-list { max-height: none; }
  .mobile-account-back { grid-column: 1/-1; justify-self: start; display: inline-flex; }
  .editor-header { padding: 16px 18px; grid-template-columns: 44px minmax(0,1fr) auto; }
  .avatar { width: 44px; height: 44px; }
  .account-settings, .systems-section, .detail-section, .change-section, .audit-section, .create-panel { padding: 20px 18px; }
  .settings-grid, .create-grid, .capability-grid, .mini-grant-grid { grid-template-columns: minmax(0,1fr); }
  .capability-card:nth-child(odd) { margin-right: 0; }
  .system-card { grid-template-columns: minmax(0,1fr) 44px; }
  .system-card > input { grid-column: 2; }
  .system-card > .switch { grid-column: 2; }
  .toast { right: 16px; bottom: 16px; left: 16px; }
}
@media (max-width: 359px) {
  .topbar-inner, .admin-main { padding-left: 12px; padding-right: 12px; }
  .brand { gap: 7px; letter-spacing: .025em; }
  .brand-mark { width: 22px; height: 22px; }
  .editor-meta { display: none; }
  .editor-header { grid-template-columns: 44px minmax(0,1fr); }
}
/* 在线人员（仅管理员可见），与 design/banfuly-tokens.css 同一套变量 */
.presence { position: relative; }
.presence-button { min-height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; background: #e8f6ec; color: #1e8e3e; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; transition: background-color .18s ease; }
.presence-button:hover, .presence-button[aria-expanded="true"] { background: #d7efdf; }
.presence-dot { width: 7px; height: 7px; border-radius: 50%; background: #1e8e3e; box-shadow: 0 0 0 3px rgba(30, 142, 62, .18); }
.presence-panel { position: absolute; z-index: 40; top: calc(100% + 10px); right: 0; width: 340px; max-height: min(70vh, 480px); overflow: auto; padding: 10px 14px 6px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 18px 48px rgba(0, 0, 0, .12); }
.presence-head { padding: 2px 0 8px; display: flex; justify-content: space-between; gap: 12px; color: #86868b; font-size: 12px; }
.presence-list { margin: 0; padding: 0; list-style: none; }
.presence-item { padding: 9px 0; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; border-top: 1px solid rgba(0, 0, 0, .06); }
.presence-avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #f5f5f7; color: #424245; font-size: 13px; font-weight: 600; }
.presence-text { min-width: 0; display: grid; }
.presence-text strong { overflow: hidden; color: #1d1d1f; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.presence-text small { overflow: hidden; color: #86868b; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.presence-system { color: #424245; }
.presence-system[data-tone="data"] { color: #0071e3; }
.presence-system[data-tone="trend"] { color: #e86a00; }
.presence-system[data-tone="image"] { color: #7a3ff2; }
.presence-system[data-tone="chart"] { color: #1e8e3e; }
.presence-system[data-tone="check"] { color: #0a7f86; }
.presence-time { color: #86868b; font-size: 12px; white-space: nowrap; }
.presence-empty { padding: 14px 0; border-top: 1px solid rgba(0, 0, 0, .06); color: #86868b; font-size: 13px; text-align: center; }
@media (max-width: 767px) {
  .presence-button { padding: 0 10px; }
  .presence-panel { position: fixed; top: 64px; right: 12px; left: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
