:root {
    --ih-primary: #0d6efd;
    --ih-success: #198754;
    --ih-danger: #dc3545;

    /* UI density (mobile-first) */
    --ih-body-size: 0.9375rem;
    --ih-line-height: 1.35;
    --ih-block-gap: 0.625rem;
    --ih-section-gap: 0.75rem;
    --ih-touch-min: 2.75rem;

    /* Bootstrap density overrides */
    --bs-body-font-size: var(--ih-body-size);
    --bs-body-line-height: var(--ih-line-height);
    --bs-spacer: 0.75rem;
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 0.75rem;
    --bs-card-spacer-y: 0.75rem;
    --bs-card-spacer-x: 0.875rem;
    --bs-card-cap-padding-y: 0.5rem;
    --bs-card-cap-padding-x: 0.875rem;
    --bs-navbar-padding-y: 0.4rem;
    --bs-border-radius: 0.375rem;
    --bs-border-radius-lg: 0.5rem;
}

body {
    background-color: #f8f9fa;
    font-size: var(--ih-body-size);
    line-height: var(--ih-line-height);
}

h1, .h1 { font-size: calc(1.25rem + 0.6vw); }
h2, .h2 { font-size: calc(1.125rem + 0.45vw); }
h3, .h3 { font-size: 1.125rem; }
h4, .h4 { font-size: 1.0625rem; }
h5, .h5 { font-size: 0.975rem; }
h6, .h6 { font-size: 0.875rem; }

.lead {
    font-size: 1.0625rem;
    line-height: var(--ih-line-height);
}

.display-5 {
    font-size: calc(1.35rem + 1vw);
}

main.container {
    padding-top: var(--ih-section-gap) !important;
    padding-bottom: var(--ih-section-gap) !important;
}

footer.border-top {
    margin-top: calc(var(--bs-spacer) * 2) !important;
    padding-top: var(--ih-section-gap) !important;
    padding-bottom: var(--ih-section-gap) !important;
}

.card-body {
    padding: var(--bs-card-spacer-y) var(--bs-card-spacer-x);
}

.card.p-3 {
    padding: calc(var(--bs-spacer) * 0.85) calc(var(--bs-spacer) * 1) !important;
}

.card.p-4 {
    padding: calc(var(--bs-spacer) * 1.15) calc(var(--bs-spacer) * 1.25) !important;
}

.btn:not(.btn-sm):not(.btn-lg) {
    min-height: var(--ih-touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sm {
    min-height: 2.25rem;
}

.navbar-nav .nav-link {
    min-height: var(--ih-touch-min);
    display: flex;
    align-items: center;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.form-control,
.form-select {
    min-height: var(--ih-touch-min);
    font-size: var(--ih-body-size);
    line-height: var(--ih-line-height);
}

.form-check-input {
    width: 1.125em;
    height: 1.125em;
    margin-top: 0.2em;
}

.form-check-label {
    padding-top: 0.125rem;
    padding-bottom: 0.125rem;
}

.table > :not(caption) > * > * {
    padding: 0.45rem 0.5rem;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    color: #6c757d;
    font-size: 0.8125rem;
}

.gain-positive { color: var(--ih-success); }
.gain-negative { color: var(--ih-danger); }

.price-above-import {
    background-color: #146c43;
    color: #fff;
    border-radius: 0.25rem;
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-weight: 600;
}

.price-below-import {
    background-color: #b02a37;
    color: #fff;
    border-radius: 0.25rem;
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-weight: 600;
}

.table th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
}

.app-brand {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.15;
}

.app-brand--nav {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.app-brand__icon {
    font-size: 1.25rem;
    opacity: 0.9;
}

.app-brand__text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.app-brand__site {
    font-weight: 700;
    font-size: 1rem;
}

.app-brand__product {
    font-size: 0.68rem;
    font-weight: 500;
    opacity: 0.78;
    letter-spacing: 0.02em;
}

.hero-section .hero-brand {
    font-size: 0.975rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0.9;
    text-transform: none;
}

.hero-section {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    color: white;
    border-radius: var(--bs-border-radius-lg);
    padding: 1.5rem 1.125rem;
    margin-bottom: calc(var(--bs-spacer) * 1.5) !important;
}

.hero-section .lead {
    margin-top: var(--ih-block-gap) !important;
}

.hero-section .mt-4 {
    margin-top: var(--ih-section-gap) !important;
}

.feature-icon {
    font-size: 1.625rem;
    color: var(--ih-primary);
    margin-bottom: var(--ih-block-gap);
}

@media (min-width: 768px) {
    .hero-section {
        padding: 2rem 1.5rem;
    }

    h1, .h1 { font-size: 1.875rem; }
    h2, .h2 { font-size: 1.625rem; }
}

.help-tip {
    cursor: help;
    line-height: 1;
    vertical-align: middle;
}

.help-tip i {
    font-size: 0.85em;
}

.stat-label .help-tip,
.form-label .help-tip {
    vertical-align: text-top;
}

body.ih-loading,
body.ih-loading * {
    cursor: wait !important;
}

.ih-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(248, 249, 250, 0.72);
    backdrop-filter: blur(2px);
}

.ih-loading-overlay[hidden] {
    display: none !important;
}

.ih-loading-overlay__panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    border: none;
}

.ih-loading-overlay__spinner {
    width: 2.5rem;
    height: 2.5rem;
}

.ih-loading-overlay__text {
    font-weight: 600;
    color: #212529;
    text-align: center;
    max-width: 22rem;
}

.ih-loading-overlay--success .ih-loading-overlay__text {
    color: var(--ih-success);
}

.ih-loading-overlay--fail .ih-loading-overlay__text {
    color: var(--ih-danger);
}

.ih-ai-analysis-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    overflow-x: clip;
}

