/* LAFI design tokens - pārnesti no claude.ai/design handoff bundle.
   Vienīgais dizaina pirmavots. Bez magic hex inline stilos, bez Tailwind. */

:root {
  /* Brand greens */
  --brand-50:  #e8f5eb;
  --brand-100: #c6e6cd;
  --brand-200: #9fd4ab;
  --brand-300: #77c188;
  --brand-400: #58b26e;
  --brand-500: #2f8550;
  --brand-600: #297748;
  --brand-700: #22663e;
  --brand-800: #1c5634;
  --brand-900: #1a3b28;
  --brand-950: #0f2619;

  /* Surfaces */
  --surface-ground:    #ecece3;
  --app-chrome-bg:     #ffffff;
  --app-card-bg:       #f0f0e9;
  --app-card-bg-alt:   #eaeae2;
  --app-card-bg-hover: #e5e5dc;
  --surface-card:      #ffffff;

  /* Topbar */
  --topbar-bg:           #1a3431;
  --topbar-border:       #15292a;
  --topbar-fg:           #ffffff;
  --topbar-action-hover: rgba(255, 255, 255, 0.1);
  --topbar-height:       4rem;

  /* Type / structure */
  --text-color:           #1f2937;
  --text-color-secondary: #6b7280;
  --text-color-tertiary:  #9ca3af;
  --border-subtle:        #e5e7eb;
  --border-strong:        #d1d5db;
  --content-radius:       6px;

  /* Status */
  --error-bg:     #fef2f2;
  --error-border: #dc2626;
  --error-fg:     #7f1d1d;
  --warn-bg:      #fffbeb;
  --warn-border:  #d97706;
  --warn-fg:      #78350f;

  /* Density (overridable via data-density on .lafi-app) */
  --density-row-y:    12px;
  --density-cell-y:   10px;
  --density-card-pad: 20px;

  /* Transitions */
  --transition-fast: 0.12s ease;

  /* Focus - the ring every focusable control shares */
  --focus-ring: 0 0 0 3px rgba(47, 133, 80, 0.15);

  /* Elevation - tinted with --topbar-bg (#1a3431), never neutral black */
  --shadow-raised: 0 1px 2px rgba(26, 52, 49, 0.08);
  --shadow-lifted: 0 -2px 8px rgba(26, 52, 49, 0.06);

  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                "Helvetica Neue", Arial, sans-serif;
}

/* data-brand is reserved for future variant tokens; default greens already
   live in :root. data-density flips the row/cell padding wholesale. */
[data-density="compact"] {
  --density-row-y:    6px;
  --density-cell-y:   6px;
  --density-card-pad: 14px;
}
[data-density="comfortable"] {
  --density-row-y:    12px;
  --density-cell-y:   10px;
  --density-card-pad: 20px;
}

/* =========================================================================
   Base
   ========================================================================= */
html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-ground);
}
body {
  font-family: var(--font-stack);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }

a {
  color: var(--brand-700);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--brand-800); }

/* App shell */
.lafi-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-ground);
}

/* =========================================================================
   Topbar
   ========================================================================= */
.lafi-topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  color: var(--topbar-fg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.lafi-topbar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #fff;
  text-decoration: none;
}
.lafi-topbar__logo:hover { color: #fff; }
.lafi-topbar__logo svg { display: block; }
.lafi-topbar__logo-tag {
  font-weight: 500;
  letter-spacing: 0.04em;
}
.lafi-topbar__logo-sep {
  opacity: 0.5;
  margin-left: 4px;
}
.lafi-topbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lafi-topbar__action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--content-radius);
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
  font-size: 13px;
}
.lafi-topbar__action:hover { background: var(--topbar-action-hover); color: #fff; }
.lafi-topbar__email {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  padding: 0 12px;
}
/* Logout is a POST form, but it has to sit in the action row like a button. */
.lafi-topbar__form { margin: 0; }

/* =========================================================================
   Cards
   ========================================================================= */
.lafi-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  padding: var(--density-card-pad);
}
.lafi-card--muted {
  background: var(--app-card-bg);
  border-color: transparent;
}

/* =========================================================================
   File exchange - Excel veidne cenu lapā
   Divi soļi vienā kartītē: lejupielādē sarakstu, augšupielādē aizpildīto.
   Solis = teksts pa kreisi, darbība pa labi; šaurā ekrānā tie salaužas
   viens zem otra, tāpēc poga nekad neizspiež aprakstu no ekrāna.
   ========================================================================= */
