:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --surface: #ffffff;
  --surface-soft: #eef5ef;
  --ink: #17211d;
  --muted: #627067;
  --line: #dbe4dc;
  --green: #174d3c;
  --green-2: #216b50;
  --teal: #0d7f83;
  --amber: #b97805;
  --red: #b23b3b;
  --blue: #276b99;
  --shadow: 0 18px 50px rgba(30, 55, 44, 0.13);
  --pet-size: clamp(28px, 5vw, 42px);
  --pet-edge: clamp(6px, 2vw, 12px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(23, 77, 60, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(13, 127, 131, 0.1), transparent 32%),
    var(--bg);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

html,
body {
  overflow-x: hidden;
}

.screen-fade-out {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 400ms ease, transform 400ms ease;
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  color: var(--green);
  background:
    linear-gradient(135deg, rgba(23, 77, 60, 0.1), transparent 34%),
    var(--bg);
  font-weight: 900;
}

.app-loader[hidden] {
  display: none;
}

.app-loader img {
  width: min(240px, calc(100% - 48px));
  height: auto;
  max-height: 150px;
  object-fit: contain;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.loader-ring {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(23, 77, 60, 0.16);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: loader-spin 900ms linear infinite;
}

.app-loader p {
  margin: 0;
}

.loader-tagline {
  color: var(--ink);
  font-size: 1.05rem;
  letter-spacing: 0;
  animation: tagline-pulse 1.6s ease-in-out infinite alternate;
}

button,
input,
select,
textarea {
  font: inherit;
  user-select: auto;
  -webkit-user-select: auto;
}

button {
  cursor: pointer;
}

.auth-layout {
  flex: 1 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 440px);
  gap: 32px;
  align-items: center;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.compact-auth {
  grid-template-columns: minmax(320px, 460px);
  justify-content: center;
}

.brand-panel,
.login-panel,
.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-panel {
  min-height: 420px;
  display: grid;
  align-content: end;
  gap: 28px;
  padding: 44px;
  background:
    linear-gradient(160deg, rgba(23, 77, 60, 0.92), rgba(33, 107, 80, 0.82)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 16px);
  color: #ffffff;
}

.brand-mark {
  width: 72px;
  height: 72px;
  display: block;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.68);
  box-shadow: 0 12px 28px rgba(23, 77, 60, 0.18);
}

.company-logo {
  display: block;
  width: 118px;
  height: 94px;
  object-fit: contain;
  border-radius: 26px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(23, 77, 60, 0.16);
}

.company-logo.large {
  width: 142px;
  height: 112px;
}

.company-logo.small {
  width: 58px;
  height: 46px;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(23, 77, 60, 0.13);
}

.brand-mark.small {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(23, 77, 60, 0.13);
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: inherit;
  opacity: 0.74;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-panel h1,
.topbar h1,
.panel h2,
.login-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-panel h1 {
  max-width: 720px;
  font-size: clamp(2.25rem, 6vw, 4.8rem);
  line-height: 0.95;
}

.lead {
  max-width: 620px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.1rem;
  line-height: 1.7;
}

.login-panel {
  padding: 28px;
}

.password-panel {
  display: grid;
  gap: 18px;
}

.password-panel .company-logo {
  justify-self: center;
}

.form-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

textarea {
  resize: vertical;
}

.selected-bills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -8px;
}

.selected-bill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  background: var(--surface-soft);
  font-size: 0.82rem;
  font-weight: 900;
}

.selected-bill span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-bill small {
  color: var(--muted);
}

.selected-bill-remove {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  min-height: 20px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  color: #ffffff;
  background: var(--red);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 127, 131, 0.14);
}

.primary-action,
.secondary-action,
.ghost-action,
.danger-action,
.link-action,
.mini-action {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 900;
}

.primary-action {
  color: #ffffff;
  background: var(--green);
}

.primary-action:hover {
  background: var(--green-2);
}

