:root {
  --bg: #f4f6fb; --surface: #ffffff; --ink: #1a2230; --muted: #6b7689;
  --line: #e3e8f0; --accent: #2f6df6; --accent-ink: #fff;
  --ok: #15a36a; --warn: #d98a00; --bad: #d23b3b;
  --radius: 10px; --shadow: 0 1px 3px rgba(20,30,60,.08), 0 8px 24px rgba(20,30,60,.05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--mono); font-size: .92em; }
.cap { text-transform: capitalize; }
.muted { color: var(--muted); font-weight: 400; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 28px; background: #0f1830; color: #fff; padding: 0 24px; height: 56px; }
.brand { font-weight: 700; letter-spacing: .3px; }
.brand span { color: #8fb4ff; font-weight: 600; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: #c3ccde; padding: 8px 14px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar nav a.active { background: var(--accent); color: #fff; }
.topbar .user { color: #c3ccde; font-size: 13px; }
.link, .topbar .user button { background: none; border: none; color: #8fb4ff; cursor: pointer; font: inherit; }

.view { max-width: 1040px; margin: 28px auto; padding: 0 24px; }
h2 { margin: 0 0 18px; font-size: 22px; }
h3 { margin: 0; font-size: 16px; }
.rowhead { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.loading, .empty { color: var(--muted); padding: 24px 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; }
.btn:hover { border-color: #c5cfde; }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); border-color: #f0c4c4; }
.btn.danger:hover { background: #fdecec; }
button.primary { padding: 10px 18px; border-radius: 8px; font-weight: 600; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.statcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.statcard .num { font-size: 30px; font-weight: 700; }
.statcard .lbl { color: var(--muted); margin-top: 4px; font-size: 13px; }
.statcard.ok .num { color: var(--ok); }
.statcard.warn .num { color: var(--warn); }
.statcard.bad .num { color: var(--bad); }

/* Table */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: #f7f9fd; }
.search { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin-bottom: 14px; }

/* Badges / tags */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.badge.ok { background: #e6f6ee; color: var(--ok); }
.badge.warn { background: #fdf2dd; color: var(--warn); }
.badge.bad { background: #fdecec; color: var(--bad); }
.badge.muted { background: #eef1f6; color: var(--muted); }
.tag { display: inline-block; background: #eef2fb; color: #34507f; border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 0 2px 2px 0; }

/* Detail */
.back { display: inline-block; margin-bottom: 10px; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.drow { display: grid; grid-template-columns: 160px 1fr; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.drow:last-child { border-bottom: none; }
.dl { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 10px; margin-top: 16px; }

/* Forms */
.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); max-width: 720px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 18px; padding: 14px 16px; }
legend { font-weight: 600; padding: 0 6px; color: #34507f; }
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label input, label select { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font: inherit; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.modules { margin-bottom: 12px; }
.modules .ml { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.chk { display: inline-flex; align-items: center; gap: 5px; margin: 0 12px 6px 0; font-size: 13px; color: var(--ink); }
.chk input { width: auto; margin: 0; }

.success { background: #e8f7ee; border: 1px solid #bce6cd; border-radius: 8px; padding: 14px 16px; margin-top: 16px; }
.success .actions { margin-top: 10px; }
.err { background: #fdecec; border: 1px solid #f1c4c4; color: #a92626; border-radius: 8px; padding: 11px 14px; margin-top: 12px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 340px; }
.login .brand.big { font-size: 20px; margin-bottom: 2px; }
.login p { margin: 0 0 20px; }
.login label { color: var(--ink); font-weight: 500; }
.login button { width: 100%; margin-top: 6px; }

/* Role pill + distributor badge */
.rolepill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; vertical-align: middle; }
.rolepill.admin { background: #ece3ff; color: #6b3fd1; }
.rolepill.staff { background: #e3eefe; color: #2f6df6; }
.topbar .rolepill { margin: 0 6px; }
.badge.dist { background: #ece3ff; color: #6b3fd1; }
.small { font-size: 12px; }
.rowactions { white-space: nowrap; text-align: right; }
.rowactions .link { color: var(--accent); margin-left: 12px; }
.rowactions .link.danger, .link.danger { color: var(--bad); }
.tbl tbody tr.norow, .rowactions { cursor: default; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,24,48,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(15,24,48,.3); width: 460px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-head .link { color: var(--muted); font-size: 16px; }
.modal .form { border: none; box-shadow: none; padding: 20px 22px; max-width: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.confirm-body { margin: 2px 0 18px; line-height: 1.55; color: var(--ink); }

/* select + inline action button (issue form customer picker) */
.selectrow { display: flex; gap: 8px; align-items: stretch; margin-top: 5px; }
.selectrow select { flex: 1; margin-top: 0; }
.selectrow .btn { white-space: nowrap; }

/* version-picker rows (new release) */
.picker-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.picker-mod { width: 130px; font-weight: 600; color: var(--ink); font-size: 13px; }
.picker-sel { flex: 1; margin-top: 0; }

/* build/bundle status row (manifest detail) */
.buildrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 0; }
