@layer reset, tokens, report, auth, datatables;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html,
  body {
    min-height: 100%;
  }
}

@layer tokens {
  :root {
    --surface-bg: #eff1ec;
    --surface-bg-deep: #dce4da;
    --surface-panel: rgba(255, 255, 255, 0.88);
    --surface-panel-strong: #ffffff;
    --surface-text: #18212c;
    --surface-muted: #5b6876;
    --surface-accent: #163a5b;
    --surface-accent-strong: #0f2b43;
    --surface-accent-soft: rgba(22, 58, 91, 0.1);
    --surface-border: rgba(24, 33, 44, 0.12);
    --surface-border-strong: rgba(24, 33, 44, 0.2);
    --surface-error: #a63c2f;
    --surface-shadow: 0 22px 50px rgba(16, 24, 40, 0.09);
    --surface-radius-lg: 24px;
    --surface-radius-md: 18px;
    --surface-radius-sm: 10px;
    --surface-sans: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --surface-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  }
}

@layer report {
  body.report-page {
    margin: 0;
    background:
      radial-gradient(1100px 700px at 15% -10%, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0) 58%),
      radial-gradient(780px 480px at 100% 8%, rgba(180, 151, 109, 0.15) 0%, rgba(180, 151, 109, 0) 64%),
      linear-gradient(160deg, var(--surface-bg) 0%, #e6ece4 52%, var(--surface-bg-deep) 100%);
    color: var(--surface-text);
    font: 14px/1.6 var(--surface-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body.report-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
      linear-gradient(rgba(24, 33, 44, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(24, 33, 44, 0.03) 1px, transparent 1px);
    background-size: 100% 36px, 36px 100%;
    opacity: 0.26;
    pointer-events: none;
  }

  .report-container {
    position: relative;
    max-width: 1240px;
    margin: 28px auto 56px;
    padding: 0 18px;
  }

  .report-title {
    margin: 0 0 10px;
    color: var(--surface-text);
    font-family: var(--surface-serif);
    font-size: clamp(1.85rem, 3vw, 2.7rem);
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1.05;
  }

  .report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
  }

  .report-controls,
  .report-card,
  .report-table-wrap,
  .report-link-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(250, 251, 248, 0.82) 100%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--surface-radius-md);
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(18px);
  }

  .report-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 18px;
    align-items: end;
    padding: 14px;
    margin-bottom: 14px;
  }

  .report-control {
    display: grid;
    gap: 7px;
  }

  .report-label,
  .reports-home .reports-home-kicker,
  .reports-home .report-card-kicker {
    color: var(--surface-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .report-page input[type="date"],
  .report-page select {
    min-width: 190px;
    padding: 0.72rem 0.8rem;
    border: 1px solid var(--surface-border-strong);
    border-radius: var(--surface-radius-sm);
    background: rgba(255, 255, 255, 0.92);
    color: var(--surface-text);
    font: inherit;
    box-shadow: none;
  }

  .report-page button:not(.report-tab),
  .report-button,
  .report-link-button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0.72rem 1rem;
    border: 1px solid var(--surface-accent);
    border-radius: var(--surface-radius-sm);
    background: var(--surface-accent);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
    box-shadow: none;
  }

  .report-page button:not(.report-tab):hover,
  .report-button:hover,
  .report-link-button:hover {
    transform: translateY(-1px);
    background: var(--surface-accent-strong);
    border-color: var(--surface-accent-strong);
  }

  .report-page button:not(.report-tab):active,
  .report-button:active,
  .report-link-button:active {
    transform: translateY(0);
  }

  .report-page button:not(.report-tab).secondary,
  .report-button.secondary,
  .report-link-button.secondary {
    background: rgba(255, 255, 255, 0.58);
    border-color: var(--surface-border-strong);
    color: var(--surface-text);
  }

  .report-page button:not(.report-tab).secondary:hover,
  .report-button.secondary:hover,
  .report-link-button.secondary:hover {
    background: #fff;
    border-color: var(--surface-accent);
    color: var(--surface-accent);
  }

  .report-page button:not(.report-tab)[disabled],
  .report-button[disabled] {
    opacity: 0.58;
    cursor: not-allowed;
  }

  .report-page button:not(.report-tab):focus-visible,
  .report-page input[type="date"]:focus-visible,
  .report-page select:focus-visible,
  .report-link-button:focus-visible {
    outline: 2px solid rgba(22, 58, 91, 0.4);
    outline-offset: 2px;
    border-color: var(--surface-accent);
  }

  .report-status {
    min-height: 20px;
    margin: 6px 2px 14px;
    color: var(--surface-muted);
    font-size: 13px;
  }

  .report-status.error {
    color: var(--surface-error);
    font-weight: 600;
  }

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

  .report-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }

  .report-table-wrap thead th {
    padding: 12px 10px;
    text-align: left;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: rgba(245, 247, 242, 0.94);
    border-bottom: 1px solid var(--surface-border);
    color: var(--surface-muted);
  }

  .report-table-wrap tbody td {
    padding: 11px 10px;
    border-top: 1px solid var(--surface-border);
  }

  .report-table-wrap tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.46);
  }

  .report-table-wrap tbody tr:hover {
    background: rgba(22, 58, 91, 0.045);
  }

  .report-card {
    padding: 24px;
  }

  .report-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin: 0 0 14px;
    padding: 0 0 2px;
  }

  .report-tab {
    min-height: 0;
    padding: 0 0 6px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--surface-muted);
    box-shadow: none;
  }

  .report-tab:hover {
    background: transparent;
    border-color: rgba(22, 58, 91, 0.26);
    color: var(--surface-text);
  }

  .report-tab[aria-selected="true"] {
    border-color: var(--surface-accent);
    color: var(--surface-text);
  }

  .reports-home {
    color: var(--surface-text);
  }

  .reports-home .reports-home-shell {
    position: relative;
  }

  .reports-home .reports-home-hero {
    max-width: 720px;
    margin-bottom: 1.4rem;
  }

  .reports-home h1,
  .reports-home .report-link-card strong {
    color: var(--surface-text);
    font-family: var(--surface-serif);
  }

  .reports-home h1 {
    margin: 0;
    font-size: clamp(2.1rem, 4vw, 3.25rem);
    font-weight: 600;
    letter-spacing: -0.05em;
    line-height: 0.98;
  }

  .reports-home .report-links {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.1rem;
    margin-bottom: 2rem;
  }

  .reports-home .report-link-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 0.95rem;
    isolation: isolate;
    z-index: 1;
    min-height: 152px;
    padding: 1.35rem 1.45rem 1.25rem;
    color: var(--surface-text);
    text-decoration: none;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  }

  .reports-home .report-link-card::after {
    content: "";
    position: absolute;
    left: 1.45rem;
    right: 1.45rem;
    bottom: 1rem;
    height: 1px;
    background: linear-gradient(90deg, rgba(24, 33, 44, 0.14), rgba(24, 33, 44, 0));
    pointer-events: none;
  }

  .reports-home .report-link-card:hover,
  .reports-home .report-link-card:focus-visible,
  .reports-home .report-link-card.active {
    transform: translateY(-3px);
    border-color: var(--surface-border-strong);
    box-shadow: 0 24px 50px rgba(16, 24, 40, 0.11);
    outline: none;
  }

  .reports-home .report-card-index {
    padding-top: 0.08rem;
    color: var(--surface-muted);
    font: 700 0.76rem/1 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    letter-spacing: 0.16em;
    text-transform: uppercase;
  }

  .reports-home .report-card-copy {
    display: grid;
    gap: 0.35rem;
  }

  .reports-home .report-link-card strong {
    font-size: 1.17rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.12;
  }

  .reports-home .report-card-meta {
    max-width: 28ch;
    color: var(--surface-muted);
    font-size: 0.94rem;
    line-height: 1.5;
  }

  .power-bi-report-page {
    height: 100vh;
    overflow: hidden;
  }

  .power-bi-report-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 12px;
  }

  .power-bi-report-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 52px;
    padding-bottom: 12px;
  }

  .power-bi-report-toolbar h1 {
    flex: 1;
    margin: 0;
    font: 600 clamp(1.2rem, 2vw, 1.65rem)/1.2 var(--surface-serif);
  }

  .power-bi-report-frame,
  .power-bi-report-pending {
    flex: 1;
    min-height: 0;
    background: var(--surface-panel-strong);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius-sm);
    overflow: hidden;
  }

  .power-bi-report-frame:fullscreen {
    border: 0;
    border-radius: 0;
  }

  .power-bi-report-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
  }

  .power-bi-report-status {
    margin: 0;
    color: var(--surface-muted);
  }

  .power-bi-report-pending {
    display: grid;
    place-items: center;
    padding: 1rem;
    color: var(--surface-muted);
    text-align: center;
  }
}

