:root {
  --brand: #d1000d;
  --brand-dark: #a3000a;
  --ink: #1b1b1f;
  --muted: #6b6b73;
  --faint: #8a8a92;
  --line: #ebecf0;
  --bg: #f4f5f7;
  --card: #ffffff;
  --green-bg: #e7f6ec;
  --green: #137a39;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(20, 20, 30, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 48px 0; }

.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 0 auto; }
.spinner.small { width: 26px; height: 26px; border-width: 2px; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto; display: grid; place-items: center;
  color: #fff; font-weight: 800; letter-spacing: .4px; font-size: 15px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}
.brand-mark.lg { width: 60px; height: 60px; border-radius: 16px; font-size: 20px; background: rgba(255,255,255,0.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25); }
.brand-mark.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 13px; }

/* ---------- AUTH (split screen) ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-shell {
  width: 100%; max-width: 940px; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--card); border-radius: 24px; overflow: hidden; box-shadow: 0 24px 70px rgba(20,20,30,.12);
}
.auth-hero {
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  color: #fff; padding: 44px 40px; display: flex; flex-direction: column;
}
.hero-top { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.hero-logo { background: #fff; border-radius: 12px; padding: 13px 18px; display: inline-flex; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.hero-logo img { height: 36px; display: block; }
.hero-kicker { margin: 0; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700; opacity: .9; }
.hero-lead { font-size: 22px; line-height: 1.4; font-weight: 600; margin: 36px 0 28px; }
.hero-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.hero-points li { display: flex; align-items: flex-start; gap: 11px; font-size: 15px; opacity: .95; line-height: 1.4; }
.tick { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,0.2); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.hero-foot { margin-top: auto; padding-top: 30px; font-size: 12px; opacity: .75; }

.auth-main { display: grid; place-items: center; padding: 40px 38px; }
.auth-card { width: 100%; max-width: 360px; }
.brand-compact { display: none; margin-bottom: 24px; }
.brand-compact img { height: 32px; display: block; }
.auth-card h2 { font-size: 23px; margin: 0 0 4px; }
.auth-subhead { font-size: 14px; color: var(--muted); margin: 0 0 22px; }

.tabs { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.tab { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer; transition: .15s; }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; padding: 13px 14px; font-size: 16px; border: 1px solid #dcdde2; border-radius: 11px; background: #fff; transition: .15s; outline: none; }
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(209,0,13,.12); }

.btn-primary { width: 100%; border: 0; padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); cursor: pointer; transition: .15s; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-text { width: 100%; background: 0; border: 0; color: var(--muted); padding: 12px; font-size: 14px; cursor: pointer; }
.btn-text:hover { color: var(--brand); }

.message { font-size: 14px; padding: 11px 13px; border-radius: 10px; margin: 4px 0 14px; }
.message.error { background: #fdecec; color: #b3000b; }
.message.success { background: var(--green-bg); color: var(--green); }
.auth-hint { font-size: 13px; color: var(--muted); text-align: center; margin: 20px 0 0; line-height: 1.5; }

/* ---------- APP ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 13px 22px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-brand { display: flex; align-items: center; gap: 11px; font-weight: 600; min-width: 0; }
.topbar-logo { height: 22px; width: auto; max-width: 150px; display: block; flex: 0 0 auto; }
.topbar-tag { font-size: 13px; color: var(--muted); font-weight: 600; padding-left: 11px; border-left: 1px solid var(--line); white-space: nowrap; }

/* Profile menu */
.profile { position: relative; flex: 0 0 auto; }
.avatar-btn { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px 4px 4px; cursor: pointer; transition: .15s; }
.avatar-btn:hover { border-color: var(--brand); }
.avatar-btn > span { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.avatar-btn .chev { width: 16px; height: 16px; color: var(--muted); }
.profile-menu { position: absolute; right: 0; top: calc(100% + 10px); width: 300px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 44px rgba(20,20,30,.16); padding: 14px; z-index: 30; }
.pm-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.pm-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.pm-id { min-width: 0; }
.pm-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-email { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-block { margin-bottom: 13px; }
.pm-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.pm-inline { display: flex; gap: 8px; }
.pm-inline input { flex: 1; min-width: 0; padding: 9px 11px; font-size: 14px; border: 1px solid #dcdde2; border-radius: 9px; outline: none; }
.pm-inline input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(209,0,13,.12); }
.pm-save { border: 0; background: var(--ink); color: #fff; border-radius: 9px; padding: 0 15px; font-size: 13px; font-weight: 700; cursor: pointer; flex: 0 0 auto; }
.pm-save:hover { background: var(--brand); }
.pm-locked { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; background: var(--bg); border-radius: 9px; font-size: 14px; }
.pm-locked span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-locked svg { width: 15px; height: 15px; color: var(--faint); flex: 0 0 auto; }
.pm-hint { font-size: 12px; color: var(--muted); margin: 6px 2px 0; line-height: 1.4; }
.pm-check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; cursor: pointer; line-height: 1.35; }
.pm-check input { margin: 1px 0 0; width: 18px; height: 18px; accent-color: var(--brand); flex: 0 0 auto; }
.pm-action { width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: .15s; }
.pm-action svg { width: 16px; height: 16px; }
.pm-action:hover { border-color: var(--brand); color: var(--brand); }
.pm-action.danger { color: #b3000b; border-color: #f3c4c4; }
.pm-action.danger:hover { background: #fdecec; border-color: #e88; }
.pm-logo-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.pm-logo-btn svg { width: 16px; height: 16px; }
.pm-logo-btn:hover { border-color: var(--brand); color: var(--brand); }
.pm-msg { font-size: 13px; padding: 9px 11px; border-radius: 9px; margin: 12px 0 0; }
.pm-msg.success { background: var(--green-bg); color: var(--green); }
.pm-msg.error { background: #fdecec; color: #b3000b; }

.content { max-width: 720px; margin: 0 auto; padding: 30px 20px 50px; }
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 26px; margin: 0 0 3px; }

.reports { display: flex; flex-direction: column; gap: 13px; }
.report-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; align-items: center; gap: 15px; transition: .15s; }
.report-card:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(20,20,30,.10); }
.report-icon { width: 50px; height: 50px; flex: 0 0 auto; border-radius: 13px; background: #fdecec; color: var(--brand); display: grid; place-items: center; }
.report-icon svg { width: 24px; height: 24px; }
.report-body { flex: 1; min-width: 0; }
.report-title { font-size: 16px; font-weight: 700; margin: 0 0 2px; }
.report-sub { font-size: 14px; color: var(--muted); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-meta { display: flex; gap: 14px; align-items: center; margin-top: 7px; font-size: 13px; color: var(--faint); flex-wrap: wrap; }
.report-meta .mi { display: inline-flex; align-items: center; gap: 5px; }
.report-meta svg { width: 14px; height: 14px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; background: var(--green-bg); color: var(--green); }
.badge.submitted { background: #fff1df; color: #a35a00; }
/* Unified action-button system — every inline button shares the same height,
   padding, radius and font; only the color role differs. */
.btn-download, .btn-ghost, .btn-del, .btn-solid {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 20px; border-radius: 11px; border: 1px solid transparent;
  font-size: 15px; font-weight: 700; line-height: 1.2; white-space: nowrap;
  text-decoration: none; cursor: pointer; transition: .15s;
}
.btn-download svg, .btn-ghost svg, .btn-del svg, .btn-solid svg { width: 16px; height: 16px; }

/* Solid dark (Download) */
.btn-download { background: var(--ink); color: #fff; }
.btn-download:hover { background: var(--brand); }

.empty { text-align: center; padding: 56px 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px; background: #fdecec; color: var(--brand); display: grid; place-items: center; }
.empty-icon svg { width: 30px; height: 30px; }
.empty h3 { margin: 0 0 6px; font-size: 18px; }
.empty p { color: var(--muted); margin: 0 auto; max-width: 360px; line-height: 1.5; }

.app-foot { text-align: center; font-size: 12px; color: var(--faint); padding: 24px 20px 36px; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 420px; }
  .auth-hero { display: none; }
  .brand-compact { display: flex; }
  .auth-main { padding: 30px 26px; }
}
@media (max-width: 520px) {
  .report-card { flex-wrap: wrap; }
  .btn-download { width: 100%; justify-content: center; }
  .topbar-tag { display: none; }
}

/* ---------- Admin ---------- */
.admin-tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 22px; max-width: 360px; }
.atab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.atab.active { background: var(--brand); color: #fff; }
.head-row { display: flex; align-items: center; justify-content: space-between; }
.grp { font-size: 14px; color: var(--muted); margin: 22px 0 10px; }
.user-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 20px; }
.uf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.uf-grid select { width: 100%; padding: 13px 14px; font-size: 16px; border: 1px solid #dcdde2; border-radius: 11px; background: #fff; }
.module-checks { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.user-row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.user-row .ur-body { flex: 1; min-width: 0; }
.user-row .ur-name { font-weight: 700; font-size: 15px; }
.user-row .ur-sub { font-size: 13px; color: var(--muted); }
.user-row .ur-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 2px 8px; border-radius: 999px; background: var(--green-bg); color: var(--green); margin-left: 6px; }
/* Danger outline (Delete) */
.btn-del { border-color: #f3c4c4; color: #b3000b; background: #fff; }
.btn-del:hover { background: #b3000b; border-color: #b3000b; color: #fff; }
/* Brand outline (Add user) */
.btn-ghost { border-color: var(--brand); color: var(--brand); background: #fff; }
.btn-ghost:hover { background: var(--brand); color: #fff; }
/* Solid gradient (Create user) */
.btn-solid { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.btn-solid:hover { filter: brightness(1.06); }
.btn-solid:disabled { opacity: .6; cursor: default; }
@media (max-width: 560px) { .uf-grid { grid-template-columns: 1fr; } }

/* Admin gets a wider workspace on larger screens; everything stays fluid. */
#adminContent { max-width: 1000px; }
@media (min-width: 760px) {
  #adminReportsList, #staffList, #clientList { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 13px; }
}
.user-row { flex-wrap: wrap; }
