:root {
  --sidebar-width: 272px;
  --font-size-base: clamp(12.5px, 0.62vw + 10.6px, 14px);
  --font-size-h1: clamp(1.2rem, 0.95vw + 0.9rem, 1.65rem);
  --font-size-h2: clamp(1.08rem, 0.7vw + 0.84rem, 1.32rem);
  --font-size-h3: clamp(0.97rem, 0.42vw + 0.82rem, 1.1rem);
}

body {
  font-size: var(--font-size-base);
  line-height: 1.45;
  overflow-x: hidden;
}

img,
svg,
canvas {
  max-width: 100%;
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }

main,
section,
article,
aside,
header,
footer,
.dashboard-shell,
.finance-wrap,
.table-responsive {
  min-width: 0;
}

h1, h2, h3, h4, h5, h6,
p {
  overflow-wrap: break-word;
  word-break: normal;
}

a,
label,
button {
  overflow-wrap: normal;
  word-break: normal;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 8px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  border-radius: 999px;
}

.table-zebra tbody tr {
  transition: background-color 0.2s ease;
}

.table-zebra {
  width: 100%;
}

[data-alert] {
  transition: opacity 0.3s ease;
}

[data-loading][disabled] {
  cursor: wait;
  opacity: 0.78;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

main > * {
  animation: fadeSlideIn 0.25s ease;
}

.table-responsive {
  width: 100%;
  overflow: visible;
  -webkit-overflow-scrolling: auto;
}

.table-responsive > table {
  min-width: 0;
}

@media (max-width: 1024px) {
  .table-responsive > table {
    min-width: 0;
  }
}

@media (max-width: 768px) {
  form [class*="md:grid-cols-2"],
  form [class*="md:grid-cols-3"],
  form [class*="lg:grid-cols-2"],
  form [class*="lg:grid-cols-3"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

table.responsive-stack-mobile {
  width: 100%;
  table-layout: fixed;
}

table.responsive-stack-mobile td,
table.responsive-stack-mobile th {
  overflow-wrap: break-word;
  word-break: normal;
}

@media (max-width: 768px) {
  table.responsive-stack-mobile {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
  }

  table.responsive-stack-mobile thead {
    display: none;
  }

  table.responsive-stack-mobile tbody {
    display: block;
    width: 100%;
  }

  table.responsive-stack-mobile tbody tr {
    display: block;
    width: 100%;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card-bg);
    overflow: hidden;
    box-shadow: var(--shadow);
  }

  table.responsive-stack-mobile tbody tr:last-child {
    margin-bottom: 0;
  }

  table.responsive-stack-mobile tbody td {
    display: block;
    width: 100%;
    border-bottom: 1px solid var(--border) !important;
    padding: 0.72rem 0.82rem;
    white-space: normal !important;
    text-align: left;
  }

  table.responsive-stack-mobile tbody td::before {
    content: attr(data-label);
    display: block;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.35;
    color: var(--text-muted);
    margin-bottom: 0.32rem;
  }

  table.responsive-stack-mobile tbody td a,
  table.responsive-stack-mobile tbody td span,
  table.responsive-stack-mobile tbody td strong {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  table.responsive-stack-mobile tbody td.mobile-no-label::before {
    content: '';
    display: none;
  }

  table.responsive-stack-mobile tbody td.mobile-no-label {
    padding-top: 0.85rem;
  }

  table.responsive-stack-mobile tbody td.mobile-full-row {
    display: block;
    text-align: left;
    padding: 0.78rem 0.82rem;
  }

  table.responsive-stack-mobile tbody td:last-child {
    border-bottom: 0 !important;
  }
}

@media (min-width: 1280px) {
  body {
    font-size: 12.5px;
  }
}

.records-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
}

.records-grid.records-grid-4 {
  grid-template-columns: minmax(0, 1fr);
}

.records-grid.records-grid-3 {
  grid-template-columns: minmax(0, 1fr);
}

.record-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.95rem;
  min-width: 0;
}

.record-card__title {
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.25;
}

.record-card__meta {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.record-card__grid {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.45rem;
}

.record-card__line {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: flex-start;
}

.record-card__line span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.record-card__line strong {
  color: var(--text);
  font-size: 0.88rem;
  text-align: right;
  overflow-wrap: anywhere;
  max-width: 60%;
}

.record-card__actions {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.record-card__actions a {
  font-weight: 600;
  font-size: 0.86rem;
}

.desktop-table-only {
  display: block;
}

.mobile-cards-only {
  display: none;
}

@media (min-width: 640px) {
  .records-grid.records-grid-4,
  .records-grid.records-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .records-grid.records-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .records-grid.records-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .desktop-table-only {
    display: none;
  }

  .mobile-cards-only {
    display: grid;
  }

  .record-card__line {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .record-card__line strong {
    text-align: left;
    max-width: 100%;
  }
}
