/* GME Portal — application styling.

   Two rules worth knowing before editing:

   1. --ink is the colour of ALL secondary text on a light background.
      It is black on purpose: hierarchy here comes from size and weight,
      not from greying text out.
   2. Text on the dark sidebar cannot follow that rule — it is light on
      dark and has its own variables (--on-dark, --on-dark-dim). */

:root {
  --green: #1c7a44;          /* primary — buttons, active nav, links */
  --green-deep: #115c33;     /* buttons and links on a light background */
  --leaf: #3cbf4a;           /* the logo green, for small accents */

  --ink: #000;               /* every piece of body text on light */
  --paper: #f5f4f1;          /* app background */
  --surface: #fff;           /* cards, tables, panels */
  --line: #e2e0d9;           /* hairlines */
  --line-soft: #eeece6;

  --sidebar: #1b201d;
  --sidebar-line: rgba(255, 255, 255, .09);
  --on-dark: rgba(255, 255, 255, .86);
  --on-dark-dim: rgba(255, 255, 255, .5);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

/* The progressive-enhancement scripts hide sections with the `hidden`
   attribute. A class that sets `display` beats the UA stylesheet's
   [hidden] rule, so .form-grid sections stayed visible when hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-deep); }

/* ==================================================================== */
/* Shell                                                                */
/* ==================================================================== */
/* The sidebar colour is on the shell so the left column stays dark all
   the way down a long page, not just for the first screen. */
.shell { display: flex; min-height: 100vh; align-items: stretch;
         background: var(--sidebar); }

.sidebar {
  width: 16rem;
  flex: 0 0 16rem;
  background: var(--sidebar);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 1.5rem 1.4rem 1.35rem;
  border-bottom: 1px solid var(--sidebar-line);
}
.sidebar-brand img { display: block; width: 8.5rem; height: auto; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1.25rem 0; }

.nav-group {
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--on-dark-dim);
  padding: 0 1.4rem;
  margin: 1.4rem 0 .5rem;
}
.nav-group:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .5rem 1.4rem;
  color: var(--on-dark);
  text-decoration: none;
  font-size: .93rem;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item.is-active {
  background: rgba(255, 255, 255, .08);
  border-left-color: var(--leaf);
  color: #fff;
  font-weight: 600;
}

/* --- Profile menu --------------------------------------------------
   Anchored to the foot of the sidebar and opening upward, so it never
   pushes the navigation around or runs off the bottom of the screen. */
.profile {
  border-top: 1px solid var(--sidebar-line);
  position: relative;
}
.profile-trigger {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .85rem 1.4rem;
  cursor: pointer;
  list-style: none;             /* Firefox */
  user-select: none;
}
.profile-trigger::-webkit-details-marker { display: none; }
.profile-trigger:hover { background: rgba(255, 255, 255, .05); }
.profile[open] .profile-trigger { background: rgba(255, 255, 255, .08); }
.profile-trigger:focus-visible { outline: 2px solid var(--leaf); outline-offset: -2px; }

.avatar {
  width: 2rem; height: 2rem; flex: 0 0 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 600; letter-spacing: .02em;
}
.who { min-width: 0; flex: 1; }
.who-name {
  display: block; color: #fff; font-size: .88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.who-role {
  display: block; color: var(--on-dark-dim); font-size: .75rem;
  text-transform: capitalize;
}
.chev {
  width: .75rem; flex: 0 0 .75rem; color: var(--on-dark-dim);
  transform: rotate(180deg);
}
.profile[open] .chev { transform: none; }

.profile-menu {
  position: absolute;
  bottom: calc(100% + .4rem);
  left: .6rem; right: .6rem;
  background: var(--surface);
  /* The menu sits inside the sidebar, which sets a light-on-dark colour.
     Say so explicitly or the text inherits white onto white. */
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
  overflow: hidden;
  z-index: 20;
}
.profile-head {
  padding: .85rem .9rem;
  border-bottom: 1px solid var(--line);
  background: var(--line-soft);
}
.profile-name { font-weight: 600; font-size: .9rem; }
.profile-email { font-size: .76rem; margin: .1rem 0 .45rem; word-break: break-all; }
.profile-item {
  display: block;
  padding: .6rem .9rem;
  font-size: .89rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
}
.profile-item:last-child { border-bottom: none; }
.profile-item:hover { background: var(--line-soft); }
.profile-out { color: #8a2118; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column;
        background: var(--paper); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.15rem 2.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-eyebrow {
  font-size: .68rem; font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink);
}
.topbar-when { font-size: .85rem; text-align: right; }
.topbar-when strong { display: block; font-weight: 600; }

