:root {
  --ink: #132238;
  --muted: #667085;
  --line: #d8e3e7;
  --surface: #f8f6f8;
  --panel: rgba(255, 255, 255, .9);
  --brand: #F36066;
  --brand-dark: #d93e49;
  --brand-deep: #992b36;
  --brand-soft: #ffe2e4;
  --brand-glow: rgba(243, 96, 102, .32);
  --rose: #F36066;
  --rose-soft: #fff0f1;
  --gold: #f7bd4b;
  --sky: #277fb8;
  --aqua: #1fb6a6;
  --shadow: 0 18px 50px rgba(19, 34, 56, .10);
  --shadow-soft: 0 8px 24px rgba(19, 34, 56, .08);
}

* { letter-spacing: 0; }

body {
  background:
    linear-gradient(90deg, rgba(243, 96, 102, .055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(243, 96, 102, .055) 1px, transparent 1px),
    radial-gradient(circle at 8% 0%, rgba(243, 96, 102, .20), transparent 30rem),
    radial-gradient(circle at 94% 7%, rgba(31, 182, 166, .12), transparent 28rem),
    linear-gradient(180deg, #fffafa 0%, var(--surface) 48%, #f4f8fb 100%);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
  color: var(--ink);
  min-height: 100vh;
}

a {
  color: var(--brand-deep);
  font-weight: 650;
  text-decoration-color: rgba(243, 96, 102, .28);
  text-underline-offset: .2rem;
}

h1, h2 {
  color: var(--ink);
  font-weight: 800;
}

h2 { font-size: 1.05rem; }

.app-nav {
  backdrop-filter: blur(18px);
  background: linear-gradient(90deg, rgba(255, 255, 255, .96), rgba(255, 240, 241, .94));
  border-bottom: 1px solid rgba(243, 96, 102, .12);
  box-shadow: 0 12px 34px rgba(153, 43, 54, .08);
  min-height: 4.55rem;
  padding: .45rem 0;
}

.navbar-brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 1.08rem;
  font-weight: 900;
  gap: .65rem;
  letter-spacing: 0;
  margin-right: 1.15rem;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(145deg, var(--brand), #ff9aa0);
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(243, 96, 102, .28);
  color: #fff;
  display: inline-grid;
  height: 2.2rem;
  place-items: center;
  width: 2.2rem;
}

.navbar-nav {
  align-items: center;
  gap: .18rem;
}

.nav-link {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #405064;
  display: inline-flex;
  font-size: .98rem;
  font-weight: 850;
  gap: .52rem;
  margin: 0 .12rem;
  min-height: 2.8rem;
  padding: .68rem .92rem;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease, transform .16s ease;
}

.nav-link i {
  color: var(--brand);
  font-size: 1.08rem;
}

.nav-link:hover,
.nav-link:focus,
.nav-link.show {
  background: linear-gradient(135deg, #fff, var(--rose-soft));
  border-color: rgba(243, 96, 102, .22);
  box-shadow: 0 10px 22px rgba(153, 43, 54, .08);
  color: var(--brand-deep);
  transform: translateY(-1px);
}

.nav-link.dropdown-toggle::after {
  border: 0;
  content: "\F282";
  font-family: bootstrap-icons !important;
  font-size: .72rem;
  margin-left: .12rem;
  vertical-align: middle;
}

.dropdown-menu {
  background: rgba(255, 255, 255, .98);
  border: 1px solid rgba(243, 96, 102, .14);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(19, 34, 56, .16);
  margin-top: .58rem;
  min-width: 15.5rem;
  padding: .45rem;
}

.dropdown-item {
  align-items: center;
  border-radius: 8px;
  color: #34465a;
  display: flex;
  font-size: .94rem;
  font-weight: 800;
  gap: .65rem;
  padding: .72rem .8rem;
}

.dropdown-item i {
  align-items: center;
  background: var(--rose-soft);
  border: 1px solid rgba(243, 96, 102, .12);
  border-radius: 8px;
  color: var(--brand);
  display: inline-grid;
  flex: 0 0 2rem;
  height: 2rem;
  place-items: center;
  width: 2rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: linear-gradient(135deg, var(--brand-soft), #fff9ee);
  color: var(--brand-deep);
}

.dropdown-divider {
  border-top-color: rgba(243, 96, 102, .12);
  margin: .45rem .25rem;
}

.role-chip,
.eyebrow {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: .78rem;
  font-weight: 800;
  gap: .35rem;
}

.role-chip {
  background: var(--brand-soft);
  color: var(--brand-deep);
  padding: .45rem .7rem;
}

.top-search {
  align-items: center;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(243, 96, 102, .18);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(153, 43, 54, .06);
  display: flex;
  gap: .45rem;
  margin-right: 1rem;
  min-width: min(330px, 34vw);
  padding: .48rem .85rem;
}

.top-search:focus-within {
  border-color: rgba(243, 96, 102, .46);
  box-shadow: 0 14px 28px rgba(243, 96, 102, .16);
}

.top-search i {
  color: var(--brand);
}

.top-search input {
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
  outline: 0;
  width: 100%;
}

.top-search input::placeholder {
  color: #8b98a8;
}

.eyebrow {
  background: var(--rose-soft);
  color: var(--brand-deep);
  margin-bottom: .4rem;
  padding: .35rem .7rem;
  text-transform: uppercase;
}

.app-main { padding: 1.5rem; }

.toast-stack {
  display: grid;
  gap: .6rem;
  margin: 0 auto 1rem;
  max-width: 1220px;
}

.app-alert {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(243, 96, 102, .16);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: flex;
  gap: .7rem;
  padding: .8rem 1rem;
}

.app-alert i {
  color: var(--brand);
}

.btn {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-weight: 800;
  gap: .4rem;
  justify-content: center;
  min-height: 2.35rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand-dark);
  box-shadow: 0 14px 24px var(--brand-glow);
}

.btn-outline-primary {
  --bs-btn-color: var(--brand-deep);
  --bs-btn-border-color: rgba(243, 96, 102, .4);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
}

.page-head {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto 1.25rem;
  max-width: 1220px;
}

.page-head h1,
.form-shell h1 {
  font-size: clamp(1.55rem, 2vw, 2.25rem);
  margin: 0;
}

.page-head p { margin: .35rem 0 0; }

.metric-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  margin: 0 auto 1.25rem;
  max-width: 1220px;
}

.metric,
.content-band,
.auth-panel,
.form-shell {
  background: var(--panel);
  border: 1px solid rgba(243, 96, 102, .10);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.metric {
  overflow: hidden;
  padding: 1rem;
  position: relative;
}

.metric::after {
  background: linear-gradient(180deg, rgba(243, 96, 102, .24), rgba(31, 182, 166, .14));
  border-radius: 999px;
  content: "";
  height: 5rem;
  position: absolute;
  right: -2.1rem;
  top: -2.1rem;
  width: 5rem;
}

.metric > i {
  background: var(--brand-soft);
  border: 1px solid rgba(243, 96, 102, .16);
  border-radius: 14px;
  color: var(--brand-deep);
  display: inline-grid;
  font-size: 1.1rem;
  height: 2.4rem;
  margin-bottom: .8rem;
  place-items: center;
  width: 2.4rem;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: .86rem;
  font-weight: 750;
}

.metric strong {
  display: block;
  font-size: 2.15rem;
  line-height: 1.05;
}

.content-band {
  margin: 0 auto 1.25rem;
  max-width: 1220px;
  padding: 1rem;
  position: relative;
}

.content-band::before {
  background: linear-gradient(90deg, var(--brand), var(--gold), var(--aqua));
  border-radius: 8px 8px 0 0;
  content: "";
  height: 3px;
  left: -1px;
  position: absolute;
  right: -1px;
  top: -1px;
}

.section-head,
.searchbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.section-head h2 { margin: 0; }

.searchbar {
  background: var(--panel);
  border: 1px solid rgba(243, 96, 102, .10);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  margin: 0 auto 1rem;
  max-width: 1220px;
  padding: .8rem;
}

.form-control,
.form-select {
  border-color: #cbdce1;
  border-radius: 8px;
  min-height: 2.55rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .22rem rgba(243, 96, 102, .15);
}

.table { margin: 0; }

.table thead th {
  background: #fff6f6;
  border-bottom: 1px solid var(--line);
  color: #496174;
  font-size: .78rem;
  text-transform: uppercase;
}

.table tbody tr { transition: background .16s ease; }
.table tbody tr:hover { background: #fffafa; }

.tab-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin: 0 auto 1rem;
  max-width: 1220px;
}

.action-row.compact { margin: 0; }

.tab-row span {
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #496174;
  font-weight: 800;
  padding: .5rem .85rem;
}

.two-col {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.record-list {
  display: grid;
  gap: .45rem 1rem;
  grid-template-columns: 140px 1fr;
}

.grid-list { grid-template-columns: repeat(2, 140px 1fr); }

.record-list dt {
  color: var(--muted);
  font-weight: 750;
}

.record-link {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(19, 34, 56, .05);
  display: flex;
  flex-direction: column;
  padding: .85rem;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.record-link:hover {
  border-color: rgba(243, 96, 102, .38);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.record-link span {
  color: var(--muted);
  font-weight: 500;
}

.timeline {
  border-left: 2px solid rgba(243, 96, 102, .25);
  display: grid;
  gap: .75rem;
  padding-left: 1rem;
}

.timeline a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  padding: .7rem .8rem;
  position: relative;
  text-decoration: none;
}

.timeline a::before {
  background: var(--rose);
  border: 3px solid #fff;
  border-radius: 999px;
  content: "";
  height: .85rem;
  left: -1.5rem;
  position: absolute;
  top: .9rem;
  width: .85rem;
}

.timeline span {
  color: var(--muted);
  font-size: .88rem;
  font-weight: 500;
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: .82rem;
  font-weight: 800;
  padding: .28rem .65rem;
}

.status.ok {
  background: #dcfce7;
  color: #166534;
}

.status.muted {
  background: #eef2f6;
  color: var(--muted);
}

.auth-shell {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(83, 18, 29, .56), rgba(243, 96, 102, .22)),
    linear-gradient(135deg, rgba(243, 96, 102, .42) 0%, rgba(255, 145, 148, .24) 48%, rgba(31, 182, 166, .18) 100%),
    url("/static/img/login-cover.png");
  background-position: center;
  background-size: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr) 430px;
  margin: 0 auto;
  max-width: 1180px;
  min-height: calc(100vh - 9rem);
  overflow: hidden;
  padding: clamp(1rem, 4vw, 3rem);
  position: relative;
}

.auth-shell::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0));
  content: "";
  height: 38%;
  left: 0;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
}

