:root {
  --ppp-bg: #f4f6fb;
  --ppp-sidebar: #11203b;
  --ppp-sidebar-muted: #8a9bbd;
  --ppp-primary: #3b6ef5;
  --ppp-border: #e6e9f2;
  --ppp-card: #ffffff;
  --ppp-muted: #666f7d;
}

* { box-sizing: border-box; }

body.admin-body {
  margin: 0;
  background: var(--ppp-bg);
  color: #1f2933;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

/* ── Layout ───────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  background: var(--ppp-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  transition: transform .2s ease;
}
.sidebar-brand {
  padding: 20px 22px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { color: #6ea0ff; font-size: 22px; }
.sidebar-brand strong { color: #fff; }
.sidebar-nav { padding: 14px 12px; flex: 1; }
.sidebar-nav .nav-link {
  color: var(--ppp-sidebar-muted);
  padding: 10px 14px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 4px;
  font-size: 14.5px;
  transition: background .15s, color .15s;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--ppp-primary); color: #fff; }
.sidebar-footer { padding: 16px 22px; border-top: 1px solid rgba(255,255,255,.08); }

.content { margin-left: 248px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--ppp-border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.topbar-title { font-size: 19px; margin: 0; font-weight: 600; }
.topbar-spacer { flex: 1; }
.content-inner { padding: 26px 28px; max-width: 1200px; width: 100%; }

/* ── Cards & components ───────────────────────────────── */
.card {
  border: 1px solid var(--ppp-border);
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--ppp-border);
  font-weight: 600;
  font-size: 14.5px;
  border-radius: 13px 13px 0 0 !important;
}

