
:root {
  color: #31356b;
  background: #eef1f5;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  --fpbs-ink: #31356b;
  --fpbs-primary: #9fa1ff;
  --fpbs-surface: #f6f8ff;
  --fpbs-line: #d9e0ff;
  --fpbs-muted: #68709f;
  --fpbs-danger: #d64b73;
  --fpbs-bg: #eef1f5;
}

html {
  color-scheme: light;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--fpbs-bg);
  color: var(--fpbs-ink);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

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

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

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--fpbs-line);
  background: #fff;
  color: var(--fpbs-ink);
  padding: 0 1rem;
}

textarea {
  padding: 0.75rem 1rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(159, 161, 255, 0.28);
  outline-offset: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 0.5rem;
  min-height: 100vh;
  padding: 0.5rem;
  transition: grid-template-columns 160ms ease;
}

.app-shell.is-collapsed {
  grid-template-columns: 4.5rem minmax(0, 1fr);
}

.auth-shell {
  min-height: 100vh;
  padding: 0.5rem;
}

.auth-shell-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 1rem);
}

.auth-card {
  width: min(calc(100vw - 1rem), 37.5rem);
  border: 1px solid var(--fpbs-line);
  background: #fff;
  padding: 2rem 1.6rem 1.8rem;
}

.auth-brand {
  display: flex;
  justify-content: center;
}

.auth-logo {
  display: block;
  width: auto;
  height: 4.5rem;
  object-fit: contain;
}

.auth-copy {
  margin-top: 1rem;
  text-align: center;
}

.auth-copy h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.15;
}

.auth-copy p {
  margin: 0.5rem 0 0;
  color: var(--fpbs-muted);
  font-size: 0.98rem;
}

.auth-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  margin-top: 1.4rem;
  color: var(--fpbs-muted);
  font-weight: 600;
}

.auth-spinner {
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid rgba(49, 53, 107, 0.18);
  border-top-color: var(--fpbs-ink);
  border-radius: 999px !important;
  animation: auth-spin 0.9s linear infinite;
}

.login-form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.5rem;
}

.login-form .field {
  gap: 0.35rem;
  font-size: 0.96rem;
}

.login-form .field span {
  color: var(--fpbs-ink);
}

.login-form .field input {
  height: 3.1rem;
  background: rgba(217, 224, 255, 0.38);
  padding: 0 0.95rem;
}

.login-error {
  border: 1px solid #f0ccd7;
  background: #fff3f6;
  color: #b33e64;
  padding: 0.8rem 0.95rem;
  font-weight: 600;
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 3rem;
  border: 1px solid var(--fpbs-ink);
  background: #41447f;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--fpbs-line);
  background: #fff;
  min-height: calc(100vh - 1rem);
  padding: 0.75rem;
  transition: padding 160ms ease;
}