.lafi-filedrop {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lafi-filedrop__step {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.lafi-filedrop__step + .lafi-filedrop__step {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}
.lafi-filedrop__text {
  flex: 1 1 320px;
  min-width: 0;
}
.lafi-filedrop__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color);
}
/* Šeit paskaidrojums stāv zem virsraksta, ne virs vadīklas - apakšējā
   atstarpe nāk no soļa `gap`, ne no paša teksta. */
.lafi-filedrop__text .lafi-field__hint {
  margin-bottom: 0;
}
.lafi-filedrop__pick {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.lafi-filedrop__pick input[type="file"] {
  font: inherit;
  font-size: 12px;
  color: var(--text-color-secondary);
  max-width: 260px;
}
/* Pārlūka noklusētā "Choose file" poga ir vienīgā vadīkla lapā, kas
   neizskatās pēc mūsu pogām - tāpēc tā ir pārzīmēta. */
.lafi-filedrop__pick input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 12px;
  margin-right: 10px;
  padding: 7px 12px;
  border-radius: var(--content-radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-card);
  color: var(--text-color);
  cursor: pointer;
}
.lafi-filedrop__pick input[type="file"]::file-selector-button:hover {
  background: var(--app-card-bg-hover);
}

/* =========================================================================
   Buttons
   ========================================================================= */
.lafi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--content-radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
  line-height: 1.2;
  white-space: nowrap;
}
.lafi-btn--primary {
  background: var(--brand-500);
  color: #fff;
}
.lafi-btn--primary:hover { background: var(--brand-600); color: #fff; }
.lafi-btn--primary:active { background: var(--brand-700); }
.lafi-btn--primary:disabled,
.lafi-btn--primary[disabled] { background: var(--border-strong); color: #fff; cursor: not-allowed; }

.lafi-btn--secondary {
  background: #fff;
  color: var(--brand-700);
  border-color: var(--border-strong);
}
.lafi-btn--secondary:hover {
  background: var(--app-card-bg);
  border-color: var(--brand-500);
  color: var(--brand-700);
}

.lafi-btn--teal {
  background: var(--topbar-bg);
  color: #fff;
  border: 1px solid var(--topbar-bg);
}
.lafi-btn--teal:hover { background: #244641; color: #fff; }

.lafi-btn--lg { padding: 11px 20px; font-size: 14px; }
.lafi-btn--block { width: 100%; }

/* =========================================================================
   Form fields
   ========================================================================= */
.lafi-field { display: flex; flex-direction: column; gap: 5px; }
.lafi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-color-secondary);
}
/* Explanatory line between a label and its control. */
.lafi-field__hint {
  font-size: 12px;
  color: var(--text-color-secondary);
  margin: 2px 0 8px;
}
.lafi-input,
.lafi-textarea {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text-color);
  border: 1px solid var(--border-strong);
  border-radius: var(--content-radius);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.lafi-input:hover,
.lafi-textarea:hover { border-color: var(--brand-300); }
.lafi-input:focus,
.lafi-textarea:focus {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}

.lafi-input--lg {
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
}
.lafi-textarea {
  resize: vertical;
  min-height: 72px;
}

/* =========================================================================
   Messages / banners
   ========================================================================= */
.lafi-msg {
  border-radius: var(--content-radius);
  padding: 12px 16px;
  font-size: 13px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.lafi-msg__icon {
  flex-shrink: 0;
  margin-top: 2px;
}
.lafi-msg__body { flex: 1; }
.lafi-msg__title {
  font-weight: 600;
  margin: 0 0 2px;
}
.lafi-msg__list {
  margin: 4px 0 0;
  padding-left: 18px;
}
/* Django messages stack at the top of the page column. */
.lafi-messages { margin-bottom: 16px; }
.lafi-messages > * + * { margin-top: 8px; }
.lafi-msg--error   { background: var(--error-bg); border-color: var(--error-border); color: var(--error-fg); }
.lafi-msg--warn    { background: var(--warn-bg);  border-color: var(--warn-border);  color: var(--warn-fg); }
.lafi-msg--success { background: var(--brand-50); border-color: var(--brand-500);    color: var(--brand-900); }
.lafi-msg--info    { background: #fff; border-color: var(--border-strong); color: var(--text-color); }

/* =========================================================================
   Status badges
   ========================================================================= */
.lafi-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.lafi-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.lafi-badge--new      { background: var(--brand-50);    color: var(--brand-700);             border-color: var(--brand-200); }
.lafi-badge--viewed   { background: var(--app-card-bg); color: var(--text-color-secondary);  border-color: var(--border-subtle); }
.lafi-badge--answered { background: var(--brand-500);   color: #fff; }
.lafi-badge--closed   { background: #f3f4f6;            color: var(--text-color-tertiary);   border-color: var(--border-subtle); }

/* Tag (compact pill, neutral) */

/* =========================================================================
   Page chrome
   ========================================================================= */
.lafi-page {
  flex: 1;
  padding: 28px 32px 60px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

.lafi-page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.lafi-h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-color);
}
.lafi-page__sub {
  margin: 0;
  color: var(--text-color-secondary);
  font-size: 14px;
}

/* Breadcrumbs */
.lafi-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-color-secondary);
  margin-bottom: 10px;
}
.lafi-crumbs svg { color: var(--text-color-tertiary); flex-shrink: 0; }
.lafi-crumbs__current { color: var(--text-color); }

/* Progress bar - shared by anything that reports "N of M done" */
.lafi-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--app-card-bg-hover);
  overflow: hidden;
}
.lafi-progress__bar {
  height: 100%;
  background: var(--brand-500);
  border-radius: 999px;
  transition: width 0.25s;
}

