:root {
  --ams-ink: #1c1916;
  --ams-muted: #6b6258;
  --ams-sand: #f4efe6;
  --ams-sand-deep: #e8dfd0;
  --ams-sea: #1f4d4a;
  --ams-sea-soft: #2d6a66;
  --ams-coral: #b85c38;
  --ams-line: #d9d0c2;
  --ams-ok: #2f6f4e;
  --ams-warn: #9a6b1f;
  --ams-danger: #9b2c2c;
}

body.app-body {
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff8ec 0%, transparent 55%),
    linear-gradient(180deg, var(--ams-sand) 0%, #f7f4ee 40%, #f3f1ec 100%);
  color: var(--ams-ink);
  min-height: 100vh;
}

body.auth-body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(28, 25, 22, 0.72), rgba(31, 77, 74, 0.55)),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="160" height="160" viewBox="0 0 160 160"><path fill="%23ffffff10" d="M0 80h160v2H0zM80 0v160h2V0z"/></svg>'),
    linear-gradient(160deg, #1f4d4a, #2a3a2f 55%, #3d2a1f);
}

/* SPA-parity sign-in (light card) */
body.auth-v2-body {
  min-height: 100vh;
  margin: 0;
  background: #f4f6fa;
  color: #172033;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.auth-v2-wrap {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.auth-v2-brand {
  text-align: center;
  margin-bottom: 20px;
}

.auth-v2-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  margin: 0 auto 12px;
  background: linear-gradient(145deg, #2d6a66, #1f4d4a);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.auth-v2-brand h1 {
  font-size: 1.25rem;
  margin: 0 0 4px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.auth-v2-sub {
  margin: 0;
  color: #667085;
  font-size: 13px;
}

.auth-v2-card {
  background: #fff;
  border: 1px solid #e3e8f0;
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.07);
}

.auth-v2-card label,
.auth-v2-card .form-label {
  display: block;
  font-size: 12px;
  color: #667085;
  margin: 0 0 6px;
  font-weight: 600;
}

.auth-v2-card input.form-control,
.auth-v2-card input[type="email"],
.auth-v2-card input[type="password"],
.auth-v2-card input[type="text"],
.auth-v2-card input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e3e8f0;
  border-radius: 8px;
  font: inherit;
  margin-bottom: 14px;
}

.auth-v2-card input:focus {
  outline: none;
  border-color: #8da1eb;
  box-shadow: 0 0 0 3px #eef1ff;
}

.auth-v2-card input.totp-input {
  letter-spacing: 0.2em;
  font-size: 1.25rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth-v2-card .btn-sea,
.auth-v2-card #primaryBtn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  background: #1f4d4a;
  color: #fff;
  font-weight: 650;
  font: inherit;
  cursor: pointer;
}

.auth-v2-card .btn-sea:hover,
.auth-v2-card #primaryBtn:hover {
  filter: brightness(0.95);
}

.auth-v2-card .btn-passkey {
  width: 100%;
  background: #1d1d1f;
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.25;
  box-shadow: none;
}

.auth-v2-card .btn-passkey:hover,
.auth-v2-card .btn-passkey:focus {
  background: #272729;
  color: #fff;
}

.auth-v2-card .btn-passkey:focus {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #0071e3;
}

.btn-passkey-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-passkey-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  display: block;
  object-fit: contain;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
  color: #667085;
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e3e8f0;
}

.auth-v2-hint {
  margin: -6px 0 14px;
  color: #667085;
  font-size: 12px;
  line-height: 1.4;
}

.auth-v2-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
}

.auth-v2-foot a {
  color: #1f4d4a;
  text-decoration: none;
}

.auth-v2-foot.muted {
  color: #667085;
}

.auth-v2-body .auth-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-v2-body .ams-footer {
  border-top-color: #e3e8f0;
  background: #f4f6fa;
}

.auth-v2-body .ams-footer .text-muted {
  color: #667085 !important;
}

