:root {
  --font-family: "Source Sans 3", "Noto Sans", "Liberation Sans", sans-serif;
  --font-family-heading: "Fraunces", "Source Sans 3", serif;
  --pico-border-radius: 14px;
  --pico-box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  --pico-primary: #0c6b4b;
  --pico-primary-background: #0c6b4b;
  --pico-primary-inverse: #f8fffb;
  --pico-modal-overlay-backdrop-filter: none;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1000px 400px at 10% -10%, rgba(12, 107, 75, 0.12), transparent 60%),
    radial-gradient(900px 360px at 110% 5%, rgba(14, 92, 158, 0.12), transparent 60%),
    var(--pico-background-color);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family-heading);
  letter-spacing: -0.01em;
}

main {
  flex: 1;
  padding-block: 2rem;
}

.container {
  max-width: 1200px;
}

body>header.container {
  position: relative;
}

body>header.container>nav {
  align-items: center;
}

body>header.container>nav hgroup {
  margin: 0;
}

body>header.container>nav h1 {
  margin: 0;
}

body>header.container::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100vw;
  transform: translateX(-50%);
  border-bottom: 1px solid var(--pico-muted-border-color);
  pointer-events: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.site-header nav {
  align-items: center;
  gap: 1rem;
}

.nav-links {
  gap: 0.75rem;
}

.nav-links a {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.nav-links a[aria-current="page"] {
  color: var(--pico-primary-inverse);
  background: var(--pico-primary-background);
}

.nav-menu summary {
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
}

.upload-summary {
  list-style: none;
}

.upload-summary::-webkit-details-marker {
  display: none;
}

.upload-summary::marker {
  content: "";
}

.upload-summary::after {
  content: none;
  display: none;
}

.upload-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.upload-summary-row h2 {
  margin: 0;
}

.statement-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.statement-group h3 {
  margin: 0;
}


.upload-summary-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
}

.upload-summary-chevron svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

details[open] .upload-summary-chevron {
  transform: rotate(180deg);
}

.site-footer {
  border-top: 1px solid var(--pico-muted-border-color);
  padding-block: 1.5rem;
}


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

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

.page-header h1,
.page-header h2 {
  margin-bottom: 0.35rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pico-spacing);
  align-items: center;
  margin-bottom: var(--pico-spacing);
}

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

.stat-grid.invoice-details-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.transaction-import-mapping-grid {
  grid-template-columns: repeat(6, minmax(160px, 1fr));
}

.panel {
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-muted-border-color);
  background: var(--pico-background-color);
  padding: 1.5rem;
  box-shadow: var(--pico-box-shadow);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.table-wrap {
  overflow-x: auto;
}

.sticky-header thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.sticky-header thead th,
.sticky-header thead td {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #e6e6e6;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--pico-muted-border-color);
  background: rgba(15, 23, 42, 0.04);
}

.tag.success {
  color: #0f6b3b;
  border-color: rgba(15, 107, 59, 0.3);
  background: rgba(15, 107, 59, 0.12);
}

.tag.warning {
  color: #b54708;
  border-color: rgba(181, 71, 8, 0.3);
  background: rgba(181, 71, 8, 0.12);
}

.tag.info {
  color: #0b5f9a;
  border-color: rgba(11, 95, 154, 0.3);
  background: rgba(11, 95, 154, 0.12);
}

.tag.danger {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.3);
  background: rgba(180, 35, 24, 0.12);
}

.tone-success {
  color: #0f6b3b;
}

.tone-warning {
  color: #b54708;
}

.tone-danger {
  color: #b42318;
}

.tone-info {
  color: #0b5f9a;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.attachment-actions {
  text-align: right;
}

.attachment-actions .card-actions {
  justify-content: flex-end;
}

.plaid-import-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pico-muted-color);
  animation: plaid-spin 1s linear infinite;
}

.plaid-import-spinner svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

.processing-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pico-muted-color);
  animation: plaid-spin 1s linear infinite;
}

.processing-spinner svg {
  width: 1.4rem;
  height: 1.4rem;
  display: block;
}

.processing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.1rem;
}

.processing-dots span {
  display: inline-block;
  width: 0.25rem;
  animation: processing-dot 1.2s infinite ease-in-out;
  opacity: 0.2;
}

.processing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.processing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

.plaid-import-label {
  font-size: 0.9rem;
}

