:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #20242c;
  --muted: #667085;
  --primary: #175cd3;
  --primary-strong: #0b4bb3;
  --danger: #b42318;
  --success: #067647;
  --soft-blue: #eaf2ff;
  --soft-green: #ecfdf3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.topbar p,
.muted {
  color: var(--muted);
}

.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 13px;
  cursor: pointer;
}

button:hover {
  border-color: #9aa4b2;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.tab.active,
.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

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

.account-pill {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f9fafb;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel,
.result,
.notice,
.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.field-block {
  display: grid;
  gap: 7px;
  position: relative;
  color: var(--muted);
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: white;
}

.multi-select {
  position: relative;
}

.multi-select-toggle {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 43px;
  padding: 10px 11px;
  color: var(--text);
  text-align: left;
  background: white;
}

.multi-select-toggle span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-arrow {
  color: var(--muted);
  font-size: 16px;
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  max-height: 240px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(16, 24, 40, 0.14);
}

.multi-select-menu.hidden {
  display: none;
}

.multi-option {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 9px 8px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.multi-option:hover {
  background: #f2f4f7;
}

.multi-option.disabled {
  color: var(--muted);
  cursor: default;
}

.multi-option input {
  width: auto;
}

.checkbox-row {
  display: flex;
  gap: 9px;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.required {
  color: var(--danger);
  font-weight: 700;
}

.required-note {
  align-self: center;
  color: var(--muted);
  font-size: 14px;
}

.result,
.notice {
  margin-top: 16px;
  padding: 14px 16px;
  white-space: pre-wrap;
}

.notice {
  margin-bottom: 18px;
}

.hidden {
  display: none;
}

.list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.item {
  padding: 16px;
}

.item-head,
.section-heading,
.user-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.request-title {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: center;
}

.request-title strong {
  overflow-wrap: anywhere;
}

.request-checkbox {
  width: auto;
  flex: 0 0 auto;
}

.user-bar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.danger {
  color: var(--danger);
  border-color: #f3b4ae;
}

.strong-action {
  background: #fff7f6;
}

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

.meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

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

.log-meta span {
  overflow-wrap: anywhere;
}

.item-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--danger);
  background: #fff7f6;
  font-size: 14px;
  line-height: 1.6;
}

.status-pill {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #f2f4f7;
  font-size: 13px;
}

.status-pill.pending {
  color: #92400e;
  background: #fffbeb;
}

.status-pill.approved {
  color: var(--success);
  background: var(--soft-green);
}

.status-pill.rejected {
  color: var(--danger);
  background: #fff7f6;
}

.status-pill.stopped {
  color: #475467;
  background: #eef2f6;
}

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
}

.bulk-bar.hidden {
  display: none;
}

.helper {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.compact-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.key-box {
  margin-top: 10px;
  padding: 12px;
  border-radius: 6px;
  background: #f2f4f7;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  word-break: break-all;
}

.empty-state {
  display: grid;
  gap: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.42);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.22);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin-bottom: 6px;
}

.modal-head p {
  line-height: 1.65;
  white-space: normal;
  overflow-wrap: anywhere;
}

.confirm-panel {
  display: grid;
  gap: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.profile-panel {
  display: grid;
  gap: 16px;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.login-page {
  min-height: 100vh;
  overflow-x: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 70%, rgba(232, 241, 255, 0.88) 100%),
    radial-gradient(circle at 7% 11%, rgba(45, 126, 255, 0.14), transparent 26%),
    radial-gradient(circle at 92% 11%, rgba(72, 144, 255, 0.12), transparent 24%),
    linear-gradient(115deg, #f7fbff 0%, #eef6ff 48%, #f9fcff 100%);
}

.login-page::before,
.login-page::after {
  content: "";
  position: fixed;
  pointer-events: none;
  opacity: 0.4;
}

.login-page::before {
  left: 0;
  bottom: 74px;
  width: 420px;
  height: 190px;
  background:
    linear-gradient(160deg, transparent 42%, rgba(40, 118, 224, 0.16) 43%, rgba(40, 118, 224, 0.16) 45%, transparent 46%) 14px 10px / 90px 150px no-repeat,
    linear-gradient(to top, transparent 54%, rgba(40, 118, 224, 0.16) 55%, rgba(40, 118, 224, 0.16) 57%, transparent 58%) 150px 60px / 210px 84px no-repeat,
    repeating-linear-gradient(to right, transparent 0 26px, rgba(40, 118, 224, 0.12) 27px 29px, transparent 30px 56px) 165px 70px / 180px 70px no-repeat;
}

.login-page::after {
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(45, 126, 255, 0.18) 0 3px, transparent 4px),
    linear-gradient(130deg, transparent 0 96%, rgba(45, 126, 255, 0.14) 96.3%, transparent 97%);
  background-size: 120px 120px, 180px 180px;
}

.login-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(470px, 1fr) minmax(360px, 420px);
  gap: 52px;
  align-items: center;
  align-self: center;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 44px 36px;
}