.stat-card {
  background: var(--ppp-card);
  border: 1px solid var(--ppp-border);
  border-radius: 13px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
}
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { color: #6b7280; font-size: 13px; }

.app-search { flex: 1 1 320px; min-width: 240px; max-width: 440px; margin: 0; }

.empty-state { text-align: center; padding: 48px 20px; color: #6b7280; }
.empty-state i { font-size: 42px; color: #c3cad9; display: block; margin-bottom: 12px; }

.btn-primary { background: var(--ppp-primary); border-color: var(--ppp-primary); }
.btn-primary:hover { background: #2f5fe0; border-color: #2f5fe0; }

/* ── Wizard ───────────────────────────────────────────── */
.wizard-steps {
  list-style: none;
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 0 0 22px;
  flex-wrap: wrap;
}
.wizard-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8a93a6;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px 6px 6px;
  border-radius: 30px;
  background: #fff;
  border: 1px solid var(--ppp-border);
}
.wizard-steps li span {
  width: 26px; height: 26px; border-radius: 50%;
  background: #e9edf6; color: #6b7280;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.wizard-steps li.active { color: var(--ppp-primary); border-color: #bcd0ff; }
.wizard-steps li.active span { background: var(--ppp-primary); color: #fff; }
.wizard-steps li.done span { background: #16a34a; color: #fff; }

.toggle-card input, .sdk-card input { position: absolute; opacity: 0; }
.toggle-card { display: block; cursor: pointer; margin: 0; }
.toggle-card-body {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--ppp-border);
  border-radius: 10px; background: #fff; transition: all .15s; font-size: 14px;
}
.toggle-card-body i { font-size: 18px; color: #8a93a6; }
.toggle-card input:checked + .toggle-card-body {
  border-color: var(--ppp-primary); background: #eef3ff; color: var(--ppp-primary);
}
.toggle-card input:checked + .toggle-card-body i { color: var(--ppp-primary); }

.sdk-group { margin-bottom: 18px; }
.sdk-group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #8a93a6; margin-bottom: 8px; font-weight: 600; }
.sdk-card { display: block; cursor: pointer; margin: 0; height: 100%; }
.sdk-card-body {
  display: block; padding: 10px 13px; border: 1px solid var(--ppp-border);
  border-radius: 10px; background: #fff; transition: all .15s; height: 100%;
}
.sdk-card .sdk-name { display: block; font-weight: 600; font-size: 13.5px; }
.sdk-card .sdk-meta { display: block; font-size: 11.5px; color: #98a2b3; line-height: 1.4; margin-top: 2px; }
.sdk-card input:checked + .sdk-card-body { border-color: var(--ppp-primary); background: #eef3ff; }

/* ── AAB import dropzone ──────────────────────────────── */
.aab-import { border-style: dashed; }
.aab-dropzone {
  border: 2px dashed #c7d0e0; border-radius: 12px; padding: 22px;
  cursor: pointer; transition: border-color .15s, background .15s; outline: none;
}
.aab-dropzone:hover, .aab-dropzone:focus-visible { border-color: var(--ppp-primary); background: #f5f8ff; }
.aab-dropzone.is-dragover { border-color: var(--ppp-primary); background: #eef3ff; }
.aab-dz-idle { display: flex; align-items: center; gap: 16px; }
.aab-dz-idle > i { font-size: 34px; color: var(--ppp-primary); }
.aab-dz-text { display: flex; flex-direction: column; }
.aab-dz-text strong { font-size: 15px; }
.aab-dz-text span { font-size: 13px; color: #6b7280; }
.aab-dz-busy .progress { height: 8px; border-radius: 6px; margin: 8px 0 6px; }
.aab-file-name { font-size: 13.5px; font-weight: 600; }
.aab-status { font-size: 12.5px; color: #6b7280; }
.aab-summary {
  border: 1px solid var(--ppp-border); border-radius: 10px; padding: 12px 14px; height: 100%;
}
.aab-summary-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #8a93a6; font-weight: 600; margin-bottom: 8px; }
.aab-summary-group + .aab-summary-group { margin-top: 10px; }
.aab-summary-sub { font-size: 11.5px; color: #6b7280; font-weight: 600; margin-bottom: 4px; }

/* ── Permission tags ──────────────────────────────────── */
.perm-chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 8px; }
.perm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef3ff; border: 1px solid #cfe0ff; color: #1f3a8a;
  border-radius: 20px; padding: 4px 6px 4px 12px; font-size: 12.5px; line-height: 1.4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.perm-chip-label { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perm-chip-remove {
  border: 0; background: transparent; color: #5b6b9a; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 50%;
}
.perm-chip-remove:hover { color: #b91c1c; background: #fde2e2; }
/* Origin tag: where a permission most likely came from (app vs merged-in SDK). */
.perm-chip-origin {
  font-family: var(--bs-body-font-family, system-ui, sans-serif);
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  padding: 1px 7px; border-radius: 20px; white-space: nowrap;
  background: #e5e7eb; color: #4b5563;
}
.perm-origin-app { background: #dcfce7; color: #15803d; }
.perm-origin-sdk { background: #e0e7ff; color: #4338ca; }
.perm-origin-common { background: #e5e7eb; color: #4b5563; }
.perm-origin-internal { background: #f1f5f9; color: #64748b; }
.perm-origin-invalid { background: #fef3c7; color: #92400e; }
.perm-add { max-width: 460px; }

/* ── Play Store permission levels & recommendations ───── */
[data-level], .perm-level { --lvl: #94a3b8; }
[data-level="runtime"], .perm-level--runtime { --lvl: #2563eb; }
[data-level="special"], .perm-level--special { --lvl: #d97706; }
[data-level="restricted"], .perm-level--restricted { --lvl: #dc2626; }
.perm-chip[data-level]::before, .rec-chip[data-level]::after, .perm-level::before {
  content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--lvl);
}
.perm-chip[data-level="restricted"] { background: #fff1f1; border-color: #fbcaca; color: #8f1d1d; }

/* Permissions found in the bundle but left out of the policy. These rules come
   AFTER the [data-level] ones above so an excluded chip still reads as excluded
   even when Play treats the permission as restricted. */
.perm-chip-check { margin: 0; accent-color: #2563eb; cursor: pointer; flex: none; }
.perm-chip[data-included="0"] {
  background: #f8fafc; border-color: #e2e8f0; color: #64748b; border-style: dashed;
}
.perm-chip[data-included="0"] .perm-chip-label {
  text-decoration: line-through; text-decoration-color: #cbd5e1;
}
.perm-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.perm-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: #6b7280; }
.perm-level { display: inline-flex; align-items: center; gap: 6px; }

.rec-tip {
  font-size: 12.5px; color: #4b5563; background: #f6f8fc; border: 1px solid var(--ppp-border);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 12px;
}
.rec-tip i { color: #d97706; }
.rec-group + .rec-group { margin-top: 12px; }
.rec-group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #8a93a6; margin-bottom: 6px; font-weight: 600; }
.rec-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rec-chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px dashed #b9c6e4; background: #fff;
  color: #1f3a8a; border-radius: 20px; padding: 3px 10px; font-size: 12.5px; line-height: 1.4; cursor: pointer;
}
.rec-chip:hover:not(:disabled) { border-style: solid; background: #eef3ff; }
.rec-chip.is-added { border-style: solid; border-color: #bbe5c8; background: #effaf2; color: #166534; cursor: default; }

.perm-warnings {
  margin-top: 14px; border: 1px solid #fbcaca; background: #fff7f7; border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; color: #4b1d1d;
}
.perm-warnings-title { font-weight: 600; color: #b91c1c; margin-bottom: 6px; }
.perm-warnings ul { margin: 0; padding-left: 18px; }
.perm-warnings li + li { margin-top: 6px; }
.perm-warnings code { font-size: 11.5px; }

.preview-card { position: sticky; top: 92px; }
.preview-body {
  max-height: 70vh; overflow-y: auto; font-size: 13px; line-height: 1.6;
  background: #fbfcfe; border-radius: 0 0 13px 13px;
}
.preview-body h1 { font-size: 20px; }
.preview-body h2 { font-size: 15px; border-bottom: 1px solid var(--ppp-border); padding-bottom: 4px; margin-top: 18px; }
.preview-body h3 { font-size: 13.5px; }

/* ── Auth ─────────────────────────────────────────────── */
body.auth-body {
  margin: 0; min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #1b2a4a 0%, #2f4d8f 100%);
  font-family: "Segoe UI", system-ui, sans-serif; padding: 20px;
}
.auth-card { background: #fff; width: 100%; max-width: 400px; padding: 36px 34px; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-logo { width: 56px; height: 56px; border-radius: 14px; background: #eef3ff; color: var(--ppp-primary); display: grid; place-items: center; font-size: 26px; margin: 0 auto 14px; }

/* ── Public policy page ───────────────────────────────── */
/* One centered reading column — no sidebar, no header chrome. */
body.public-body {
  margin: 0; background: #ffffff; color: #1f2933;
  font: 16px/1.7 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.policy-page { max-width: 760px; margin: 0 auto; padding: 56px 24px 40px; }
.policy-document { word-break: break-word; }
.policy-document h1 { font-size: 30px; line-height: 1.2; font-weight: 700; margin: 0 0 6px; }
.policy-document .policy-meta { color: #64748b; font-size: 14px; margin: 0 0 32px; }
.policy-document h2 { font-size: 20px; line-height: 1.3; font-weight: 600; margin: 40px 0 10px; }
.policy-document h3 { font-size: 17px; font-weight: 600; margin: 24px 0 8px; }
.policy-document h4 { font-size: 16px; font-weight: 600; margin: 20px 0 6px; }
.policy-document p, .policy-document ul { margin: 0 0 14px; }
.policy-document ul { padding-left: 22px; }
.policy-document li { margin-bottom: 4px; }
.policy-document a { color: #2563eb; }
.policy-document code { background: #f1f5f9; color: inherit; padding: 1px 5px; border-radius: 4px; font-size: .875em; }
.policy-footer {
  margin-top: 56px; padding-top: 20px; border-top: 1px solid #e5e7eb;
  color: #94a3b8; font-size: 13px; text-align: center;
}

.status-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.status-code { font-size: 64px; font-weight: 800; color: var(--ppp-primary); line-height: 1; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; }
  .preview-card { position: static; }
}

@media (max-width: 575.98px) {
  .policy-page { padding: 32px 16px 28px; }
  .policy-document h1 { font-size: 24px; }
}
