:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #667085;
  --line: #dfe5ee;
  --line-soft: #edf1f5;
  --primary: #1769ff;
  --primary-dark: #0d51d6;
  --primary-soft: #eaf2ff;
  --green: #11845b;
  --green-soft: #e7f7f0;
  --amber: #a76608;
  --amber-soft: #fff4dd;
  --red: #c9374f;
  --red-soft: #fff0f2;
  --violet: #7057d9;
  --shadow: 0 16px 40px rgba(32, 51, 83, .08);
  --topbar: 72px;
  --sidebar: 232px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { min-width: 320px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.mobile-brand { display: none; }

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 170px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--primary); border-radius: 8px; }
.brand-mark svg { width: 21px; height: 21px; }
.brand > span:last-child { display: grid; line-height: 1.05; }
.brand strong { font-size: 18px; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.brand-light .brand-mark { color: #12344e; background: #fff; }
.brand-light strong, .brand-light small { color: #fff; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 46%) 1fr; background: var(--surface); }
.login-brand { padding: clamp(42px, 6vw, 88px); color: #fff; background: #11344e; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; inset: auto 0 0; height: 28%; background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px); background-size: 32px 32px; pointer-events: none; }
.brand-copy { margin: auto 0; max-width: 620px; position: relative; z-index: 1; }
.eyebrow { margin: 0 0 10px; font-size: 11px; color: var(--primary); font-weight: 800; text-transform: uppercase; }
.login-brand .eyebrow { color: #7fd5bd; }
.brand-copy h1 { margin: 0; font-size: clamp(38px, 4.2vw, 68px); line-height: 1.12; font-weight: 750; }
.brand-copy > p:last-child { margin: 24px 0 0; color: #c8d7e2; font-size: 17px; }
.brand-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; position: relative; z-index: 1; }
.brand-facts > div { display: flex; gap: 10px; align-items: center; border-top: 1px solid rgba(255,255,255,.18); padding-top: 18px; color: #c8d7e2; font-size: 12px; }
.brand-facts svg { width: 20px; flex: 0 0 20px; color: #7fd5bd; }
.brand-facts span { display: grid; gap: 5px; }
.brand-facts strong { color: #fff; font-size: 13px; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-form { width: min(400px, 100%); display: grid; gap: 22px; }
.login-form h2 { margin: 0 0 8px; font-size: 30px; }
.muted, .login-form .muted { margin: 0; color: var(--muted); font-size: 14px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; }
.segmented button { min-height: 38px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; }
.segmented button.active { color: var(--primary); background: var(--surface); box-shadow: 0 1px 4px rgba(16,24,40,.09); font-weight: 700; }
.field { display: grid; gap: 8px; font-size: 13px; font-weight: 700; color: #344054; }
.input-wrap { display: flex; align-items: center; min-height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 0 12px; transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,105,255,.11); }
.input-wrap > svg { width: 17px; color: #98a2b3; flex: 0 0 17px; }
.input-wrap input { min-width: 0; flex: 1; border: 0; outline: 0; padding: 10px; background: transparent; color: var(--ink); }
.input-icon { border: 0; background: transparent; color: var(--muted); padding: 6px; display: grid; }
.input-icon svg { width: 17px; }
.form-error { min-height: 18px; margin: -10px 0 0; color: var(--red); font-size: 12px; }
.login-foot { text-align: center; margin: -8px 0 0; color: var(--muted); font-size: 12px; }

.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 14px; color: #344054; background: var(--surface); font-weight: 650; transition: transform .12s, background .12s, border-color .12s; }
.btn:hover { border-color: #b9c3d1; background: var(--surface-soft); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { color: #fff; background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--red); background: var(--red-soft); border-color: #f2c8ce; }
.btn-small { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn-wide { width: 100%; min-height: 46px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 7px; color: #475467; background: transparent; padding: 0; }
.icon-btn:hover { background: var(--surface-soft); border-color: var(--line); }
.icon-btn svg { width: 19px; height: 19px; }

.app-shell { min-height: 100vh; }
.topbar { position: fixed; z-index: 30; inset: 0 0 auto; height: var(--topbar); padding: 0 24px; display: flex; align-items: center; gap: 30px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); }
.top-nav { height: 100%; display: flex; align-items: stretch; gap: 2px; margin: 0 auto; }
.top-nav a { min-width: 92px; display: grid; place-items: center; color: #475467; font-size: 14px; border-bottom: 2px solid transparent; }
.top-nav a:hover, .top-nav a.active { color: var(--primary); background: var(--primary-soft); border-bottom-color: var(--primary); }
.top-actions { display: flex; align-items: center; gap: 4px; }
.user-menu { margin-left: 6px; display: flex; align-items: center; gap: 9px; min-width: 150px; border: 0; background: transparent; padding: 6px; border-radius: 7px; text-align: left; }
.user-menu:hover { background: var(--surface-soft); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #e5eeff; color: var(--primary); font-size: 13px; font-weight: 800; }
.user-copy { display: grid; flex: 1; min-width: 0; }
.user-copy strong, .user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: 13px; }
.user-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.user-menu > svg { width: 16px; }

.sidebar { position: fixed; z-index: 20; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
#sideNav { flex: 1; overflow: auto; padding: 18px 12px; }
.nav-group { margin-bottom: 18px; }
.nav-group-title { margin: 0 10px 7px; color: #98a2b3; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.nav-item { width: 100%; min-height: 40px; display: flex; align-items: center; gap: 11px; margin: 2px 0; padding: 8px 11px; color: #475467; border: 0; border-radius: 7px; background: transparent; font-size: 13px; text-align: left; }
.nav-item svg { width: 17px; height: 17px; color: #7b8798; }
.nav-item:hover { color: var(--ink); background: var(--surface-soft); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.nav-item.active svg { color: var(--primary); }
.nav-badge { margin-left: auto; min-width: 20px; padding: 2px 6px; border-radius: 9px; color: var(--amber); background: var(--amber-soft); font-size: 10px; text-align: center; }
.sidebar-foot { height: 72px; display: flex; align-items: center; gap: 6px; padding: 12px; border-top: 1px solid var(--line); }
.system-state { min-width: 0; flex: 1; display: flex; gap: 9px; align-items: center; font-size: 11px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.system-state > span:last-child { display: grid; gap: 3px; }
.system-state small { color: var(--muted); }
.sidebar-backdrop { display: none; }

.workspace { min-height: 100vh; margin-left: var(--sidebar); padding: calc(var(--topbar) + 30px) clamp(22px, 3vw, 44px) 50px; }
.page-head { min-height: 80px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.breadcrumb { margin: 0 0 8px; color: var(--muted); font-size: 11px; }
.page-head h1 { margin: 0; font-size: 24px; line-height: 1.25; }
.page-head > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; align-items: center; gap: 8px; padding-top: 20px; }
.page-content { min-width: 0; }

.notice { min-height: 50px; display: flex; align-items: center; gap: 11px; margin-bottom: 20px; padding: 12px 16px; border: 1px solid #bdd8fc; border-left: 4px solid var(--primary); border-radius: 7px; background: #f2f7ff; color: #24466f; font-size: 13px; }
.notice svg { width: 18px; color: var(--primary); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.stat-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 7px; color: var(--primary); background: var(--primary-soft); }
.stat-icon.green { color: var(--green); background: var(--green-soft); }
.stat-icon.amber { color: var(--amber); background: var(--amber-soft); }
.stat-icon.violet { color: var(--violet); background: #f0edff; }
.stat-icon svg { width: 17px; }
.stat-value { margin: 12px 0 7px; font-size: 30px; font-weight: 760; line-height: 1; overflow-wrap: anywhere; }
.stat-foot { color: var(--muted); font-size: 11px; }
.stat-foot strong { color: var(--green); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .65fr); gap: 18px; }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.panel + .panel { margin-top: 18px; }
.panel-head { min-height: 58px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 9px; }
.panel-title svg { width: 18px; color: var(--primary); }
.panel-title h2 { margin: 0; font-size: 15px; }
.panel-title p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 18px; }
.chart { height: 220px; display: flex; align-items: flex-end; gap: 8px; padding-top: 20px; }
.bar-cell { min-width: 0; flex: 1; display: grid; grid-template-rows: 1fr 20px; gap: 7px; height: 100%; text-align: center; color: var(--muted); font-size: 9px; }
.bar-track { height: 100%; display: flex; align-items: flex-end; background: var(--surface-soft); border-radius: 4px 4px 2px 2px; overflow: hidden; }
.bar { width: 100%; min-height: 3px; background: var(--primary); border-radius: 3px 3px 0 0; }
.quick-list { display: grid; gap: 2px; }
.quick-item { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px; border-radius: 7px; }
.quick-item:hover { background: var(--surface-soft); }
.quick-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 7px; }
.quick-icon svg { width: 17px; }
.quick-item span { display: grid; gap: 3px; font-size: 12px; }
.quick-item small { color: var(--muted); }
.quick-item > svg { margin-left: auto; width: 16px; color: #98a2b3; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.search-box { width: min(320px, 42vw); min-height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,105,255,.08); }
.search-box svg { width: 16px; color: #98a2b3; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; font-size: 13px; }
.select { min-height: 38px; border: 1px solid var(--line); border-radius: 7px; padding: 0 32px 0 10px; background: var(--surface); color: #475467; font-size: 12px; }
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th, .data-table td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; font-size: 12px; }
.data-table th { color: #667085; background: var(--surface-soft); font-size: 11px; font-weight: 700; white-space: nowrap; }
.data-table tbody tr:hover { background: #fbfcfe; }
.data-table tr:last-child td { border-bottom: 0; }
.cell-main { display: grid; gap: 3px; }
.cell-main strong { font-size: 12px; }
.cell-main small { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 5px; min-height: 23px; padding: 3px 8px; border-radius: 12px; background: #eef1f5; color: #556070; font-size: 10px; font-weight: 750; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.success { color: var(--green); background: var(--green-soft); }
.status.warning { color: var(--amber); background: var(--amber-soft); }
.status.danger { color: var(--red); background: var(--red-soft); }
.status.info { color: var(--primary); background: var(--primary-soft); }
.row-actions { display: flex; gap: 6px; }
.empty { min-height: 280px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty > div { display: grid; justify-items: center; gap: 9px; }
.empty svg { width: 34px; height: 34px; color: #a9b4c2; }
.empty h3 { margin: 0; color: #475467; font-size: 15px; }
.empty p { margin: 0; font-size: 12px; }
.pagination { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.pagination-actions { display: flex; gap: 5px; }
.pagination-actions button { min-width: 32px; height: 30px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; color: #475467; }
.pagination-actions button:disabled { opacity: .4; cursor: default; }

.modal-root { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(13, 23, 38, .48); }
.modal { position: relative; width: min(680px, 100%); max-height: min(780px, calc(100vh - 48px)); display: flex; flex-direction: column; border-radius: 8px; background: var(--surface); box-shadow: 0 28px 70px rgba(15,23,42,.25); overflow: hidden; }
.modal > header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; overflow: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.field-full { grid-column: 1 / -1; }
.control { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--surface); color: var(--ink); }
.control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,105,255,.09); }
textarea.control { resize: vertical; min-height: 100px; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.help { margin: 5px 0 0; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.55; }
.checkbox { display: flex; align-items: center; gap: 8px; min-height: 40px; color: #475467; font-size: 12px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.detail-item { padding: 12px; border: 1px solid var(--line-soft); background: var(--surface-soft); border-radius: 7px; }
.detail-item span { display: block; color: var(--muted); font-size: 10px; }
.detail-item strong { display: block; margin-top: 5px; font-size: 12px; overflow-wrap: anywhere; }
.ticket-thread { display: grid; gap: 12px; margin: 18px 0; }
.message { width: min(85%, 560px); padding: 12px 14px; border-radius: 7px; background: var(--surface-soft); border: 1px solid var(--line); }
.message.admin { justify-self: end; background: var(--primary-soft); border-color: #c9dcff; }
.message-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.message p { margin: 0; white-space: pre-wrap; line-height: 1.65; font-size: 12px; }
.code-box { padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: #172033; color: #d8e3f0; overflow: auto; font: 11px/1.7 Consolas, monospace; white-space: pre; }
.key-secret { display: flex; align-items: center; gap: 8px; padding: 12px; border: 1px solid #f1d39b; background: var(--amber-soft); border-radius: 7px; }
.key-secret code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 12px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

.toast-root { position: fixed; z-index: 150; top: 88px; right: 20px; width: min(360px, calc(100vw - 40px)); display: grid; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); animation: toast-in .2s ease; pointer-events: auto; }
.toast.error { border-left-color: var(--red); }
.toast svg { width: 17px; color: var(--green); }
.toast.error svg { color: var(--red); }
.toast span { display: grid; gap: 3px; font-size: 12px; }
.toast small { color: var(--muted); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-7px); } }

.eye-mode { --bg: #f2f6ef; --surface: #fbfdf9; --surface-soft: #f3f7f0; --line: #d9e2d5; --line-soft: #e8eee5; --primary-soft: #e9f2e8; }
.skeleton { position: relative; overflow: hidden; background: #edf1f5; border-radius: 6px; min-height: 20px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); transform: translateX(-100%); animation: shimmer 1.1s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

@media (max-width: 1100px) {
  .top-nav { display: none; }
  .top-actions { margin-left: auto; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .brand-facts { grid-template-columns: 1fr; }
  .brand-facts > div:nth-child(n+3) { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar: 62px; --sidebar: min(286px, 84vw); }
  .mobile-only { display: grid !important; }
  .mobile-brand { display: inline-flex; }
  .login-view { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { padding: 28px 20px; align-items: start; padding-top: 10vh; }
  .mobile-brand { margin-bottom: 18px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar > .brand { min-width: 0; }
  .topbar .brand > span:last-child { display: none; }
  .topbar .brand-mark { width: 34px; height: 34px; }
  #globalSearchButton { display: none; }
  .user-menu { min-width: 0; margin-left: 0; }
  .user-copy, .user-menu > svg { display: none; }
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 19; inset: var(--topbar) 0 0; width: 100%; height: auto; border: 0; background: rgba(15,23,42,.35); }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .workspace { margin-left: 0; padding: calc(var(--topbar) + 22px) 14px 34px; }
  .page-head { min-height: 70px; margin-bottom: 14px; }
  .page-head h1 { font-size: 21px; }
  .page-head > div > p:last-child { max-width: 62vw; }
  .page-actions { padding-top: 14px; }
  .page-actions .btn span { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .search-box { width: 100%; }
  .toolbar-right .btn { flex: 1; }
  .panel-head { padding: 12px 14px; }
  .data-table th, .data-table td { padding: 11px 12px; }
  .modal-root { padding: 0; place-items: end center; }
  .modal { width: 100%; max-height: 92vh; border-radius: 8px 8px 0 0; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full, .form-actions { grid-column: 1; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .stat-head { grid-column: 1 / -1; }
  .stat-value { margin-bottom: 0; }
  .stat-foot { text-align: right; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
