:root {
    /* Primary Colors */
    --grafits: #1A1C1E;       /* Dark background / Dark text */
    --papirs: #F2F1EC;        /* Light background / Light text */
    --oranzs: #F04E23;        /* Prime mark ′, badges, focus, hover, single accent */
    
    /* Auxiliary Colors */
    --zils-gaisa: #23479E;    /* Blueprint blue: links on light background */
    --zils-tumsas: #7E9BDE;   /* Blueprint blue: links on dark background */
    --betons-tumsas: #9EA3A8; /* Secondary text on dark background */
    --betons-gaisa: #5B5E62;  /* Secondary text on light background */

    /* Borders & Surfaces */
    --robez-gaisa: #D5D3CA;   /* Main borders in light mode */
    --linija-smalka: #EDECE5; /* Fine grid lines in light mode */
    --hover-gaisa: #F7F6F2;   /* Row hover background in light mode */
    --robez-tumsas: #34373B;  /* Borders in dark mode */
    --hover-tumsas: #212427; /* Card/row hover background in dark mode */
    --aktivs-sanjosla: #E6E4DC;/* Active category item background in sidebar */

    /* Typography */
    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    --primary-color: #1A1C1E;
    --kforma-cyan: #00BCD4;
    /* Galvenās darbības akcents. Atsevišķs tokens no `--kforma-cyan`, jo tas ir
       TENANTA lielums: KFORMA versijā tas ir zīmola ciāns, SNCD komerciālajā
       versijā (calcs.sncd.dev) tam jābūt SNCD oranžajam `--oranzs`. Nomaiņa tad
       ir viena rinda, nevis 20 failu.
       Teksta krāsa abiem ir grafīts: uz ciāna 7.44, uz oranžā 4.74 — balts uz
       oranžā dotu 3.61, tāpēc balts neder ne vienam, ne otram. */
    --brand-accent: #00BCD4;
    --brand-accent-hover: #0097A7;
    --brand-accent-ink: #1A1C1E;
    /* Hover tonis primārajām pogām. `3fd8901` to izņēma kopā ar pārējiem
       tēmu mainīgajiem, un kopš tā laika pogas uz peles neatsaucās vispār —
       fons palika identisks (mērīts 2026-09-01). Vērtība no pirms-3fd8901
       tēmas bloka. */
    --kforma-cyan-dark: #0097A7;
    --secondary-color: #5B5E62;
    --dark-gray: #1A1C1E;
    --light-gray: #F2F1EC;
    --text-dark: #1A1C1E;
    --text-muted: #5B5E62;
    --bg-white: #ffffff;
    --border-color: #D5D3CA;
}

body, input, select, textarea, button, label, .form-control, .form-select, .btn {
    font-family: var(--font-sans);
}

/* SNCD' Typography helper classes */
.font-sans { font-family: var(--font-sans) !important; }
.font-mono, code, pre, samp,
.calc-unit, .calc-value, .calc-val, .calc-formula, .calc-var,
.report-mono, .report-value, .report-formula, .report-unit,
.table td, .table th, table td, table th {
    font-family: var(--font-mono);
}

/* SNCD' Calculation Report Font Rules (v1.1 Specification) */
.calculation-report,
.report-content,
.print-preview {
    font-family: var(--font-mono);
}

.calculation-report h1, .calculation-report h2, .calculation-report h3,
.calculation-report h4, .calculation-report h5, .calculation-report h6,
.report-content h1, .report-content h2, .report-content h3,
.report-content h4, .report-content h5, .report-content h6,
.print-preview h1, .print-preview h2, .print-preview h3,
.print-preview h4, .print-preview h5, .print-preview h6 {
    font-family: var(--font-sans);
}

.calculation-report table,
.calculation-report td,
.calculation-report th,
.report-content table,
.report-content td,
.report-content th,
.print-preview table,
.print-preview td,
.print-preview th,
.calculation-report .formula,
.calculation-report p.formula {
    font-family: var(--font-mono) !important;
}