.login-story {
  display: grid;
  gap: 34px;
}

.login-brand {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.brand-mark {
  width: 58px;
  height: 66px;
  color: #1565d8;
}

.brand-mark svg,
.flow-icon svg,
.login-card-title svg,
.login-input svg,
.password-toggle svg,
.login-note svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-brand h1 {
  color: #0f172a;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-brand p {
  margin-top: 12px;
  color: #5f6f85;
  font-size: 15px;
  line-height: 1.55;
}

.flow-section {
  display: grid;
  gap: 18px;
}

.flow-section h2 {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0;
  color: #111827;
  font-size: 18px;
}

.flow-section h2 span {
  width: 4px;
  height: 22px;
  border-radius: 999px;
  background: #2478f2;
}

.flow-list {
  display: grid;
  gap: 24px;
  max-width: 520px;
}

.flow-card {
  position: relative;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  min-height: 88px;
  padding: 13px 24px 13px 18px;
  border: 1px solid rgba(197, 213, 236, 0.7);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 44px rgba(34, 78, 137, 0.09);
}

.flow-card:not(:last-child)::after {
  content: "↓";
  position: absolute;
  left: 50%;
  bottom: -24px;
  color: #2d7eff;
  font-size: 21px;
  line-height: 1;
  transform: translateX(-50%);
}

.flow-icon {
  width: 70px;
  height: 60px;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 10px;
  color: #1268d8;
  background: linear-gradient(135deg, #f3f8ff, #eaf2ff);
}

.flow-card h3 {
  margin: 0 0 8px;
  color: #111827;
  font-size: 17px;
}

.flow-card p {
  color: #617089;
  font-size: 13px;
  line-height: 1.6;
}

.flow-card strong {
  color: #e7effc;
  font-size: 28px;
  line-height: 1;
}

.login-card {
  display: grid;
  gap: 22px;
  margin-top: 0;
  padding: 44px 38px 36px;
  border: 1px solid rgba(197, 213, 236, 0.82);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 72px rgba(32, 75, 125, 0.14);
}

.login-card-title {
  display: flex;
  gap: 13px;
  align-items: center;
  color: #1268d8;
}

.login-card-title svg {
  width: 36px;
  height: 36px;
  fill: #1268d8;
  stroke-width: 0;
}

.login-card-title h2 {
  margin: 0;
  color: #111827;
  font-size: 21px;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label {
  gap: 8px;
  color: #1f2937;
  font-size: 13px;
}

.login-input {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid #d5deea;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: inset 0 0 0 1px rgba(220, 229, 241, 0.45);
}

.login-input svg {
  color: #8c9ab0;
  stroke-width: 1.9;
}

.login-input input {
  border: 0;
  padding: 0;
  color: #111827;
  background: transparent;
  font-size: 13px;
  outline: 0;
}

.login-input input::placeholder {
  color: #a7b2c2;
}

.password-toggle {
  width: 26px;
  height: 26px;
  padding: 5px;
  border: 0;
  color: #8c9ab0;
  background: transparent;
}

.password-toggle:hover {
  border: 0;
  color: var(--primary);
}

.login-submit {
  width: 100%;
  min-height: 50px;
  margin-top: 4px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2d7eff, #1762e8);
  border-color: #1762e8;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(23, 98, 232, 0.24);
}

.login-error {
  padding: 14px 16px;
  border: 1px solid #f3b4ae;
  border-radius: 8px;
  color: var(--danger);
  background: #fff7f6;
}

.login-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  color: #8a97aa;
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  background: #dce4ef;
}

.login-note {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 13px 16px;
  border-radius: 10px;
  color: #52657f;
  background: #f0f5ff;
}

.login-note svg {
  color: #2478f2;
  stroke-width: 2.2;
}

.login-note ul {
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.8;
}

.login-note strong {
  color: #2478f2;
}

.login-apply-link {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: center;
  min-height: 50px;
  border-top: 1px solid rgba(197, 213, 236, 0.78);
  color: #4f6077;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.48);
}

.login-apply-link a {
  color: #1762e8;
  font-weight: 700;
  text-decoration: none;
}

.login-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 12px;
  border-top: 1px solid rgba(223, 231, 242, 0.88);
  color: #8a97aa;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.setup-shell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 48px 18px;
}

.setup-card {
  display: grid;
  gap: 26px;
  width: min(520px, 100%);
  padding: 40px;
  border: 1px solid rgba(197, 213, 236, 0.82);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 72px rgba(32, 75, 125, 0.14);
}

.setup-brand {
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 18px;
}

.setup-brand .brand-mark {
  width: 54px;
  height: 62px;
}

.setup-brand h1 {
  font-size: 24px;
}

.setup-brand p {
  margin-top: 10px;
  font-size: 14px;
}

code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #f2f4f7;
  color: #344054;
}