/* .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-muted-border-color);
  background: var(--pico-background-color);
  color: inherit;
  font-weight: 600;
  cursor: pointer;
} */

/* .icon-button svg {
  width: 1rem;
  height: 1rem;
} */

/* .icon-button.primary {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-color: transparent;
} */

/* .icon-button.secondary {
  background: transparent;
} */

.hidden {
  display: none !important;
}

.rotate-180 {
  transform: rotate(180deg);
}

.overflow-hidden {
  overflow: hidden !important;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.drawer-toggle {
  display: none;
}

.drawer-trigger {
  position: relative;
  z-index: 0;
}

.drawer-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.drawer-toggle:checked~.drawer-layer {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer-panel {
  position: absolute;
  inset-block: 0;
  right: 0;
  width: min(36rem, 100%);
  background: var(--pico-background-color);
  border-left: 1px solid var(--pico-muted-border-color);
  box-shadow: var(--pico-box-shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.drawer-toggle:checked~.drawer-layer .drawer-backdrop {
  opacity: 1;
}

.drawer-toggle:checked~.drawer-layer .drawer-panel {
  transform: translateX(0);
}

.translate-x-full {
  transform: translateX(100%);
}

.panel-body {
  padding-top: 0.5rem;
}

dialog article {
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

dialog article header,
dialog article footer {
  flex: 0 0 auto;
}

.modal-footer {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal-footer>button {
  width: 100%;
}

dialog article form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.account-field {
  width: 100%;
  min-width: 0;
}

.account-chip {
  max-width: 100%;
  white-space: nowrap;
  box-sizing: border-box;
  margin-bottom: 0;
  min-width: 0;
  border: 1px solid rgba(11, 95, 154, 0.3);
  border-bottom: 1px solid rgba(11, 95, 154, 0.3) !important;
  box-shadow: none;
}

.account-chip:focus-within {
  box-shadow: none;
  outline: none;
}

.account-chip span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 1rem;
  height: 1rem;
  border: none;
  background: transparent;
  color: inherit;
  box-shadow: none;
  flex: 0 0 auto;
  cursor: pointer;
}

.account-chip-clear svg {
  width: 0.75rem;
  height: 0.75rem;
  display: block;
}

.account-chip-clear:hover {
  color: inherit;
  opacity: 0.6;
  box-shadow: none;
}

.toast {
  position: fixed;
  right: 1rem;
  top: 5rem;
  z-index: 60;
}

.icon-button {
  padding: 0;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  line-height: 0;
  cursor: pointer;
}

.icon-button[data-tooltip]::before {
  line-height: 1.2;
  display: block;
}

.icon-button.primary {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-color: transparent;
}

.icon-button.danger {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.3);
  background: rgba(180, 35, 24, 0.12);
}

.stacked-labels>label>span,
.stacked-labels>.grid>label>span {
  display: block;
  margin-bottom: 0.35rem;
}

a.icon-button,
.icon-button[role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

label.icon-button {
  background: var(--pico-primary-background);
  border: 1px solid #111;
  border-bottom: 1px solid #111 !important;
  border-style: solid;
  box-shadow: none;
  cursor: pointer !important;
  transition: background 0.15s ease, border-color 0.15s ease;
}

label.icon-button:hover {
  background: rgba(207, 226, 255, 0.7);
  border-color: #111;
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

.actions :is(button, a[role="button"]) {
  margin-bottom: 0;
}

.cell-highlight {
  background: rgba(12, 107, 75, 0.12);
}

.cell-error {
  background: rgba(180, 35, 24, 0.12);
  color: #b42318;
}

#transactions-table .transaction-date {
  width: 7rem;
}

#transactions-table .transaction-account {
  width: 20rem;
  max-width: 20rem;
}

#transactions-table .account-field,
#transactions-table .account-chip,
#transactions-table .account-datalist {
  width: 100%;
  min-width: 0;
}

#transaction-import-error-banner {
  margin-bottom: var(--pico-spacing);
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.3);
}

.row-highlight {
  background-color: rgba(12, 107, 75, 0.18);
  transition: background-color 0.8s ease-out;
}

table tbody tr.htmx-added,
table tbody tr.htmx-swapping {
  background-color: rgba(12, 107, 75, 0.18);
  transition: background-color 0.8s ease-out;
}

@media (max-width: 720px) {
  .page-header {
    align-items: flex-start;
  }
}

@keyframes plaid-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes processing-dot {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }

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