/* SNCD' Summary Table Fit-to-Content & Column Alignment */
.table-summary,
.hcs-summary-table,
.calc-summary-table,
.report-summary-table,
.table-results {
    width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse;
}

.table-summary th:first-child,
.table-summary td:first-child,
.hcs-summary-table th:first-child,
.hcs-summary-table td:first-child,
.calc-summary-table th:first-child,
.calc-summary-table td:first-child,
.report-summary-table th:first-child,
.report-summary-table td:first-child,
.table-results th:first-child,
.table-results td:first-child {
    white-space: nowrap !important;
    font-family: var(--font-sans);
    font-weight: 500;
}

.table-summary th:last-child,
.table-summary td:last-child,
.hcs-summary-table th:last-child,
.hcs-summary-table td:last-child,
.calc-summary-table th:last-child,
.calc-summary-table td:last-child,
.report-summary-table th:last-child,
.report-summary-table td:last-child,
.table-results th:last-child,
.table-results td:last-child {
    width: 1px !important;
    white-space: nowrap !important;
    text-align: center !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
}

.table-summary td:nth-child(2),
.table-summary td:nth-child(3),
.hcs-summary-table td:nth-child(2),
.hcs-summary-table td:nth-child(3),
.calc-summary-table td:nth-child(2),
.calc-summary-table td:nth-child(3),
.report-summary-table td:nth-child(2),
.report-summary-table td:nth-child(3),
.table-results td:nth-child(2),
.table-results td:nth-child(3) {
    font-family: var(--font-mono);
    white-space: nowrap !important;
}

.table-summary th:nth-child(4),
.table-summary td:nth-child(4),
.hcs-summary-table th:nth-child(4),
.hcs-summary-table td:nth-child(4),
.calc-summary-table th:nth-child(4),
.calc-summary-table td:nth-child(4),
.report-summary-table th:nth-child(4),
.report-summary-table td:nth-child(4),
.table-results th:nth-child(4),
.table-results td:nth-child(4) {
    font-family: var(--font-mono);
    white-space: nowrap !important;
    text-align: right !important;
    width: 1px !important;
    padding-right: 12px !important;
}

/* SNCD' Full-Width Report Container (Remove 210mm squeeze on screen) */
.report-content,
.report-content.print-preview,
.calculation-report {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    font-family: var(--font-sans);
}
.report-content table,
.report-content.print-preview table,
.calculation-report table {
    width: 100% !important;
}

/* SNCD' Form Language: Zero Radius & Zero Box-Shadow */
.sncd-zero-radius,
.card,
.btn,
.form-control,
.form-select,
.dropdown-menu,
.modal-content,
.alert,
.badge,
.input-group-text {
    border-radius: 0px !important;
}

.card,
.btn,
.dropdown-menu,
.modal-content,
.shadow,
.shadow-sm,
.shadow-lg {
    box-shadow: none !important;
}

/* Crisp 1px Borders */
.border-sncd {
    border: 1px solid var(--robez-gaisa) !important;
}

/* SNCD' Navbar */
.navbar-kforma {
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--robez-gaisa) !important;
    padding-top: 10px;
    padding-bottom: 10px;
}
.navbar-kforma .nav-link {
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--grafits) !important;
}
.navbar-kforma .nav-link:hover {
    color: var(--oranzs) !important;
}

/* Custom Navbar - Dark Blue/Gray */
.navbar-custom {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--dark-gray) 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.navbar-custom .navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

