:root {
  --indigo: #6366f1;
  --indigo-dark: #4f46e5;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --text: #172033;
  --muted: #667085;
  --border: #dde2ee;
  --danger: #dc2626;
  --success: #15803d;
  --warning: #d97706;
  --shadow: 0 16px 40px rgba(23, 32, 51, .08);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0e1320;
  --surface: #171e30;
  --surface-2: #222b42;
  --text: #edf1f8;
  --muted: #a3adbf;
  --border: #2d3852;
  --shadow: 0 16px 40px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
input, select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: .62rem .75rem; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99,102,241,.16); }
label { display: grid; gap: .38rem; font-weight: 600; font-size: .9rem; }
textarea { min-height: 88px; resize: vertical; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .hint { color: var(--muted); font-size: .88rem; margin: 0; }
.error { color: var(--danger); background: rgba(220,38,38,.08); border: 1px solid rgba(220,38,38,.2); padding: .7rem; border-radius: 10px; }
.success-text { color: var(--success); }
.stack { display: grid; gap: .9rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1100px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 720px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.auth-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 1.6rem; }
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 800; letter-spacing: -.02em; }
.brand-large { font-size: 1.3rem; margin-bottom: .5rem; }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--indigo); color: white; font-size: .88rem; box-shadow: 0 8px 18px rgba(99,102,241,.35); }

.app-shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.1rem; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; gap: 1rem; }
.sidebar-foot { margin-top: auto; }
.nav { display: grid; gap: .28rem; }
.nav-section { margin: .85rem .4rem .3rem; color: var(--muted); text-transform: uppercase; font-size: .7rem; font-weight: 800; letter-spacing: .1em; }
.nav-item { display: flex; align-items: center; gap: .65rem; width: 100%; border: 0; background: transparent; color: var(--text); border-radius: 11px; padding: .62rem .7rem; cursor: pointer; text-align: left; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: rgba(99,102,241,.13); color: var(--indigo-dark); font-weight: 700; }
html[data-theme="dark"] .nav-item.active { color: #a5b4fc; }
.nav-icon { width: 26px; text-align: center; flex: 0 0 26px; }
.nav-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.count-pill { background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: .08rem .48rem; font-size: .76rem; font-weight: 700; }
.nav-item.active .count-pill { background: var(--surface); color: var(--indigo); }
.main-column { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); padding: .8rem 1.25rem; }
.global-search { position: relative; flex: 1; max-width: 620px; }
.search-results { position: absolute; inset: calc(100% + .4rem) 0 auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: .4rem; z-index: 60; }
.search-result { width: 100%; text-align: left; background: transparent; border: 0; border-radius: 9px; padding: .55rem .65rem; cursor: pointer; color: var(--text); }
.search-result:hover { background: var(--surface-2); }
.top-actions { display: flex; align-items: center; gap: .65rem; margin-left: auto; }
.icon-btn { position: relative; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.bell-count { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border-radius: 999px; font-size: .68rem; font-weight: 800; padding: .1rem .34rem; }
.theme-toggle { width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; }
.theme-icon { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(90deg, #4c1d95 0 50%, #fde68a 50% 100%); border: 2px solid rgba(23,32,51,.15); display: block; }
html[data-theme="dark"] .theme-icon { background: linear-gradient(90deg, #fde68a 0 50%, #312e81 50% 100%); }
.avatar-wrap { position: relative; }
.avatar { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--indigo); color: white; font-weight: 800; cursor: pointer; }
.avatar-menu { position: absolute; right: 0; top: calc(100% + .5rem); width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: .8rem; z-index: 70; }
.avatar-user { font-weight: 700; margin-bottom: .5rem; overflow-wrap: anywhere; }
.bell-panel { margin: 1rem 1.25rem 0 auto; width: min(520px, calc(100% - 2rem)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 1rem; }
.view { padding: 1.4rem; width: 100%; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; }
.page-head h1, .page-head h2 { margin: 0; letter-spacing: -.03em; }
.page-head p { margin: .35rem 0 0; color: var(--muted); }
.actions, .inline-actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1rem; box-shadow: 0 4px 16px rgba(23,32,51,.03); }
.card h3 { margin-top: 0; }
.stat-card { min-height: 116px; }
.stat-value { font-size: 2rem; font-weight: 800; letter-spacing: -.04em; margin: .25rem 0; }
.stat-label { color: var(--muted); font-weight: 600; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: .58rem .85rem; cursor: pointer; font-weight: 650; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn.primary:hover { background: var(--indigo-dark); }
.btn.danger { color: var(--danger); border-color: rgba(220,38,38,.3); }
.btn.link { border: 0; background: transparent; color: var(--indigo); padding-inline: .25rem; }
.btn.link.danger { color: var(--danger); }
.btn.small { padding: .38rem .6rem; font-size: .86rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: .5rem .85rem; cursor: pointer; font-weight: 650; }
.tab.active { background: var(--indigo); color: white; border-color: var(--indigo); }
.filters { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .filters { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) { .filters { grid-template-columns: 1fr; } }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: .75rem; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .18rem .5rem; font-size: .76rem; font-weight: 750; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.green { background: rgba(21,128,61,.12); color: var(--success); }
.badge.blue { background: rgba(37,99,235,.12); color: #2563eb; }
.badge.orange { background: rgba(217,119,6,.13); color: var(--warning); }
.badge.red { background: rgba(220,38,38,.1); color: var(--danger); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.site-name { font-weight: 750; }
.url { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(10,14,25,.5); display: grid; place-items: start center; overflow: auto; padding: 1rem; }
.modal { width: min(760px, 100%); background: var(--surface); border-radius: 18px; border: 1px solid var(--border); box-shadow: var(--shadow); padding: 1.25rem; margin-top: 2vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.modal-head h2 { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .9rem; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 2.8rem; }
.eye-btn { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: var(--muted); }
.eye-btn:hover { background: var(--surface-2); }
.checkbox-grid { display: flex; gap: .55rem; flex-wrap: wrap; }
.check-pill { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); padding: .45rem .65rem; border-radius: 999px; font-weight: 600; }
.check-pill input { width: auto; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: .7rem; margin: .5rem 0; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--indigo); border-radius: inherit; }
.ai-content { white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.ai-saved-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.ai-saved-row:last-child { border-bottom: none; }
.ai-saved-main { min-width: 0; }
#toast-root { position: fixed; top: 1rem; right: 1rem; z-index: 200; display: grid; gap: .5rem; }
.toast { background: var(--text); color: var(--bg); padding: .75rem 1rem; border-radius: 12px; box-shadow: var(--shadow); max-width: min(440px, calc(100vw - 2rem)); }
.toast.error { background: var(--danger); color: white; }
.mobile-only { display: none; }
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; left: 0; top: 0; width: min(310px, 86vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .view { padding: 1rem; }
  .page-head { flex-direction: column; }
}
.audit-issue-body { display: none; }
.audit-issue-body.open { display: block; }
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .audit-issue-body { display: block !important; }
  .app-shell { display: block; }
  .view { max-width: none; padding: 0; }
  .card, .table-wrap { box-shadow: none; }
}