/* Fold-away sidebar. The toggle lives in the topbar and is always
   reachable; collapsing hides the sidebar and the main area reflows to
   full width. State is remembered per browser (see base.html). */
.topbar { justify-content: flex-start; }
.topbar-when { margin-left: auto; }
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.15rem; height: 2.15rem; padding: 0;
  border: 1px solid var(--line); border-radius: .5rem;
  background: var(--surface); color: var(--ink); cursor: pointer;
  flex: none;
}
.nav-toggle:hover { background: var(--paper); }
html.nav-collapsed .sidebar { display: none; }

/* ==================================================================== */
/* Page                                                                 */
/* ==================================================================== */
.page {
  flex: 1;
  width: 100%;
  max-width: 76rem;
  padding: 2.25rem 2.5rem 4rem;
}

h1 {
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.01em;
  margin: 0 0 .4rem;
}
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .3rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .3rem; }

.crumb {
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin: 0 0 .5rem;
}
.crumb a { color: var(--ink); text-decoration: none; }
.crumb a:hover { color: var(--green-deep); }

.lede { font-size: 1rem; margin: 0 0 1.9rem; max-width: 52rem; }
.muted { font-size: .9rem; }
p { margin: 0 0 1rem; }

.section-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: .4rem;
  margin: 2.2rem 0 1rem;
  display: flex; align-items: center; gap: .5rem;
}

/* ==================================================================== */
/* Cards                                                                */
/* ==================================================================== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.3rem 1.4rem;
}
.card p { font-size: .9rem; margin: 0 0 1rem; }
.card h3 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .35rem; }
.card-pending { background: var(--line-soft); }
.card-link { color: var(--green-deep); font-weight: 600; text-decoration: none; font-size: .9rem; }
.card-link:hover { text-decoration: underline; }

.badge, .you-tag, .scope-tag {
  display: inline-block;
  font-size: .7rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .1rem .55rem;
  text-transform: none; letter-spacing: 0;
}

/* ==================================================================== */
/* Dashboard                                                            */
/* ==================================================================== */
.dash-head h1 { margin-bottom: .1rem; }
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2.5rem;
  margin-top: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.feed { list-style: none; margin: 0; padding: 0; }