/* KFORMA White Navbar */
.navbar-kforma {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-kforma .navbar-brand {
    color: var(--text-dark);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.navbar-kforma .navbar-brand img {
    height: 55px;
    width: auto;
}

.navbar-kforma .nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.5rem 1rem !important;
}

.navbar-kforma .nav-link:hover {
    color: var(--kforma-cyan);
}

.navbar-kforma .navbar-toggler {
    border-color: #e5e5e5;
}

.navbar-kforma .navbar-nav {
    align-items: center;
}

.navbar-kforma .btn {
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
}

.navbar-kforma .btn-outline-primary {
    border-color: var(--kforma-cyan);
    color: var(--kforma-cyan);
}

.navbar-kforma .btn-outline-primary:hover {
    background-color: var(--kforma-cyan);
    border-color: var(--kforma-cyan);
    color: white;
}

.navbar-kforma .btn-primary {
    background-color: var(--kforma-cyan);
    border-color: var(--kforma-cyan);
}

.navbar-kforma .btn-primary:hover {
    background-color: var(--kforma-cyan-dark);
    border-color: var(--kforma-cyan-dark);
}

/* Custom Footer */
.footer-custom {
    background-color: var(--light-gray);
    border-top: 2px solid var(--secondary-color);
}

.footer-bottom {
    background: linear-gradient(135deg, var(--dark-gray) 0%, var(--primary-color) 100%);
    color: white !important;
}

/* Cards */
.card {
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
}

.card:hover {
    transform: translateY(-4px);
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.5rem 1.25rem;
}

.btn-primary {
    background-color: var(--kforma-cyan);
    border-color: var(--kforma-cyan);
    /* Grafīts, ne balts. Zīmola ciāns ir gaišs tonis: baltam tekstam uz tā ir
       2.30, kas ir zem lasāmības sliekšņa, un tā ir galvenā darbības poga
       («Aprēķināt») visos moduļos. Grafīts dod 7.44, un ciāns — tonis, ko
       cilvēki atpazīst — paliek neskarts; mainās tikai uzraksta krāsa.
       Hover tonis #0097A7 ar grafītu ir 4.87, tātad arī tas iztur.
       Mērīts 2026-09-01. */
    color: #1A1C1E;
}

.btn-primary:hover {
    background-color: var(--kforma-cyan-dark);
    border-color: var(--kforma-cyan-dark);
    /* Bez šīs rindas hover atgriezās pie Bootstrap baltā (3.51 uz #0097A7).
       Ar grafītu — 4.87. */
    color: #1A1C1E;
    transform: translateY(-1px);
}

/* Publiskā/autentifikācijas lapu galvenā darbības poga.
   Klase `btn-sncd-prime` veidnēs bija jau kopš SNCD pārstrādes, bet definīcijas
   tai nekad nebija: reģistrācijas lapā tā rezultējās pogā BEZ fona — tikai
   treknraksts uz lapas (kontrasts 1.36, mērīts 2026-09-01), t.i. galvenā
   darbība neizskatījās pēc pogas vispār. Pieteikšanās lapā un sākumlapā tas
   bija noslēpts ar inline oranžu, kas savukārt deva 3.61.

   Īpašnieka lēmums 2026-09-01: pieteikšanās poga ir ciāna, tāpat kā visas
   pārējās primārās pogas; oranžais izņēmums atkrīt. */
.btn-sncd-prime {
    background-color: var(--brand-accent);
    border: none;
    color: var(--brand-accent-ink);
}

.btn-sncd-prime:hover,
.btn-sncd-prime:focus {
    background-color: var(--brand-accent-hover);
    color: var(--brand-accent-ink);
}

.btn-outline-primary {
    border-color: var(--kforma-cyan);
    color: var(--kforma-cyan);
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--kforma-cyan);
    border-color: var(--kforma-cyan);
    color: #1A1C1E;          /* tas pats iemesls, kas `.btn-primary` */
    transform: translateY(-1px);
}

/* Hero Section */
.hero-section {
    min-height: 60vh;
    display: flex;
    align-items: center;
    background-color: white;
}

.hero-content {
    max-width: 800px;
}

