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

html,
body,
#app {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
}

:root {
  color-scheme: light;

  --color-primary: #509C06;
  --color-primary-hover: #5fb008;
  --color-primary-pressed: #3f7b05;
  --color-primary-suppl: #6cc60a;

  --color-background: #FFFFFF;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F7F7F7;

  --color-text: #1F2937;
  --color-text-muted: #6B7280;
  --color-text-disabled: #9CA3AF;

  --color-border: #D7E2E6;
  --color-divider: #E5E7EB;

  --card-radius: 8px;
  --card-shadow:
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 10px 15px -5px rgba(0, 0, 0, 0.05),
    0 7px 7px -5px rgba(0, 0, 0, 0.04);
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --color-background: #18181C;
  --color-surface: #1F2128;
  --color-surface-alt: #262931;

  --color-text: #E5E7EB;
  --color-text-muted: #9CA3AF;
  --color-text-disabled: #4B5563;

  --color-border: #2C3038;
  --color-divider: #2C3038;

  --card-shadow:
    0 1px 3px rgba(0, 0, 0, 0.4),
    0 10px 15px -5px rgba(0, 0, 0, 0.3),
    0 7px 7px -5px rgba(0, 0, 0, 0.25);
}

:root[data-palette='blue'] {
  --color-primary: #2563eb;
  --color-primary-hover: #3b82f6;
  --color-primary-pressed: #1d4ed8;
  --color-primary-suppl: #60a5fa;
}

:root[data-palette='purple'] {
  --color-primary: #7c3aed;
  --color-primary-hover: #8b5cf6;
  --color-primary-pressed: #6d28d9;
  --color-primary-suppl: #a78bfa;
}

:root[data-palette='teal'] {
  --color-primary: #0891b2;
  --color-primary-hover: #06b6d4;
  --color-primary-pressed: #0e7490;
  --color-primary-suppl: #22d3ee;
}

:root[data-palette='red'] {
  --color-primary: #dc2626;
  --color-primary-hover: #ef4444;
  --color-primary-pressed: #b91c1c;
  --color-primary-suppl: #f87171;
}

.pane-card {
  height: 100%;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.pane-card > .n-card-content {
  height: 100%;
  padding: 0;
  box-sizing: border-box;
  overflow: auto;
  padding-top: 0 !important;
}
.n-form-item.n-form-item--top-labelled:has(input),
.n-form-item.n-form-item--top-labelled:has(textarea),
.n-form-item.n-form-item--top-labelled:has(.n-base-selection) {
  position: relative;
  grid-template-rows: 0 34px 0;
  .n-input-number {
    width: 100%;
  }
  .n-form-item-label {
    position: absolute;
    top: -0.5rem;
    left: 0.4rem;
    grid-area: blank;
    z-index: 10;
    .n-form-item-label__text {
      font-size: 0.75rem;
      padding: 0 4px;
      background: linear-gradient(to bottom, var(--color-surface) 50%, transparent 100%);
    }
  }
}
.n-form-item.n-form-item--top-labelled:has(textarea) {
  grid-template-rows: 0 80px 0;
}

.cbp-caret {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  color: var(--color-text-muted);
  transition: color 0.15s ease, background 0.15s ease;
}
.cbp-caret:hover {
  color: var(--color-text);
  background: var(--color-border);
}
.grid-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 0.75rem;
  margin-top: 0.5rem;

  .grid {
    flex: 1;
    min-height: 0;
  }
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;

  .search-slot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;

    .grid-search {
      flex: none;
    }

    .fp,
    .fp__favs {
      display: contents;
    }

    .drp {
      order: 1;
      margin-left: auto;
    }
  }

  @media (max-width: 48rem) {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-top: 0.5rem;
    flex-direction: column;

    .search-slot {
      width: 100%;
      gap: 0.25rem;

      .drp {
        order: -1;
        margin-left: 0;
        width: 100%;
      }

      .grid-search {
        flex: 1;
        min-width: 0;
      }
    }

    .drp .drp__group,
    .drp .n-date-picker {
      width: 100%;
    }

    .fp__fav-wrapper {
      flex-grow: 1;

      .n-button {
        width: 100%;
      }
    }

    .create-button {
      width: 100%;
    }
  }
}

.table-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 0.75rem;

  .grid {
    flex: 1;
    min-height: 0;
  }
}

.cell-center {
  display: flex;
  align-items: center;
  height: 100%;
}

.text-link {
  cursor: pointer;
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.125rem;
}
.text-link:hover {
  opacity: 0.8;
}

.section-divider {
  margin: 0.5rem 0;
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);

  &--spaced {
    margin-top: 0.625rem;
  }
}

.muted {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.text-block {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text);
  white-space: pre-wrap;
}

.field-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-row {
  display: grid;
  grid-template-columns: 50% 1fr;
  align-items: baseline;
  gap: 0.25rem;
  font-size: 0.8125rem;

  .field-label {
    color: var(--color-text-muted);
    white-space: nowrap;
    text-transform: uppercase;
    min-width: 8.125rem;
    font-size: 0.6875rem;
  }

  .field-value {
    color: var(--color-text);
    display: flex;
    align-items: center;

    .bool-yes {
      color: var(--color-success, #22c55e);
    }

    .bool-no {
      color: var(--color-error, #ef4444);
    }
  }
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.field-header {
  font-weight: bold;
}

.field-block {
  display: flex;
  flex-direction: column;
  font-size: 0.8125rem;

  .field-label {
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
  }

  .field-value {
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.375rem;

    .bool-yes {
      color: var(--color-success, #22c55e);
    }

    .bool-no {
      color: var(--color-error, #ef4444);
    }
  }
}

.field-block-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;

  .field-block-actions {
    display: flex;
    gap: 0.125rem;
    flex-shrink: 0;
  }
}

.details-panel {
  height: 100%;

  .details-split {
    height: 100%;
  }

  .details-content {
    position: relative;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .title-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--color-surface-alt);
    padding-bottom: 0.5rem;

    .title {
      margin: 0;
      font-size: 1rem;
      font-weight: 600;
    }

    .title-actions {
      margin-left: auto;
    }

    .right-actions {
      margin-left: auto;
    }
    .close-btn {
      margin-left: auto;
    }
  }

  .cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    gap: 0.75rem;
    align-items: start;
    hr {
      border-top: 0;
      border-bottom: 1px solid var(--color-border);
      width: 100%;
    }
  }

  .bottom-tabs {
    display: flex;
    flex-direction: column;
    height: 100%;

    .n-tabs-nav {
      flex-shrink: 0;
    }

    .n-tab-pane {
      flex: 1;
      min-height: 0;
      padding: 0;
      height: 100%;
    }
  }
}
.card-header-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.widget-card {
  background-color: color-mix(in srgb, var(--color-primary, #06309c) 10%, transparent);

  .widget-header {
    text-transform: uppercase;
    font-size: 0.8rem;
    font-weight: 600;
  }

  .widget-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .widget-container {
    display: flex;
    gap: 0.25rem;

    .widget-value,
    .widget-label {
      font-size: 1.1rem;
    }

    .widget-value {
      color: var(--color-primary);
    }
  }
}