/* =========================================================================
   Tab group - filters as segments in one rounded track. The active segment
   is a raised white pill, so the track reads as one control, not as five
   loose buttons.
   ========================================================================= */
.lafi-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--app-card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}
/* Works on both <a> (dashboard, one URL per filter) and <button> (price
   grid, client-side filter) -- hence the button reset, without which the
   UA border and background leak through and the track falls apart. */
.lafi-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--text-color-secondary);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.lafi-tab:hover { color: var(--text-color); }
.lafi-tab--active {
  background: var(--surface-card);
  color: var(--brand-700);
  font-weight: 600;
  box-shadow: var(--shadow-raised);
}
.lafi-tab--active:hover { color: var(--brand-700); }
.lafi-tab__n {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--app-card-bg-hover);
  color: var(--text-color-secondary);
}
.lafi-tab--active .lafi-tab__n {
  background: var(--brand-500);
  color: #fff;
}

/* =========================================================================
   Search
   ========================================================================= */
.lafi-search {
  position: relative;
  flex: 1;
  max-width: 360px;
}
.lafi-search input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--content-radius);
  font: inherit;
  font-size: 13px;
  background: #fff;
  outline: none;
}
.lafi-search input:focus {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}
.lafi-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-color-tertiary);
}

/* =========================================================================
   Toolbar - filters + search on one line above a list
   ========================================================================= */
.lafi-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* =========================================================================
   Guide - collapsible "how this works" note. A <details>, so it needs
   no JS and no stored dismissal state.
   ========================================================================= */
.lafi-guide {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.lafi-guide__summary {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  color: var(--text-color);
  cursor: pointer;
  list-style: none;
}
.lafi-guide__summary::-webkit-details-marker { display: none; }
.lafi-guide__summary svg { flex-shrink: 0; color: var(--brand-600); }
.lafi-guide__chev { transition: transform var(--transition-fast); }
.lafi-guide[open] .lafi-guide__chev { transform: rotate(90deg); }
.lafi-guide__steps {
  margin: 10px 0 0;
  padding-left: 41px;
  color: var(--text-color-secondary);
  display: grid;
  gap: 4px;
}
.lafi-guide__steps strong { color: var(--text-color); }

/* =========================================================================
   Contract group + inquiry rows - the dashboard list
   ========================================================================= */
.lafi-group {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  overflow: hidden;
}
.lafi-group + .lafi-group { margin-top: 16px; }
.lafi-group__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  background: var(--app-card-bg);
  border-bottom: 1px solid var(--border-subtle);
}
.lafi-group__title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
}
.lafi-group__title svg {
  flex-shrink: 0;
  color: var(--text-color-secondary);
}
.lafi-group__meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-color-secondary);
  white-space: nowrap;
}

.lafi-inq-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 116px 172px;
  gap: 18px;
  align-items: center;
  padding: var(--density-row-y) 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.lafi-inq-row:last-child { border-bottom: 0; }
