:root {
  --bg: #f3f2fb;
  --panel: #ffffff;
  --ink: #25223f;
  --muted: #7b7894;
  --border: #e1dfec;
  --accent: #1410dc;
  --accent-dark: #0f0bb6;
  --navy: #231f43;
  --navy-2: #2b2650;
  --gold: #d8ac3c;
  --danger: #a13a32;
  --warning: #8a6116;
  --focus: #2f80ed;
  --shadow: 0 18px 45px rgba(31, 27, 58, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

.portal-body {
  background: var(--bg);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 44%, #eef2f5 44%, #eef2f5 100%);
  padding: 18px;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  max-width: 100%;
  padding: 0 16px;
  white-space: nowrap;
}

a {
  color: var(--accent-dark);
  font-weight: 800;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  background: #aeb6c2;
  cursor: not-allowed;
}

.button-secondary {
  background: #efeff7;
  color: var(--ink);
}

.button-secondary:hover {
  background: #dde3eb;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 0 16px;
  text-decoration: none;
  white-space: nowrap;
}

.button-link:hover {
  background: var(--accent-dark);
}

.page {
  max-width: none;
  margin: 0;
  padding: 0;
}

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

.portal-topbar {
  background: #fff;
  border-bottom: 1px solid #eceaf4;
  color: var(--ink);
  min-height: 88px;
  margin-left: 278px;
  padding: 0 28px;
}

.portal-topbar .title-block p {
  color: var(--muted);
}

.portal-topbar .title-block h1 {
  color: var(--ink);
  font-size: 28px;
  margin: 0;
  max-width: 720px;
}

.portal-topbar .brand-lockup {
  display: none;
}

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

.brand-logo {
  display: block;
  height: 34px;
  max-width: 134px;
  object-fit: contain;
  width: auto;
}

.auth-logo {
  height: 42px;
  max-width: 170px;
}

.brand-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.title-block h1 {
  margin: 0 0 6px;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 800;
  letter-spacing: 0;
}

.title-block p {
  margin: 0;
  color: var(--muted);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  min-width: 220px;
  max-width: 520px;
}

.nav-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(17, 28, 45, 0.05);
  padding: 8px;
}

.nav-row a {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  text-decoration: none;
}

.nav-row a[aria-current="page"] {
  border-color: rgba(11, 111, 92, 0.24);
  background: #e7f2ef;
  color: var(--accent-dark);
}

.nav-row form {
  margin-left: auto;
}

.nav-context {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  min-height: 38px;
  text-transform: uppercase;
}

.portal-layout {
  display: block;
}

.side-nav {
  background: var(--navy);
  border: 0;
  border-radius: 0;
  bottom: 0;
  box-shadow: none;
  color: #fff;
  left: 0;
  max-height: none;
  min-height: 100vh;
  overflow-y: auto;
  padding: 18px 15px;
  position: fixed;
  top: 0;
  width: 278px;
  z-index: 5;
}

.side-nav-brand {
  align-items: start;
  border-bottom: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 4px 0 22px;
}

.side-logo {
  display: block;
  max-height: 43px;
  max-width: 180px;
  object-fit: contain;
}

.side-title {
  color: rgba(255, 255, 255, 0.66);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.15;
}

.side-user {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.56);
  font-size: 12px;
  margin: 0 0 14px;
  overflow: hidden;
  padding: 12px 2px 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-nav-section + .side-nav-section {
  border-top: 0;
  margin-top: 8px;
  padding-top: 0;
}

.side-nav-heading {
  color: rgba(255, 255, 255, 0.42);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 18px 12px 8px;
  text-transform: uppercase;
}

.side-nav a {
  align-items: center;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.68);
  display: flex;
  gap: 10px;
  font-weight: 650;
  min-height: 44px;
  overflow-wrap: anywhere;
  padding: 0 12px;
  text-decoration: none;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.side-nav a.active {
  background: var(--accent);
  box-shadow: none;
  color: #fff;
}

.back-link {
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 8px;
}

.nav-icon {
  align-items: center;
  border-radius: 6px;
  color: currentColor;
  display: inline-flex;
  flex: 0 0 24px;
  font-size: 10px;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  outline: 1px solid rgba(255, 255, 255, 0.18);
}

.side-link-disabled {
  align-items: center;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.42);
  cursor: default;
  display: flex;
  gap: 10px;
  font-size: 15px;
  font-weight: 650;
  min-height: 44px;
  overflow-wrap: anywhere;
  padding: 0 12px;
}

.live-dot {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 800;
  margin-left: auto;
  padding: 3px 7px;
  text-transform: uppercase;
}

.disabled-dot {
  color: rgba(255, 255, 255, 0.44);
}

.side-signout {
  margin-top: 24px;
}

.side-signout button {
  width: 100%;
}

.side-signout .button-secondary {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

.side-signout .button-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.workspace {
  margin-left: 278px;
  min-width: 0;
  padding: 30px 28px 54px;
}

.workspace-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  border: 1px solid #e7e5f1;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  min-height: 102px;
  padding: 22px 24px;
}