.hero-description {
    font-size: 1.3rem;
    line-height: 1.7;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.hero-description.secondary {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.hero-features {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

.hero-features li {
    padding: 0.75rem 0;
    padding-left: 1.5rem;
    position: relative;
    font-size: 1rem;
    color: var(--text-dark);
    border-left: 3px solid var(--kforma-cyan);
    margin-bottom: 0.5rem;
}

.hero-features li::before {
    content: "";
    position: absolute;
    left: -3px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 100%;
    background-color: var(--kforma-cyan);
}

/* Dashboard Styles */
.dashboard-header {
    margin-bottom: 3rem;
}

.dashboard-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.dashboard-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin: 0;
}

.category-section {
    background: white;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.category-header {
    border-left: 4px solid var(--kforma-cyan);
    padding-left: 1.5rem;
}

.category-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.category-description {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0;
}

.category-divider {
    margin: 3rem 0;
    border-color: #e5e5e5;
}

/* Apakšgrupa kategorijas iekšienē (piem. DZELZSBETONS → "Lokālās pārbaudes").
   Pakļauta kategorijas virsrakstam: mazāks, retināts, ar plānu līniju, kas
   aizpilda atlikušo platumu — dala režģi, nekonkurējot ar kategoriju. */
.module-group-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-top: 0.5rem;
    padding-left: 0.25rem;
}
.module-group-head span {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}
.module-group-head::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}
.category-section .row > .module-group-head:first-child {
    margin-top: 0;
}

/* Module Cards */
.module-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-white);
    height: 100%;
}

.module-card .card-body {
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.module-available:hover {
    border-color: var(--kforma-cyan);
    transform: translateY(-6px);
}

.module-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.module-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.module-disabled .module-title {
    color: var(--text-muted);
}

.module-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    flex-grow: 1;
}

.module-badge {
    font-size: 0.75rem;
    padding: 0.4rem 0.9rem;
    font-weight: 500;
    border-radius: 20px;
}

.badge-active {
    background-color: var(--kforma-cyan);
    color: white;
}

.badge-inactive {
    background-color: #e5e5e5;
    color: var(--text-muted);
}

/* Module Icons - Premium Style */
.module-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--bg-white) 0%, var(--light-gray) 100%);
    color: var(--kforma-cyan);
    font-size: 1.7rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04), inset 0 2px 0 rgba(255, 255, 255, 1);
    border: 1px solid var(--border-color);
}

.module-available:hover .module-icon {
    background: linear-gradient(135deg, var(--kforma-cyan) 0%, var(--kforma-cyan-dark) 100%);
    color: white;
    transform: scale(1.08) translateY(-2px);
    border-color: transparent;
}

.module-disabled .module-icon {
    color: #bdbdbd;
    background: #f1f5f9;
    box-shadow: none;
    border-color: #e2e8f0;
}
/* ==========================================================================
   MODULE UI MODERNIZATION (STEP 4)
   Overrides for standard Bootstrap classes used in calculation modules
   ========================================================================== */

/* 1. Form Inputs & Selects */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.8rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
}

/* ── Lapas virsraksts ─────────────────────────────────────────────────────
   Semantiski `h1` (līdz 2026-08-20 44 moduļiem lapā nebija neviena — meklētājam
   un ekrānlasītājam lapa sākās ar `h5`), bet vizuāli tāds pats kā līdz šim.
   Sk. docs/design-system.md §1. */
.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-dark);
}
.page-subtitle {
    font-size: 0.85rem;
    color: #607D8B;
    margin-bottom: 1rem;
}

/* Kartes virsraksts: semantiski h6 (h2-h5 paliek lapas struktūrai), bet
   VIZUĀLI tāds pats, kāds bija h5 — pretējā gadījumā pāreja uz pareizo
   līmeni sarautu visu karšu galvenes. Sk. docs/design-system.md §1. */
.card-header .card-title {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 0;
}
.card-header .card-title.card-title-sm {
    font-size: 1rem;
}