.auth-shell::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, .08) 1px, transparent 1px);
  background-size: 38px 38px;
  content: "";
  inset: 0;
  opacity: .32;
  position: absolute;
}

.auth-copy,
.auth-panel {
  position: relative;
  z-index: 1;
}

.auth-copy {
  color: #fff;
  max-width: 620px;
  text-shadow: 0 2px 18px rgba(83, 18, 29, .55);
}

.auth-copy h1 {
  color: #fff;
  font-size: clamp(2.3rem, 5vw, 4.65rem);
  line-height: 1;
  margin: .75rem 0 1rem;
}

.auth-copy p {
  color: rgba(255, 255, 255, .92);
  font-size: 1.08rem;
  max-width: 36rem;
}

.auth-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-top: 1.4rem;
}

.auth-stats span {
  align-items: center;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .36);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  gap: .45rem;
  padding: .55rem .85rem;
}

.auth-stats i {
  color: #ffe7e8;
  font-size: 1rem;
}

.auth-panel,
.form-shell {
  padding: 1.4rem;
  width: 100%;
}

.auth-panel {
  backdrop-filter: blur(18px);
  background: linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(255, 245, 246, .88));
  border-color: rgba(255, 255, 255, .46);
  box-shadow: 0 28px 80px rgba(83, 18, 29, .28);
  max-width: 430px;
}