.sidebar.is-collapsed {
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

.brand {
  display: flex;
  flex-direction: column;
  padding-bottom: 0.75rem;
}

.brand-logo {
  display: block;
  width: auto;
  height: 2.5rem;
  object-fit: contain;
  margin-bottom: 0.7rem;
}

.brand-eyebrow,
.section-kicker {
  margin: 0 0 0.25rem;
  color: var(--fpbs-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.brand h1,
.section-head h2,
.modal-head h3 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.2;
}

.sidebar.is-collapsed .brand-copy,
.sidebar.is-collapsed .sidebar-text {
  display: none;
}

.sidebar.is-collapsed .brand-logo {
  display: none;
}

.side-nav {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.side-link,
.side-footer-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.25rem;
  border: 0;
  background: #fff;
  color: var(--fpbs-ink);
  padding: 0 0.7rem;
  font-size: 0.97rem;
  font-weight: 600;
  text-align: left;
}

.side-link:hover,
.side-footer-link:hover:not(:disabled) {
  background: var(--fpbs-surface);
}

.nav-icon,
.button-icon,
.search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.nav-icon svg,
.button-icon svg,
.search-icon svg,
.square-action svg {
  width: 1rem;
  height: 1rem;
}

.side-link.is-active {
  background: var(--fpbs-ink);
  color: #fff;
}

.side-footer {
  margin-top: auto;
  display: grid;
  gap: 0.35rem;
  padding-top: 1rem;
}

.sidebar.is-collapsed .side-link,
.sidebar.is-collapsed .side-footer-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.main-shell {
  min-width: 0;
}

.content-card {
  height: calc(100vh - 1rem);
  border: 1px solid var(--fpbs-line);
  background: #fff;
}

.scroll-shell {
  height: 100%;
  overflow-y: auto;
}

.content-stack {
  display: grid;
  gap: 0;
}

.content-pad {
  padding: 0.75rem;
}

.page-section {
  display: grid;
  gap: 0.75rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat-box {
  border: 1px solid var(--fpbs-line);
  background: #fff;
  padding: 0.95rem 1rem;
}

.stat-label {
  display: block;
  color: var(--fpbs-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-box strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1rem;
}

.section-block {
  display: grid;
  gap: 0.7rem;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: 2.8fr 1.8fr 1.6fr 1.7fr;
  gap: 0.45rem;
  align-items: end;
}

.toolbar-field {
  display: grid;
  gap: 0.15rem;
  font-size: 0.84rem;
}

.toolbar-field span,
.field span {
  color: var(--fpbs-muted);
}

.toolbar-fill {
  min-width: 0;
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 0.7rem;
}

.search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fpbs-muted);
  pointer-events: none;
}

.month-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.25rem;
  gap: 0.35rem;
}

.toolbar-chip {
  display: flex;
  align-items: center;
  height: 3.05rem;
  border: 1px solid var(--fpbs-line);
  background: rgba(246, 248, 255, 0.55);
  padding: 0 1rem;
  color: var(--fpbs-ink);
}

.toolbar-field input,
.toolbar-field select {
  height: 2.2rem;
  padding: 0 0.7rem;
}

.toolbar-search {
  min-width: 0;
}

.toolbar-action {
  justify-self: end;
  width: auto;
  min-width: 0;
}

.toolbar-action-group {
  grid-column: 4;
  display: inline-flex;
  justify-self: end;
  gap: 0.35rem;
}

.toolbar-action-secondary {
  min-width: 0;
}

.primary-action,
.secondary-action,
.ghost-action,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.2rem;
  border: 1px solid var(--fpbs-line);
  padding: 0 0.75rem;
  font-weight: 700;
}

.primary-action {
  background: var(--fpbs-primary);
  color: var(--fpbs-ink);
}

.secondary-action,
.ghost-action,
.icon-button {
  background: #fff;
  color: var(--fpbs-ink);
}

.text-right {
  text-align: right !important;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--fpbs-line);
}

.data-table {
  width: 100%;
  min-width: 64rem;
  border-collapse: collapse;
}

.data-table thead {
  background: rgba(246, 248, 255, 0.75);
}

.data-table th,
.data-table td {
  border-bottom: 1px solid rgba(217, 224, 255, 0.9);
  padding: 0.85rem 0.95rem;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--fpbs-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.data-table td {
  font-size: 0.98rem;
}

.empty-cell,
.detail-placeholder {
  padding: 2rem 1rem !important;
  color: var(--fpbs-muted);
  text-align: center;
  font-weight: 600;
}

.detail-placeholder.detail-error,
.flash.flash-error {
  color: #b33e64;
}

.flash {
  margin: 1rem 1rem 0;
  border: 1px solid transparent;
  padding: 0.9rem 1rem;
  font-weight: 700;
}

.flash-success {
  border-color: #cde8d6;
  background: #eefcf2;
  color: #307845;
}

.flash-error {
  border-color: #f0ccd7;
  background: #fff3f6;
}

.action-stack {
  display: inline-flex;
  gap: 0.4rem;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.square-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.55rem;
  height: 2.55rem;
  border: 1px solid var(--fpbs-line);
  background: #fff;
  color: var(--fpbs-ink);
  font-weight: 700;
}

.square-action-folder {
  border-color: #c7ddd0;
  color: #1f5c3f;
  background: #f7fcf9;
}

.square-action-edit {
  border-color: #f4d2bf;
  color: #c66a2f;
  background: #fff9f4;
}

.square-action-danger {
  border-color: #f2ccd6;
  color: var(--fpbs-danger);
  background: #fff8fa;
}

.data-table .cell-date {
  white-space: nowrap;
}

.data-table .cell-summary {
  max-width: 34rem;
}

.detail-card {
  display: grid;
  gap: 0.7rem;
}

.detail-summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: start;
}

.detail-summary-card {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--fpbs-line);
  background: rgba(246, 248, 255, 0.8);
  padding: 0.32rem 0.55rem;
}

