:root {
  --bg: #edf4ff;
  --surface: rgba(251, 253, 255, 0.82);
  --surface-strong: #ffffff;
  --surface-dark: #0a2a67;
  --text: #0f2143;
  --muted: #5a6f95;
  --line: rgba(16, 33, 63, 0.1);
  --accent: #1246b0;
  --accent-strong: #0b3487;
  --accent-soft: rgba(18, 70, 176, 0.12);
  --accent-soft-strong: rgba(18, 70, 176, 0.22);
  --sky: #5d94e7;
  --ice: #d7e7ff;
  --danger-soft: rgba(201, 80, 80, 0.14);
  --danger: #9f4343;
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow: 0 24px 70px rgba(11, 44, 111, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(93, 148, 231, 0.22), transparent 26%),
    radial-gradient(circle at top right, rgba(18, 70, 176, 0.16), transparent 32%),
    radial-gradient(circle at bottom left, rgba(215, 231, 255, 0.95), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(215, 231, 255, 0.2)),
    var(--bg);
  z-index: -1;
}

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

.auth-card,
.hero-card,
.card,
.modal-card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(980px, 100%);
  padding: 32px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 44%;
  height: 100%;
  background:
    radial-gradient(circle at 10% 15%, rgba(18, 70, 176, 0.16), transparent 48%),
    repeating-linear-gradient(
      90deg,
      rgba(18, 70, 176, 0.08) 0,
      rgba(18, 70, 176, 0.08) 2px,
      transparent 2px,
      transparent 42px
    ),
    linear-gradient(180deg, rgba(18, 70, 176, 0.12), rgba(93, 148, 231, 0.04));
  pointer-events: none;
}

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

.auth-brand {
  margin-bottom: 24px;
}

.brand-subline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.brand-subline-light {
  color: rgba(238, 245, 255, 0.68);
}

.brand-mark {
  width: 66px;
  height: 74px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 18px 26px rgba(20, 58, 132, 0.2));
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand h1,
.topbar h2,
.hero-card h3,
.card h3,
.section-heading h3,
.modal-card h3,
.auth-copy h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: inherit;
  opacity: 0.68;
}

.auth-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.institution-pill {
  align-self: flex-start;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(18, 70, 176, 0.12), rgba(93, 148, 231, 0.08));
  border: 1px solid rgba(18, 70, 176, 0.12);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.auth-highlights span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(18, 70, 176, 0.12);
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
}

.auth-copy p,
.helper-text,
.hero-copy,
.stack-item p,
.staff-card p,
.report-item p,
.stat-card p:last-child,
.integration-note,
.integration-status-box p,
.table-subline {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(243, 248, 255, 0.92));
  border: 1px solid rgba(31, 63, 126, 0.1);
  border-radius: 24px;
  padding: 24px;
  display: grid;
  gap: 16px;
}

.form-message {
  min-height: 24px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field label {
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

#cometApiUrl {
  min-height: 118px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus {
  outline: none;
  border-color: rgba(43, 103, 216, 0.44);
  box-shadow: 0 0 0 4px rgba(43, 103, 216, 0.12);
}

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px;
  background:
    radial-gradient(circle at top right, rgba(93, 148, 231, 0.18), transparent 22%),
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.05), transparent 18%),
    linear-gradient(180deg, rgba(10, 42, 103, 0.98), rgba(8, 26, 66, 1));
  color: #eef5ff;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(140, 185, 255, 0.16);
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-link,
.primary-action,
.secondary-action,
.ghost-action,
.icon-button,
.ghost-light {
  border: 0;
  cursor: pointer;
  transition: 180ms ease;
}

.nav-link {
  text-align: left;
  padding: 14px 16px;
  border-radius: 16px;
  background: transparent;
  color: rgba(238, 245, 255, 0.82);
}

.nav-link:hover,
.nav-link.active {
  background: linear-gradient(90deg, rgba(18, 70, 176, 0.48), rgba(255, 255, 255, 0.08));
  color: #fff;
  box-shadow: inset 3px 0 0 #ffffff;
}

.sidebar-note {
  margin-top: auto;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(93, 148, 231, 0.08));
  color: rgba(238, 245, 255, 0.84);
  display: grid;
  gap: 10px;
  border: 1px solid rgba(146, 190, 255, 0.14);
}

.ghost-light {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-align: left;
  border: 1px solid rgba(146, 190, 255, 0.12);
}

.content {
  padding: 28px;
}

.topbar,
.section-heading,
.card-header,
.modal-header,
.modal-actions,
.toolbar,
.hero-card,
.report-highlights,
.hero-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero-side {
  display: grid;
  justify-items: end;
  gap: 18px;
}

.integration-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 20px;
  margin-bottom: 18px;
}

.integration-card {
  display: grid;
  gap: 16px;
}

.integration-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.integration-form .full {
  grid-column: 1 / -1;
}

.integration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.integration-message {
  min-height: 24px;
}

.integration-status {
  display: grid;
  gap: 14px;
}

.integration-status-box {
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(239, 246, 255, 0.88));
  border: 1px solid rgba(18, 70, 176, 0.1);
}