.feed-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: .6rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.feed-item:last-child { border-bottom: none; }
.feed-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink); transform: translateY(-1px);
}
.feed-dot-auth      { background: #2f6fb0; }
.feed-dot-admin     { background: #8e44ad; }
.feed-dot-hub       { background: var(--green); }
.feed-dot-proposals { background: #b8801a; }
.feed-text { color: var(--ink); }
.feed-when { font-size: .78rem; white-space: nowrap; }
.feed-fail .feed-text { color: #a4291b; }
.feed-fail em { font-style: normal; font-size: .78rem; }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.25rem 0 1.75rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 1rem 1.4rem; min-width: 7rem;
}
.stat-n { display: block; font-family: var(--serif); font-size: 1.9rem; font-weight: 500; }
.stat-l { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; }

/* ==================================================================== */
/* Tables                                                               */
/* ==================================================================== */
.table {
  width: 100%; border-collapse: collapse; font-size: .89rem;
  background: var(--surface); border: 1px solid var(--line);
  margin-top: .5rem;
}
.table th {
  text-align: left; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .1em; font-weight: 500; color: var(--ink);
  border-bottom: 1px solid var(--line); padding: .7rem .85rem;
  background: var(--line-soft);
}
.table td { padding: .65rem .85rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fbfbf9; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .82rem; }
.detail-cell { max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-inactive td { background: var(--line-soft); }
.row-fail td { background: #fdf3f2; }

.pill {
  display: inline-block;
  font-size: .7rem; padding: .12rem .55rem; border-radius: 999px; font-weight: 500;
  letter-spacing: .02em; white-space: nowrap;
}
.pill-ok   { background: #e4f1e6; color: #10502a; }
.pill-fail { background: #fbe4e1; color: #8a2118; }
.pill-off  { background: #ebe9e3; color: #000; }

/* ==================================================================== */
/* Buttons, forms                                                       */
/* ==================================================================== */
.btn {
  display: inline-block;
  padding: .6rem 1.15rem;
  border-radius: 3px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: .92rem;
  font-family: inherit;
}
.btn:hover { border-color: #cfccc2; }
.btn-primary { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
.btn-primary:hover { background: #0d4a29; border-color: #0d4a29; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-small { padding: .32rem .65rem; font-size: .8rem; font-weight: 500; }
.btn-danger { color: #9a1c1c; border-color: #e3b7b7; background: var(--surface); }
.btn-danger:hover { background: #fbeaea; border-color: #d69595; }
.table-wrap { overflow-x: auto; }
.inline-form { display: inline; margin: 0; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }

.link-btn {
  background: none; border: none; color: var(--green-deep); cursor: pointer;
  font-size: .85rem; font-family: inherit; padding: 0; text-decoration: underline;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .9rem 1.4rem;
  margin-bottom: 1.5rem;
}
.field { display: flex; flex-direction: column; gap: .3rem; }
.field-l { font-size: .82rem; font-weight: 500; color: var(--ink); }
.field-l em { font-weight: 400; font-style: normal; }
.field input, .field select {
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  font: inherit;
  color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
  border-color: var(--green);
}
.field .muted { font-size: .78rem; }

.inv-row { margin-bottom: .5rem; }
.yield-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: .6rem .9rem;
  margin-bottom: 1.5rem;
}
.form-actions {
  display: flex; align-items: center; gap: 1.25rem;
  padding-top: 1rem; margin-top: .5rem;
  border-top: 1px solid var(--line);
}

.add-user { margin-top: 2.5rem; max-width: 48rem; }
.add-grid { display: grid; grid-template-columns: 1.4fr 1.2fr .8fr; gap: .9rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .add-grid { grid-template-columns: 1fr; } }
.add-grid label { display: block; font-size: .82rem; font-weight: 500; }
.add-grid input, .add-grid select {
  width: 100%; margin-top: .25rem; padding: .55rem; border: 1px solid var(--line);
  border-radius: 3px; font-size: .9rem; font-family: inherit; background: var(--surface);
}

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: 1.25rem 0; }
.filters select, .filters input {
  padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 3px;
  font-size: .85rem; font-family: inherit; background: var(--surface);
}
.inline-form { display: inline; margin: 0; }
.inline-form select {
  font-size: .82rem; padding: .25rem .4rem; border: 1px solid var(--line);
  border-radius: 3px; font-family: inherit; background: var(--surface);
}
.role-static { font-size: .85rem; }
.admin-links { display: flex; gap: .7rem; margin: 1rem 0; }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1.5rem 0; font-size: .88rem; }
.pager a { color: var(--green-deep); text-decoration: none; }

/* ==================================================================== */
/* Sign-in                                                              */
/* ==================================================================== */
.signin { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 2rem 1.5rem; }
.signin-card {
  width: 100%; max-width: 24rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2.25rem 2rem 1.9rem;
}
.signin-head { text-align: center; margin-bottom: 1.75rem; }
.signin-head img { width: 11rem; height: auto; margin: 0 auto .9rem; display: block; }
.signin-head h1 { font-size: 1.5rem; margin: 0 0 .15rem; }
.signin-sub { font-size: .88rem; margin: 0; }
.btn-microsoft {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; background: #2f2f2f; border-color: #2f2f2f; color: #fff;
}
.btn-microsoft:hover { background: #1f1f1f; border-color: #1f1f1f; }
.ms-logo { display: inline-grid; grid-template-columns: 9px 9px; gap: 2px; }
.ms-logo span { width: 9px; height: 9px; }
.ms-logo span:nth-child(1) { background: #f25022; }
.ms-logo span:nth-child(2) { background: #7fba00; }
.ms-logo span:nth-child(3) { background: #00a4ef; }
.ms-logo span:nth-child(4) { background: #ffb900; }
.signin-divider {
  display: flex; align-items: center; text-align: center;
  font-size: .78rem; margin: 1.4rem 0;
}
.signin-divider::before, .signin-divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--line); }
.signin-divider span { padding: 0 .7rem; }
.fallback-form label { display: block; font-size: .82rem; margin: .7rem 0 .25rem; font-weight: 500; }
.fallback-form input {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 3px; font-size: .95rem; font-family: inherit;
}
.fallback-form input:focus { outline: 2px solid var(--green); outline-offset: 0; }
.fallback-form .btn { margin-top: 1rem; }
.fallback-note { margin-top: 1rem; }

/* ==================================================================== */
/* Notices                                                              */
/* ==================================================================== */
.warn {
  background: #fdf6e3;
  border-left: 3px solid #b8801a;
  padding: .8rem 1rem;
  font-size: .88rem;
  margin: 1rem 0;
  color: var(--ink);
}
.flashes { margin-bottom: 1.5rem; }
.flash {
  padding: .75rem 1rem; border-radius: 3px;
  font-size: .9rem; margin-bottom: .5rem; border-left: 3px solid;
  color: var(--ink);
}
.flash p { margin: .4rem 0 0; }
.flash ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.flash-error   { background: #fbe4e1; border-color: #8a2118; }
.flash-info    { background: #e9eff7; border-color: #2f6fb0; }
.flash-success { background: #e4f1e6; border-color: var(--green); }

/* Marks any portal that is not the live one. Amber, not red: this is a
   statement of where you are, and an error colour on every page trains
   people to ignore it. */
.envbar {
  background: #fbecc0;
  border-bottom: 1px solid #e3cd8a;
  color: var(--ink);
  font-size: .86rem;
  padding: .55rem 2.5rem;
}

.foot {
  border-top: 1px solid var(--line);
  padding: 1.25rem 2.5rem;
  font-size: .8rem;
  display: flex; gap: 1rem; justify-content: space-between;
}

/* ==================================================================== */
/* Narrow screens — engineers open the Hub on site                      */
/* ==================================================================== */
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar-nav { display: flex; flex-wrap: wrap; padding: .5rem; gap: .15rem; }
  .nav-group { display: none; }
  .nav-item { border-left: 0; border-bottom: 3px solid transparent; padding: .45rem .8rem; }
  .nav-item.is-active { border-left: 0; border-bottom-color: var(--leaf); }
  .page { padding: 1.5rem 1.1rem 3rem; }
  .topbar, .envbar, .foot { padding-left: 1.1rem; padding-right: 1.1rem; }
}

/* ==================================================================== */
/* Page head, KPI tiles, panels                                         */
/* ==================================================================== */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.9rem;
}
.page-head .lede { margin: 0; }
.page-head-actions { flex: 0 0 auto; padding-top: .35rem; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin: 0 0 1.5rem;
}
.kpi { padding: 1.1rem 1.3rem; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi-l {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: .35rem;
}
.kpi-n { font-family: var(--serif); font-size: 1.85rem; line-height: 1.1; }
.kpi-sub { font-size: .78rem; margin-top: .35rem; }

/* A titled box around a table: the table alone gives no room for the
   name of the thing or the note that belongs with it. */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin: 1.25rem 0 1.75rem;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem;
  padding: .95rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.panel-title { font-size: .95rem; font-weight: 600; }
.panel-meta { font-size: .8rem; }
.panel .table { border: 0; margin: 0; }
.panel .table th { background: var(--line-soft); }
.panel > p, .panel > .muted { padding: .95rem 1.1rem; margin: 0; }

@media (max-width: 700px) {
  .page-head { flex-direction: column; gap: 1rem; }
  .kpi { border-left: 0; border-top: 1px solid var(--line); }
  .kpi:first-child { border-top: 0; }
}
