
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1eb;
  --nav: #0d223d;
  --nav-2: #112d4d;
  --accent: #186fd3;
  --accent-2: #0f5cad;
  --danger: #a52424;
  --danger-bg: #fff1f1;
  --warning: #8a5a00;
  --warning-bg: #fff7df;
  --ok: #1d6b3b;
  --ok-bg: #eaf7ef;
  --info: #255d8c;
  --info-bg: #eef6ff;
  --shadow: 0 8px 28px rgba(17, 39, 69, 0.08);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101722;
    --surface: #172231;
    --surface-2: #1c2939;
    --text: #edf3fa;
    --muted: #a8b4c5;
    --line: #314258;
    --nav: #081525;
    --nav-2: #0f233a;
    --accent: #5ba8ff;
    --accent-2: #86bfff;
    --danger: #ffb0b0;
    --danger-bg: #3a2020;
    --warning: #ffd68a;
    --warning-bg: #3d321b;
    --ok: #a8e8bc;
    --ok-bg: #1b3626;
    --info: #b9dcff;
    --info-bg: #19324a;
    --shadow: 0 8px 28px rgba(0,0,0,.22);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { background: linear-gradient(180deg, var(--nav), var(--nav-2)); color: #fff; padding: 20px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.13); margin-bottom: 16px; }
.brand-mark { width: 42px; height: 42px; border-radius: 10px; background: #fff; color: #0d223d; display: grid; place-items: center; font-weight: 800; letter-spacing: -1px; }
.brand-title { font-weight: 800; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .76; margin-top: 2px; }
.dev-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 5px 8px; margin: 0 8px 16px; }
.nav-group { margin: 18px 0; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 0 10px 8px; }
.nav-item { width: 100%; border: 0; background: transparent; color: #fff; text-align: left; padding: 10px 11px; border-radius: 9px; display: flex; align-items: center; justify-content: space-between; gap: 10px; opacity: .86; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.11); opacity: 1; }
.nav-count { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.12); }

.main { min-width: 0; }
.topbar { min-height: 72px; background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 12px 26px; gap: 18px; }
.topbar-left { display: flex; align-items: center; min-width: 0; gap: 12px; }
.page-kicker { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.page-title { font-size: 22px; font-weight: 800; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.mobile-menu { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 10px; }
.avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--info-bg); color: var(--info); display: grid; place-items: center; font-weight: 800; }
.user-chip-name { font-size: 13px; font-weight: 700; }
.user-chip-role { color: var(--muted); font-size: 11px; }

.content { padding: 28px; max-width: 1520px; margin: 0 auto; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

.client-card { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.client-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.client-name { font-size: 20px; font-weight: 850; }
.client-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.health-box { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
.health-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 5px 0; }
.health-line span:first-child { color: var(--muted); }
.module-stack { display: grid; gap: 9px; }
.module-mini { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.module-mini:hover { border-color: var(--accent); }
.module-mini-title { font-weight: 700; font-size: 13px; }
.module-mini-type { font-size: 11px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge.info { color: var(--info); background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 24%, transparent); }
.badge.warn { color: var(--warning); background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 24%, transparent); }
.badge.danger { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 24%, transparent); }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 24%, transparent); }
.badge.neutral { color: var(--muted); background: var(--surface-2); border-color: var(--line); }

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.module-card { padding: 18px; position: relative; overflow: hidden; }
.module-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.module-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.module-title { font-weight: 800; font-size: 16px; }
.module-id { color: var(--muted); font-size: 11px; margin-top: 5px; word-break: break-all; }
.module-path { font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); background: var(--surface-2); padding: 9px; border-radius: 8px; margin: 12px 0; word-break: break-all; }
.action-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.action-pill { font-size: 11px; font-weight: 700; border-radius: 999px; border: 1px solid var(--line); padding: 5px 8px; background: var(--surface-2); }
.action-pill.allowed { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); color: var(--ok); }
.action-pill.denied { color: var(--muted); text-decoration: line-through; opacity: .72; }
.card-actions { display: flex; gap: 8px; margin-top: 16px; }