/* ── Uzziņas tabulu moduļi (/bolts, /welds) ────────────────────────────────
   Blīvas tabulas ar daudz kolonnām (īpašnieka norāde 2026-08-20). Agrāk
   šeit bija atsevišķs Arial Narrow platuma ekonomijai; SNCD′ dizaina
   sistēma (2026-08-22) to aizstāja ar tiem pašiem --font-sans/--font-mono
   tokeniem, ko lieto visur pārējā platformā (IBM Plex Sans/Mono) —
   konsekvence uzvarēja pret platuma ekonomiju. Klase ir uz `body`, tāpēc
   sedz VISU lapu, arī tabulas un pogas. */
body.reference-table,
body.reference-table .form-control,
body.reference-table .form-select,
body.reference-table .btn,
body.reference-table .input-group-text {
    font-family: var(--font-sans);
}
body.reference-table table,
body.reference-table .weld-eq,
body.reference-table .hcs-eq {
    font-family: var(--font-mono);
}

/* ── Ievades lauku gridline (sk. CLAUDE.md «Ievades lauku gridline») ──────────
   Rindā ar `field-grid` klasi etiķetei rezervētas divas rindas, tāpēc blakus
   esošie lauki sākas vienā līmenī arī tad, ja kāda etiķete lauzās divās rindās.
   Bez tā gara etiķete pabīda savu lauku uz leju un rinda vairs nav pret rindu. */
.field-grid > [class*="col-"] > label,
.field-grid > [class*="col-"] > .form-label {
    display: flex;
    align-items: flex-end;
    min-height: 2.6em;
    margin-bottom: 0.3rem;
    line-height: 1.25;
}
/* Ievades grupa nedrīkst lauzties: Bootstrap pēc noklusējuma ļauj mērvienībai
   nokrist nākamajā rindā, un tad `b_w = [300]` stāv vienā rindā, bet `mm` zem
   tā (īpašnieka atrade 2026-08-18 /bending/ L-šķērsgriezuma rindā). Ar nowrap
   sarūk pats ievadlauks, ne izkārtojums. */
.field-grid .input-group {
    flex-wrap: nowrap;
}

/* Simbola prefikss nedrīkst lauzties ne aizņemt pusi lauka. */
.field-grid .input-group-text {
    white-space: nowrap;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
}
.field-grid .input-group > .form-control {
    min-width: 4.5rem;
}

/* Bultiņa zīmējas kā fona attēls pie labās malas, tāpēc izvēlnei labajā pusē
   jāatstāj vieta — citādi garāks teksts aiziet zem bultiņas (Bootstrap savu
   2.25rem atkāpi zaudē, kad augšējais noteikums pārraksta visu padding). */
.form-select {
    padding-right: 2.25rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--kforma-cyan);
    /* Fokusa gredzens ar TIEŠU vērtību, ne mainīgo: nederīgs `var()` box-shadow
       aprēķinās uz `unset` (= `none`), nevis atkāpjas uz Bootstrap noklusējumu,
       tāpēc gredzena nebija vispār; bet, deklarāciju vienkārši izdzēšot,
       cauri nāk Bootstrap zilais gredzens, kas neatbilst identitātei
       (abi izmērīti pārlūkā 2026-09-01). */
    box-shadow: 0 0 0 0.25rem rgba(0, 188, 212, 0.25);
}

/* Skaitļu ievades laukiem neder pelēkās spinnera bultiņas (augšup/lejup) —
   inženieru ievadei tās tikai aizņem vietu un soli neviens nelieto. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

.form-label, label {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.4rem;
}

/* 2. Card Headers (Softer, Premium Look) */
.card-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    background-color: var(--bg-white) !important;
    color: var(--text-dark) !important;
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
    border-left: 4px solid transparent;
}

/* Uniform Headers for all modules based on theme */
.card-header.bg-info,
.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-danger,
.card-header.bg-warning,
.card-header.bg-secondary,
.card-header.bg-dark {
    /* Fona te apzināti NAV: kartes virsraksti visos moduļos ir balti (augšējais
       `.card-header` likums), un šis bloks tikai neitralizē Bootstrap krāsainos
       `bg-*` variantus. Agrāk te stāvēja tēmas fona mainīgais, ko `3fd8901`
       izņēma no `:root` — deklarācija bija nederīga un tik un tā neko nedarīja.
       Īpašnieka lēmums 2026-09-01: kartes virsraksti paliek balti. */
    border-left-color: var(--kforma-cyan) !important;
}

