:root {
  --sidebar-width: 196px;
  --sidebar-green: #006b3c;
  --sidebar-green-dark: #00552f;
  font-family: Inter, "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-width: 0; min-height: 100%; }

body {
  padding-left: var(--sidebar-width);
  font-family: inherit;
}

.app-header {
  display: flex !important;
  position: fixed !important;
  inset: 0 auto 0 0 !important;
  z-index: 50;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  box-sizing: border-box;
  overflow-y: auto;
  padding: .9rem .7rem !important;
  flex-direction: column;
  align-items: stretch !important;
  justify-content: flex-start !important;
  background: linear-gradient(180deg, var(--sidebar-green), var(--sidebar-green-dark)) !important;
  box-shadow: 7px 0 24px rgba(0, 65, 36, .16) !important;
  font-family: Inter, "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif !important;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: .58rem;
  padding: .1rem .25rem 1rem;
}
.app-header .brand-mark {
  flex: 0 0 auto;
  width: 2.65rem;
  height: 3.1rem;
  max-width: 2.65rem;
  max-height: 3.1rem;
  object-fit: contain;
}
.app-header .brand h1 { margin: 0; color: #fff; font-family: inherit; font-size: .83rem; font-weight: 760; line-height: 1.18; letter-spacing: -.012em; }
.app-header .brand h1 span { display: block; }
.app-header .brand p { margin: .18rem 0 0; color: rgba(255,255,255,.8); font-family: inherit; font-size: .62rem; font-weight: 560; line-height: 1.25; letter-spacing: .01em; }
.app-header .brand p strong { color: #fff; font-size: .72rem; }

.side-nav {
  display: grid;
  gap: .5rem;
  margin-top: .2rem;
}

.side-nav a {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: .55rem;
  min-height: 3.2rem;
  padding: .68rem .65rem;
  color: rgba(255,255,255,.9);
  border: 1px solid transparent;
  border-radius: .75rem;
  text-decoration: none;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 680;
  line-height: 1.2;
  letter-spacing: .005em;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}

.side-nav a:hover { color: white; background: rgba(255,255,255,.11); transform: translateX(2px); }
.side-nav a.active {
  color: #073b23;
  background: white;
  font-weight: 760;
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}
.side-nav svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 2.15; stroke-linecap: round; stroke-linejoin: round; shape-rendering: geometricPrecision; }
.system-footer { margin: auto .1rem .05rem; padding: .72rem .68rem; border: 1px solid rgba(255,255,255,.72); border-radius: .75rem; background: #fff; color: #365b49; box-shadow: 0 8px 22px rgba(0,0,0,.16); font-size: .61rem; font-weight: 620; line-height: 1.4; overflow-wrap: anywhere; }
.system-footer > div + div { margin-top: .25rem; }
.system-footer .git-state { color: #075b35; }
.system-footer .git-state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #65e29b; vertical-align: 1px; }
.system-footer .git-state.inactive { color: #76570c; }
.system-footer .git-state.inactive::before { background: #e9aa1b; }
.system-footer .current-user { padding-top: .45rem; border-top: 1px solid #dce9e2; color: #083e25; font-weight: 720; }
.footer-button { width: 100%; margin-top: .5rem; padding: .48rem .5rem; border: 0; border-radius: .48rem; background: #067344; color: #fff; font: inherit; font-weight: 720; cursor: pointer; }
.footer-button.secondary { margin-top: .3rem; background: #edf5f1; color: #315b47; }

[hidden] { display: none !important; }
.auth-layer, .modal-backdrop { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 1rem; background: rgba(3, 48, 28, .72); backdrop-filter: blur(5px); }
.auth-card, .users-card { width: min(400px, 100%); max-height: calc(100vh - 2rem); overflow-x: hidden; overflow-y: auto; padding: 1.2rem; border: 1px solid #d3e2db; border-radius: 1rem; background: #fff; color: #10281d; box-shadow: 0 24px 70px rgba(0, 42, 23, .28); }
.auth-card > img { display: block; width: 58px; height: 68px; margin: 0 auto .65rem; object-fit: contain; }
.auth-card h2, .users-card h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.025em; }
.eyebrow { margin: 0 0 .25rem; color: #087245; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.auth-intro, .role-help { margin: .4rem 0 .78rem; color: #52675e; font-size: .78rem; line-height: 1.45; }
.auth-form, .user-form { display: grid; gap: .58rem; }
.auth-form label, .user-form label { display: grid; gap: .32rem; color: #274b3a; font-size: .75rem; font-weight: 720; }
.auth-form input, .user-form input, .user-form select { width: 100%; min-height: 2.25rem; padding: .46rem .58rem; border: 1px solid #b9d0c4; border-radius: .55rem; background: #fbfdfc; color: #10281d; font: inherit; font-size: .82rem; outline: none; }
.auth-form input:focus, .user-form input:focus, .user-form select:focus { border-color: #087245; box-shadow: 0 0 0 3px rgba(8,114,69,.13); }
.auth-form button, .user-form button { min-height: 2.35rem; padding: .52rem .8rem; border: 0; border-radius: .58rem; background: #087245; color: #fff; font: inherit; font-size: .82rem; font-weight: 780; cursor: pointer; }
.terms-box { max-height: 165px; overflow: auto; margin: .65rem 0 .75rem; padding: .7rem .78rem; border: 1px solid #d4e3db; border-radius: .65rem; background: #f5faf7; color: #40574c; font-size: .73rem; line-height: 1.45; }
.terms-box p { margin: 0 0 .7rem; }
.terms-box p:last-child { margin-bottom: 0; }
.auth-form .check-line { display: flex; grid-template-columns: none; align-items: flex-start; gap: .55rem; }
.auth-form .check-line input { flex: 0 0 auto; width: 1rem; min-height: 1rem; margin-top: .12rem; accent-color: #087245; }
.form-error { min-height: 1rem; margin: 0; color: #a52727; font-size: .74rem; font-weight: 650; }
.modal-backdrop { z-index: 180; }
.users-card { width: min(760px, calc(100vw - 2rem)); padding: 1.35rem; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.icon-button { width: 2.3rem; height: 2.3rem; border: 1px solid #c9dbd2; border-radius: .55rem; background: #fff; color: #315b47; font-size: 1.4rem; cursor: pointer; }
.user-form { grid-template-columns: 1.3fr 1fr .8fr 1fr auto; align-items: end; margin: 1rem 0; padding: 1rem; border-radius: .75rem; background: #f3f8f5; }
.user-form .form-error { grid-column: 1 / -1; }
.users-list { display: grid; gap: .5rem; }
.users-list article { display: flex; justify-content: space-between; gap: 1rem; padding: .72rem .8rem; border: 1px solid #d6e4dd; border-radius: .65rem; }
.users-list article > div { display: grid; gap: .18rem; }
.users-list article > div:last-child { text-align: right; }
.users-list strong, .users-list b { color: #133c29; font-size: .8rem; }
.users-list span { color: #60736a; font-size: .7rem; }

.page-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 3rem;
}

html.embedded body { padding-left: 0 !important; }
html.embedded .app-header { display: none !important; }
html.embedded .page-shell,
html.embedded body > main {
  width: 100%;
  max-width: none;
  margin: 0;
}

.module-frame {
  position: fixed;
  inset: 0 0 0 var(--sidebar-width);
  width: calc(100vw - var(--sidebar-width));
  height: 100vh;
  border: 0;
  background: #f4f8f6;
}

body.auth-pending .app-header,
body.auth-pending .module-frame,
body.auth-only .app-header,
body.auth-only .module-frame { visibility: hidden; }
body.auth-pending,
body.auth-only { padding-left: 0; overflow: hidden; background: #eaf3ee; }
body.auth-only .auth-layer {
  background:
    radial-gradient(circle at 20% 18%, rgba(255,255,255,.18), transparent 32%),
    linear-gradient(145deg, #174d39 0%, #39705a 52%, #0b3828 100%);
  backdrop-filter: none;
}
body.auth-only .auth-card { box-shadow: 0 28px 80px rgba(0, 28, 16, .35); }

@media (max-width: 900px) {
  :root { --sidebar-width: 78px; }
  .app-header { padding: .85rem .55rem !important; }
  .app-header .brand { justify-content: center; padding: 0 0 .8rem; }
  .app-header .brand-mark { width: 2.7rem; height: 2.7rem; }
  .app-header .brand div, .system-footer, .side-nav .nav-label { display: none; }
  .side-nav a { grid-template-columns: 1fr; justify-items: center; padding: .72rem .4rem; }
}

@media (max-width: 760px) {
  .user-form { grid-template-columns: 1fr; }
  .user-form .form-error { grid-column: auto; }
}

@media print {
  body { padding-left: 0 !important; }
  .app-header { display: none !important; }
}
