:root {
  --primary_bg: #FDFAFB;
  --primary: #322A33;
  --primary_light: #A6484E;
  --forest: #322A33;
  --text: #322A33;
  --text-muted: #6B6468;
  --gold: #B98A4A;
  --card: #ffffff;
  --border: rgba(50, 42, 51, 0.14);
  --aside-width: 260px;
  --aside-min: 80px;
  --sidebar-bg: #FFFEFB;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, sans-serif;
  background: var(--primary_bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary_light); }

.aside {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--aside-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(50, 42, 51, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 110;
}

.aside-logo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.1rem 0.85rem 1.1rem 1.1rem;
  background: linear-gradient(160deg, #322A33 0%, #241E25 100%);
  isolation: isolate;
}

.aside-logo + .aside-sep {
  display: none;
}

.aside-logo a {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.brand-logo {
  display: block;
  height: 34px;
  width: auto;
  max-width: 168px;
  object-fit: contain;
  mix-blend-mode: normal;
  filter: brightness(0) invert(1);
}

.aside-toggle {
  position: static;
  transform: none;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: rgba(246, 243, 234, 0.8);
  cursor: pointer;
}

.aside-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #F6F3EA;
}

.aside-sep {
  height: 1px;
  background: var(--border);
  margin: 0 1.25rem;
}

.aside-menu, .aside-footer {
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.aside-menu { flex: 1; overflow: auto; }

.menu-link, .menu-link-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}

.menu-link:hover, .menu-link-btn:hover {
  background: rgba(49, 80, 29, 0.06);
  color: var(--text);
}

.menu-link.active {
  background: rgba(49, 80, 29, 0.12);
  color: var(--text);
  position: relative;
}

.menu-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
  border-radius: 4px;
}

.menu-icon {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.wrapper {
  margin-left: var(--aside-width);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 2rem 0.5rem;
}

.topbar .btn-icon {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  color: var(--text);
}

.header-mobile-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #322A33 0%, #241E25 100%);
  border-radius: 0.65rem;
  padding: 0.35rem 0.7rem;
  isolation: isolate;
}

.header-mobile-logo img {
  height: 28px;
  width: auto;
  object-fit: contain;
  mix-blend-mode: normal;
  filter: brightness(0) invert(1);
  background: none;
  padding: 0;
  border-radius: 0;
}

.page-title h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
}

.page-title p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.content {
  padding: 1rem 2rem 3rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 4px 24px rgba(50, 42, 51, 0.08);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-card .value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  word-break: break-all;
}

.table {
  color: var(--text);
}

