/* =====================================================================
   admin-theme.css — Frenzon SACCO Admin Dashboard
   Same design language as the member portal (drawer menu, sticky top
   bar, rounded cards, soft shadows, pills) in the admin's navy.
   Loaded after style.css. To go back to the old look, remove the
   <link> to this file and shell.js from index.html.
   Shell selectors start with "body" and module selectors with
   "#pageBody" so they beat the styles each module injects itself.
   ===================================================================== */

:root {
  --primary: #0f1f3d;
  --primary-700: #0b1830;
  --primary-900: #070f20;
  --primary-500: #1f4e9c;
  --blue: #2563b8;
  --primary-light: #e3ecfa;
  --accent: #e0b04a;
  --success: #1c7c54;  --success-light: #dcf3e8;
  --warning: #9a5a06;  --warning-light: #fff4dc;
  --danger: #b42318;   --danger-light: #fde9e7;
  --info: #1f5fa8;     --info-light: #e6f0fb;
  --bg: #eef1f6;
  --bg-subtle: #f5f7fa;
  --surface: #ffffff;
  --text-main: #10192b;
  --text-muted: #5c6779;
  --border-color: #dde3ec;
  --border-dark: #c5cedb;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px; --radius-xl: 26px;
  --shadow-sm: 0 1px 2px rgba(15, 31, 61, .06);
  --shadow-md: 0 10px 28px -14px rgba(15, 31, 61, .28);
  --shadow-focus: 0 0 0 4px rgba(37, 99, 184, .18);
  --sidebar-w: 268px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font: 400 1rem/1.5 var(--font);
  color: var(--text-main);
  background:
    radial-gradient(900px 380px at 100% -8%, rgba(37, 99, 184, .12), transparent 60%),
    var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible { outline: 3px solid rgba(37, 99, 184, .55); outline-offset: 2px; }
.muted { color: var(--text-muted); }

/* ---------- Sign-in ---------- */
body #loginScreen:not(.hidden) {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(520px 320px at 85% 8%, rgba(224, 176, 74, .22), transparent 65%),
    radial-gradient(600px 400px at 0% 100%, rgba(37, 99, 184, .3), transparent 60%),
    linear-gradient(160deg, var(--primary-900), var(--primary) 55%, var(--primary-500));
}

body .login-card {
  width: 100%;
  max-width: 410px;
  margin: 0;
  padding: 30px 24px 24px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
  text-align: left;
}

body .login-card .brand-title,
body .login-card .brand-subtitle { text-align: center; }

body .login-card .brand-title {
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 750;
  letter-spacing: -.01em;
}

body .login-card .brand-title::before,
body .sidebar-brand::before {
  content: "F";
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 18px;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--accent);
  background: linear-gradient(145deg, var(--primary-500), var(--primary-900));
  box-shadow: 0 10px 20px -10px rgba(15, 31, 61, .8);
}

body .login-card .brand-subtitle { color: var(--text-muted); font-size: .92rem; margin-bottom: 22px; }

body .login-card label { display: block; margin: 0 0 6px; font-size: .88rem; font-weight: 600; }

body .login-card input {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0 0 16px;
  padding: 12px 14px;
  font: 400 1rem/1.3 var(--font);
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
}

body .login-card input:focus { outline: 0; border-color: var(--blue); box-shadow: var(--shadow-focus); }

body .login-card button[type="submit"] {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  font: 600 .95rem/1.2 var(--font);
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, var(--blue), var(--primary-500));
  box-shadow: 0 8px 16px -8px rgba(15, 31, 61, .7);
}

/* ---------- App shell ---------- */
body #dashboardScreen:not(.hidden) { display: block; min-height: 100vh; min-height: 100dvh; }

body #sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: min(84vw, 300px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 14px 16px;
  color: #fff;
  background: linear-gradient(175deg, var(--primary-700), var(--primary-900));
  transform: translateX(-102%);
  transition: transform .26s cubic-bezier(.3, .8, .3, 1);
  overflow-y: auto;
}

body #sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .45); }

body #sidebarOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(7, 15, 32, .55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