.lafi-inq-row:hover { background: var(--app-card-bg); }
.lafi-inq-row__name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
  text-decoration: none;
}
.lafi-inq-row__name:hover { color: var(--brand-700); }
.lafi-inq-row__meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-color-secondary);
}
.lafi-inq-row__due {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-color-secondary);
}
.lafi-inq-row__due b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color);
}
.lafi-inq-row__due--soon b { color: var(--warn-border); }
.lafi-inq-row__due--over b { color: var(--error-border); }
.lafi-inq-row__action { justify-self: end; }

/* Empty state inside a list */
.lafi-empty {
  text-align: center;
  padding: 44px 24px;
  font-size: 13px;
}
.lafi-empty__title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-color);
}

/* =========================================================================
   Focus - everything reachable by Tab has to show it (DESIGN.md §12)
   ========================================================================= */
a:focus-visible,
.lafi-btn:focus-visible,
.lafi-tab:focus-visible,
.lafi-guide__summary:focus-visible,
.lafi-inq-row__name:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--content-radius);
}
/* On the dark topbar a green ring disappears -- use the topbar foreground. */
.lafi-topbar__logo:focus-visible,
.lafi-topbar__action:focus-visible {
  outline: 2px solid var(--topbar-fg);
  outline-offset: 2px;
  border-radius: var(--content-radius);
}

/* =========================================================================
   Sticky action bar
   ========================================================================= */
.lafi-actionbar {
  position: sticky;
  bottom: 0;
  margin-top: 20px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  box-shadow: var(--shadow-lifted);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  z-index: 2;
}
.lafi-actionbar__stat {
  font-size: 12px;
  color: var(--text-color-secondary);
}
.lafi-actionbar__stat b {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-color);
  font-variant-numeric: tabular-nums;
}
.lafi-actionbar__fill {
  width: 130px;
  margin-top: 6px;
}
.lafi-actionbar__spacer { flex: 1; }
.lafi-actionbar__hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-color-secondary);
}

/* =========================================================================
   KBD-style key
   ========================================================================= */

/* =========================================================================
   Section header
   ========================================================================= */

/* =========================================================================
   Stat tiles
   ========================================================================= */

/* =========================================================================
   Utilities
   ========================================================================= */
.lafi-stack > * + * { margin-top: 16px; }

/* One block's worth of space below an element that is not a .lafi-stack
   child -- banners and cards sitting directly in a page column. */
.lafi-stack-gap { margin-bottom: 16px; }

.lafi-mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.lafi-muted { color: var(--text-color-secondary); }
.lafi-faint { color: var(--text-color-tertiary); }
.lafi-trunc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Scroll containers - clean scrollbars */
.lafi-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.lafi-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.lafi-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* =========================================================================
   Login (LoginAB) - dark-teal full-bleed shell
   ========================================================================= */