.workspace-header h2 {
  color: var(--ink);
  font-size: 26px;
  letter-spacing: 0;
  margin: 2px 0 4px;
  overflow-wrap: anywhere;
}

.workspace-header p {
  color: var(--muted);
  margin: 0;
}

.section-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chip {
  border: 1px solid #e1dfec;
  border-radius: 999px;
  background: #f7f6fb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  max-width: 220px;
  overflow: hidden;
  padding: 6px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-ok {
  background: #ecfbf3;
  border-color: #d4f3e3;
  color: #5a9d73;
}

.chip-warn {
  background: #fff8ea;
  border-color: #f0dfb8;
  color: #bd8b29;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: 0;
  color: var(--navy);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 14px;
}

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

.metric-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  margin-bottom: 24px;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 126px;
}

.metric-card strong {
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.metric-card span:last-child {
  color: var(--muted);
}

.metric-label {
  color: var(--muted);
  font-weight: 700;
}

.category-card {
  color: var(--ink);
  display: grid;
  gap: 10px;
  min-height: 150px;
  text-decoration: none;
}

.category-card:hover {
  border-color: rgba(20, 16, 220, 0.32);
}

.category-card-disabled {
  opacity: 0.54;
}

.category-card-disabled:hover {
  border-color: var(--border);
}

.category-card .nav-icon {
  background: #efefff;
  color: var(--accent);
  outline: 0;
}

.category-card strong {
  font-size: 22px;
}

.category-card span:last-child {
  color: var(--muted);
  font-weight: 600;
}

.details-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.details-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid #edf0f3;
  padding-bottom: 8px;
}

.details-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.details-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.details-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  min-width: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.subhead {
  margin-top: 22px !important;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

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

.import-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.compact-settings-form {
  border-bottom: 1px solid #edf0f3;
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.settings-form button,
.settings-form .field-wide {
  grid-column: 1 / -1;
}

.config-details {
  margin-top: 16px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.import-form textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  min-height: 240px;
}

input[readonly] {
  background: #f8f7fc;
  color: var(--muted);
}

.disabled-dashboard {
  opacity: 0.72;
}

.users-table {
  margin-bottom: 8px;
}

.users-table table {
  min-width: 900px;
}

details {
  display: grid;
  gap: 10px;
}

summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(110px, 140px) auto;
  gap: 8px;
  margin: 10px 0;
  align-items: center;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
}

.check-row input {
  min-height: auto;
  width: auto;
}

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

.legal-page .panel {
  max-width: 820px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr)) repeat(3, max-content);
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.report-panel {
  padding: 18px 20px 22px;
}

.report-controls {
  border-bottom: 1px solid #edf0f3;
  padding-bottom: 18px;
}

.report-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 10px;
}

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

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
  padding: 0 10px;
}

textarea {
  padding: 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.22);
  outline-offset: 1px;
  border-color: var(--focus);
}

.message {
  display: none;
  border-radius: 6px;
  margin: 0 0 14px;
  padding: 10px 12px;
  font-weight: 700;
}

.message-error {
  display: block;
  background: #fff0ef;
  color: var(--danger);
}

.message-note {
  display: block;
  background: #fff8e9;
  color: var(--warning);
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  background: #f8f7fc;
  color: #3a3658;
  font-size: 13px;
  font-weight: 800;
}

td {
  background: #fff;
  overflow-wrap: anywhere;
}

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

.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.login {
  max-width: 420px;
  width: min(420px, 100%);
  margin: 0;
}

.auth-panel {
  border: 0;
  box-shadow: 0 28px 70px rgba(17, 28, 45, 0.2);
  overflow: hidden;
  padding: 0;
}

.auth-brand {
  background: #101c2d;
  border-bottom: 4px solid var(--gold);
  justify-content: center;
  margin-bottom: 0;
  min-height: 104px;
  padding: 24px;
}

.auth-brand .brand-name {
  color: #fff;
  display: none;
}

.auth-logo {
  height: 52px;
  max-width: 230px;
}

.login h1 {
  margin: 22px 24px 14px;
  font-size: 26px;
}

.login form {
  display: grid;
  gap: 12px;
  padding: 0 24px;
}

.login-divider {
  color: var(--muted);
  font-weight: 800;
  margin: 14px 24px;
  text-align: center;
}

.auth-actions {
  display: flex;
  justify-content: center;
  padding: 0 24px 24px;
}

.entra-link {
  width: 100%;
}

.auth-panel .message {
  margin: 0 24px 14px;
}

.not-found-copy {
  color: var(--muted);
  margin: 0 24px 18px;
}

@media (max-width: 820px) {
  .portal-topbar,
  .workspace {
    margin-left: 0;
  }

  .portal-topbar {
    padding: 18px;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .status-row {
    justify-content: flex-start;
  }

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

  .report-controls button {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .portal-layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    max-height: none;
    min-height: auto;
    position: static;
    width: auto;
  }

  .user-form,
  .settings-form,
  .inline-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 18px 12px 28px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
    white-space: normal;
  }

  .button-link,
  .nav-row a,
  .nav-row form {
    width: 100%;
  }

  .details-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .portal-topbar {
    min-height: 0;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .status-row,
  .chip {
    max-width: 100%;
  }
}