.integration-status-box strong {
  display: block;
  margin-bottom: 4px;
}

.budget-layout {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 20px;
  margin-bottom: 18px;
}

.budget-summary-card,
.budget-categories-card {
  display: grid;
  gap: 16px;
}

.budget-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.amount-positive {
  color: #0f7d5f;
  font-weight: 800;
}

.amount-negative {
  color: #b24646;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(18, 70, 176, 0.12);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.topbar-badge img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.topbar {
  margin-bottom: 24px;
}

.primary-action,
.secondary-action,
.ghost-action {
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 700;
}

.primary-action {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 30px rgba(43, 103, 216, 0.26);
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(43, 103, 216, 0.12);
}

.ghost-action,
.icon-button {
  background: transparent;
  color: var(--muted);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.hero-card {
  padding: 28px;
  margin-bottom: 22px;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 49.7%, rgba(255, 255, 255, 0.22) 49.7%, rgba(255, 255, 255, 0.22) 50.3%, rgba(255, 255, 255, 0.08) 50.3%),
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.12), transparent 38%),
    linear-gradient(135deg, #0d378b, #1246b0 58%, #2664d1 100%);
  color: #f5f9ff;
  border-color: rgba(35, 90, 190, 0.5);
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 54%;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.12) 0,
      rgba(255, 255, 255, 0.12) 2px,
      transparent 2px,
      transparent 48px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.1) 0,
      rgba(255, 255, 255, 0.1) 2px,
      transparent 2px,
      transparent 56px
    );
  opacity: 0.42;
  mask-image: radial-gradient(circle at left center, black 38%, transparent 84%);
  pointer-events: none;
}

.hero-copy {
  max-width: 620px;
  color: rgba(245, 249, 255, 0.82);
}

.hero-copy-block {
  position: relative;
  z-index: 1;
}

.hero-ribbon {
  margin-top: 22px;
}

.hero-ribbon span {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #f7fbff;
  font-weight: 700;
}

.hero-crest-frame {
  width: 208px;
  padding: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.06);
}

.hero-crest {
  width: 100%;
  height: auto;
  display: block;
}

.hero-card .eyebrow {
  color: rgba(245, 249, 255, 0.72);
}

.hero-badges {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-badges span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f5f9ff;
}

.stats-grid,
.dashboard-grid,
.reports-layout {
  display: grid;
  gap: 20px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

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

.reports-layout {
  grid-template-columns: 1.1fr 1.4fr;
}

.card {
  padding: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(247, 250, 255, 0.82));
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #0b3487, #1246b0, #7caeff);
}

.stat-card {
  padding: 22px;
  min-height: 148px;
  display: grid;
  gap: 14px;
}

.stat-card strong,
.highlight-box strong {
  font-size: 2rem;
  font-family: "Space Grotesk", sans-serif;
}

.stack-list {
  display: grid;
  gap: 14px;
}

.stack-item,
.staff-card,
.report-item {
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(244, 248, 255, 0.9));
  border: 1px solid rgba(18, 70, 176, 0.1);
}

.stack-item strong,
.staff-card strong,
.report-item strong {
  display: block;
  margin-bottom: 4px;
}

.toolbar {
  margin: 18px 0;
  justify-content: flex-start;
}

.toolbar input {
  width: min(420px, 100%);
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.table-card {
  overflow: hidden;
  padding: 0;
}

.table-subline {
  font-size: 0.84rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  background: rgba(235, 242, 255, 0.9);
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr:hover {
  background: rgba(231, 241, 255, 0.66);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
}

.tag.ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tag.warn {
  background: rgba(93, 148, 231, 0.16);
  color: #1246b0;
}

.tag.alert {
  background: var(--danger-soft);
  color: var(--danger);
}

.staff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.staff-card {
  display: grid;
  gap: 10px;
}

.staff-meta,
.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(18, 70, 176, 0.1);
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 700;
}

.report-summary {
  min-height: 220px;
}

.report-highlights {
  margin-top: 16px;
  align-items: stretch;
  flex-wrap: wrap;
}

.highlight-box {
  min-width: 180px;
  flex: 1;
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(239, 246, 255, 0.9));
  border: 1px solid rgba(18, 70, 176, 0.1);
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(7, 20, 48, 0.5);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(760px, calc(100vw - 24px));
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 8px;
}

@media (max-width: 1100px) {
  .stats-grid,
  .dashboard-grid,
  .reports-layout,
  .staff-grid,
  .integration-grid,
  .budget-layout {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 920px) {
  .auth-card,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    gap: 20px;
  }

  .content {
    padding: 20px;
  }

  .topbar,
  .section-heading,
  .hero-card,
  .modal-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-side {
    width: 100%;
    justify-items: start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .stats-grid,
  .dashboard-grid,
  .reports-layout,
  .staff-grid,
  .form-grid,
  .integration-grid,
  .integration-form,
  .budget-layout,
  .budget-summary-grid {
    grid-template-columns: 1fr;
  }

  .integration-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  td {
    border-bottom: 0;
    padding: 10px 16px;
  }

  tbody tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
}