.ih-ai-analysis-panel__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.ih-ai-analysis-panel__header h5 {
    font-size: 1rem;
}

.ih-ai-analysis {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    font-size: 0.9375rem;
    line-height: 1.35;
    color: #212529;
}

.ih-ai-analysis__content {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 0;
}

.ih-ai-konklusion,
.ih-ai-observationer {
    width: 100%;
    min-width: 0;
}

.ih-ai-konklusion {
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(13, 110, 253, 0.08);
    border: 1px solid rgba(13, 110, 253, 0.14);
}

.ih-ai-konklusion__label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0a58ca;
    margin-bottom: 0.35rem;
}

.ih-ai-konklusion__text {
    margin: 0;
    font-weight: 600;
    color: #1b2a41;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ih-ai-observationer__label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #495057;
    margin-bottom: 0.35rem;
}

.ih-ai-observationer__list {
    margin: 0;
    padding-left: 1.1rem;
}

.ih-ai-observationer__list li {
    margin-bottom: 0.35rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ih-ai-observationer__list li:last-child {
    margin-bottom: 0;
}

.ih-ai-details {
    margin-top: 0.15rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 0.5rem;
}

.ih-ai-details__summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.5rem 0.15rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6c757d;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ih-ai-details__summary::-webkit-details-marker {
    display: none;
}

.ih-ai-details__summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 0.35rem;
    transition: transform 0.15s ease;
}

.ih-ai-details[open] .ih-ai-details__summary::before {
    transform: rotate(90deg);
}

.ih-ai-details__body {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.35;
    color: #6c757d;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ih-ai-details__raw p {
    margin-bottom: 0.5rem;
}

.ih-ai-details__raw p:last-child {
    margin-bottom: 0;
}

.ih-ai-detail-section {
    margin-bottom: 0.5rem;
}

.ih-ai-detail-section:last-child {
    margin-bottom: 0;
}

.ih-ai-detail-section__title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #868e96;
    margin-bottom: 0.25rem;
}

.ih-ai-detail-section__body p {
    margin-bottom: 0.45rem;
}

.ih-ai-detail-section__body p:last-child {
    margin-bottom: 0;
}

.ih-ai-list {
    margin: 0;
    padding-left: 1.1rem;
}

.ih-ai-list li {
    margin-bottom: 0.25rem;
}

.ih-ai-list li:last-child {
    margin-bottom: 0;
}

.ih-ai-sentiment-result {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow-x: clip;
}

.ih-ai-sentiment-result__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ih-ai-sentiment-result__label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

@media (min-width: 768px) {
    .ih-ai-analysis-panel {
        padding: 0.85rem 1rem;
    }

    .ih-ai-analysis,
    .ih-ai-sentiment-result {
        max-width: min(48rem, 100%);
    }
}