.card-header.bg-info h5, .card-header.bg-info h6, .card-header.bg-info i,
.card-header.bg-primary h5, .card-header.bg-primary h6, .card-header.bg-primary i,
.card-header.bg-success h5, .card-header.bg-success h6, .card-header.bg-success i,
.card-header.bg-danger h5, .card-header.bg-danger h6, .card-header.bg-danger i,
.card-header.bg-warning h5, .card-header.bg-warning h6, .card-header.bg-warning i,
.card-header.bg-secondary h5, .card-header.bg-secondary h6, .card-header.bg-secondary i,
.card-header.bg-dark h5, .card-header.bg-dark h6, .card-header.bg-dark i {
    color: var(--text-dark) !important;
    font-weight: 600;
}

/* 3. Results Tables & Status Badges */
.table {
    margin-bottom: 0;
    color: var(--text-dark);
}

.table td, .table th {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: var(--border-color);
}

/* Soften table context colors */
.table-success {
    background-color: rgba(16, 185, 129, 0.1) !important;
    color: #065f46;
}
.table-success td {
    border-color: rgba(16, 185, 129, 0.2) !important;
}

.table-danger {
    background-color: rgba(239, 68, 68, 0.1) !important;
    color: #991b1b;
}
.table-danger td {
    border-color: rgba(239, 68, 68, 0.2) !important;
}

.table-warning {
    background-color: rgba(245, 158, 11, 0.1) !important;
    color: #92400e;
}
.table-warning td {
    border-color: rgba(245, 158, 11, 0.2) !important;
}

.table-light {
    background-color: var(--light-gray) !important;
}
.table-light td {
    border-color: var(--border-color) !important;
}

/* Badges */
.badge {
    border-radius: 6px;
    font-weight: 600;
    padding: 0.5em 0.8em;
}

/* Big Status Badges */
.badge.fs-5 {
    border-radius: 12px;
    padding: 0.8rem 1.5rem !important;
}

/* Statusa nozīmītes. Krāsas no SNCD specifikācijas (docs/STRICT_UI_
   IMPLEMENTATION_RULES.md §2: pass #1A6A3C, near-limit #B9770E, fail #B3261E),
   nevis izdomātas — un teksta krāsa katrai izvēlēta pēc izmērītā kontrasta.

   Iepriekš šeit bija gaiša Tailwind palete ar uzspiestu baltu tekstu, un neviena
   no kombinācijām nesasniedza WCAG AA 4.5:1 (mērīts 2026-09-01):
   #10b981 balts = 2.54, #ef4444 balts = 3.76, #f59e0b balts = 2.15, un
   Bootstrap info #0dcaf0 ar baltu = 1.96. Nozīmīte, kas paziņo aprēķina
   rezultātu, ir tieši tā vieta, kur teksts nedrīkst būt tikko salasāms. */
.badge.bg-success {
    background-color: #1A6A3C !important;   /* balts: 6.62 */
    color: #FFFFFF !important;
}

.badge.bg-danger {
    background-color: #B3261E !important;   /* balts: 6.54 */
    color: #FFFFFF !important;
}

.badge.bg-warning {
    /* Dzintara tonim balts dod tikai 3.68, tumšs — 4.65. */
    background-color: #B9770E !important;
    color: #1A1C1E !important;
}

.btn-info,
.btn-info:hover,
.btn-info:focus {
    /* Tas pats Bootstrap ciāns, kas nozīmītēm: ar baltu 1.96, ar tumšu 8.73.
       Fons paliek, uzraksts kļūst lasāms. */
    color: #1A1C1E !important;
}

.badge.bg-info {
    /* Bootstrap ciāns paliek, mainās teksts: balts 1.96 -> tumšs 8.73. */
    color: #1A1C1E !important;
}