.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; padding: 9px 12px; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.small { padding: 6px 9px; font-size: 12px; }
.btn:disabled { cursor: not-allowed; opacity: .52; }
.icon-button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-grid; place-items: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; }
.input, .select, .textarea { width: 100%; min-height: 39px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; padding: 9px 10px; outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.search { min-width: 260px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; z-index: 1; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

.tri-select { min-width: 96px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px; font-size: 12px; }
.effective-note { font-size: 10px; color: var(--muted); margin-top: 4px; }
.effective-allow { color: var(--ok); font-weight: 800; }
.effective-deny { color: var(--danger); font-weight: 800; }

.notice { border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; padding: 12px 14px; background: var(--surface); display: flex; gap: 10px; align-items: flex-start; }
.notice.info { border-left-color: var(--info); }
.notice.warn { border-left-color: var(--warning); background: var(--warning-bg); }
.notice.danger { border-left-color: var(--danger); background: var(--danger-bg); }
.notice-title { font-weight: 800; font-size: 13px; }
.notice-text { color: var(--muted); font-size: 12px; margin-top: 3px; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
.login-hero { background: linear-gradient(140deg, #091b31, #123d6a); color: #fff; padding: 70px clamp(34px, 7vw, 100px); display: flex; flex-direction: column; justify-content: center; }
.login-hero h1 { font-size: clamp(38px, 5vw, 68px); max-width: 760px; line-height: 1.03; margin: 14px 0 18px; letter-spacing: -.035em; }
.login-hero p { max-width: 680px; color: rgba(255,255,255,.78); font-size: 17px; line-height: 1.65; }
.login-points { display: grid; gap: 12px; margin-top: 28px; max-width: 650px; }
.login-point { display: flex; gap: 10px; color: rgba(255,255,255,.88); }
.login-side { background: var(--bg); display: grid; place-items: center; padding: 30px; }
.login-card { width: min(470px, 100%); padding: 28px; }
.login-card h2 { margin: 0 0 8px; }
.login-card > p { color: var(--muted); margin-top: 0; }
.login-form { display: grid; gap: 14px; margin-top: 22px; }
.demo-list { display: grid; gap: 8px; margin-top: 18px; }
.demo-user { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; text-align: left; }
.demo-user:hover { border-color: var(--accent); }
.demo-user small { color: var(--muted); }
.login-error { color: var(--danger); background: var(--danger-bg); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: 9px; padding: 9px 10px; font-size: 12px; display: none; }
.login-error.show { display: block; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(4, 11, 20, .62); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(720px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.modal-head { display: flex; justify-content: space-between; gap: 16px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 18px; font-weight: 850; }
.modal-body { padding: 20px; }
.modal-foot { padding: 15px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; width: min(390px, calc(100vw - 40px)); }
.toast { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 12px; padding: 12px; display: grid; grid-template-columns: 30px 1fr 34px; gap: 10px; align-items: start; }
.toast-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--info-bg); color: var(--info); font-weight: 800; }
.toast-title { display: block; font-size: 13px; }
.toast-message { color: var(--muted); font-size: 12px; margin-top: 3px; }

.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); background: var(--surface); }
.metric { padding: 18px; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { font-size: 28px; font-weight: 850; margin-top: 7px; }
.metric-sub { color: var(--muted); font-size: 11px; margin-top: 4px; }

@media (max-width: 1120px) {
  .grid-3, .module-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 70; transform: translateX(-104%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; }
  .topbar { padding: 10px 14px; }
  .content { padding: 18px 14px 30px; }
  .topbar-actions .user-chip-role { display: none; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 320px; padding: 42px 28px; }
  .login-hero h1 { font-size: 42px; }
  .login-side { padding: 24px 16px 38px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .grid-3, .grid-4, .module-grid { grid-template-columns: 1fr; }
  .section-heading { flex-direction: column; }
  .search { min-width: 100%; }
  .topbar-actions .simulate-select { display: none; }
  .page-title { font-size: 18px; }
  .login-hero { display: none; }
  .login-card { box-shadow: none; }
}


.nav-item {text-decoration:none;}
.deployment-notice {margin-bottom:18px;}