@media (max-width: 760px) {
  .topbar,
  .section-heading,
  .item-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    padding: 16px;
  }

  .form-grid,
  .compact-form,
  .meta,
  .log-meta,
  .helper {
    grid-template-columns: 1fr;
  }

  .login-shell {
    grid-template-columns: 1fr;
    align-items: start;
    align-self: start;
    gap: 28px;
    padding: 36px 16px 32px;
  }

  .login-story {
    gap: 28px;
  }

  .login-brand {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 16px;
  }

  .brand-mark {
    width: 56px;
    height: 64px;
  }

  .login-brand h1 {
    font-size: 24px;
  }

  .login-brand p {
    margin-top: 10px;
    font-size: 15px;
  }

  .flow-list {
    gap: 22px;
  }

  .flow-card {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 16px;
    min-height: 104px;
    padding: 16px;
  }

  .flow-card:not(:last-child)::after {
    display: none;
  }

  .flow-icon {
    width: 72px;
    height: 66px;
    padding: 15px;
  }

  .flow-card h3 {
    font-size: 19px;
  }

  .flow-card p {
    font-size: 14px;
  }

  .flow-card strong {
    display: none;
  }

  .login-card {
    padding: 28px 18px;
  }

  .login-card-title h2 {
    font-size: 24px;
  }

  .login-input {
    min-height: 58px;
  }

  .login-submit {
    min-height: 58px;
    font-size: 18px;
  }

  .login-apply-link {
    flex-direction: column;
    gap: 8px;
    min-height: 88px;
    font-size: 16px;
  }

  .setup-shell {
    padding: 28px 16px;
  }

  .setup-card {
    padding: 26px 18px;
  }

  .setup-brand {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .setup-brand h1 {
    font-size: 22px;
  }
}

/* Grants and usage workspace */
.section-note { margin: 0 0 16px; line-height: 1.7; }
.section-title { margin-top: 28px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 20px 0; }
.stat-card { display: grid; gap: 12px; padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.stat-card > span { color: var(--muted); font-size: 14px; }
.stat-card > strong { font-size: 26px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart { width: 100%; height: 280px; }
.chart-empty { display: grid; place-items: center; height: 280px; color: var(--muted); background: #f9fafb; border-radius: 6px; }
.chart-empty.hidden { display: none; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 20px 0; color: var(--muted); font-size: 14px; }
.key-box { overflow-wrap: anywhere; white-space: pre-wrap; padding: 14px; background: #f2f4f7; border: 1px solid var(--line); border-radius: 6px; font-family: ui-monospace, monospace; }
.conversation { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.conversation details { margin: 12px 0; }
.conversation summary { cursor: pointer; color: var(--primary); padding: 8px 0; }
.conversation pre { margin: 8px 0; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 540px; overflow: auto; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.75; }
.download-link { display: inline-block; margin-left: 12px; color: var(--primary); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #84adff; outline-offset: 3px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .chart-grid { grid-template-columns: 1fr; } .stat-card { padding: 16px; } .stat-card > strong { font-size: 22px; } .pager { gap: 10px; flex-wrap: wrap; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
