:root {
  --ink: #18211c;
  --muted: #6f7972;
  --line: #e3e8e4;
  --canvas: #f4f6f3;
  --panel: #ffffff;
  --forest: #153b2d;
  --forest-2: #205941;
  --mint: #d9efe4;
  --lime: #b9df72;
  --danger: #b5483f;
  --warning: #b57928;
  --shadow: 0 18px 50px rgba(22, 48, 35, .09);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 8px; color: #6b766f; font-size: 11px; font-weight: 750; letter-spacing: .13em; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 42px 20px 72px; position: relative; overflow: hidden; background: radial-gradient(circle at 18% 20%, rgba(185,223,114,.23), transparent 27%), radial-gradient(circle at 85% 78%, rgba(80,143,111,.16), transparent 29%), #f3f6f1; }
.login-shell::before, .login-shell::after { content: ""; position: absolute; border: 1px solid rgba(21,59,45,.1); border-radius: 999px; width: 520px; height: 520px; }
.login-shell::before { left: -320px; top: -280px; }
.login-shell::after { right: -350px; bottom: -300px; }
.login-card { z-index: 1; width: min(440px, 100%); padding: 44px; border: 1px solid rgba(21,59,45,.12); border-radius: 24px; background: rgba(255,255,255,.88); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 24px; border-radius: 14px; color: white; background: var(--forest); font-size: 23px; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.brand-mark.small { width: 34px; height: 34px; margin: 0; border-radius: 10px; font-size: 16px; }
.login-card h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 37px; font-weight: 500; letter-spacing: -.03em; }
.login-copy { margin: 12px 0 28px; color: var(--muted); line-height: 1.7; }
.login-foot { position: absolute; bottom: 22px; color: #849087; font-size: 11px; letter-spacing: .12em; }
.stack-form { display: grid; gap: 16px; }
.stack-form label { display: grid; gap: 7px; color: #4d5851; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); border: 1px solid #d8dfda; border-radius: 10px; outline: none; background: #fbfcfb; transition: border .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.55; }
input:disabled { color: #7d8780; background: #f0f3f1; }
input:focus, select:focus, textarea:focus { border-color: #4f8069; box-shadow: 0 0 0 3px rgba(79,128,105,.13); }
.button { min-height: 42px; padding: 10px 17px; border: 0; border-radius: 10px; font-weight: 720; transition: transform .15s, filter .15s; }
.button:hover { filter: brightness(1.06); }
.button:active { transform: translateY(1px); }
.button.primary { color: white; background: var(--forest); }
.button.secondary { color: var(--forest); background: var(--mint); }
.button.danger { color: var(--danger); background: #fbe9e7; }
.button.ghost { color: var(--forest); border: 1px solid var(--line); background: white; }
.button.wide { width: 100%; margin-top: 4px; }
.button.small { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.text-button, .logout-button { border: 0; color: var(--forest-2); background: none; font-size: 13px; font-weight: 650; }
.text-button { display: block; margin: 19px auto 0; }
.bootstrap { margin-top: 18px; }
.section-rule { display: flex; align-items: center; gap: 10px; color: #8b948f; font-size: 11px; }
.section-rule::before, .section-rule::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 16px 18px; color: #edf6f0; background: var(--forest); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 28px; font-weight: 720; }
.sidebar nav { display: grid; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 0; border-radius: 10px; color: #c7d7ce; text-align: left; background: transparent; font-weight: 620; }
.nav-item span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 7px; color: #bed1c5; border: 1px solid rgba(255,255,255,.13); font-size: 11px; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.1); }
.nav-item.active span { color: var(--forest); border-color: var(--lime); background: var(--lime); }
.sidebar-foot { margin-top: auto; display: grid; gap: 13px; padding: 16px 10px 4px; border-top: 1px solid rgba(255,255,255,.12); color: #b9cbbf; font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(185,223,114,.12); }
.logout-button { padding: 0; color: #d8e5dd; text-align: left; }
.workspace { min-width: 0; }
.topbar { height: 86px; display: flex; align-items: center; gap: 18px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.82); backdrop-filter: blur(12px); }
.topbar h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 24px; font-weight: 500; }
.topbar .eyebrow { margin-bottom: 4px; }
.admin-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.admin-chip > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: white; background: #63806f; font-size: 13px; font-weight: 700; }
.admin-chip strong, .admin-chip small { display: block; }
.admin-chip strong { font-size: 13px; }
.admin-chip small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.menu-toggle { display: none; border: 0; background: none; font-size: 21px; }
.content { padding: 30px 34px 56px; }
.view-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.view-head h3 { margin: 0 0 5px; font-size: 19px; }
.view-head p { margin: 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 9px; }
.search { width: 230px; min-height: 40px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; }
.stat-card { min-height: 146px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 8px 30px rgba(28,55,41,.04); }
.stat-card.accent { color: white; border-color: var(--forest); background: var(--forest); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.accent .stat-label { color: #c7d9ce; }
.stat-value { margin: 15px 0 7px; font-family: Georgia, serif; font-size: 38px; line-height: 1; }
.stat-note { color: #8a948e; font-size: 11px; }
.accent .stat-note { color: #a9c2b3; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(280px,.7fr); gap: 16px; margin-top: 18px; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.panel h3 { margin: 0 0 18px; font-size: 15px; }
.principle { min-height: 210px; display: grid; align-content: center; padding: 28px; border-radius: 14px; color: #eff8f2; background: linear-gradient(140deg, #1e4938, #102f24); }
.principle strong { max-width: 520px; font-family: Georgia, "Songti SC", serif; font-size: 28px; font-weight: 500; line-height: 1.45; }
.principle p { margin: 18px 0 0; color: #b8d0c1; font-size: 12px; }
.quick-list { display: grid; gap: 10px; }
.quick-list button { display: flex; align-items: center; justify-content: space-between; padding: 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fafbfa; text-align: left; }
.quick-list button:hover { border-color: #9db5a7; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: white; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 12px 16px; color: #768078; background: #f8faf8; font-size: 11px; letter-spacing: .04em; text-align: left; }
td { padding: 14px 16px; border-top: 1px solid #edf0ee; font-size: 13px; }
tr:hover td { background: #fbfcfb; }
.cell-main { display: block; font-weight: 680; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; color: #236247; background: #e6f4eb; font-size: 11px; font-weight: 700; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.off { color: #8b4b45; background: #f9eae8; }
.badge.warn { color: #8a601f; background: #fff3dc; }
.badge.risk { color: #8f211b; background: #ffdeda; box-shadow: 0 0 0 2px rgba(181,72,63,.12); }
.row-actions { display: flex; gap: 6px; }
.empty { padding: 46px 20px; color: var(--muted); text-align: center; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.audit-subject { display: grid; gap: 6px; min-width: 210px; white-space: normal; }
.audit-subject span { display: block; }
.audit-subject b { font-size: 12px; font-weight: 680; }
.audit-subject small { margin-left: 7px; color: var(--muted); font-size: 10px; }
.device-list { display: grid; gap: 7px; min-width: 270px; white-space: normal; }
.device-list > span { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfa; }
.device-list b, .device-list small { min-width: 0; }
.device-list small { color: var(--muted); font-size: 10px; }
.device-unbind { grid-column: 2; grid-row: 1 / span 2; align-self: center; padding: 3px 6px; border: 0; color: var(--danger); background: none; font-size: 11px; }
.device-unbind:disabled { color: #aeb5b0; cursor: not-allowed; }
.risk-row td { border-top-color: #f2bbb5; background: #fff4f2; }
.risk-row:hover td { background: #ffeae7; }
.risk-row td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.risk-flag { display: block; color: #9a2f27; font-weight: 800; }
.risk-detail { display: grid; gap: 4px; max-width: 310px; white-space: normal; color: #7f2d27; }
.risk-detail small { color: #9a514b; }

dialog { width: min(480px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 90px rgba(12,35,24,.25); }
dialog::backdrop { background: rgba(10,30,21,.48); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: start; justify-content: space-between; padding: 24px 26px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 20px; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 8px; color: #68736c; background: #f2f5f2; font-size: 22px; }
#modal-form { padding: 22px 26px 26px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-help { margin: -6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.toast { position: fixed; z-index: 50; right: 24px; top: 22px; max-width: 380px; padding: 13px 17px; border-radius: 10px; color: white; background: #243b30; box-shadow: var(--shadow); opacity: 0; transform: translateY(-10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #963e37; }

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { z-index: 20; position: fixed; left: -250px; width: 238px; transition: left .2s; box-shadow: 20px 0 50px rgba(0,0,0,.16); }
  .sidebar.open { left: 0; }
  .menu-toggle { display: block; }
  .topbar { height: 78px; padding: 0 18px; }
  .admin-chip div { display: none; }
  .content { padding: 22px 16px 42px; }
  .view-head { align-items: stretch; flex-direction: column; }
  .actions { flex-wrap: wrap; }
  .search { width: 100%; }
  .login-card { padding: 32px 24px; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar .eyebrow { display: none; }
}

.device-actions { grid-column: 2; grid-row: 1 / span 2; align-self: center; display: flex; gap: 6px; }
.device-actions .text-button { font-size: 11px; padding: 3px 6px; }
.audit-detail-fields { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.audit-detail-fields dt { color: var(--muted); }
.audit-detail-fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