@layer auth {
  body.auth-body {
    margin: 0;
    background:
      radial-gradient(1100px 700px at 15% -10%, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0) 58%),
      radial-gradient(640px 420px at 100% 0%, rgba(180, 151, 109, 0.12) 0%, rgba(180, 151, 109, 0) 68%),
      linear-gradient(180deg, #eef2eb 0%, #e4ebe2 100%);
    color: var(--surface-text);
    font: 14px/1.6 var(--surface-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
  }

  .auth-card {
    width: 100%;
    max-width: 640px;
    padding: 40px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(250, 251, 248, 0.86) 100%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--surface-radius-lg);
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(18px);
  }

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

  .auth-title {
    margin: 0;
    color: var(--surface-text);
    font-family: var(--surface-serif);
    font-size: clamp(1.9rem, 4vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.03em;
  }

  .auth-subtitle {
    margin-top: 6px;
    color: var(--surface-muted);
    font-size: 1.05rem;
  }

  .auth-footer {
    margin-top: 18px;
    color: var(--surface-muted);
    text-align: center;
  }
}

@layer datatables {
  .dt-body-right {
    text-align: right;
  }

  .dt-body-center {
    text-align: center;
  }

  .dataTables_wrapper .dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0 10px;
  }

  .dataTables_wrapper .dt-button,
  .dataTables_wrapper .dt-button:hover,
  .dataTables_wrapper .dt-button:active {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0.68rem 0.95rem;
    border: 1px solid var(--surface-border-strong);
    border-radius: var(--surface-radius-sm);
    background: rgba(255, 255, 255, 0.58);
    color: var(--surface-text);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
    box-shadow: none;
  }

  .dataTables_wrapper .dt-button:hover {
    transform: translateY(-1px);
    background: #fff;
    border-color: var(--surface-accent);
    color: var(--surface-accent);
  }

  .dataTables_wrapper .dt-button:active {
    transform: translateY(0);
  }

  .dataTables_wrapper .dt-button:focus-visible {
    outline: 2px solid rgba(22, 58, 91, 0.4);
    outline-offset: 2px;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    margin: 10px 0;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.3em 0.8em;
    border-radius: 8px;
  }

  table.dataTable thead .sorting:before,
  table.dataTable thead .sorting:after,
  table.dataTable thead .sorting_asc:before,
  table.dataTable thead .sorting_asc:after,
  table.dataTable thead .sorting_desc:before,
  table.dataTable thead .sorting_desc:after {
    bottom: 50%;
  }
}

@media (min-width: 1200px) {
  .auth-card {
    max-width: 680px;
  }
}

@media (min-width: 1400px) {
  .auth-card {
    max-width: 720px;
  }
}

@media (min-width: 576px) {
  .reports-home .report-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .reports-home .report-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .report-page input[type="date"],
  .report-page select {
    min-width: 160px;
  }
}

@media (max-width: 640px) {
  .report-container {
    margin-top: 20px;
    padding: 0 14px;
  }

  .report-controls {
    gap: 10px 12px;
    padding: 12px;
  }

  .report-page input[type="date"],
  .report-page select {
    min-width: 140px;
  }

  .report-table-wrap thead th,
  .report-table-wrap tbody td {
    padding: 9px 8px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 26px;
  }

  .auth-title {
    font-size: 1.5rem;
  }
}