.login-brand {
  align-items: center;
  display: flex;
  font-size: 1.25rem;
  gap: .7rem;
  margin-bottom: .8rem;
}

.login-care-icons {
  display: flex;
  gap: .55rem;
  margin: .35rem 0 .9rem;
}

.login-care-icons span {
  background: linear-gradient(145deg, var(--brand), #ff9aa0);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(243, 96, 102, .22);
  color: #fff;
  display: grid;
  height: 2.45rem;
  place-items: center;
  width: 2.45rem;
}

.auth-panel .form-label {
  color: #34465a;
  font-size: .84rem;
  font-weight: 800;
}

.auth-panel .form-control {
  background: #fff;
  border: 1px solid rgba(243, 96, 102, .24);
  min-height: 3rem;
}

.auth-panel .btn-primary {
  min-height: 3rem;
}

.forgot-link {
  color: var(--brand-deep);
  display: inline-block;
  font-size: .9rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.form-shell {
  margin: 0 auto;
  max-width: 760px;
}

.form-shell.wide { max-width: 1080px; }

.form-shell h1 {
  border-bottom: 1px solid rgba(243, 96, 102, .12);
  margin-bottom: 1rem;
  padding-bottom: .7rem;
}

.form-intro {
  font-size: .92rem;
  margin: -.35rem 0 1rem;
  max-width: 48rem;
}

.form-helper {
  align-items: flex-start;
  background: linear-gradient(135deg, #fff2f2, #fffaf3);
  border: 1px solid rgba(243, 96, 102, .16);
  border-radius: 8px;
  display: flex;
  gap: .75rem;
  margin: -.35rem 0 1rem;
  padding: .85rem;
}

.form-helper i {
  color: var(--brand);
  font-size: 1.15rem;
}

.form-helper strong,
.form-helper span {
  display: block;
}

.form-helper span {
  color: var(--muted);
  font-size: .86rem;
}

.form-shell section {
  background: rgba(255, 255, 255, .66);
  border: 1px solid rgba(243, 96, 102, .10);
  border-radius: 8px;
  padding: 1rem;
}

.form-shell section h2 {
  align-items: center;
  display: flex;
  gap: .5rem;
  margin-bottom: .85rem;
}

.form-shell section h2::before {
  background: var(--brand);
  border-radius: 999px;
  content: "";
  height: .65rem;
  width: .65rem;
}

.form-grid {
  display: grid;
  gap: .7rem .85rem;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
}

.form-grid > div {
  margin: 0;
}

.form-grid label {
  color: #34465a;
  font-size: .84rem;
  font-weight: 800;
  margin-bottom: .25rem;
}

.form-grid .helptext,
.form-grid .form-text {
  color: #778599;
  display: block;
  font-size: .76rem;
  line-height: 1.25;
  margin-top: .25rem;
}

.form-grid ul.errorlist {
  color: var(--brand-deep);
  font-size: .8rem;
  margin: 0 0 .25rem;
  padding-left: 1rem;
}

.form-grid div:has(textarea),
.form-grid div:has(input[type="file"]) {
  grid-column: 1 / -1;
}

.form-grid textarea {
  min-height: 5.5rem;
}

.form-actions {
  align-self: end;
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.setup-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin: 0 auto 1.25rem;
  max-width: 1220px;
}

.setup-panel.content-band {
  margin-bottom: 0;
}

.lookup-grid,
.location-list,
.permission-grid {
  display: grid;
  gap: .75rem;
}

.lookup-grid,
.permission-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.lookup-card,
.location-item,
.permission-card {
  background: linear-gradient(180deg, #fff, #fff8f8);
  border: 1px solid rgba(243, 96, 102, .13);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(153, 43, 54, .06);
  padding: .9rem;
}

.lookup-card strong,
.location-item summary span,
.permission-card strong {
  color: var(--ink);
  display: flex;
  font-weight: 850;
  gap: .45rem;
}

.permission-card {
  display: grid;
  gap: .45rem;
}

.permission-card > i {
  background: var(--brand-soft);
  border-radius: 8px;
  color: var(--brand);
  display: grid;
  height: 2.25rem;
  place-items: center;
  width: 2.25rem;
}

.lookup-card span,
.location-item small,
.location-children span,
.permission-card span {
  color: var(--muted);
  font-size: .86rem;
}

.location-item summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.location-children {
  border-top: 1px solid rgba(243, 96, 102, .12);
  display: grid;
  gap: .55rem;
  margin-top: .75rem;
  padding-top: .75rem;
}

.location-children div {
  display: grid;
  gap: .1rem;
}

.app-footer {
  color: var(--muted);
  font-size: .85rem;
  padding: 1rem;
  text-align: center;
}

.print-doc {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  margin: 0 auto;
  max-width: 980px;
  padding: 2rem;
}

.print-doc table {
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  width: 100%;
}

.print-doc th,
.print-doc td {
  border: 1px solid #d8e3e7;
  padding: .55rem;
}

.print-doc th {
  background: #fff2f2;
}

.print-actions {
  display: flex;
  justify-content: flex-end;
}

@media print {
  .app-nav,
  .app-footer,
  .print-actions {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app-main {
    padding: 0;
  }

  .print-doc {
    border: 0;
    box-shadow: none;
    max-width: none;
    padding: 0;
  }
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-copy { max-width: none; }
}

@media (max-width: 720px) {
  .app-main { padding: 1rem; }

  .top-search {
    margin: .5rem 0 1rem;
    min-width: 100%;
  }

  .navbar-nav {
    align-items: stretch;
    gap: .25rem;
    padding-top: .65rem;
  }

  .nav-link {
    justify-content: space-between;
    margin: 0;
    width: 100%;
  }

  .dropdown-menu {
    border-color: rgba(243, 96, 102, .12);
    box-shadow: none;
    margin: .25rem 0 .55rem;
  }

  .page-head,
  .section-head,
  .searchbar {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-list,
  .record-list {
    grid-template-columns: 1fr;
  }
}