/* 4. Segmented Controls (Radio button groups) */
.btn-group .btn-outline-primary, .btn-group .btn-outline-info {
    border-color: var(--border-color);
    color: var(--text-muted);
    background-color: var(--bg-white);
    padding: 0.5rem 1rem;
    font-weight: 500;
}

.btn-group .btn-outline-primary:hover, .btn-group .btn-outline-info:hover {
    background-color: var(--light-gray);
    color: var(--text-dark);
    box-shadow: none;
    transform: none;
}

.btn-group .btn-check:checked + .btn-outline-primary, 
.btn-group .btn-check:checked + .btn-outline-info {
    background-color: var(--kforma-cyan);
    border-color: var(--kforma-cyan);
    color: white;
    z-index: 1;
}

/* Fix rounding for button groups */
.btn-group > .btn:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}
.btn-group > .btn:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Load combos row styling */
.load-combo-row {
    background: var(--bg-white) !important;
    border: 1px solid var(--border-color) !important;
}

/* ==========================================================================
   Admin Panel — tehnisks, tēmatiski saskaņots (issue #87)
   ========================================================================== */
.admin-page { padding: 1.5rem 0 3rem; }
.admin-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    flex-wrap: wrap; gap: .75rem 1rem; margin-bottom: 1.25rem;
}
.admin-head .admin-title {
    font-size: 1.35rem; font-weight: 700; color: var(--text-dark);
    margin: 0; display: flex; align-items: center; gap: .55rem;
}
.admin-head .admin-title i { color: var(--kforma-cyan); }
.admin-head .admin-sub { color: var(--text-muted); font-size: .85rem; margin: .2rem 0 0; }
.admin-actions-top { display: flex; gap: .5rem; flex-wrap: wrap; }

/* KPI kartes */
.admin-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-white); border: 1px solid var(--border-color);
    border-left: 3px solid var(--kforma-cyan); border-radius: 12px;
    padding: .95rem 1.1rem;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.stat-card .stat-val { font-size: 1.85rem; font-weight: 800; line-height: 1; color: var(--text-dark); }
.stat-card .stat-label {
    font-size: .72rem; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: .04em; margin-top: .35rem;
}
.stat-card .stat-icon {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
    background: var(--hover-gaisa); color: var(--kforma-cyan);
}