body #sidebarOverlay.open { opacity: 1; pointer-events: auto; }

body .sidebar-brand { padding: 6px 8px 18px; margin: 0; border: 0; }

body .sidebar-brand::before {
  width: 44px;
  height: 44px;
  margin: 0 0 12px;
  border-radius: 14px;
  font-size: 1.4rem;
  background: rgba(255, 255, 255, .1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}

body .brand-title-small { margin: 0; font-size: 1.15rem; font-weight: 750; letter-spacing: -.01em; color: #fff; }
body .brand-subtitle-small { margin: 0; font-size: .82rem; color: rgba(255, 255, 255, .6); }

body .nav-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: visible;
}

body .nav-list li { margin: 0; flex-shrink: 0; }

body .nav-group {
  margin: 16px 10px 6px;
  padding: 0;
  font-size: .78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .45);
}

body .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, .74);
  font-size: .95rem;
  font-weight: 550;
  text-decoration: none;
  transition: background .15s, color .15s;
}

body .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }

body .nav-link.active {
  background: rgba(255, 255, 255, .13);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

body .nav-link.nav-soon { color: rgba(255, 255, 255, .45); }
body .nav-link.nav-soon::after {
  content: "Soon";
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .1);
  font-size: .68rem;
  font-weight: 600;
}

body #sidebar :focus-visible { outline-color: var(--accent); }

body .sidebar-footer { margin-top: 16px; padding: 16px 0 0; border-top: 1px solid rgba(255, 255, 255, .12); }

body #logoutButton {
  width: 100%;
  max-width: none;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 14px;
  background: transparent;
  color: #fff;
  font: 600 .95rem/1.2 var(--font);
  cursor: pointer;
}

body #logoutButton:hover { background: rgba(255, 255, 255, .1); }

/* Top bar — phones and tablets */
body #topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: env(safe-area-inset-top, 0px) 14px 0;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border-color);
}

body #menuButton {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  color: var(--text-main);
  cursor: pointer;
}

body #topbarTitle {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body #mainContent { min-width: 0; padding: 18px 14px 48px; margin: 0; }

/* Page heading */
body #pageHeader {
  max-width: 1120px;
  margin: 4px auto 18px;
  padding: 0;
  border: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-direction: row;
}

body #pageTitle { margin: 0; font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; color: var(--text-main); }
body #pageSubtitle { margin: 4px 0 0; color: var(--text-muted); font-size: .92rem; }
body #pageSubtitle:empty { display: none; }

body #adminUserName {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .82rem;
  font-weight: 650;
}

body #adminUserName:empty { display: none; }

body #pageBody { max-width: 1120px; margin: 0 auto; }

/* The page title already sits in the top bar on phones */
@media (max-width: 899px) {
  body #pageTitle { display: none; }
  body #pageHeader:has(#pageSubtitle:empty) { display: none; }
  body #adminUserArea { display: none; }
}

/* Desktop: fixed sidebar, no top bar */
@media (min-width: 900px) {
  body #topbar, body #sidebarOverlay { display: none; }

  body #sidebar {
    width: var(--sidebar-w);
    transform: none;
    box-shadow: none;
    transition: none;
  }

  body #mainContent { margin-left: var(--sidebar-w); padding: 30px 40px 64px; }
  body #pageTitle { font-size: 1.7rem; }
}

/* ---------- Cards, headings ---------- */
body .card,
body .table-container,
body .task-card,
body .task-form-card,
body #pageBody .pm-card,
body #pageBody .ru-card,
body #pageBody .st-card,
body #pageBody .fz-reg-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

body #pageBody .pm-card,
body #pageBody .ru-card,
body #pageBody .st-card,
body #pageBody .fz-reg-card { padding: 18px; }

body #pageBody .pm-wrap,
body #pageBody .ru-wrap,
body #pageBody .rt-wrap,
body #pageBody .st-wrap,
body #pageBody .fz-reg-wrap { max-width: none; gap: 14px; }

body #pageBody .pm-card h3,
body #pageBody .ru-card h3,
body #pageBody .st-card h3,
body #pageBody .fz-reg-card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-main);
}