.secondary-action,
.mini-action {
  color: var(--green);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.ghost-action {
  color: var(--green);
  background: transparent;
  border: 1px solid var(--line);
}

.danger-action {
  color: #ffffff;
  background: var(--red);
}

.danger-mini {
  color: #ffffff;
  background: var(--red);
  border-color: var(--red);
}

.link-action {
  min-height: auto;
  padding: 4px 0;
  color: var(--green);
  background: transparent;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 800;
}

.form-message.success-message {
  color: var(--green);
}

.demo-access {
  margin-top: 24px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.9rem;
}

.demo-access p {
  margin: 7px 0;
}

.app-shell {
  flex: 1 0 auto;
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  font-size: 1.55rem;
}

.user-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.role-pill,
.pending-pill,
.notification-pill,
.count-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.role-pill {
  gap: 4px;
  color: var(--green);
  background: var(--surface-soft);
}

.role-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.role-dots span {
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.25;
  animation: role-dot-blink 1.2s infinite ease-in-out;
}

.role-dots span:nth-child(2) {
  animation-delay: 160ms;
}

.role-dots span:nth-child(3) {
  animation-delay: 320ms;
}

.pending-pill,
.notification-pill,
.count-badge {
  color: #ffffff;
  background: var(--amber);
}

.notification-pill {
  background: var(--blue);
}

.signed-user {
  color: var(--muted);
  font-weight: 800;
}

.tabbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.tab-button {
  min-height: 42px;
  white-space: nowrap;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.tab-button.active {
  color: #ffffff;
  background: var(--green);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.notification-panel {
  margin-bottom: 16px;
}

.metric {
  display: grid;
  gap: 9px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.metric span,
.report-summary span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.55rem;
  letter-spacing: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.72fr);
  gap: 16px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.wide-field {
  grid-column: 1 / -1;
}

.compact-list,
.approval-list,
.category-summary {
  display: grid;
  gap: 10px;
}

.compact-item,
.approval-item,
.category-chip {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.admin-users-panel {
  margin-top: 16px;
}

.user-reset-item header {
  align-items: center;
}

.compact-item header,
.approval-item header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.compact-item h3,
.approval-item h3 {
  margin: 0;
  font-size: 1rem;
}

.compact-item p,
.approval-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pending {
  color: #7c5204;
  background: #fff3d6;
}

.status-approved {
  color: #135c43;
  background: #ddf3e8;
}

.status-rejected {
  color: #8c2f2f;
  background: #ffe0e0;
}

.status-declined {
  color: #8c2f2f;
  background: #ffe0e0;
}

.no-bill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-weight: 900;
}

.notification-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.notification-item.unread {
  border-left-color: var(--blue);
  background: #f2f8fc;
}

.notification-item p {
  margin: 0;
  color: var(--muted);
}

.notification-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.pet-playground {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

.pixel-pet {
  position: absolute;
  width: var(--pet-size);
  height: var(--pet-size);
  transform-origin: center bottom;
  opacity: 0.96;
}

.pet-sprite {
  display: block;
  width: 100%;
  height: 100%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 5px 6px rgba(23, 77, 60, 0.22));
  image-rendering: pixelated;
}

.route-bottom {
  left: var(--pet-edge);
  bottom: max(var(--pet-edge), env(safe-area-inset-bottom));
  animation: pet-route-bottom 24s linear infinite;
}

.route-right {
  right: var(--pet-edge);
  top: max(72px, calc(var(--pet-size) * 1.8));
  animation: pet-route-right 26s linear infinite;
  animation-delay: -7s;
}

.route-top {
  right: var(--pet-edge);
  top: max(var(--pet-edge), env(safe-area-inset-top));
  animation: pet-route-top 24s linear infinite;
  animation-delay: -12s;
}

.route-left {
  left: var(--pet-edge);
  bottom: max(72px, calc(var(--pet-size) * 1.8));
  animation: pet-route-left 26s linear infinite;
  animation-delay: -18s;
}

.pet-dog .pet-sprite {
  background-image: url("pets/dog.gif");
}

.pet-chicken .pet-sprite {
  background-image: url("pets/chicken.gif");
}

.pet-cockatiel .pet-sprite {
  background-image: url("pets/cockatiel.gif");
}

.pet-fox .pet-sprite {
  background-image: url("pets/fox.gif");
}

.pet-horse .pet-sprite {
  background-image: url("pets/horse.gif");
}

.pet-panda .pet-sprite {
  background-image: url("pets/panda.gif");
}

@keyframes pet-route-bottom {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(calc(100vw - var(--pet-size) - (var(--pet-edge) * 2)), 0);
  }
}

@keyframes pet-route-right {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(0, calc(100dvh - var(--pet-size) - 96px));
  }
}

@keyframes pet-route-top {
  0% {
    transform: translate(0, 0) scaleX(-1);
  }

  100% {
    transform: translate(calc(-100vw + var(--pet-size) + (var(--pet-edge) * 2)), 0) scaleX(-1);
  }
}

@keyframes pet-route-left {
  0% {
    transform: translate(0, 0) scaleX(-1);
  }

  100% {
    transform: translate(0, calc(-100dvh + var(--pet-size) + 96px)) scaleX(-1);
  }
}


.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
  background: #ffffff;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: 0;
}