.detail-summary-card span {
  color: var(--fpbs-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail-summary-card strong {
  font-size: 0.88rem;
}

.detail-item-form {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
  border: 1px solid var(--fpbs-line);
  padding: 0.6rem;
  background: rgba(246, 248, 255, 0.28);
}

.detail-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.detail-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.detail-head-compact {
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.detail-head-compact h2,
.detail-table-head h2 {
  font-size: 1rem;
}

.detail-head-compact h2 {
  text-align: left;
}

.detail-back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2rem;
  border: 0;
  background: transparent;
  color: var(--fpbs-ink);
  padding: 0;
  font-weight: 700;
}

.detail-modal-card {
  width: min(calc(100vw - 1.2rem), 71.875rem);
}

.import-modal-card {
  width: min(calc(100vw - 1.2rem), 71.875rem);
}

.import-actions-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.45rem;
  align-items: end;
}

.import-file-field input[type="file"] {
  height: auto;
  padding: 0.45rem 0.65rem;
}

.import-helper {
  color: var(--fpbs-muted);
  font-size: 0.86rem;
}

.import-empty {
  border: 1px solid var(--fpbs-line);
  padding: 0.8rem;
  color: var(--fpbs-muted);
  font-weight: 600;
}

.import-preview-table,
.import-error-table {
  min-width: 100%;
}

.detail-table-head {
  align-items: center;
}

.detail-add-button {
  min-height: 2.2rem;
  padding: 0 0.75rem;
}

.detail-item-form .field {
  gap: 0.15rem;
}

.detail-item-form .field input,
.detail-item-form .field select {
  height: 2.1rem;
  padding: 0 0.6rem;
}

.detail-item-form .ghost-action,
.detail-item-form .primary-action {
  min-height: 2.2rem;
  padding: 0 0.75rem;
}

.checkbox-inline {
  align-items: center;
}

.checkbox-inline input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.detail-status-valid {
  color: #2f7b48;
}

.detail-status-invalid {
  color: #b33e64;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.detail-meta-grid > div {
  border: 1px solid var(--fpbs-line);
  padding: 0.8rem 0.9rem;
  background: rgba(246, 248, 255, 0.45);
}

.detail-meta-grid span {
  display: block;
  color: var(--fpbs-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail-meta-grid strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.98rem;
}

.detail-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.detail-total {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  background: rgba(16, 24, 40, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 2.5rem 0.6rem 0.6rem;
}

.modal-card {
  width: min(calc(100vw - 1.2rem), 71.875rem);
  border: 1px solid var(--fpbs-line);
  background: #fff;
  padding: 0.75rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.modal-form {
  display: grid;
  gap: 0.4rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.field {
  display: grid;
  gap: 0.15rem;
  font-size: 0.88rem;
}

.field input,
.field select {
  height: 2.2rem;
  padding: 0 0.65rem;
}

.field textarea {
  min-height: 7rem;
  padding: 0.55rem 0.65rem;
  resize: vertical;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--fpbs-ink);
}

.helper-text {
  margin: 0.2rem 0 0;
  color: var(--fpbs-muted);
}

.item-rows {
  display: grid;
  gap: 0.45rem;
}

.item-row {
  border: 1px solid var(--fpbs-line);
  padding: 0.55rem;
  background: #fff;
}

.item-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
}

.checkbox-field input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.1rem;
}

.modal-close {
  width: 2.25rem;
  min-width: 2.25rem;
  padding: 0;
  color: var(--fpbs-danger);
  border-color: #f2ccd6;
  background: #fff8fa;
}

.modal-form .row-remove {
  min-height: 2.25rem;
  padding: 0 0.75rem;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(116, 121, 223, 0.32);
}

::-webkit-scrollbar-track {
  background: transparent;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .toolbar-grid {
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
  }

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

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

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

  .sidebar {
    min-height: auto;
  }

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

  .toolbar-action {
    grid-column: auto;
    justify-self: stretch;
    width: 100%;
  }

  .toolbar-action-group {
    grid-column: auto;
    justify-self: stretch;
    display: grid;
  }

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

  .import-actions-top {
    grid-template-columns: 1fr;
  }

  .dashboard-grid,
  .item-grid,
  .detail-meta-grid,
  .detail-form-grid {
    grid-template-columns: 1fr;
  }

  .content-card {
    height: auto;
  }

  .item-row-head,
  .detail-headline,
  .section-head {
    flex-direction: column;
  }
}