body #pageBody .pm-item,
body #pageBody .pm-info {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-subtle);
}

body #pageBody .pm-item-name { font-weight: 650; }
body #pageBody .pm-amount { font-weight: 750; font-size: 1.05rem; }
body #pageBody .pm-grid span,
body #pageBody .pm-hint,
body #pageBody .pm-item-sub { color: var(--text-muted); }

/* ---------- Buttons ---------- */
body #pageBody .pm-btn,
body #pageBody .ru-btn,
body #pageBody .st-btn,
body #pageBody .fz-btn,
body #pageBody .pm-refresh,
body .button-primary,
body .button-danger,
body .button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: 600 .92rem/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .08s;
}

body #pageBody .pm-btn:active,
body #pageBody .ru-btn:active,
body #pageBody .st-btn:active,
body #pageBody .fz-btn:active { transform: scale(.98); }

/* primary */
body #pageBody .pm-btn,
body #pageBody .ru-btn,
body #pageBody .st-btn,
body #pageBody .fz-btn-primary,
body .button-primary {
  color: #fff;
  background: linear-gradient(180deg, var(--blue), var(--primary-500));
  box-shadow: 0 8px 16px -8px rgba(15, 31, 61, .7);
}

/* secondary / outline */
body #pageBody .pm-refresh,
body #pageBody .st-btn.secondary,
body #pageBody .fz-btn-secondary,
body .button-secondary {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border-dark);
  box-shadow: none;
}

body #pageBody .pm-refresh:hover,
body #pageBody .st-btn.secondary:hover,
body #pageBody .fz-btn-secondary:hover { background: var(--primary-light); border-color: var(--blue); }

/* danger */
body #pageBody .pm-btn.warn,
body #pageBody .ru-btn.warn,
body #pageBody .st-btn.warn,
body #pageBody .fz-btn-danger,
body .button-danger {
  color: var(--danger);
  background: var(--surface);
  border-color: #f1c2bd;
  box-shadow: none;
}

body #pageBody .pm-btn.warn:hover,
body #pageBody .ru-btn.warn:hover,
body #pageBody .st-btn.warn:hover,
body #pageBody .fz-btn-danger:hover,
body .button-danger:hover { background: var(--danger-light); }

body #pageBody .pm-btn[disabled],
body #pageBody .ru-btn[disabled],
body #pageBody .st-btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Forms ---------- */
body #pageBody input:not([type="checkbox"]):not([type="radio"]),
body #pageBody select,
body #pageBody textarea {
  min-height: 44px;
  padding: 10px 14px;
  font: 400 .95rem/1.3 var(--font);
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  max-width: 100%;
}

body #pageBody textarea { min-height: 96px; line-height: 1.5; }

body #pageBody input:focus,
body #pageBody select:focus,
body #pageBody textarea:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: var(--shadow-focus);
}

body #pageBody label { font-size: .88rem; font-weight: 600; }

@media (max-width: 899px) {
  /* 16px stops iOS zooming into fields */
  body #pageBody input,
  body #pageBody select,
  body #pageBody textarea { font-size: 16px; }
}

/* ---------- Tables ---------- */
body #pageBody .table-container,
body #pageBody .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

body #pageBody table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; background: transparent; }

body #pageBody th {
  padding: 10px 12px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: .76rem;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
  border: 0;
}

body #pageBody th:first-child { border-radius: 10px 0 0 10px; }
body #pageBody th:last-child { border-radius: 0 10px 10px 0; }

body #pageBody td {
  padding: 12px;
  border: 0;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

body #pageBody tbody tr:last-child td { border-bottom: 0; }
body #pageBody tbody tr:hover td { background: var(--bg-subtle); }

@media (max-width: 699px) {
  body #pageBody table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------- Badges ---------- */
body .status-badge,
body #pageBody .badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 650;
  white-space: nowrap;
}

/* ---------- FDF: same layout, navy ---------- */
body #pageBody .fdf-page {
  --fdf-ink: var(--text-main);
  --fdf-muted: var(--text-muted);
  --fdf-line: var(--border-color);
  --fdf-green: var(--blue);
  --fdf-pale: var(--primary-light);
}

