:root {
  --bs-primary: #2d7ff9;
  --bs-primary-rgb: 45, 127, 249;
  --bs-link-color: #2d7ff9;
  --bs-link-hover-color: #1d67d3;
  --ink: #18212f;
  --muted: #66758a;
  --line: rgba(24, 33, 47, 0.08);
  --surface: #ffffff;
  --canvas: #eef3ff;
  --navy: #1f2937;
  --blue-soft: #eaf3ff;
  --green-soft: #ebf9ef;
  --amber-soft: #fff6e7;
  --red-soft: #fff0ee;
  --slate-soft: #eef1f5;
  --shadow: 0 16px 40px rgba(31, 41, 55, 0.08);
}

body {
  color: var(--ink);
  min-height: 100vh;
  font-family: "Manrope", system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(45,127,249,0.12), transparent 24%),
    linear-gradient(180deg, #e9eefb 0%, #f4f7fc 34%, #eff4fb 100%);
}

.app-frame {
  min-height: 100vh;
}

.app-navbar {
  padding: 0.85rem 0;
  background: rgba(31, 41, 55, 0.94) !important;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
}

.app-navbar-shell {
  max-width: 1600px;
  align-items: center;
}

.navbar-toggler {
  border-color: rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(120,174,252,0.18);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.92%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: #fff;
  text-decoration: none;
}

.app-brand:hover {
  color: #fff;
}

.app-brand-mark {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #2d7ff9, #78aefc);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.24);
}

.app-brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.app-brand-copy strong {
  font-size: 1rem;
  font-weight: 800;
}

.app-brand-copy small {
  color: rgba(255,255,255,0.66);
  font-size: 0.77rem;
}

.app-nav-links {
  margin-left: 2rem;
  gap: 0.35rem;
}

.app-nav-links .nav-link {
  color: rgba(255,255,255,0.72);
  border-radius: 999px;
  padding: 0.7rem 1rem !important;
  font-weight: 600;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.app-nav-links .nav-link:hover,
.app-nav-links .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.app-account {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.45rem 0.45rem 0.45rem 1rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}

.app-account-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.app-account-copy strong {
  color: #fff;
  font-size: 0.94rem;
}

.app-account-copy span {
  color: rgba(255,255,255,0.64);
  font-size: 0.76rem;
}

.app-logout.btn {
  min-height: 40px;
  border: 0;
  color: var(--navy);
}

.app-shell {
  max-width: 1600px;
  padding: 2rem 1.25rem 2.5rem;
}

.app-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-shell {
  min-height: calc(100vh - 180px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 480px);
  gap: 1.5rem;
  align-items: center;
}

.auth-copy {
  padding: 2rem 1rem 2rem 0;
}

.auth-title {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
  font-weight: 800;
  max-width: 9.5ch;
}

.auth-subtitle {
  max-width: 620px;
  margin: 1rem 0 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.auth-points {
  display: grid;
  gap: 0.95rem;
  margin-top: 1.8rem;
  max-width: 620px;
}

.auth-point {
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.68);
  border: 1px solid rgba(24,33,47,0.08);
  box-shadow: var(--shadow);
}

.auth-point strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.98rem;
}

.auth-point span {
  color: var(--muted);
  line-height: 1.5;
}

.auth-card {
  max-width: 480px;
  justify-self: end;
}