.auth-v2-body .alert-danger {
  background: #ffeded;
  color: #bd3030;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
}

.ams-nav {
  background: rgba(255, 252, 246, 0.92);
  border-bottom: 1px solid var(--ams-line);
  backdrop-filter: blur(8px);
}

.navbar-brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

.brand-mark {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ams-sea);
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--ams-muted);
  font-weight: 400;
}

.ams-footer {
  border-top: 1px solid var(--ams-line);
  margin-top: 2rem;
}

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

/* Login / 2FA: dark canvas — Bootstrap text-muted is too dark to read */
.auth-body .ams-footer {
  border-top-color: rgba(255, 255, 255, 0.18);
}

.auth-body .ams-footer .text-muted {
  color: rgba(255, 252, 246, 0.72) !important;
}

.auth-main {
  min-height: calc(100vh - 60px);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255, 252, 246, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0;
  padding: 2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.auth-card h1 {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.75rem;
  margin-bottom: 0.35rem;
}

.panel {
  background: #fffdf8;
  border: 1px solid var(--ams-line);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}

.panel h2, .page-title {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.55rem;
  margin: 0 0 0.35rem;
}

.muted { color: var(--ams-muted); }

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

.stat {
  background: #fffdf8;
  border: 1px solid var(--ams-line);
  padding: 1rem 1.1rem;
}

.stat .label,
.panel .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ams-muted); }
.stat .value { font-size: 1.35rem; font-weight: 600; margin-top: 0.25rem; }

.timeline {
  position: relative;
  padding-left: 1.25rem;
  margin: 1rem 0 0;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 0.2rem;
  bottom: 0.2rem;
  width: 2px;
  background: linear-gradient(180deg, var(--ams-sea), var(--ams-sand-deep));
}

.timeline-item {
  position: relative;
  padding: 0.55rem 0 0.55rem 0.85rem;
  border-bottom: 1px dashed var(--ams-line);
}

.timeline-item:last-child { border-bottom: 0; }

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.05rem;
  top: 0.9rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--ams-sea);
  box-shadow: 0 0 0 3px #fffdf8;
}

.timeline-item.state-overdue::before,
.timeline-item.kind-deadline.state-overdue::before { background: var(--ams-danger); }
.timeline-item.state-done::before,
.timeline-item.kind-payment_done::before { background: var(--ams-ok); }
.timeline-item.state-today::before { background: var(--ams-coral); }

.badge-soft {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--ams-line);
  font-size: 0.75rem;
  color: var(--ams-muted);
  background: var(--ams-sand);
}

.badge-soft.overdue { color: var(--ams-danger); border-color: #e2b4b4; background: #fff5f5; }
.badge-soft.due { color: var(--ams-warn); border-color: #e5d2a8; background: #fff9ec; }
.badge-soft.paid { color: var(--ams-ok); border-color: #b9d7c4; background: #f1faf4; }

.stage-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 1rem 0 1.25rem;
}

.stage-chip {
  border: 1px solid var(--ams-line);
  background: #fff;
  padding: 0.65rem 0.5rem;
  text-align: center;
  font-size: 0.78rem;
}

.stage-chip.active {
  border-color: var(--ams-sea);
  background: rgba(31, 77, 74, 0.08);
  color: var(--ams-sea);
  font-weight: 600;
}

.stage-chip.done {
  background: rgba(47, 111, 78, 0.1);
  border-color: #b9d7c4;
}

.table-ams {
  background: #fffdf8;
  border: 1px solid var(--ams-line);
}

.table-ams th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ams-muted);
  font-weight: 600;
}

.btn-sea {
  --bs-btn-bg: var(--ams-sea);
  --bs-btn-border-color: var(--ams-sea);
  --bs-btn-hover-bg: var(--ams-sea-soft);
  --bs-btn-hover-border-color: var(--ams-sea-soft);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
}

@media (max-width: 768px) {
  .stage-rail { grid-template-columns: 1fr 1fr; }
}