.report-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.report-summary > div {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.report-summary strong {
  font-size: 1.3rem;
}

.category-summary {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 14px;
}

.category-chip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.category-chip strong {
  font-size: 1.05rem;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  text-align: center;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100% - 36px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffffff;
  background: var(--green);
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
  font-weight: 900;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.bill-viewer {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(18, 28, 24, 0.62);
}

.bill-viewer-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(980px, 100%);
  height: min(760px, calc(100dvh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.bill-viewer-panel header,
.bill-viewer-panel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

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

.bill-viewer-panel h2 {
  margin: 0;
  font-size: 1rem;
  max-width: min(620px, 70vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-viewer-content {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #f7faf8;
  overflow: auto;
}

.bill-viewer-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.bill-viewer-content iframe,
.bill-viewer-content object {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.app-footer {
  position: static;
  flex: 0 0 auto;
  width: 100%;
  margin-top: auto;
  padding: 10px 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.35;
}

@keyframes loader-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes tagline-pulse {
  from {
    opacity: 0.48;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes role-dot-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  35% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

@media (max-width: 900px) {
  .auth-layout,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: 320px;
  }

  .metrics-grid,
  .report-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-strip {
    justify-content: flex-start;
  }

  .report-controls {
    align-items: stretch;
  }

  table {
    min-width: 820px;
  }
}

@media (max-width: 560px) {
  body {
    padding-bottom: 0;
  }

  .auth-layout,
  .app-shell {
    width: min(100% - 24px, 1220px);
  }

  .auth-layout {
    min-height: auto;
    padding: 16px 0 92px;
  }

  .brand-panel,
  .login-panel,
  .panel {
    padding: 16px;
  }

  .brand-panel {
    min-height: 230px;
    gap: 18px;
  }

  .brand-panel h1 {
    max-width: 10ch;
    font-size: 1.68rem;
    line-height: 1;
  }

  .lead {
    max-width: 29ch;
    font-size: 0.98rem;
    line-height: 1.5;
  }

  .demo-access {
    padding: 14px;
    font-size: 0.82rem;
  }

  .login-panel h2 {
    font-size: 1.45rem;
  }

  .company-logo.large {
    width: 104px;
    height: 82px;
    border-radius: 20px;
  }

  .company-logo.small {
    width: 50px;
    height: 40px;
  }

  .app-loader img {
    width: min(190px, calc(100% - 48px));
    height: auto;
  }

  .loader-tagline {
    max-width: calc(100% - 40px);
    text-align: center;
    font-size: 0.96rem;
  }

  .topbar {
    gap: 12px;
    padding: 12px 0;
  }

  .topbar h1 {
    font-size: 1.28rem;
  }

  .user-strip {
    width: 100%;
    gap: 8px;
  }

  .user-strip .ghost-action,
  .user-strip .secondary-action {
    width: 100%;
  }

  .tabbar {
    margin-inline: -2px;
    padding: 6px;
  }

  .tab-button {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.88rem;
  }

  .metrics-grid,
  .report-controls,
  .report-summary {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-heading .secondary-action,
  .panel-heading .danger-action {
    width: 100%;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 1.28rem;
  }

  .compact-item header,
  .approval-item header {
    flex-direction: column;
  }

  .approval-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .approval-actions button,
  .approval-actions .mini-action {
    width: 100%;
  }

  table {
    min-width: 760px;
  }

  th,
  td {
    padding: 10px;
    font-size: 0.84rem;
  }

  .toast {
    right: 10px;
    bottom: 12px;
    max-width: calc(100% - 20px);
  }

  .app-footer {
    padding: 8px 10px;
    font-size: 0.7rem;
  }

  .pet-playground {
    --pet-size: clamp(24px, 8vw, 34px);
    --pet-edge: 6px;
  }
}
