:root {
  color-scheme: dark;
  --bg: #07101f;
  --surface: #0d1728;
  --surface-2: #121f33;
  --surface-3: #17273d;
  --border: #233753;
  --text: #f5f8ff;
  --muted: #8fa1bb;
  --blue: #2f7df6;
  --blue-soft: #122d57;
  --cyan: #24c6da;
  --green: #20c997;
  --amber: #f5b942;
  --red: #f06571;
  --shadow: 0 28px 70px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 20% -10%, #153764 0, transparent 34%), var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(460px, 100%); background: linear-gradient(155deg, rgba(18,31,51,.98), rgba(8,16,31,.98)); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); padding: 34px; }
.brand-lockup, .sidebar-brand { display: flex; gap: 12px; align-items: center; }
.brand-lockup strong, .sidebar-brand strong { display: block; letter-spacing: -.01em; }
.brand-lockup small, .sidebar-brand small { display: block; color: var(--cyan); font-size: 10px; letter-spacing: .13em; margin-top: 3px; }
.brand-logo { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 11px; display: block; object-fit: cover; border: 1px solid rgba(91, 154, 255, .34); box-shadow: 0 8px 25px rgba(47,125,246,.26); }
.login-copy { margin: 44px 0 26px; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; }
.login-copy h1, .page-heading h1 { margin: 0; font-size: clamp(26px, 3vw, 36px); letter-spacing: -.035em; }
.login-copy p:not(.eyebrow), .page-heading p:not(.eyebrow) { color: var(--muted); line-height: 1.55; margin-bottom: 0; }
form { display: grid; gap: 17px; }
label { display: grid; gap: 8px; color: #bdc9da; font-size: 13px; font-weight: 700; }
input, select, textarea { min-height: 44px; border-radius: 9px; border: 1px solid var(--border); background: #08101d; color: var(--text); padding: 0 13px; outline: none; }
textarea { padding: 12px 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,125,246,.14); }
.primary-button, .ghost-button, .secondary-button { border: 1px solid transparent; border-radius: 9px; min-height: 44px; padding: 0 17px; font-weight: 800; color: white; }
.primary-button { background: linear-gradient(135deg, var(--blue), #1e64dd); }
.ghost-button { background: transparent; border-color: var(--border); color: #c7d3e5; }
.sidebar-site-link { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.sidebar-site-link:hover { border-color: #3b82f6; color: white; background: rgba(47,125,246,.1); }
.secondary-button { background: var(--surface-3); border-color: var(--border); }
.form-message { min-height: 20px; margin: 0; color: var(--red); font-size: 13px; }
.form-message.success { color: var(--green); }
.link-button { display: block; margin: 12px auto 0; border: 0; background: transparent; color: #83b6ff; font-weight: 800; padding: 6px 8px; }
.link-button:hover, .link-button:focus-visible { color: white; text-decoration: underline; outline: none; }
.password-hint { margin: -6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.security-note { border-top: 1px solid var(--border); margin: 28px 0 0; padding-top: 20px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.security-note a { color: #83b6ff; text-decoration: none; font-weight: 800; }
.mfa-enrollment { display: grid; gap: 17px; }
.mfa-qr { display: block; width: min(240px, 100%); height: auto; margin: 0 auto; border-radius: 10px; background: white; }
.recovery-box { color: #cfd9e8; line-height: 1.55; }
.recovery-box pre { white-space: pre-wrap; word-break: break-word; padding: 14px; border-radius: 10px; background: #07101f; border: 1px solid #2a3a56; color: #bce8d8; font-size: 13px; line-height: 1.7; }

.admin-app { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: rgba(8,16,30,.97); border-right: 1px solid var(--border); padding: 21px 15px 16px; z-index: 20; }
.sidebar-brand { padding: 0 8px 20px; border-bottom: 1px solid var(--border); }
.admin-navigation { flex: 1; overflow: auto; padding: 16px 0; scrollbar-width: thin; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-left: 3px solid transparent; border-radius: 8px; background: transparent; color: #9eb0c8; min-height: 44px; padding: 0 12px; text-align: left; font-weight: 700; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.035); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(47,125,246,.2), rgba(47,125,246,.05)); border-left-color: var(--blue); color: #dceaff; }
.nav-icon { width: 22px; color: var(--cyan); text-align: center; font-size: 16px; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 15px; display: grid; gap: 10px; }
.environment-badge { color: #6f849f; font-size: 10px; letter-spacing: .12em; text-align: center; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; min-height: 70px; display: grid; grid-template-columns: minmax(160px, 1fr) minmax(260px, 470px) auto; align-items: center; gap: 22px; padding: 0 30px; background: rgba(7,16,31,.88); border-bottom: 1px solid var(--border); backdrop-filter: blur(18px); }
.breadcrumbs { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.breadcrumbs b { color: #415672; }.breadcrumbs strong { color: var(--text); }
.global-search { position: relative; display: block; }
.global-search span { position: absolute; left: 13px; top: 10px; color: var(--muted); font-size: 19px; }
.global-search input { width: 100%; padding-left: 40px; background: rgba(8,16,29,.8); }
.account-summary { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.account-summary strong, .account-summary small { display: block; max-width: 175px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-summary small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.account-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: white; background: #1b559f; font-weight: 900; }
.menu-button { display: none; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 9px; color: white; background: var(--surface); }

.content-shell { padding: 32px clamp(22px, 3vw, 46px) 60px; max-width: 1680px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; gap: 25px; align-items: flex-end; margin-bottom: 26px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.module-content { min-height: 380px; }
.loading-state, .empty-state, .error-state { min-height: 320px; border: 1px dashed var(--border); border-radius: 14px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; padding: 30px; }
.spinner { width: 27px; height: 27px; border: 3px solid #253852; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 15px; }
.metric-card, .panel { background: linear-gradient(155deg, rgba(18,31,51,.93), rgba(11,21,37,.94)); border: 1px solid var(--border); border-radius: 13px; }
.metric-card { padding: 19px; min-height: 130px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; width: 80px; height: 80px; position: absolute; top: -28px; right: -22px; border-radius: 50%; background: rgba(47,125,246,.1); }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-value { font-size: 28px; font-weight: 900; margin-top: 18px; letter-spacing: -.035em; }
.metric-foot { color: #6f849f; font-size: 11px; margin-top: 8px; }
.dashboard-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-top: 16px; }
.panel { overflow: hidden; }
.panel-header { min-height: 58px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 15px; }
.panel-body { padding: 18px; }
.module-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.module-tile { padding: 14px; border-radius: 9px; background: rgba(255,255,255,.025); border: 1px solid #1f314a; color: #c6d3e5; font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px 12px 0 0; }
.toolbar input, .toolbar select { min-height: 38px; }.toolbar input { min-width: min(330px, 100%); }
.table-shell { overflow: auto; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 12px 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th { background: #0a1424; color: #7f92ad; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; text-align: left; padding: 13px 15px; position: sticky; top: 0; }
td { padding: 14px 15px; border-top: 1px solid #1c2d44; color: #d2dcea; font-size: 12px; vertical-align: middle; }
tbody tr:hover { background: rgba(47,125,246,.035); }
.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 900; letter-spacing: .03em; background: #1c2a3e; color: #aebdd1; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.success { color: var(--green); background: rgba(32,201,151,.1); }.status.warning { color: var(--amber); background: rgba(245,185,66,.1); }.status.danger { color: var(--red); background: rgba(240,101,113,.1); }.status.info { color: #64a2ff; background: rgba(47,125,246,.11); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 9px; color: var(--muted); margin-top: 13px; font-size: 12px; }
.pager button { min-width: 36px; height: 34px; border: 1px solid var(--border); background: var(--surface); color: white; border-radius: 7px; }
.definition-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.definition-card { border: 1px solid var(--border); border-radius: 11px; background: var(--surface); padding: 17px; }
.definition-card h3 { margin: 0 0 12px; font-size: 14px; }.definition-card p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.permission-chips { display: flex; flex-wrap: wrap; gap: 6px; }.permission-chip { border: 1px solid #2b4261; color: #9fc2f5; background: #10233e; border-radius: 999px; padding: 4px 8px; font-size: 9px; }

.pdf3d-actions { display: flex; flex-wrap: wrap; gap: 7px; min-width: 220px; }
.compact-button { min-height: 34px; padding: 0 10px; font-size: 11px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:disabled, .primary-button:disabled, .secondary-button:disabled { opacity: .55; cursor: wait; }
.pdf3d-note { display: block; min-width: 180px; max-width: 320px; white-space: pre-wrap; line-height: 1.5; }
.admin-dialog { width: min(620px, calc(100vw - 28px)); color: var(--text); background: linear-gradient(155deg, #122039, #08101f); border: 1px solid #314967; border-radius: 16px; padding: 0; box-shadow: var(--shadow); }
.admin-dialog::backdrop { background: rgba(2, 8, 18, .76); backdrop-filter: blur(4px); }
.admin-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); padding-bottom: 15px; }
.dialog-heading h2 { margin: 0 0 6px; font-size: 19px; }
.dialog-heading p { margin: 0; color: var(--cyan); font-size: 12px; font-weight: 800; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .dashboard-grid, .definition-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .admin-app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: 278px; transition: transform .2s ease; box-shadow: var(--shadow); }
  .admin-app.sidebar-open .sidebar { transform: translateX(0); }
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 15px; }.menu-button { display: block; }.global-search { display: none; }.breadcrumbs span, .breadcrumbs b { display: none; }
  .account-summary { min-width: 0; }.account-summary > span:last-child { display: none; }
  .content-shell { padding: 25px 15px 45px; }.page-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 540px) {
  .login-card { padding: 25px; }.metrics-grid { grid-template-columns: 1fr; }.module-list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Light theme: keep the admin surface and its text in one coherent palette. */
html[data-theme="light"] .login-card,
html[data-theme="light"] .metric-card,
html[data-theme="light"] .panel,
html[data-theme="light"] .toolbar,
html[data-theme="light"] .table-shell,
html[data-theme="light"] .definition-card,
html[data-theme="light"] .admin-dialog {
  background: #fff !important;
  border-color: #d6deea !important;
  color: #0f172a !important;
  box-shadow: 0 20px 55px rgba(15, 23, 42, .12);
}
html[data-theme="light"] .sidebar { background: rgba(255,255,255,.98) !important; border-color: #d6deea !important; }
html[data-theme="light"] .topbar { background: rgba(255,255,255,.92) !important; border-color: #d6deea !important; }
html[data-theme="light"] .brand-lockup small,
html[data-theme="light"] .sidebar-brand small,
html[data-theme="light"] .eyebrow { color: #0369a1 !important; }
html[data-theme="light"] .login-copy p:not(.eyebrow),
html[data-theme="light"] .page-heading p:not(.eyebrow),
html[data-theme="light"] .metric-label,
html[data-theme="light"] .metric-foot,
html[data-theme="light"] .definition-card p,
html[data-theme="light"] .pager { color: #475569 !important; }
html[data-theme="light"] .login-card label { color: #334155 !important; }
html[data-theme="light"] .login-card .form-message { color: #b91c1c !important; }
html[data-theme="light"] .login-card .form-message.success { color: #047857 !important; }
html[data-theme="light"] .security-note { border-color: #d6deea !important; color: #475569 !important; }
html[data-theme="light"] .link-button,
html[data-theme="light"] .security-note a { color: #1d4ed8 !important; }
html[data-theme="light"] .nav-item { color: #475569 !important; }
html[data-theme="light"] .nav-item:hover,
html[data-theme="light"] .nav-item.active { color: #0f172a !important; background: #eaf2ff !important; }
html[data-theme="light"] .module-tile { background: #f8fafc !important; border-color: #d6deea !important; color: #334155 !important; }
html[data-theme="light"] th { background: #eef4fb !important; color: #475569 !important; }
html[data-theme="light"] td { border-color: #e2e8f0 !important; color: #1e293b !important; }
html[data-theme="light"] tbody tr:hover { background: #f3f7fd !important; }
html[data-theme="light"] .pager button,
html[data-theme="light"] .secondary-button { background: #fff !important; border-color: #cbd5e1 !important; color: #334155 !important; }
html[data-theme="light"] .permission-chip { background: #eaf2ff !important; border-color: #bfd4f5 !important; color: #1d4ed8 !important; }
html[data-theme="light"] .recovery-box pre { background: #f8fafc !important; border-color: #d6deea !important; color: #0f5132 !important; }
html[data-theme="light"] .admin-dialog::backdrop { background: rgba(15, 23, 42, .38); }