.lafi-auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--topbar-bg);
  color: #fff;
}
.lafi-auth__top {
  padding: 28px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lafi-auth__top-tag {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
}
.lafi-auth__body {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 0 24px 24px;
}
.lafi-auth__centered {
  width: 420px;
  max-width: 100%;
  text-align: center;
}
.lafi-auth__title {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: #fff;
}
.lafi-auth__lede {
  margin: 0 0 24px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.5;
}
.lafi-auth__card {
  background: #fff;
  color: var(--text-color);
  border-radius: 10px;
  padding: 28px 32px 24px;
  box-shadow:
    0 20px 50px -12px rgba(0, 0, 0, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.15);
  text-align: left;
}
.lafi-auth__after {
  margin-top: 18px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.55;
}
.lafi-auth__after a {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.4);
}
.lafi-auth__after a:hover {
  text-decoration-color: rgba(255, 255, 255, 0.8);
  color: #fff;
}
.lafi-auth__foot {
  padding: 16px 36px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 18px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  align-items: center;
}
.lafi-auth__foot a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
}
.lafi-auth__foot a:hover { color: #fff; }
.lafi-auth__foot-spacer { margin-left: auto; }

/* Field label row inside auth card */
.lafi-field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.lafi-field-row__hint a {
  font-size: 11px;
  color: var(--brand-700);
}

/* =========================================================================
   Price grid - the one data-entry surface in the portal. Scrolls inside its
   own card (DESIGN.md §8): the page itself never scrolls sideways.
   ========================================================================= */
.lafi-spread-wrap {
  overflow: auto;
  /* The grid gets its own scrollport for two reasons: wide tables scroll
     sideways HERE and never move the page (DESIGN.md §8), and a scrollport
     is what makes the sticky <thead> actually stick -- on a 45-row inquiry
     losing the column headers is how a price lands in the wrong column.
     Short inquiries never reach this height, so nothing scrolls. */
  max-height: calc(100vh - 260px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  background: var(--surface-card);
}
.lafi-spread-wrap--locked { opacity: 0.6; }

.lafi-spread {
  width: 100%;
  /* Only a floor, not a fixed size: the grid stretches to whatever the
     column gives it and starts scrolling sideways below tablet width. */
  min-width: 920px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
/* Column widths live here, never as style="" on a cell (DESIGN.md §7).
   Percentages so the grid follows the viewport; they add up to 100. */
.lafi-spread__col--idx   { width: 3%; }
.lafi-spread__col--name  { width: 21%; }
.lafi-spread__col--size  { width: 8%; }
.lafi-spread__col--maker { width: 8%; }
.lafi-spread__col--code  { width: 9%; }
.lafi-spread__col--qty   { width: 6%; }
.lafi-spread__col--unit  { width: 5%; }
.lafi-spread__col--pack  { width: 13%; }
.lafi-spread__col--price { width: 11%; }
.lafi-spread__col--sum   { width: 9%; }
.lafi-spread__col--note  { width: 7%; }

/* Long cell text is clamped ONLY when JS is present to expand it again.
   Without JS the full text stays visible -- tall rows are better than
   silently hidden product specs. JS also decides which cells are actually
   too long by measuring them, so there is no arbitrary character count. */
.lafi-spread--clamped .lafi-spread__clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lafi-spread--clamped .lafi-spread__name.lafi-spread__clamp { -webkit-line-clamp: 3; }
.lafi-spread--clamped tr.is-expanded .lafi-spread__clamp {
  display: block;
  overflow: visible;
}
.lafi-spread__clamp--long {
  cursor: pointer;
  text-decoration: underline dotted var(--brand-300);
  text-underline-offset: 2px;
}
.lafi-spread__clamp--long:hover {
  color: var(--brand-700);
  text-decoration-color: var(--brand-500);
}
.lafi-spread__clamp--long:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: 3px;
}
.lafi-spread thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--app-card-bg);
  padding: 9px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-color-secondary);
  border-bottom: 1px solid var(--border-strong);
  vertical-align: bottom;
  line-height: 1.25;
}
.lafi-spread thead th.num { text-align: right; }
.lafi-spread thead th.is-input { background: var(--brand-50); }

/* Kārtojama kolonnas galvene. Uzraksts izskatās tāpat kā pārējās galvenes -
   poga tikai pievieno bultu un klikšķi. Bultas virzienu nosaka `aria-sort`
   uz <th>, tāpēc JS pārslēdz vienu atribūtu un stilus neuzstāda (§15.3). */
.lafi-spread__sort {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.lafi-spread__sort:hover { color: var(--brand-700); }
/* Nesakārtotā stāvoklī bulta ir tikai mājiens, ka kolonnu var kārtot. */
.lafi-spread__sort-arrow { color: var(--text-color-tertiary); }
.lafi-spread thead th[aria-sort="ascending"] .lafi-spread__sort-arrow {
  color: var(--brand-600);
  transform: rotate(180deg);
}
.lafi-spread thead th[aria-sort="descending"] .lafi-spread__sort-arrow {
  color: var(--brand-600);
}
.lafi-spread tbody td {
  padding: 8px 10px;
  vertical-align: top;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-color-secondary);
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.lafi-spread tbody td.num { text-align: right; }
.lafi-spread tbody tr:hover > td { background: var(--app-card-bg); }
.lafi-spread__idx { color: var(--text-color-tertiary); }
.lafi-spread__name {
  font-weight: 600;
  color: var(--text-color);
  line-height: 1.35;
}
.lafi-spread__qty { font-weight: 600; color: var(--text-color); }

/* Price cell - a field that looks like a field. Rows still needing a price
   are tinted, so "what is left to do" is visible without counting. */
.lafi-spread__price { position: relative; display: flex; align-items: center; }
.lafi-spread__price input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 6px 24px 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--content-radius);
  background: var(--surface-card);
  color: var(--text-color);
  outline: none;
}
.lafi-spread__price input::placeholder { color: var(--text-color-tertiary); }
.lafi-spread__price input:hover { border-color: var(--brand-300); }
.lafi-spread__price input:focus {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}
.lafi-spread__price input:disabled {
  background: var(--app-card-bg);
  color: var(--text-color-secondary);
}
.lafi-spread__price--empty input {
  background: var(--brand-50);
  border-color: var(--brand-200);
}
.lafi-spread__cur {
  position: absolute;
  right: 9px;
  font-size: 12px;
  color: var(--text-color-tertiary);
  pointer-events: none;
}

