:root {
  --ink: #172033;
  --muted: #697386;
  --soft: #f4f6f8;
  --line: #dfe3e8;
  --panel: #ffffff;
  --nav: #15202b;
  --nav-soft: #22303c;
  --blue: #246bce;
  --blue-dark: #1955a6;
  --cyan: #0f8291;
  --green: #18864b;
  --amber: #a96500;
  --red: #bd3434;
  --shadow: 0 12px 36px rgba(20, 32, 50, .14);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-width: 320px; background: var(--soft); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }
.icon-button { width: 36px; height: 36px; border: 0; background: transparent; display: inline-grid; place-items: center; color: inherit; border-radius: 6px; padding: 0; }
.icon-button:hover { background: rgba(23, 32, 51, .07); }
.icon-button svg, .button svg, .nav-list svg { width: 18px; height: 18px; flex: 0 0 auto; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 480px); grid-template-rows: auto 1fr auto; background: #eef2f5; }
.login-screen::before { content: ""; grid-column: 1; grid-row: 1 / 4; background: linear-gradient(140deg, rgba(17, 31, 43, .86), rgba(15, 72, 82, .82)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cpath d='M0 45h180M0 90h180M0 135h180M45 0v180M90 0v180M135 0v180' stroke='%23ffffff' stroke-opacity='.08'/%3E%3C/svg%3E"); }
.login-brand { grid-column: 1; grid-row: 1; z-index: 1; display: flex; gap: 12px; align-items: center; padding: 36px 44px; color: #fff; }
.brand-mark { width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.42); display: grid; place-items: center; font-size: 14px; font-weight: 800; color: #fff; background: #167f8f; border-radius: 6px; }
.brand-mark.small { width: 38px; height: 38px; }
.login-brand div, .sidebar-brand div, .sidebar-user div { display: grid; gap: 2px; min-width: 0; }
.login-brand strong, .sidebar-brand strong { font-size: 17px; letter-spacing: 0; }
.login-brand span:not(.brand-mark), .sidebar-brand span, .sidebar-user span { font-size: 12px; opacity: .7; }
.login-panel { grid-column: 2; grid-row: 2; align-self: center; margin: 48px; display: grid; gap: 18px; }
.login-heading { margin-bottom: 10px; }
.login-heading p, .topbar p, .modal-head p { margin: 0 0 6px; color: var(--cyan); font-weight: 700; font-size: 12px; text-transform: uppercase; }
.login-heading h1 { font-size: 29px; margin: 0; font-weight: 700; }
.login-panel label, .field { display: grid; gap: 7px; color: #3e4858; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #cbd2da; background: #fff; color: var(--ink); border-radius: 5px; padding: 10px 11px; min-height: 40px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,107,206,.12); }
textarea { resize: vertical; min-height: 90px; }
.form-error { min-height: 18px; margin: -6px 0 0; color: var(--red); font-size: 13px; }
.button { min-height: 38px; border: 1px solid #c9d0d8; background: #fff; color: #273347; border-radius: 5px; padding: 8px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 650; font-size: 13px; white-space: nowrap; }
.button:hover { border-color: #9ca8b5; background: #f8fafb; }
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); }
.button.danger { color: var(--red); border-color: #e3bcbc; }
.button.ghost { border-color: transparent; background: transparent; }
.button.small { min-height: 32px; padding: 5px 9px; }
.login-button { min-height: 44px; margin-top: 2px; }
.login-foot { grid-column: 2; grid-row: 3; margin: 0; padding: 28px 48px; color: #8a93a0; font-size: 11px; text-transform: uppercase; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: #e8edf1; padding: 18px 14px; display: grid; grid-template-rows: auto 1fr auto; z-index: 30; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 22px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-close { display: none; margin-left: auto; color: #fff; }
.nav-list { padding-top: 18px; display: grid; align-content: start; gap: 5px; }
.nav-list button { border: 0; background: transparent; color: #aeb9c3; border-radius: 5px; padding: 10px 11px; min-height: 42px; display: flex; align-items: center; gap: 11px; font-weight: 600; text-align: left; }
.nav-list button:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-list button.active { color: #fff; background: var(--nav-soft); box-shadow: inset 3px 0 #3bb6c2; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.09); padding: 16px 4px 2px; display: grid; grid-template-columns: 34px 1fr 34px; gap: 9px; align-items: center; }
.sidebar-user .icon-button { color: #b9c2ca; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #355161; color: #fff; font-size: 13px !important; opacity: 1 !important; }
.sidebar-user strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.main-area { min-width: 0; }
.topbar { height: 74px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); display: flex; align-items: center; gap: 14px; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 0; font-size: 19px; line-height: 1.1; }
.topbar p { margin-bottom: 4px; font-size: 10px; }
.topbar-status { margin-left: auto; color: #536071; font-size: 12px; display: flex; align-items: center; gap: 7px; }
.topbar-status span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(24,134,75,.12); }
.menu-button { display: none; }
.page-content { padding: 24px 28px 48px; max-width: 1600px; margin: 0 auto; }

.page-toolbar { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.page-toolbar > div:first-child { flex: 1; }
.page-toolbar h2 { margin: 0 0 5px; font-size: 18px; }
.page-toolbar p { margin: 0; color: var(--muted); font-size: 13px; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }
.filters { padding: 12px 0; display: grid; grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(140px, 190px)); gap: 10px; margin-bottom: 8px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 11px; width: 17px; height: 17px; color: #84909d; pointer-events: none; }
.input-icon input { padding-left: 36px; }

.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px; }
.policy-summary-grid { display: grid; grid-template-columns: repeat(7, minmax(115px, 1fr)); gap: 10px; margin-bottom: 18px; }
.policy-summary-grid article { min-height: 76px; padding: 13px; display: flex; align-items: center; gap: 11px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.policy-summary-grid article > span { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 5px; color: var(--cyan); background: #eaf5f6; }
.policy-summary-grid svg { width: 17px; height: 17px; }
.policy-summary-grid strong { display: block; font-size: 20px; line-height: 1.05; }
.policy-summary-grid p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.policy-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.policy-tabs button { min-height: 40px; padding: 8px 11px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.policy-tabs button:hover { color: var(--ink); background: #f8fafb; }
.policy-tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.policy-tabs button span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 5px; padding: 0 5px; border-radius: 10px; color: #536071; background: #edf1f4; font-size: 10px; }
.package-list { max-width: 420px; }
.package-list code { display: inline-block; margin: 2px 5px 2px 0; padding: 3px 5px; border-radius: 4px; background: #f0f3f5; font: 10px/1.4 "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.metric-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; min-height: 112px; display: grid; grid-template-columns: 1fr auto; align-content: space-between; }
.metric-card p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric-card strong { font-size: 27px; line-height: 1; align-self: end; }
.metric-icon { width: 34px; height: 34px; grid-column: 2; grid-row: 1 / 3; border-radius: 6px; background: #edf3fb; color: var(--blue); display: grid; place-items: center; }
.metric-icon svg { width: 18px; }
.metric-card.alert .metric-icon { background: #faeded; color: var(--red); }
.metric-card.success .metric-icon { background: #eaf6ef; color: var(--green); }
.metric-card.warning .metric-icon { background: #fff4df; color: var(--amber); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); gap: 16px; }
.section-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.section-heading { min-height: 56px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.section-heading h3 { font-size: 14px; margin: 0; }
.section-heading span { color: var(--muted); font-size: 12px; }
.activity-list { display: grid; gap: 17px; padding: 18px 16px 22px; }
.activity-row { display: grid; grid-template-columns: minmax(100px, 150px) 1fr 36px; gap: 10px; align-items: center; font-size: 12px; }
.activity-row strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.activity-bar { width: 100%; height: 7px; border: 0; background: #eef1f4; overflow: hidden; border-radius: 3px; appearance: none; }
.activity-bar::-webkit-progress-bar { background: #eef1f4; }
.activity-bar::-webkit-progress-value { background: var(--cyan); }
.activity-bar::-moz-progress-bar { background: var(--cyan); }
.activity-row em { font-style: normal; color: var(--muted); text-align: right; }

.table-wrap { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.table-wrap.flush { border: 0; border-radius: 0; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { color: #596577; background: #f7f9fa; font-weight: 700; text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 13px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.cell-main strong { display: block; font-size: 13px; margin-bottom: 3px; }
.cell-main span, .cell-sub { color: var(--muted); font-size: 11px; }
.app-icon { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 7px; object-fit: cover; background: #e9eef2; display: grid; place-items: center; color: #526170; font-weight: 750; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 23px; border-radius: 12px; padding: 3px 8px; font-size: 11px; font-weight: 700; background: #edf1f4; color: #536071; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.pass, .badge.confirmed, .badge.low { color: var(--green); background: #eaf6ef; }
.badge.disabled, .badge.block, .badge.high { color: var(--red); background: #faeded; }
.badge.review, .badge.pending, .badge.medium, .badge.monitor { color: var(--amber); background: #fff4df; }
.badge.enforce { color: var(--blue); background: #edf3fb; }
.row-actions { display: flex; justify-content: flex-end; gap: 3px; min-width: 78px; }
.row-actions .icon-button { width: 32px; height: 32px; }
.empty-state { padding: 55px 24px; text-align: center; color: var(--muted); }
.empty-state svg { width: 30px; height: 30px; color: #a8b1bb; margin-bottom: 8px; }
.empty-state strong { display: block; color: #445063; margin-bottom: 5px; }
.loading { min-height: 360px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.loading::before { content: ""; width: 22px; height: 22px; border: 2px solid #ced5dc; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; margin-right: 9px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 14px; color: var(--muted); font-size: 12px; }

.modal { width: min(620px, calc(100vw - 28px)); max-height: calc(100vh - 40px); border: 0; border-radius: 7px; padding: 0; box-shadow: var(--shadow); color: var(--ink); }
.modal.wide { width: min(780px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(18, 28, 39, .55); }
.modal-head { padding: 17px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head p { margin-bottom: 4px; font-size: 10px; }
.modal-body { padding: 18px; overflow: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field.full { grid-column: 1 / -1; }
.toggle-field { min-height: 40px; display: flex; align-items: center; gap: 9px; color: #3e4858; font-size: 13px; font-weight: 600; }
.toggle-field input, .check-grid input { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--blue); }
.check-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin: 0; padding: 13px; border: 1px solid var(--line); border-radius: 5px; }
.check-grid legend { padding: 0 5px; color: #3e4858; font-size: 12px; font-weight: 700; }
.check-grid label { min-width: 0; display: flex; align-items: center; gap: 7px; color: #536071; font-size: 11px; }
.field-note { color: var(--muted); font-size: 11px; font-weight: 400; }
.modal-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.credential-box { background: #f6f8fa; border: 1px solid var(--line); border-radius: 5px; padding: 13px; margin-bottom: 12px; }
.credential-box label { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.credential-box code { display: block; overflow-wrap: anywhere; font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; color: #263448; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.detail-item { padding: 12px; border-bottom: 1px solid var(--line); }
.detail-item:nth-child(odd) { border-right: 1px solid var(--line); }
.detail-item label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.detail-item strong, .detail-item code { font-size: 12px; overflow-wrap: anywhere; }
.detail-block { margin-top: 15px; }
.detail-block h3 { font-size: 12px; margin: 0 0 8px; }
.json-view { background: #17212b; color: #d8e2ea; border-radius: 5px; padding: 12px; font: 11px/1.6 "Cascadia Mono", Consolas, monospace; overflow: auto; max-height: 220px; white-space: pre-wrap; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { width: min(360px, calc(100vw - 40px)); background: #192530; color: #fff; box-shadow: var(--shadow); border-radius: 5px; padding: 12px 14px; font-size: 13px; animation: toast-in .18s ease-out; }
.toast.error { background: #812d2d; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.mobile-scrim { display: none; }

@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .policy-summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  .login-screen { display: flex; flex-direction: column; min-height: 100vh; }
  .login-screen::before { display: none; }
  .login-brand { background: var(--nav); padding: 22px 24px; }
  .login-panel { width: min(440px, calc(100% - 40px)); margin: auto; padding: 46px 0; }
  .login-foot { padding: 20px; text-align: center; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 260px; transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: inline-grid; }
  .mobile-scrim.open { display: block; position: fixed; inset: 0; background: rgba(12,20,29,.5); z-index: 29; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 18px 16px 36px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .topbar-status { display: none; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 104px; padding: 13px; }
  .metric-card strong { font-size: 24px; }
  .page-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { align-self: stretch; }
  .toolbar-actions .button { flex: 1; }
  .filters { grid-template-columns: 1fr; }
  .filters > :first-child { grid-column: auto; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .field.full, .modal-actions { grid-column: auto; }
  .detail-item:nth-child(odd) { border-right: 0; }
  .policy-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
}
