@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600;700&display=swap');

/* =========================================================================
   GRC Shield — shared stylesheet (Plan 1, Change 9)
   Clean professional GRC look: navy header, white cards, restrained accents.
   ========================================================================= */

:root {
  --navy: #16283f;
  --navy-2: #1f3a5c;
  --accent: #2f6fb2;
  --accent-dark: #245a92;
  --bg: #f2f4f7;
  --card: #ffffff;
  --border: #d9dee6;
  --text: #22303f;
  --muted: #6b7787;
  --ok: #2e7d4f;
  --warn: #b07a1e;
  --danger: #b03a3a;
  --danger-bg: #fbeaea;
  --ok-bg: #e8f4ed;
  --warn-bg: #faf1de;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
h1, h2, h3 { margin: 0 0 10px; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- left sidebar navigation (BOTH themes; match overrides colors only) --
   DOM (from nav.js): <header id="app-nav"> > .nav-inner
     > .nav-brand + .cust-identity + nav.nav-modules
       ( .nav-group > .nav-group-label[+ .nav-arrow] + .nav-dropdown > .nav-link )
     + .nav-right (theme toggle / help / user / sign-out = sidebar footer).
   Accordion: .nav-dropdown hidden until the group has .open (toggled in JS,
   persisted in localStorage 'grc-nav-open'). No hover behavior. */
#app-nav {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 230px; z-index: 1030;
  background: var(--navy); color: #fff;
  border-right: 1px solid var(--navy-2);
  overflow-y: auto;
}
.nav-inner {
  display: flex; flex-direction: column; align-items: stretch;
  padding: 16px 10px; gap: 6px; min-height: 100%;
}
.nav-brand {
  color: #fff; font-size: 20px; font-weight: 700; letter-spacing: .5px;
  padding: 4px 8px 14px; border-bottom: 1px solid var(--navy-2); margin-bottom: 6px;
}
.nav-brand span { color: #8fb7e0; font-weight: 400; }
.nav-brand:hover { text-decoration: none; }
.cust-identity { padding: 0 8px 8px; color: #cdd8e5; font-size: 13px; }
.cust-identity .cust-identity-name { margin-left: 6px; }
.nav-modules { display: flex; flex-direction: column; align-items: stretch; gap: 2px; flex: 0 0 auto; }
.nav-group { width: 100%; }
.nav-group-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; user-select: none;
  color: #cdd8e5; font-weight: 600; font-size: 13px;
}
.nav-group-label:hover { background: var(--navy-2); color: #fff; }
.nav-group.active > .nav-group-label { color: #fff; background: rgba(47,111,178,0.30); }
.nav-arrow { font-size: 11px; opacity: .8; margin-left: 8px; }
/* accordion body: inline, static, indented; shown only when the group is .open */
.nav-dropdown {
  display: none;
  margin: 0 0 4px 14px;
  border-left: 1px solid var(--navy-2);
}
.nav-group.open > .nav-dropdown { display: block; }
.nav-link { display: block; padding: 7px 12px; color: #cdd8e5; font-size: 13px; border-radius: 5px; }
.nav-link:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-link.active { color: #8fb7e0; font-weight: 600; }
/* direct-link modules (no sub-pages, no arrow) */
.nav-direct {
  display: block; padding: 8px 10px; border-radius: 6px;
  color: #cdd8e5; font-weight: 600; font-size: 13px;
}
.nav-direct:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-direct.active { color: #fff; background: rgba(47,111,178,0.30); }
/* sidebar footer: theme toggle / help / user / sign-out */
.nav-right {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--navy-2);
}
.nav-user { color: #cdd8e5; font-size: 13px; }

/* ---- top-right user strip (mirrors the Platform Admin top bar) -----------
   Slim FIXED container in the viewport's top-right corner (right of the 230px
   sidebar zone), rendered under <body> by nav.js (id="user-strip"): signed-in
   email + Logout button. Base = light theme; the match theme recolors only
   (block far below). Sidebar z-index (1030) is higher, so this never covers it;
   we also start it left of the sidebar edge. */
#user-strip {
  position: fixed; top: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px; min-height: 34px;
  background: #eef1f5; border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 8px;
  font-size: 13px; color: var(--text);
}
#user-strip .us-email { color: var(--muted); font-size: 12px; white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
#user-strip .us-logout {
  font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
  padding: 4px 12px; border-radius: 5px;
  background: transparent; color: var(--accent-dark);
  border: 1px solid var(--accent); font-family: inherit;
}
#user-strip .us-logout:hover { background: #e2e9f2; }

.verify-banner {
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid #e4cf9d; padding: 8px 16px; text-align: center; font-size: 13px;
  margin-left: 230px;
}

/* ---- layout ------------------------------------------------------------ */
/* padding-top clears the fixed top-right #user-strip (~34px) so page headers
   never sit under it. */
.page-wrap { max-width: none; margin: 0 0 0 230px; padding: 44px 16px 60px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.card h2 { border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 12px; color: var(--navy-2); }

.tile-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tile {
  flex: 1; min-width: 150px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
}
.tile .num { font-size: 26px; font-weight: 700; color: var(--navy-2); }
.tile .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.tile.alert .num { color: var(--danger); }

/* ---- tables ------------------------------------------------------------ */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); border-bottom: 2px solid var(--border); padding: 8px 10px;
}
table.grid td { border-bottom: 1px solid var(--border); padding: 9px 10px; vertical-align: top; }
table.grid tr:hover td { background: #f7f9fc; }
table.grid tr:last-child td { border-bottom: none; }

/* ---- badges ------------------------------------------------------------ */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-ok      { background: var(--ok-bg);    color: var(--ok); }
.badge-warn    { background: var(--warn-bg);  color: var(--warn); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: #e8ecf2; color: var(--muted); }
.badge-info    { background: #e3edf8; color: var(--accent-dark); }

/* ---- buttons & forms ---------------------------------------------------- */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 5px;
  padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; font-family: inherit;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--accent-dark); border-color: var(--accent); }
.btn-secondary:hover { background: #eef4fa; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #932e2e; }
.btn-approve { background: var(--ok); }
.btn-approve:hover { background: #256841; }
.btn-ghost { background: transparent; color: #cdd8e5; border-color: #3a5273; }
.btn-ghost:hover { background: var(--navy-2); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 5px;
  padding: 8px 10px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 160px; }

/* ---- states ------------------------------------------------------------ */
.empty-state {
  text-align: center; color: var(--muted); padding: 30px 16px; font-size: 14px;
}
.error-box {
  background: var(--danger-bg); color: var(--danger); border: 1px solid #e3b8b8;
  border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.info-box {
  background: #e3edf8; color: var(--accent-dark); border: 1px solid #bcd4ec;
  border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.loading { color: var(--muted); padding: 20px 0; font-style: italic; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, 'Courier New', monospace; font-size: 12px; word-break: break-all; }

/* ---- tabs -------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 18px; cursor: pointer; font-weight: 600; font-size: 13px;
  color: var(--muted); border: none; background: transparent; font-family: inherit;
}
.tab.active { color: var(--accent-dark); box-shadow: inset 0 -3px 0 var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- queue items ------------------------------------------------------- */
.queue-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px;
  margin-bottom: 12px; background: var(--card);
}
.queue-item .qi-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.qi-title { font-weight: 600; font-size: 15px; color: var(--navy-2); }
.qi-meta { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.qi-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; }
.guidance-box {
  background: var(--warn-bg); border: 1px solid #e4cf9d; border-radius: 6px;
  padding: 10px 12px; font-size: 13px; margin: 8px 0;
}
.guidance-box .gb-label { font-weight: 700; color: var(--warn); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }

/* ---- login ------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 10px; padding: 34px 36px; width: 100%;
  max-width: 400px; box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.login-card .brand { font-size: 24px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.login-card .brand span { color: var(--accent); font-weight: 400; }
.login-card .tag { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .btn { width: 100%; padding: 10px; font-size: 14px; margin-top: 6px; }

/* ---- audit / chain ------------------------------------------------------ */
.chain-status { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.chain-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.chain-dot.ok { background: var(--ok); }
.chain-dot.bad { background: var(--danger); }
.chain-dot.unknown { background: var(--muted); }
tr.tampered td { background: var(--danger-bg) !important; }

@media (max-width: 760px) {
  /* narrow screens: the sidebar collapses back to a top bar (both themes);
     accordion groups still toggle, stacked full-width under the brand row */
  #app-nav {
    position: static; width: auto; bottom: auto;
    border-right: none; border-bottom: 1px solid var(--navy-2);
    overflow-y: visible;
  }
  .nav-inner {
    flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 8px 12px; min-height: 0; gap: 10px;
  }
  .nav-brand { border-bottom: none; padding: 4px 8px; margin-bottom: 0; }
  .nav-modules { order: 3; width: 100%; }
  .nav-right {
    flex-direction: row; align-items: center; margin-top: 0; margin-left: auto;
    padding-top: 0; border-top: none; order: 2; width: auto;
  }
  .page-wrap, .verify-banner { margin-left: 0; }
  /* narrow screens: the fixed top-right strip would overlap the stacked top-bar
     nav, so drop it into normal flow (full-width, right-aligned) and restore
     page-wrap's normal top padding since nothing floats over the header now. */
  #user-strip {
    position: static; width: 100%; justify-content: flex-end;
    border-left: none; border-bottom-left-radius: 0;
  }
  .page-wrap { padding-top: 20px; }
}

/* =========================================================================
   MATCH THEME — additive dark-gradient theme (matches public marketing site).
   Activated only by html[data-theme="match"]. The default (light) theme above
   is untouched. Everything below is scoped under html[data-theme="match"].
   Palette source: web/css/variables.css + components.css (marketing site).
   ========================================================================= */

/* ---- token remap: existing components inherit via these custom props ----- */
html[data-theme="match"] {
  --navy:        #14141b;   /* dark chrome base (was navy header) */
  --navy-2:      #2A1A4E;   /* deep purple, used for card headings/accents */
  --accent:      #7B3FF2;   /* purple accent */
  --accent-dark: #00A6FB;   /* blue accent (hover/darker slot) */
  --bg:          #0F0F0F;   /* page base (gradient painted on body) */
  --card:        rgba(26,26,31,0.85);
  --border:      rgba(123,63,242,0.25);
  --text:        #FFFFFF;
  --muted:       #6C6C75;
  /* status tokens kept vivid but dark-friendly */
  --ok:        #34C759;  --ok-bg:     rgba(52,199,89,0.15);
  --warn:      #FFB800;  --warn-bg:   rgba(255,184,0,0.15);
  --danger:    #FF3B30;  --danger-bg: rgba(255,59,48,0.15);
}

html[data-theme="match"] body {
  background: linear-gradient(135deg, #0F0F0F 0%, #2A1A4E 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
html[data-theme="match"] h1,
html[data-theme="match"] h2,
html[data-theme="match"] h3 { color: #FFFFFF; }
html[data-theme="match"] a { color: var(--accent); }
html[data-theme="match"] a:hover { color: var(--accent-dark); }
html[data-theme="match"] .muted,
html[data-theme="match"] .page-head .sub,
html[data-theme="match"] .tile .lbl { color: var(--text-secondary, #B8B8C0); }

/* ---- cards / panels / tiles / queue items ------------------------------- */
html[data-theme="match"] .card,
html[data-theme="match"] .tile,
html[data-theme="match"] .queue-item {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
}
html[data-theme="match"] .card h2 { color: #FFFFFF; border-bottom-color: var(--border); }
html[data-theme="match"] .tile .num,
html[data-theme="match"] .qi-title,
html[data-theme="match"] .feed .feed-actor { color: #FFFFFF; }
html[data-theme="match"] .page-head .sub,
html[data-theme="match"] .qi-meta { color: #B8B8C0; }

/* ---- buttons: purple -> blue gradient ----------------------------------- */
html[data-theme="match"] .btn {
  background: linear-gradient(135deg, #7B3FF2 0%, #00A6FB 100%);
  color: #FFFFFF; border-color: transparent;
}
html[data-theme="match"] .btn:hover { filter: brightness(1.1); background: linear-gradient(135deg, #8a52f5 0%, #1bb4ff 100%); }
html[data-theme="match"] .btn-secondary {
  background: transparent; color: #FFFFFF; border-color: var(--accent);
}
html[data-theme="match"] .btn-secondary:hover { background: rgba(123,63,242,0.15); }
html[data-theme="match"] .btn-ghost {
  background: transparent; color: #B8B8C0; border-color: var(--border);
}
html[data-theme="match"] .btn-ghost:hover { background: rgba(123,63,242,0.15); color: #FFFFFF; }
html[data-theme="match"] .btn-danger  { background: var(--danger); }
html[data-theme="match"] .btn-approve { background: var(--ok); }

/* ---- inputs / forms ----------------------------------------------------- */
html[data-theme="match"] input[type="text"],
html[data-theme="match"] input[type="email"],
html[data-theme="match"] input[type="password"],
html[data-theme="match"] input[type="number"],
html[data-theme="match"] select,
html[data-theme="match"] textarea {
  background: rgba(15,15,15,0.6);
  border-color: var(--border);
  color: #FFFFFF;
}
html[data-theme="match"] input:focus,
html[data-theme="match"] select:focus,
html[data-theme="match"] textarea:focus { border-color: var(--accent); }
html[data-theme="match"] label { color: #B8B8C0; }

/* ---- tables ------------------------------------------------------------- */
html[data-theme="match"] table.grid th {
  color: #B8B8C0; border-bottom-color: var(--border);
}
html[data-theme="match"] table.grid td { border-bottom-color: var(--border); }
html[data-theme="match"] table.grid tr:hover td { background: rgba(123,63,242,0.10); }

/* ---- tabs --------------------------------------------------------------- */
html[data-theme="match"] .tabs { border-bottom-color: var(--border); }
html[data-theme="match"] .tab { color: #B8B8C0; }
html[data-theme="match"] .tab.active { color: #FFFFFF; box-shadow: inset 0 -3px 0 var(--accent); }

/* ---- badges (translucent dark variants) --------------------------------- */
html[data-theme="match"] .badge-neutral { background: rgba(108,108,117,0.25); color: #B8B8C0; }
html[data-theme="match"] .badge-info    { background: rgba(0,166,251,0.20);  color: #00A6FB; }

/* ---- theme toggle switch (styled in BOTH themes; button lives in nav) ---- */
#theme-toggle,
.nav-theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
  background: transparent; color: inherit;
  border: 1px solid var(--muted, #6b7688);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
#theme-toggle:hover, .nav-theme-toggle:hover {
  background: rgba(255,255,255,0.10);
}
html[data-theme="match"] #theme-toggle,
html[data-theme="match"] .nav-theme-toggle {
  background: linear-gradient(135deg, rgba(123,63,242,0.35) 0%, rgba(0,166,251,0.35) 100%);
  border-color: var(--accent); color: #FFFFFF;
}
html[data-theme="match"] #theme-toggle:hover,
html[data-theme="match"] .nav-theme-toggle:hover { filter: brightness(1.15); }

/* =========================================================================
   MATCH THEME — sidebar PALETTE overrides only.
   Layout (fixed left sidebar, accordion, page-wrap margin, <760px top-bar
   fallback) lives in the BASE rules above and applies to both themes; this
   block recolors it to the dark-gradient marketing palette. No position /
   width / display rules here — colors, borders, and effects only.
   ========================================================================= */
html[data-theme="match"] #app-nav {
  background: rgba(20,20,27,0.92);
  border-right-color: var(--border);
  border-bottom-color: var(--border);   /* mobile top-bar fallback border */
  backdrop-filter: blur(8px);
}
html[data-theme="match"] #app-nav .nav-brand { border-bottom-color: var(--border); }
html[data-theme="match"] #app-nav .cust-identity { color: #B8B8C0; }
html[data-theme="match"] #app-nav .nav-group-label { color: #B8B8C0; }
html[data-theme="match"] #app-nav .nav-group-label:hover {
  background: rgba(123,63,242,0.15); color: #FFFFFF;
}
html[data-theme="match"] #app-nav .nav-group.active > .nav-group-label {
  background: rgba(123,63,242,0.18); color: #FFFFFF;
}
html[data-theme="match"] #app-nav .nav-dropdown { border-left-color: var(--border); }
html[data-theme="match"] #app-nav .nav-link { color: #B8B8C0; }
html[data-theme="match"] #app-nav .nav-link:hover { background: rgba(123,63,242,0.15); color: #FFFFFF; }
html[data-theme="match"] #app-nav .nav-link.active { color: var(--accent); }
html[data-theme="match"] #app-nav .nav-direct { color: #cdd8e5; }
html[data-theme="match"] #app-nav .nav-direct:hover { background: rgba(123,63,242,0.15); color: #FFFFFF; }
html[data-theme="match"] #app-nav .nav-direct.active { background: rgba(123,63,242,0.18); color: #FFFFFF; }
html[data-theme="match"] #app-nav .nav-right { border-top-color: var(--border); }
html[data-theme="match"] #app-nav .nav-user { color: #B8B8C0; }

/* top-right user strip — match theme recolors only (layout stays in base). */
html[data-theme="match"] #user-strip {
  background: rgba(20,20,27,0.92);
  border-left-color: var(--border);
  border-bottom-color: var(--border);
  color: var(--text);
  backdrop-filter: blur(8px);
}
html[data-theme="match"] #user-strip .us-email { color: #B8B8C0; }
html[data-theme="match"] #user-strip .us-logout {
  background: transparent; color: #B8B8C0; border-color: var(--border);
}
html[data-theme="match"] #user-strip .us-logout:hover { background: rgba(123,63,242,0.18); color: #FFFFFF; }