/* "Pārdod kā" - divi mazi lauki, kas kopā lasās kā apgalvojums:
   "1 gab = 1,25 m". Mērvienība ir teksts, ne saraksts: piegādātāji sauc vienu
   un to pašu dažādi, un aizliegt viņa vārdu nozīmētu piespiest viņu melot.
   Tukšs lauks = pārdod tajā pašā mērvienībā, ko prasījām. */
.lafi-spread__pack {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-color-tertiary);
}
.lafi-spread__pack input {
  /* `min-width: 0` atļauj sarukt zem satura; `flex` dala ATLIKUŠO vietu pēc
     tam, kad "1", "=" un mērvienības uzraksts jau ir paņēmuši savu. Procenti
     te nederēja: tie skaitījās no visas šūnas, tāpēc abi lauki kopā prasīja
     vairāk, nekā bija, un vērtība tika izspiesta ārā. */
  min-width: 0;
  font: inherit;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  padding: 6px 5px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  background: var(--surface-card);
  color: var(--text-color);
  outline: none;
}
.lafi-spread__pack input:hover { border-color: var(--brand-300); }
.lafi-spread__pack input:focus {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}
.lafi-spread__pack input:disabled {
  background: var(--app-card-bg);
  color: var(--text-color-secondary);
}
.lafi-spread__pack-unit   { flex: 1 1 0; }
/* Koeficientam vairāk vietas nekā mērvienībai: "gab" ir trīs zīmes, bet
   "1,25" jāredz līdz pēdējai. */
.lafi-spread__pack-factor { flex: 1.3 1 0; text-align: right; }
/* Rinda, kurā piegādātājs ir deklarējis citu tirdzniecības vienību, atšķiras
   klusi - iekrāsota mērvienība, nevis brīdinājums. Tā nav kļūda. */
.lafi-spread__pack--declared { color: var(--brand-700); font-weight: 600; }

.lafi-spread__note-input {
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  padding: 6px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  background: var(--surface-card);
  color: var(--text-color);
  outline: none;
}
.lafi-spread__note-input:hover { border-color: var(--brand-300); }
.lafi-spread__note-input:focus {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}

.lafi-spread__sum { font-weight: 600; color: var(--text-color); }
.lafi-spread__sum--empty { font-weight: 400; color: var(--text-color-tertiary); }

.lafi-spread__total-row td {
  background: var(--app-card-bg);
  font-weight: 600;
  border-top: 1px solid var(--border-strong);
  border-bottom: 0;
  vertical-align: middle;
}
.lafi-spread__total-row td.is-sum {
  background: var(--brand-50);
  color: var(--brand-900);
  border-top: 1px solid var(--brand-500);
}
.lafi-spread__total-label {
  text-align: right;
  color: var(--text-color-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* Row filter above the grid. Rendered `hidden` and revealed by JS, because
   filtering rendered rows is the one thing here that JS alone can do --
   a dead control is worse than no control (DESIGN.md §5.3). */
.lafi-spread-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.lafi-spread-tools__hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-color-tertiary);
}

/* =========================================================================
   Meta strip - labelled cells with hairline vertical dividers. Sits under
   the price-page title and answers "when, whose, how much" at a glance.
   ========================================================================= */
.lafi-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--content-radius);
  overflow: hidden;
}
.lafi-meta__cell {
  background: var(--surface-card);
  padding: 12px 16px;
}
.lafi-meta__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-color-tertiary);
  margin: 0;
}
.lafi-meta__body {
  margin-top: 5px;
}
.lafi-meta__primary {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-color);
}
.lafi-meta__primary--warn   { color: var(--warn-border); }
.lafi-meta__primary--over   { color: var(--error-border); }
.lafi-meta__sub {
  font-size: 12px;
  color: var(--text-color-secondary);
  margin-top: 2px;
}
