:root {
  color-scheme: dark;
  --bg: #10162a;
  --surface: #1b2340;
  --surface-2: #222c4b;
  --surface-3: #172039;
  --line: rgba(138, 164, 196, .20);
  --line-strong: rgba(99, 217, 203, .34);
  --text: #f3f7f8;
  --muted: #9eabc2;
  --muted-2: #73819d;
  --accent: #55d5c2;
  --accent-deep: #13857f;
  --danger: #ff7c75;
  --warning: #e9b45f;
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-width: 1100px; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at 75% 20%, rgba(39, 173, 153, .14), transparent 34%), linear-gradient(145deg, #10162a, #141c33); }
.login-card { width: 420px; padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: rgba(27, 35, 64, .96); box-shadow: 0 28px 80px rgba(3, 7, 20, .42); }
.login-brand, .brand { display: flex; align-items: center; gap: 12px; }
.login-brand img, .brand img { width: 43px; height: 43px; border: 2px solid rgba(85,213,194,.5); border-radius: 50%; object-fit: cover; transform: scale(1); background: white; }
.login-brand strong, .brand strong { display: block; font-size: 16px; }
.login-brand span, .brand span { display: block; margin-top: 3px; color: var(--muted-2); font: 9px Consolas, monospace; letter-spacing: .13em; }
.login-card h1 { margin: 34px 0 8px; font-size: 25px; }
.login-card > p { margin: 0 0 25px; color: var(--muted); font-size: 13px; }
.login-card form { display: grid; gap: 16px; }
.login-card label, .form-grid label, .filters label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
input, select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text); background: #141c33; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(85,213,194,.09); }
.form-error { min-height: 18px; color: var(--danger); font-size: 12px; }
.primary-button, .secondary-button { height: 42px; padding: 0 17px; border-radius: 9px; cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
.primary-button { border: 1px solid rgba(107,234,217,.26); color: #071d1b; background: linear-gradient(135deg, #69dfcf, #40c3b1); font-weight: 700; }
.primary-button:hover { background: linear-gradient(135deg, #77e8d9, #4dd1be); }
.primary-button:active, .secondary-button:active { transform: scale(.98); }
.primary-button.compact { height: 36px; padding: 0 15px; font-size: 12px; }
.secondary-button { border: 1px solid var(--line); color: var(--text); background: var(--surface-2); }
.compact-button { height: 34px; padding: 0 12px; border-radius: 8px; font-size: 11px; cursor: pointer; }
.danger-button { border: 1px solid rgba(255,124,117,.26); color: #ffaaa5; background: rgba(255,124,117,.08); }
.danger-button:hover:not(:disabled) { border-color: rgba(255,124,117,.48); background: rgba(255,124,117,.14); }
button:disabled { opacity: .42; cursor: not-allowed; transform: none !important; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 2; width: 224px; display: flex; flex-direction: column; padding: 20px 14px; border-right: 1px solid var(--line); background: #131a30; }
.brand { height: 48px; padding: 0 7px; }
.sidebar nav { display: grid; gap: 6px; margin-top: 35px; }
.nav-item { height: 43px; display: flex; align-items: center; gap: 11px; padding: 0 13px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; text-align: left; cursor: pointer; }
.nav-item i { width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 3px; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-item.active { color: var(--accent); background: rgba(85,213,194,.09); }
.nav-item.active i { background: var(--accent); border-color: var(--accent); }
.dashboard-link { margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--accent); font-size: 12px; text-align: center; text-decoration: none; background: rgba(85,213,194,.05); }
.logout-button { margin-top: 10px; height: 38px; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 1; height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 25px; border-bottom: 1px solid var(--line); background: rgba(16,22,42,.94); backdrop-filter: blur(15px); }
.topbar h1 { margin: 0; font-size: 18px; }
.topbar p { margin: 5px 0 0; color: var(--muted-2); font-size: 11px; }
.topbar-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.topbar-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(85,213,194,.1); }
.topbar-status b { margin-left: 12px; padding-left: 16px; border-left: 1px solid var(--line); color: var(--text); font: 14px Consolas, monospace; }
.theme-toggle { height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--surface-2); font-size: 10.5px; cursor: pointer; }
main { padding: 20px 22px 32px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.metrics article { min-height: 112px; display: flex; flex-direction: column; justify-content: center; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metrics span { color: var(--muted); font-size: 12px; }
.metrics strong { margin-top: 9px; font: 700 27px Consolas, monospace; }
.metrics small { margin-top: 7px; color: var(--muted-2); font-size: 10px; }
.metrics .featured { border-color: rgba(85,213,194,.24); background: linear-gradient(135deg, #176b78, #168c82 55%, #2e9b71); }
.metrics .featured span, .metrics .featured small { color: rgba(255,255,255,.76); }
.metrics .featured strong { color: white; }
.content-card { margin-top: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.card-heading { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.card-heading h2 { margin: 0; font-size: 15px; }
.card-heading p { margin: 5px 0 0; color: var(--muted-2); font-size: 10.5px; }
.card-heading-actions { display: flex; align-items: center; gap: 8px; }
.authorization-summary { display: flex; align-items: center; gap: 12px; }
.authorization-summary strong { color: var(--text); font: 600 11px Consolas, monospace; }
.bulk-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(85,213,194,.055), rgba(15,21,39,.18)); }
.bulk-selection { min-width: 180px; display: grid; gap: 3px; }
.bulk-selection strong { color: var(--text); font-size: 11.5px; }
.bulk-selection span { color: var(--muted-2); font-size: 9.5px; }
.bulk-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.bulk-actions select { width: 180px; height: 34px; font-size: 11px; }
.text-button { height: 30px; padding: 0 5px; border: 0; color: var(--muted); background: transparent; font-size: 10.5px; cursor: pointer; }
.text-button:hover:not(:disabled) { color: var(--accent); }
.filters { display: grid; grid-template-columns: minmax(260px,1fr) 170px 150px auto; gap: 10px; align-items: end; padding: 12px 14px; border-bottom: 1px solid var(--line); background: rgba(15,21,39,.3); }
.authorization-filters { grid-template-columns: minmax(320px,1fr) auto; }
.filters input, .filters select { height: 36px; font-size: 12px; }
.filters .secondary-button { height: 36px; font-size: 12px; }
.table-wrap { min-height: 460px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 42px; padding: 0 12px; color: var(--muted-2); background: #171f38; font-size: 10.5px; font-weight: 500; text-align: left; }
.sort-button { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; color: inherit; background: transparent; font-size: inherit; cursor: pointer; }
.sort-button::after { content: "↕"; color: var(--muted-2); font-size: 10px; }
.sort-button.active { color: var(--accent); }
.sort-button.active[data-order="asc"]::after { content: "↑"; color: var(--accent); }
.sort-button.active[data-order="desc"]::after { content: "↓"; color: var(--accent); }
td { height: 56px; padding: 0 12px; border-bottom: 1px solid rgba(138,164,196,.1); color: #dfe6ec; font-size: 11.5px; }
th:nth-child(1) { width: 18%; } th:nth-child(2) { width: 15%; } th:nth-child(3) { width: 9%; } th:nth-child(4) { width: 10%; } th:nth-child(5) { width: 11%; } th:nth-child(6) { width: 9%; } th:nth-child(7) { width: 11%; } th:nth-child(8) { width: 17%; }
.accounts-table th:nth-child(1) { width: 46px; }
.accounts-table th:nth-child(2) { width: 17%; }
.accounts-table th:nth-child(3) { width: 15%; }
.accounts-table th:nth-child(4) { width: 9%; }
.accounts-table th:nth-child(5) { width: 10%; }
.accounts-table th:nth-child(6) { width: 11%; }
.accounts-table th:nth-child(7) { width: 9%; }
.accounts-table th:nth-child(8) { width: 11%; }
.accounts-table th:nth-child(9) { width: 14%; }
.selection-cell { padding-right: 6px !important; padding-left: 12px !important; text-align: center; }
.selection-checkbox { width: 16px; height: 16px; margin: 0; padding: 0; border-radius: 4px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
tbody tr:hover { background: rgba(85,213,194,.035); }
.accounts-table tbody tr.selected-row { background: rgba(85,213,194,.075); box-shadow: inset 3px 0 0 var(--accent); }
.account-cell strong, .account-cell small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-cell strong { color: var(--text); font-size: 12px; }
.account-cell small { margin-top: 4px; color: var(--muted-2); font: 9.5px Consolas, monospace; }
.mono { font-family: Consolas, monospace; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; border-radius: 6px; font-size: 10px; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.live { color: var(--accent); background: rgba(85,213,194,.08); }
.status.warning { color: var(--warning); background: rgba(233,180,95,.08); }
.status.offline { color: var(--muted); background: rgba(158,171,194,.07); }
.row-actions { display: flex; align-items: center; gap: 5px; }
.row-actions button { height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; cursor: pointer; }
.row-actions button:hover { color: var(--accent); border-color: var(--line-strong); }
.row-actions button:disabled { color: var(--muted-2); border-color: var(--line); opacity: .52; cursor: not-allowed; }
.row-actions .danger:hover { color: var(--danger); border-color: rgba(255,124,117,.35); }
.empty-state { height: 460px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.pagination { height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; color: var(--muted); font-size: 11px; }
.pagination div { display: flex; align-items: center; gap: 10px; }
.pagination .page-size { gap: 16px; }
.page-size label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.page-size select { width: 68px; height: 29px; padding: 0 7px; border-radius: 6px; font-size: 10.5px; }
.pagination button { height: 29px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; }
.pagination b { min-width: 60px; color: var(--text); font: 10px Consolas, monospace; text-align: center; }
.placeholder { min-height: 520px; display: grid; place-content: center; justify-items: center; text-align: center; }
.placeholder-icon { width: 46px; height: 46px; border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(85,213,194,.08); }
.placeholder h2 { margin: 15px 0 7px; font-size: 16px; }
.placeholder p { margin: 0; color: var(--muted); font-size: 12px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(4,7,16,.72); backdrop-filter: blur(5px); }
.modal-card { width: min(650px, 100%); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 30px 90px rgba(0,0,0,.4); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.modal-heading h2 { margin: 0; font-size: 16px; }
.modal-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.modal-heading > button { width: 32px; height: 32px; border: 0; color: var(--muted); background: transparent; font-size: 23px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 20px; }
.form-grid input, .form-grid select { height: 39px; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); background: rgba(15,21,39,.25); }
.modal-actions .secondary-button { height: 36px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 380px; padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); background: #1d2c45; box-shadow: 0 16px 40px rgba(0,0,0,.3); font-size: 12px; }
.toast.error { border-color: rgba(255,124,117,.4); color: #ffd5d2; background: #3a2633; }
.users-card { margin-top: 0; }
.users-table-wrap { min-height: 320px; }
.users-table th:nth-child(1) { width: 30%; }
.users-table th:nth-child(2) { width: 20%; }
.users-table th:nth-child(3) { width: 30%; }
.users-table th:nth-child(4) { width: 20%; }
.role-badge { display: inline-flex; padding: 4px 8px; border-radius: 6px; color: var(--accent); background: rgba(85,213,194,.08); font-size: 10px; }
.role-badge.operator { color: var(--muted); background: rgba(158,171,194,.08); }
.user-modal-card { width: min(560px, 100%); }
.full-field { grid-column: 1 / -1; }
.management-view { display: grid; gap: 14px; }
.integration-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.integration-summary article { min-height: 104px; display: flex; flex-direction: column; justify-content: center; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.integration-summary span { color: var(--muted); font-size: 11px; }
.integration-summary strong { margin-top: 8px; color: var(--text); font: 700 18px "Microsoft YaHei UI", sans-serif; }
.integration-summary strong.ready { color: var(--accent); }
.integration-summary strong.warn { color: var(--warning); }
.integration-summary small { margin-top: 6px; color: var(--muted-2); font-size: 10px; }
.integration-card, .compact-card { margin-top: 0; }
.integration-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; padding: 16px; }
.integration-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.integration-form input { height: 38px; font-size: 11.5px; }
.integration-form .wide-field { grid-column: 1 / -1; }
.integration-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding-top: 3px; }
.integration-actions > span { color: var(--warning); font-size: 10.5px; }
.muted-label { color: var(--muted-2); font-size: 10px; }
.compact-table { min-height: 0; max-height: 300px; overflow: auto; }
.compact-table table { table-layout: auto; }
.compact-table th { position: sticky; top: 0; z-index: 1; width: auto !important; min-width: 110px; white-space: nowrap; }
.compact-table td { height: 48px; min-width: 110px; }
.compact-table th:first-child, .compact-table td:first-child { padding-left: 16px; }
.connection-name { display: grid; gap: 3px; }
.connection-name small { color: var(--muted-2); font: 9.5px Consolas, monospace; }
.sync-status { display: inline-flex; padding: 4px 7px; border-radius: 6px; color: var(--muted); background: rgba(158,171,194,.08); font-size: 10px; }
.sync-status.success, .sync-status.connected { color: var(--accent); background: rgba(85,213,194,.08); }
.sync-status.failed, .sync-status.error, .sync-status.expired { color: var(--danger); background: rgba(255,124,117,.08); }
.sync-status.running, .sync-status.pending { color: var(--warning); background: rgba(233,180,95,.08); }
.sync-status.not_authorized { color: var(--muted); background: rgba(158,171,194,.07); }
.audit-detail { max-width: 420px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.system-summary article strong { font-family: Consolas, monospace; }
#accountModal .modal-card { max-height: calc(100vh - 48px); overflow-y: auto; }

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5f8;
  --surface: #ffffff;
  --surface-2: #edf3f5;
  --surface-3: #f7fafb;
  --line: rgba(49, 78, 99, .16);
  --line-strong: rgba(19, 133, 127, .30);
  --text: #172632;
  --muted: #5d6d7b;
  --muted-2: #81909c;
  --accent: #168c82;
  --accent-deep: #0f706a;
}
html[data-theme="light"] body { background: var(--bg); }
html[data-theme="light"] .login-shell { background: radial-gradient(circle at 75% 20%, rgba(22,140,130,.10), transparent 34%), #eef4f6; }
html[data-theme="light"] .login-card,
html[data-theme="light"] .sidebar,
html[data-theme="light"] .topbar,
html[data-theme="light"] .content-card,
html[data-theme="light"] .metrics article,
html[data-theme="light"] .modal-card { background: #ffffff; }
html[data-theme="light"] .integration-summary article { background: #ffffff; }
html[data-theme="light"] input,
html[data-theme="light"] select { color: var(--text); background: #f7fafb; }
html[data-theme="light"] th { background: #eef3f6; }
html[data-theme="light"] td { color: #314451; }
html[data-theme="light"] .account-cell strong { color: var(--text); }
html[data-theme="light"] .filters,
html[data-theme="light"] .modal-actions { background: #f7fafb; }
html[data-theme="light"] .bulk-toolbar { background: linear-gradient(90deg, rgba(22,140,130,.065), #f7fafb); }
html[data-theme="light"] .topbar { background: rgba(255,255,255,.92); }
html[data-theme="light"] .row-actions button { color: #536778; }
@media (max-width: 1250px) { .metrics { grid-template-columns: repeat(2,1fr); } .filters { grid-template-columns: 1fr 1fr 1fr auto; } .bulk-toolbar { align-items: flex-start; flex-direction: column; } .bulk-actions { width: 100%; justify-content: flex-start; } }