.card,
.panel-card,
form.card {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel-card {
  overflow: hidden;
}

.panel-header,
.panel-footer {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.panel-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.panel-body {
  padding: 1.35rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.page-header-stack {
  align-items: start;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: #7a889c;
  font-weight: 700;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  gap: 1.25rem;
  align-items: stretch;
}

.dashboard-hero-copy,
.dashboard-highlight {
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.dashboard-hero-copy {
  padding: 2rem 2rem 1.85rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(245,249,255,0.96));
  border: 1px solid rgba(45,127,249,0.08);
}

.dashboard-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.dashboard-subtitle {
  max-width: 760px;
  margin: 0.85rem 0 0;
  font-size: 1.04rem;
  color: var(--muted);
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.quick-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.quick-stat {
  min-width: 170px;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(24,33,47,0.08);
  box-shadow: var(--shadow);
}

.quick-stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.quick-stat strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.1;
}

.dashboard-highlight {
  padding: 1.6rem;
  background: linear-gradient(145deg, #1f2937, #314054);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.dashboard-highlight::after {
  content: "";
  position: absolute;
  inset: auto -46px -46px auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(120,174,252,0.12);
}

.dashboard-highlight-label {
  display: inline-block;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.68);
  margin-bottom: 1.3rem;
  position: relative;
  z-index: 1;
}

.dashboard-highlight-grid {
  display: grid;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.dashboard-highlight-grid strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
  font-weight: 800;
}

.dashboard-highlight-grid span {
  display: block;
  margin-top: 0.35rem;
  color: rgba(255,255,255,0.68);
}

.dashboard-metrics {
  margin-top: 0;
}

.dashboard-metrics > [class*="col-"] {
  display: flex;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  justify-content: space-between;
  width: 100%;
  min-height: 176px;
  padding: 1.35rem 1.4rem;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 44px rgba(31, 41, 55, 0.12);
}

.metric-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.metric-icon {
  width: 62px;
  height: 62px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  background: rgba(255,255,255,0.78);
}

.metric-icon svg {
  width: 28px;
  height: 28px;
}

.metric-trend {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: inherit;
  opacity: 0.82;
}

.metric-label {
  display: block;
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 0.5rem;
}

.metric-value {
  display: block;
  font-size: clamp(2.05rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.metric-total {
  color: #ffffff;
  border-color: rgba(45,127,249,0.22);
  background: linear-gradient(135deg, #2d7ff9 0%, #67a3ff 100%);
  box-shadow: 0 18px 40px rgba(45,127,249,0.22);
}

.metric-total .metric-icon {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.34);
}

.metric-warn {
  color: #5a3700;
  border-color: rgba(218,138,0,0.2);
  background: linear-gradient(135deg, #ffcf53 0%, #ffe6a0 100%);
  box-shadow: 0 18px 40px rgba(239,171,22,0.18);
}

.metric-warn .metric-icon {
  background: rgba(255,255,255,0.4);
  border-color: rgba(181,109,0,0.2);
}

.metric-danger {
  color: #ffffff;
  border-color: rgba(208,79,69,0.22);
  background: linear-gradient(135deg, #d84d45 0%, #f1867d 100%);
  box-shadow: 0 18px 40px rgba(216,77,69,0.2);
}

.metric-danger .metric-icon {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.32);
}

.metric-info {
  color: #ffffff;
  border-color: rgba(40,161,103,0.22);
  background: linear-gradient(135deg, #23a26f 0%, #5cc792 100%);
  box-shadow: 0 18px 40px rgba(35,162,111,0.2);
}

.metric-info .metric-icon {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.32);
}

.metric-dark {
  color: #ffffff;
  border-color: rgba(102,117,138,0.22);
  background: linear-gradient(135deg, #3b495d 0%, #65758c 100%);
  box-shadow: 0 18px 40px rgba(59,73,93,0.2);
}

.metric-dark .metric-icon {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.32);
}

.metric-total .metric-label,
.metric-total .metric-value,
.metric-total .metric-trend,
.metric-danger .metric-label,
.metric-danger .metric-value,
.metric-danger .metric-trend,
.metric-info .metric-label,
.metric-info .metric-value,
.metric-info .metric-trend,
.metric-dark .metric-label,
.metric-dark .metric-value,
.metric-dark .metric-trend {
  color: #ffffff;
}

.metric-warn .metric-label,
.metric-warn .metric-value,
.metric-warn .metric-trend {
  color: #5a3700;
}

.table-card .panel-header {
  border-bottom: 0;
}

.filter-shell .panel-body {
  padding: 1rem 1.1rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(180px, 0.7fr) auto;
  gap: 1rem;
  align-items: end;
}

.filter-field {
  min-width: 0;
}

.filter-field-wide {
  min-width: 0;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.embedded-form {
  padding: 1rem 0.35rem 0.2rem;
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
}

.table thead th {
  color: #fff;
  font-weight: 700;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #3d9df2, #4aa6ef);
  border-bottom: 0;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.table thead th:first-child {
  border-top-left-radius: 16px;
}

.table thead th:last-child {
  border-top-right-radius: 16px;
}

.table tbody td {
  padding-top: 1rem;
  padding-bottom: 1rem;
  border-color: rgba(24, 33, 47, 0.08);
}

.table-hover > tbody > tr:hover > * {
  --bs-table-accent-bg: rgba(45,127,249,0.04);
}

.badge-expired { background:#a83d2b;color:#fff; }
.badge-soon    { background:#f3b73f;color:#342100; }
.badge-ok      { background:#daf3ec;color:#0f6c5c; }

.form-control,
.form-select {
  min-height: 48px;
  border-radius: 16px;
  border-color: rgba(24,33,47,0.12);
  box-shadow: none;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(45,127,249,0.45);
  box-shadow: 0 0 0 0.2rem rgba(45,127,249,0.12);
}

textarea.form-control {
  min-height: auto;
}

.btn {
  border-radius: 999px;
  min-height: 46px;
  padding-inline: 1.1rem;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(135deg, #2d7ff9, #4c98ff);
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(45,127,249,0.22);
}

.btn-outline-secondary {
  color: var(--ink);
  border-color: rgba(24,33,47,0.14);
  background: rgba(255,255,255,0.64);
}

.btn-sm {
  min-height: 34px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.stat-line:last-child {
  border-bottom: 0;
}

.stat-line strong {
  width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #2d7ff9;
}

.info-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.info-note {
  padding: 1rem 1.05rem;
  border-radius: 18px;
  background: rgba(45,127,249,0.05);
  border: 1px solid rgba(45,127,249,0.08);
}

.info-note strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.info-note span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

.record-item {
  padding: 1rem 1.05rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(45,127,249,0.1);
  box-shadow: 0 10px 24px rgba(31, 41, 55, 0.05);
}

.record-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.45rem;
  font-weight: 700;
}

.record-item strong {
  display: block;
  font-size: 0.98rem;
}

.record-item-wide {
  grid-column: 1 / -1;
}

.doc-list {
  display: flex;
  flex-direction: column;
}

.doc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
}

.doc-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.doc-row:first-child {
  padding-top: 0;
}

.form-section + .form-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.form-section-heading {
  margin-bottom: 1rem;
}

.table-nav {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.table-nav-link {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(45,127,249,0.05);
}

.table-nav-link.active {
  background: linear-gradient(135deg, #2d7ff9, #4c98ff);
  color: #fff;
}

.text-muted {
  color: var(--muted) !important;
}

@media (max-width: 1199.98px) {
  .app-nav-links {
    margin-left: 0;
    margin-top: 1rem;
  }

  .app-account {
    margin-top: 1rem;
    justify-content: space-between;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .auth-copy {
    padding-right: 0;
  }

  .auth-card {
    justify-self: stretch;
    max-width: none;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 767.98px) {
  .app-shell {
    padding-inline: 0.9rem;
  }

  .dashboard-hero-copy,
  .dashboard-highlight,
  .metric-card,
  .panel-card,
  form.card {
    border-radius: 22px;
  }

  .dashboard-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-stats {
    width: 100%;
  }

  .quick-stat {
    flex: 1 1 100%;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

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

  .panel-header,
  .panel-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .table thead th {
    font-size: 0.78rem;
  }
}

@media print {
  .app-navbar, .btn { display: none !important; }
  body { background: #fff; }
  .card, .panel-card { box-shadow: none; border-color: #ddd; }
}