body #pageBody .fdf-hero {
  background:
    radial-gradient(420px 220px at 100% 0, rgba(224, 176, 74, .3), transparent 65%),
    linear-gradient(155deg, var(--primary-500), var(--primary) 50%, var(--primary-900));
  border-radius: var(--radius-xl);
  box-shadow: 0 22px 40px -22px rgba(7, 15, 32, .7);
}

body #pageBody .fdf-hero h2 { color: #fff; }
body #pageBody .fdf-btn { min-height: 42px; border-color: var(--border-dark); border-radius: var(--radius-md); color: var(--primary); }
body #pageBody .fdf-hero .fdf-btn { color: #fff; background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .35); }
body #pageBody .fdf-kpi,
body #pageBody .fdf-panel { border-radius: var(--radius-lg); border-color: var(--border-color); box-shadow: var(--shadow-sm); }
body #pageBody .fdf-kpi-icon { color: var(--blue); }
body #pageBody .fdf-kpi-value,
body #pageBody .fdf-panel-head h3 { color: var(--text-main); }
body #pageBody .fdf-input,
body #pageBody .fdf-select { border-color: var(--border-dark); color: var(--text-main); }
body #pageBody .fdf-table-action { border-color: var(--border-dark); background: var(--primary-light); color: var(--primary-500); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* ---------- Who this page is for, and who is logged in (access.js) ---------- */
body .nav-link.mine::after {
  content: "Yours";
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 99px;
  background: rgba(224, 176, 74, .2);
  color: #f1cf84;
  font-size: .68rem;
  font-weight: 600;
}

body .identity { margin: 0 4px 12px; }
body .identity-label { font-size: .72rem; color: rgba(255, 255, 255, .5); }
body .identity-email { margin-top: 2px; font-weight: 650; font-size: .88rem; color: #fff; overflow-wrap: anywhere; }
body .identity-roles { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
body .identity-role {
  padding: 2px 9px; border-radius: 99px; font-size: .7rem; font-weight: 600;
  background: rgba(255, 255, 255, .12); color: #e3ecfa;
}

body .access-banner {
  display: flex; align-items: flex-start; gap: 12px;
  max-width: 1120px; margin: 0 auto 16px; padding: 12px 14px;
  border: 1px solid var(--border-color); border-radius: 14px;
  background: var(--surface); font-size: .9rem; line-height: 1.45;
}
body .access-badge {
  flex: 0 0 auto; padding: 3px 11px; border-radius: 99px;
  font-size: .76rem; font-weight: 700; white-space: nowrap;
}
body .access-note { margin-top: 2px; color: var(--text-muted); font-size: .82rem; }
body .access-yours { background: var(--success-light); border-color: #b5e2cb; }
body .access-yours .access-badge { background: #fff; color: #0e5a3a; }
body .access-view,
body .access-other { background: var(--warning-light); border-color: #f2d99b; }
body .access-view .access-badge,
body .access-other .access-badge { background: #fff; color: #7a4504; }


/* ---------- Bottom bar on phones and tablets (shell.js) ---------- */
body #bottomNav { display: none; }

@media (max-width: 899px) {
  body #bottomNav {
    position: fixed; z-index: 30; left: 12px; right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
    padding: 6px;
    background: var(--surface); border: 1px solid var(--border-color); border-radius: 22px;
    box-shadow: 0 14px 34px -10px rgba(7, 15, 32, .38);
  }
  body #bottomNav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 54px; padding: 4px 0;
    background: none; border: 0; border-radius: 16px;
    color: var(--text-muted); font-size: .7rem; font-weight: 600; cursor: pointer;
  }
  body #bottomNav button.active { background: var(--primary-light); color: var(--primary); }
  body #mainContent { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}


/* ---------- Missing-file warning (shell.js) ---------- */
body #healthBanner {
  max-width: 1120px; margin: 0 auto 16px; padding: 12px 14px;
  border: 1px solid #f4c3be; border-radius: 14px;
  background: var(--danger-light); color: #8a1a10; font-size: .9rem; line-height: 1.5;
}
body #healthBanner div { margin-top: 2px; }