.table thead th {
  background: rgba(49, 80, 29, 0.12);
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom-color: var(--border);
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.badge-accrued, .badge-active { background: #dcfce7; color: #15803d; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-voided, .badge-inactive { background: #ffe4e6; color: #dc2626; }
.badge-neutral { background: #e2e8f0; color: #475569; }

.btn-dark, .btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #F6F3EA !important;
  font-weight: 700;
}

.btn-dark:hover, .btn-primary:hover {
  background: var(--primary_light) !important;
  border-color: var(--primary_light) !important;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(49, 80, 29, 0.18);
}

.copy-row {
  display: flex;
  gap: 0.5rem;
}

.copy-row input { flex: 1; }

.aside-scrim {
  display: none;
}

body.aside-minimized .aside { width: var(--aside-min); }
body.aside-minimized .wrapper { margin-left: var(--aside-min); }
body.aside-minimized .menu-title,
body.aside-minimized .aside-toggle { display: none; }
body.aside-minimized .menu-link { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
body.aside-minimized .aside-logo { justify-content: center; padding: 1rem 0.5rem; }
body.aside-minimized .aside-logo a { padding: 0; justify-content: center; }
body.aside-minimized .brand-logo { height: 28px; max-width: 44px; }

@media (max-width: 991.98px) {
  .aside {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: min(260px, 86vw);
    pointer-events: none;
  }
  body.drawer-on .aside {
    transform: none;
    pointer-events: auto;
  }
  body.drawer-on { overflow: hidden; }
  .aside-scrim.is-open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(14, 17, 15, 0.45);
    z-index: 105;
  }
  .wrapper { margin-left: 0; }
  .topbar { min-height: 64px; padding: 0.75rem 1rem; position: relative; }
  .page-title { display: none; }
  .header-mobile-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  .content { padding: 1rem 1rem 2.5rem; }
  body.aside-minimized .aside { width: min(260px, 86vw); }
  body.aside-minimized .wrapper { margin-left: 0; }
  body.aside-minimized .menu-title { display: inline; }
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.auth-page::before, .auth-page::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth-page::before {
  width: 420px; height: 420px; top: -120px; right: -80px;
  background: rgba(185, 138, 74, 0.22);
}
.auth-page::after {
  width: 320px; height: 320px; bottom: -100px; left: -60px;
  background: rgba(50, 42, 51, 0.12);
}
.auth-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 920px;
  min-height: 560px;
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 24px 64px rgba(50, 42, 51, 0.14);
  overflow: hidden;
  border: 1px solid rgba(50, 42, 51, 0.12);
}
.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  background: linear-gradient(160deg, #322A33 0%, #241E25 100%);
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}
.auth-brand::before,
.auth-brand::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth-brand::before {
  width: 220px;
  height: 220px;
  top: -60px;
  left: -60px;
  background: rgba(255, 255, 255, 0.08);
}
.auth-brand::after {
  width: 160px;
  height: 160px;
  bottom: -40px;
  right: -30px;
  background: rgba(255, 255, 255, 0.06);
}
.auth-brand-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.auth-brand img {
  width: min(170px, 55vw);
  height: auto;
  mix-blend-mode: normal;
  filter: brightness(0) invert(1);
}
.auth-tagline {
  margin: 1.25rem 0 0;
  color: rgba(255,255,255,0.92);
  max-width: 240px;
  line-height: 1.5;
}
.auth-brand-inner .auth-tagline {
  margin: 0;
}
.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.75rem;
}
.auth-form-inner { width: 100%; max-width: 360px; position: relative; }
.auth-form-content {
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.auth-form-content.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  position: absolute;
  width: 100%;
  visibility: hidden;
}
.auth-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  animation: authSuccessIn 0.45s ease forwards;
}
.auth-success.is-visible { display: flex; }
@keyframes authSuccessIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary_light) 100%);
  color: #F6F3EA;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: 0 14px 32px rgba(49, 80, 29, 0.35);
  animation: authSuccessPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}
@keyframes authSuccessPop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.auth-success-icon svg {
  width: 34px;
  height: 34px;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: authCheckDraw 0.45s ease 0.35s forwards;
}
@keyframes authCheckDraw {
  to { stroke-dashoffset: 0; }
}
.auth-success-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 800;
}
.auth-success-text {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  max-width: 280px;
}
.auth-success-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(49, 80, 29, 0.1);
  color: var(--primary_light);
  font-size: 0.8rem;
  font-weight: 600;
}
.auth-success-loader .spinner-border {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
}
.auth-eyebrow {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(49, 80, 29, 0.12);
  color: var(--primary_light);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.auth-title { margin: 0 0 0.5rem; font-size: 1.85rem; font-weight: 800; }
.auth-subtitle { margin: 0 0 2rem; color: var(--text-muted); }
.auth-label { display: block; margin-bottom: 0.45rem; font-size: 0.82rem; font-weight: 600; }
.auth-input {
  height: 48px;
  border-radius: 0.75rem;
}
.auth-submit {
  width: 100%;
  height: 48px;
  margin-top: 0.5rem;
  border: 0;
  border-radius: 0.75rem;
  background: var(--primary);
  color: #F6F3EA;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 10px 24px rgba(49, 80, 29, 0.28);
}
.auth-submit:hover:not(:disabled) { background: var(--primary_light); }
.auth-submit:disabled { opacity: 0.75; cursor: not-allowed; }
.swal2-popup.auth-error-popup {
  border-radius: 1rem;
  padding: 1.75rem 1.5rem 1.5rem;
  font-family: Inter, sans-serif;
}
.swal2-popup.auth-error-popup .swal2-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}
.swal2-popup.auth-error-popup .swal2-html-container {
  color: var(--text-muted);
  font-size: 0.92rem;
}
.swal2-popup.auth-error-popup .swal2-confirm {
  border-radius: 0.65rem !important;
  background: var(--primary) !important;
  font-weight: 700;
  padding: 0.6rem 1.25rem;
  box-shadow: none !important;
}
.auth-footer { margin-top: 1.5rem; text-align: center; font-size: 0.8rem; color: rgba(50, 42, 51, 0.8); }
.auth-alt { margin-top: 1rem; text-align: center; font-size: 0.88rem; }

@media (max-width: 768px) {
  .auth-card { grid-template-columns: 1fr; min-height: auto; }
  .auth-brand { padding: 2rem 1.5rem 1.75rem; }
  .auth-form-wrap { padding: 2rem 1.5rem 2.25rem; }
}