/* Kartes */
.admin-card {
    background: var(--bg-white); border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1.5rem; overflow: hidden;
}
.admin-card-head {
    padding: .8rem 1.1rem; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: .5rem;
    font-weight: 600; font-size: .92rem; color: var(--text-dark);
}
.admin-card-head i { color: var(--kforma-cyan); }
.admin-card-head .count { color: var(--text-muted); font-weight: 500; }
.admin-card-head.is-warn { background: #fff8ec; color: #8a5a00; border-bottom-color: #f3d79a; }
.admin-card-head.is-warn i { color: #d98a00; }
.admin-card-body { padding: 1rem 1.1rem; }
.admin-card-body.p0 { padding: 0; }

/* Tabula */
.admin-table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; margin: 0; border-collapse: collapse; font-size: .85rem; }
table.admin-table thead th {
    background: var(--light-gray); color: var(--text-muted);
    font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .03em;
    padding: .6rem .8rem; border-bottom: 1px solid var(--border-color);
    white-space: nowrap; text-align: left;
}
table.admin-table thead th.text-end { text-align: right; }
table.admin-table tbody td { padding: .58rem .8rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
table.admin-table tbody tr:last-child td { border-bottom: 0; }
table.admin-table tbody tr:hover { background: var(--hover-gaisa); }
table.admin-table .u-email { font-weight: 600; color: var(--text-dark); }
table.admin-table .u-email a { color: var(--text-dark); text-decoration: none; }
table.admin-table .u-email a:hover { color: var(--kforma-cyan); }
.cell-sub { display: block; font-size: .72rem; color: var(--text-muted); }

/* Statusa čipi */
.chip { display: inline-flex; align-items: center; gap: .3em; padding: .2em .6em; border-radius: 6px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.chip-accent { background: #e0f7fa; color: var(--kforma-cyan-dark); }
.chip-ok { background: #e7f6ec; color: #1a7f3c; }
.chip-danger { background: #fdeaea; color: #c0392b; }
.chip-warn { background: #fff4e0; color: #9a6300; }
.chip-muted { background: var(--light-gray); color: var(--text-muted); }
.chip-role-admin { background: #efe7fb; color: #6b32c9; }
.verified-ic { color: #1a7f3c; font-size: .8rem; }

/* Darbību dropdown */
.row-actions .btn-actions {
    border: 1px solid var(--border-color); background: var(--bg-white);
    color: var(--text-muted); width: 30px; height: 30px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.row-actions .btn-actions:hover { border-color: var(--kforma-cyan); color: var(--kforma-cyan); }
.row-actions .dropdown-menu { font-size: .85rem; border-color: var(--border-color); border-radius: 10px; padding: .35rem; }
.row-actions .dropdown-item { border-radius: 7px; padding: .4rem .6rem; display: flex; align-items: center; gap: .55rem; }
.row-actions .dropdown-item i { width: 16px; text-align: center; }
.row-actions .dropdown-item.text-danger:hover { background: #fdeaea; }
.row-actions form { margin: 0; }
.row-actions form button.dropdown-item { width: 100%; background: none; border: 0; text-align: left; font: inherit; cursor: pointer; }
.row-self { color: var(--text-muted); font-size: .78rem; font-style: italic; }

/* Detaļu definīciju tabula */
.def-table { width: 100%; font-size: .85rem; }
.def-table th { width: 42%; text-align: left; font-weight: 500; color: var(--text-muted); padding: .5rem .5rem .5rem 0; vertical-align: top; }
.def-table td { padding: .5rem 0; color: var(--text-dark); }
.def-table tr + tr th, .def-table tr + tr td { border-top: 1px solid var(--border-color); }

@media (max-width: 992px) { .col-hide-lg { display: none !important; } }
@media (max-width: 768px) { .col-hide-md { display: none !important; } }

/* Bootstrap CDN fallback (issue #101): .dropdown-menu redzamību parasti nosaka
   bootstrap.min.css (display:none, .show → display:block). Ja CDN neielādējas
   (izejošā tīkla kļūme, ad-blocker, lēns savienojums), pārlūks pēc noklusējuma
   rāda <ul class="dropdown-menu"> kā parastu bloku VIENMĒR izvērstu — admin
   tabulā tas nozīmē, ka katras rindas darbību saraksts (row-actions) paliek
   pastāvīgi redzams zem rindas, sagraujot tabulas izkārtojumu tieši tā, kā
   aprakstīts #101 ("nevis rinda viena, bet daudzas saliktas kolonnā"). Šis
   pašu-avota (ne-CDN) noteikums garantē pareizu paslēpto/redzamo stāvokli
   neatkarīgi no CDN pieejamības; ja Bootstrap CSS ielādējas normāli, abi
   noteikumi sakrīt un uzvedība nemainās. */
.dropdown-menu { display: none; }
.dropdown-menu.show { display: block; }

/* SNCD' Admin Table Sortable & Resizable Styling */
.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sortable-th:hover {
    background-color: var(--hover-gaisa) !important;
    color: var(--oranzs) !important;
}

.sort-icon {
    font-size: 0.7rem;
    opacity: 0.35;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.sortable-th:hover .sort-icon,
.sortable-th.sort-asc .sort-icon,
.sortable-th.sort-desc .sort-icon {
    opacity: 1;
    color: var(--oranzs);
}

.resizable-th {
    position: relative;
}

.column-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 10;
    border-right: 2px solid transparent;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.column-resizer:hover,
.column-resizer.is-resizing {
    border-right-color: var(--oranzs);
    background-color: rgba(240, 78, 35, 0.15);
}
