/* =================================================================
   InnoFarm v3 — Design System
   Shared component styles used across all pages.
   ================================================================= */

/* ===== PAGE SCAFFOLD ===== */
.if-page {
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
}

.if-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
}

.if-page-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -.6px;
    color: var(--if-on-surface, #0F1A12);
    line-height: 1.15;
    margin: 0;
}

.if-page-meta {
    font-size: 13px;
    color: var(--if-on-surface-4, #9BA89D);
    margin-top: 3px;
}

.if-page-meta strong {
    color: var(--if-green-700, #15803D);
    font-weight: 600;
}

.if-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.if-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: var(--if-radius-xs, 8px);
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    background: var(--if-surface, white);
    border: 1px solid var(--if-border, #E2E8E3);
    color: var(--if-on-surface-2, #374839);
}

.if-action-btn:hover {
    border-color: var(--if-on-surface-4, #9BA89D);
}

.active-period {
    color: var(--if-green-700, #15803D);
    font-weight: 700;
}

/* ===== LOADING / EMPTY ===== */
.if-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.if-welcome {
    text-align: center;
    padding: 60px 20px;
}

.if-welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--if-green-50, #F0FDF4);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.if-welcome h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--if-on-surface, #0F1A12);
}

.if-welcome p {
    font-size: 14px;
    color: var(--if-on-surface-3, #6B7D6E);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===== KPI CARDS ===== */
.if-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.if-kpi {
    background: var(--if-surface, white);
    border: 1px solid var(--if-border, #E2E8E3);
    border-radius: var(--if-radius, 14px);
    padding: 22px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--if-shadow-card);
    transition: all .3s cubic-bezier(.4,0,.2,1);
    position: relative;
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
}

.if-kpi:nth-child(1) { animation-delay: .04s; }
.if-kpi:nth-child(2) { animation-delay: .08s; }
.if-kpi:nth-child(3) { animation-delay: .12s; }
.if-kpi:nth-child(4) { animation-delay: .16s; }
.if-kpi:nth-child(5) { animation-delay: .20s; }

.if-kpi:hover {
    border-color: var(--if-green-200, #BBF7D0);
    box-shadow: 0 0 0 1px var(--if-green-200), 0 4px 12px rgba(22,197,94,.06), 0 12px 40px rgba(15,26,18,.04);
    transform: translateY(-2px);
}

/* Top accent gradient */
.if-kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 16px; right: 16px;
    height: 2px;
    border-radius: 0 0 2px 2px;
    opacity: .8;
    transition: opacity .3s;
}

.if-kpi:hover::before { opacity: 1; left: 10px; right: 10px; }
.if-kpi.total::before  { background: linear-gradient(90deg, #22C55E, #4ADE80); }
.if-kpi.success::before { background: linear-gradient(90deg, #16A34A, #4ADE80); }
.if-kpi.info::before   { background: linear-gradient(90deg, #2563EB, #60A5FA); }
.if-kpi.error::before  { background: linear-gradient(90deg, #DC2626, #F87171); }
.if-kpi.amber::before  { background: linear-gradient(90deg, #F59E0B, #FBBF24); }

.if-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--if-radius-sm, 10px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.if-kpi-icon.total,
.if-kpi-icon.success { background: #DCFCE7; color: #15803D; }
.if-kpi-icon.info    { background: #DBEAFE; color: #2563EB; }
.if-kpi-icon.error   { background: #FEE2E2; color: #DC2626; }
.if-kpi-icon.amber   { background: #FEF3C7; color: #B45309; }

.if-kpi-content { flex: 1; min-width: 0; }

.if-kpi-value {
    font-family: 'Roboto Mono', 'Roboto', monospace;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -1.5px;
    line-height: 1;
}

.if-kpi.total   .if-kpi-value { color: #166534; }
.if-kpi.success .if-kpi-value { color: #15803D; }
.if-kpi.info    .if-kpi-value { color: #2563EB; }
.if-kpi.error   .if-kpi-value { color: #DC2626; }
.if-kpi.amber   .if-kpi-value { color: #B45309; }

.if-kpi-label {
    font-size: 12.5px;
    color: var(--if-on-surface-3, #6B7D6E);
    margin-top: 3px;
    font-weight: 450;
}

.if-kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 100px;
    margin-top: 8px;
}

.if-kpi-badge .mud-icon-root { font-size: 13px !important; }
.if-kpi-badge.up   { background: #DCFCE7; color: #15803D; }
.if-kpi-badge.down { background: #FEE2E2; color: #DC2626; }

/* ===== KPI GRID VARIANTS ===== */
.if-kpi-grid-5 {
    grid-template-columns: repeat(5, 1fr) !important;
}

.if-kpi-grid-3 {
    grid-template-columns: repeat(3, 1fr) !important;
}

/* ===== CARDS ===== */
.if-card {
    background: var(--if-surface, white);
    border: 1px solid var(--if-border, #E2E8E3);
    border-radius: var(--if-radius, 14px);
    box-shadow: var(--if-shadow-card);
}

.if-card-head {
    padding: 20px 22px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.if-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--if-on-surface, #0F1A12);
}

.if-card-sub {
    font-size: 12px;
    color: var(--if-on-surface-4, #9BA89D);
    margin-top: 2px;
}

/* ===== BAR CHART ===== */
.if-chart-body {
    padding: 20px 22px 22px;
    height: 240px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.if-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.if-bar {
    width: 100%;
    max-width: 30px;
    min-height: 2px;
    border-radius: 5px 5px 2px 2px;
    transition: all .2s;
    cursor: pointer;
}

.if-bar.primary {
    background: linear-gradient(to top, #BBF7D0, #4ADE80);
}

.if-bar.primary:hover {
    background: linear-gradient(to top, #4ADE80, #22C55E);
    box-shadow: 0 -2px 12px rgba(34,197,94,.15);
}

.if-bar.peak {
    background: linear-gradient(to top, #22C55E, #4ADE80);
    box-shadow: 0 0 10px rgba(34,197,94,.1);
}

.if-bar-lbl {
    font-size: 9px;
    color: var(--if-on-surface-4, #9BA89D);
    font-weight: 500;
}

/* ===== STATS / QUICK INFO ===== */
.if-stats-body { padding: 14px 22px 20px; }

.if-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--if-border-faint, #F5F7F5);
}

.if-stat-row:last-child { border-bottom: none; }
.if-stat-k { font-size: 13px; color: var(--if-on-surface-3, #6B7D6E); }

.if-stat-v {
    font-size: 14px;
    font-weight: 600;
    color: var(--if-on-surface, #0F1A12);
}

.if-stat-v.green { color: #15803D; }
.if-stat-v.amber { color: #F59E0B; }

/* ===== CHARTS GRID ===== */
.if-charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
    margin-bottom: 24px;
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
    animation-delay: .22s;
}

/* ===== TABLE CARD ===== */
.if-table-card {
    background: var(--if-surface, white);
    border: 1px solid var(--if-border, #E2E8E3);
    border-radius: var(--if-radius, 14px);
    box-shadow: var(--if-shadow-card);
    overflow: hidden;
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
    animation-delay: .3s;
}

.if-table-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--if-border, #E2E8E3);
}

.if-rank {
    width: 28px;
    height: 28px;
    border-radius: var(--if-radius-xs, 8px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.if-rank.gold {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    color: #B45309;
    box-shadow: 0 1px 2px rgba(180,83,9,.1);
}

.if-rank.silver { background: #EEF1EE; color: #6B7D6E; }
.if-rank.bronze { background: #FED7AA; color: #C2410C; }
.if-rank.normal { background: #F5F7F5; color: #9BA89D; }

.if-name-bold { font-weight: 600; color: var(--if-on-surface, #0F1A12); }
.if-mono { font-family: 'Roboto Mono', 'Roboto', monospace; font-size: 12.5px; }
.if-trend-up { color: #15803D; font-weight: 600; font-size: 12px; }
.if-trend-down { color: #EF4444; font-weight: 600; font-size: 12px; }
.if-trend-flat { color: #9BA89D; font-size: 12px; }

.if-progress-track {
    width: 72px;
    height: 5px;
    background: #EEF1EE;
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 7px;
    overflow: hidden;
}

.if-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #86EFAC, #22C55E);
}

/* ===== SHARED TABLE ===== */
.if-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--if-border-light, #EEF1EE);
    gap: 16px;
}

.if-table-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--if-border-faint, #F5F7F5);
    border: 1.5px solid transparent;
    border-radius: var(--if-radius-xs, 8px);
    padding: 0 12px;
    flex: 1;
    max-width: 420px;
    transition: all .18s ease;
}

.if-table-search:focus-within {
    border-color: var(--if-green-400, #4ADE80);
    background: white;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .1);
}

.if-table-search-icon {
    color: var(--if-on-surface-4, #9BA89D) !important;
    flex-shrink: 0;
}

.if-table-search-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--if-on-surface, #0F1A12);
    padding: 9px 0;
    width: 100%;
}

.if-table-search-input::placeholder {
    color: var(--if-on-surface-4, #9BA89D);
}

.if-table-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--if-on-surface-4, #9BA89D);
    padding: 2px;
    border-radius: 4px;
    transition: color .15s;
}

.if-table-search-clear:hover {
    color: var(--if-on-surface, #0F1A12);
}

.if-table-meta {
    flex-shrink: 0;
}

.if-table-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--if-on-surface-3, #6B7D6E);
    background: var(--if-border-faint, #F5F7F5);
    padding: 5px 12px;
    border-radius: 100px;
}

.if-table-wrap {
    overflow-x: auto;
}

.if-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.if-table thead {
    background: var(--if-border-faint, #F5F7F5);
}

.if-table th {
    padding: 10px 20px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--if-on-surface-3, #6B7D6E);
    white-space: nowrap;
    border-bottom: 1px solid var(--if-border, #E2E8E3);
}

.if-table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--if-border-faint, #F5F7F5);
    vertical-align: middle;
}

.if-table tbody tr {
    transition: background .12s ease;
}

.if-table tbody tr:hover {
    background: var(--if-green-50, #F0FDF4);
}

.if-table tbody tr:last-child td {
    border-bottom: none;
}

.if-table tbody tr.inactive {
    opacity: .55;
}

.if-table tbody tr.inactive:hover {
    opacity: .8;
}

.if-table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 20px;
    color: var(--if-on-surface-4, #9BA89D);
    font-size: 13px;
}

/* ── Status Pills ── */
.if-status-pill {
    display: inline-flex;
    align-items: center;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 100px;
}

.if-status-pill.active {
    background: var(--if-green-50, #F0FDF4);
    color: var(--if-green-700, #15803D);
}

.if-status-pill.inactive {
    background: var(--if-border-faint, #F5F7F5);
    color: var(--if-on-surface-4, #9BA89D);
}

/* ── Table Row Actions ── */
.if-actions-row {
    display: flex;
    align-items: center;
    gap: 2px;
    justify-content: flex-end;
}

.if-actions-row .if-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
    color: var(--if-on-surface-4, #9BA89D);
    transition: all .15s ease;
}

.if-actions-row .if-action-btn.edit:hover {
    background: #DBEAFE;
    color: #2563EB;
}

.if-actions-row .if-action-btn.delete:hover {
    background: #FEE2E2;
    color: #DC2626;
}

@media (max-width: 768px) {
    .if-table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .if-table-search { max-width: 100%; }

    .if-table th,
    .if-table td { padding: 10px 12px; }
}

/* ===== ONBOARDING ===== */
.if-onboarding {
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
}

/* ===== STAMMDATEN CREATE LAYOUT ===== */
.sd-create-grid {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 20px;
    align-items: start;
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
    animation-delay: .08s;
}

.sd-form-card,
.sd-info-card {
    background: var(--if-surface, white);
    border: 1px solid var(--if-border, #E2E8E3);
    border-radius: var(--if-radius, 14px);
    box-shadow: var(--if-shadow-card);
}

.sd-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 22px 0;
}

.sd-card-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--if-radius-sm, 10px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sd-card-icon.green  { background: #DCFCE7; color: #15803D; }
.sd-card-icon.blue   { background: #DBEAFE; color: #2563EB; }
.sd-card-icon.amber  { background: #FEF3C7; color: #B45309; }
.sd-card-icon.purple { background: #EDE9FE; color: #7C3AED; }

.sd-card-body { padding: 20px 22px; }

.sd-card-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--if-border-light, #EEF1EE);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.sd-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--if-border-faint, #F5F7F5);
    border-radius: var(--if-radius-xs, 8px);
}

.sd-switch-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sd-switch-label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--if-on-surface, #0F1A12);
}

.sd-switch-hint {
    display: block;
    font-size: 11.5px;
    color: var(--if-on-surface-4, #9BA89D);
}

.sd-betrieb-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--if-green-50, #F0FDF4);
    border: 1px solid var(--if-green-200, #BBF7D0);
    border-radius: var(--if-radius-xs, 8px);
    font-size: 13px;
    font-weight: 600;
    color: var(--if-green-800, #166534);
    margin-bottom: 20px;
}

.sd-info-body {
    padding: 18px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sd-info-item {
    display: flex;
    gap: 10px;
    font-size: 12.5px;
    color: var(--if-on-surface-3, #6B7D6E);
    line-height: 1.5;
}

.sd-info-item strong {
    color: var(--if-on-surface, #0F1A12);
}

/* ===== ERROR / NOT FOUND PAGES ===== */
.if-error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--if-topbar-h, 60px) - 56px);
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
}

.if-error-card {
    text-align: center;
    max-width: 440px;
    padding: 48px 32px;
}

.if-error-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.if-error-icon.error   { background: #FEE2E2; }
.if-error-icon.warning { background: #FEF3C7; }

.if-error-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--if-on-surface, #0F1A12);
    margin-bottom: 12px;
}

.if-error-card p {
    font-size: 14px;
    color: var(--if-on-surface-3, #6B7D6E);
    line-height: 1.6;
}

.if-error-meta {
    font-size: 12px;
    color: var(--if-on-surface-4, #9BA89D);
    font-family: 'Roboto Mono', monospace;
}

/* ===== ADMIN FILTER CARD ===== */
.adm-filter-card {
    background: var(--if-surface, white);
    border: 1px solid var(--if-border, #E2E8E3);
    border-radius: var(--if-radius, 14px);
    box-shadow: var(--if-shadow-card);
    padding: 20px;
    margin-bottom: 20px;
    animation: ifFadeUp .4s cubic-bezier(0,0,.2,1) both;
    animation-delay: .24s;
}

.adm-filter-grid {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.adm-filter-grid > :not(.adm-filter-actions) {
    flex: 1;
    min-width: 160px;
    max-width: 240px;
}

/* Kill MudBlazor helper-text gap inside filter cards */
.adm-filter-card .mud-input-helper-text {
    display: none !important;
}

.adm-filter-card .mud-input-control {
    margin-bottom: 0 !important;
}

.adm-filter-card .mud-input-control-helper-container {
    min-height: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.adm-filter-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-bottom: 1px;
}

/* ===== KEYFRAMES ===== */
@keyframes ifFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .if-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .if-kpi-grid-5 { grid-template-columns: repeat(3, 1fr) !important; }
    .if-charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sd-create-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .if-page-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .if-kpi-grid { grid-template-columns: 1fr; }
    .if-kpi-grid-5 { grid-template-columns: repeat(2, 1fr) !important; }
}


/* =================================================================
   PHASE A — Shared Component Styles
   Added: 2026-02-17 (MudBlazor → Custom Migration)
   ================================================================= */

/* ===== BUTTONS (.if-btn) ===== */
.if-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--if-radius-xs, 8px);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .15s ease;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.3;
}

.if-btn.primary {
    background: var(--if-green-600, #16A34A);
    color: white;
    box-shadow: 0 1px 3px rgba(22,163,74,.25);
}
.if-btn.primary:hover {
    background: var(--if-green-700, #15803D);
    box-shadow: 0 2px 8px rgba(22,163,74,.3);
}
.if-btn.primary:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.if-btn.outline {
    background: var(--if-surface, white);
    color: var(--if-on-surface-2, #374839);
    border: 1px solid var(--if-border, #E2E8E3);
}
.if-btn.outline:hover {
    border-color: var(--if-on-surface-4, #9BA89D);
    background: var(--if-border-faint, #F5F7F5);
}
.if-btn.outline:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.if-btn.ghost {
    background: transparent;
    color: var(--if-on-surface-3, #6B7D6E);
}
.if-btn.ghost:hover {
    background: var(--if-border-faint, #F5F7F5);
    color: var(--if-on-surface-2, #374839);
}

.if-btn.danger {
    background: #DC2626;
    color: white;
    box-shadow: 0 1px 3px rgba(220,38,38,.2);
}
.if-btn.danger:hover { background: #B91C1C; }
.if-btn.danger:disabled { opacity: .4; cursor: not-allowed; }

.if-btn.sm {
    padding: 6px 12px;
    font-size: 12px;
}

.if-btn-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: white;
    animation: ifSpin .6s linear infinite;
}

@keyframes ifSpin { to { transform: rotate(360deg); } }


/* ===== GLOBAL BOX-SIZING ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ===== INPUTS (.if-input, .if-select) ===== */
.if-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.if-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--if-on-surface-3, #6B7D6E);
}

.if-input,
.if-select {
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--if-border, #E2E8E3);
    background: var(--if-surface, white);
    font-size: 13px;
    font-weight: 500;
    color: var(--if-on-surface, #0F1A12);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
    width: 100%;
}

.if-input:focus,
.if-select:focus {
    border-color: var(--if-green-400, #4ADE80);
    box-shadow: 0 0 0 3px rgba(74,222,128,.12);
}

.if-input.error {
    border-color: #DC2626;
}
.if-input.error:focus {
    box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

.if-input:disabled,
.if-select:disabled {
    opacity: .5;
    cursor: not-allowed;
    background: var(--if-border-faint, #F5F7F5);
}

.if-input::placeholder {
    color: var(--if-on-surface-4, #9BA89D);
}

/* Number input spinner visibility */
.if-input[type="number"]::-webkit-inner-spin-button { opacity: 1; }
.if-input[type="number"] { -moz-appearance: textfield; }

.if-select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239BA89D' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.if-hint {
    font-size: 11.5px;
    color: var(--if-on-surface-4, #9BA89D);
}

.if-error {
    font-size: 11.5px;
    color: #DC2626;
    font-weight: 500;
}


/* ===== TOGGLE (.if-toggle) ===== */
.if-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.if-toggle {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--if-border, #E2E8E3);
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.if-toggle.on { background: var(--if-green-500, #22C55E); }

.if-toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.if-toggle.on .if-toggle-knob { transform: translateX(20px); }

.if-toggle-text { display: flex; flex-direction: column; }
.if-toggle-label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--if-on-surface, #0F1A12);
}
.if-toggle-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--if-on-surface-3, #6B7D6E);
    margin-top: 1px;
}


/* ===== CHECKBOX (.if-check) ===== */
.if-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.if-check {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    border: 2px solid var(--if-border, #E2E8E3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .12s;
    background: white;
    flex-shrink: 0;
}
.if-check.on {
    background: var(--if-green-600, #16A34A);
    border-color: var(--if-green-600, #16A34A);
}

.if-check-label {
    font-size: 13px;
    color: var(--if-on-surface, #0F1A12);
}


/* ===== ALERTS (.if-alert) ===== */
.if-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--if-radius-sm, 10px);
    font-size: 13px;
    font-weight: 500;
}
.if-alert.info    { background: #EFF6FF; color: #1E40AF; }
.if-alert.success { background: var(--if-green-50, #F0FDF4); color: var(--if-green-800, #166534); }
.if-alert.warning { background: #FFF7ED; color: #9A3412; }
.if-alert.error   { background: #FEF2F2; color: #DC2626; }

.if-alert-text { flex: 1; }

.if-alert-close {
    width: 22px; height: 22px;
    border: none; border-radius: 5px;
    background: transparent;
    color: inherit; opacity: .5;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: opacity .12s;
}
.if-alert-close:hover { opacity: 1; }


/* ===== MODAL (.if-modal) ===== */
.if-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15,26,18,.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ifModalBgIn .2s ease both;
}

@keyframes ifModalBgIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.if-modal {
    background: var(--if-surface, white);
    border-radius: var(--if-radius, 14px);
    box-shadow: var(--if-shadow-elevated, 0 4px 12px rgba(15,26,18,.06), 0 16px 40px rgba(15,26,18,.04));
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: ifModalIn .25s cubic-bezier(.2,0,0,1) both;
}
.if-modal.sm { max-width: 360px; }
.if-modal.lg { max-width: 640px; }

@keyframes ifModalIn {
    from { opacity: 0; transform: scale(.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.if-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.if-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--if-on-surface, #0F1A12);
    margin: 0;
}

.if-modal-close {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--if-on-surface-4, #9BA89D);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
}
.if-modal-close:hover {
    background: var(--if-border-faint, #F5F7F5);
    color: var(--if-on-surface-2, #374839);
}

.if-modal-body {
    padding: 20px 24px;
}

.if-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--if-border-light, #EEF1EE);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}


/* ===== TOAST (.if-toast) ===== */
.if-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.if-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--if-radius-sm, 10px);
    background: var(--if-on-surface, #0F1A12);
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(15,26,18,.15), 0 16px 40px rgba(15,26,18,.1);
    pointer-events: auto;
    animation: ifToastIn .3s cubic-bezier(.2,0,0,1) both;
    max-width: 400px;
}

.if-toast.exit {
    animation: ifToastOut .25s ease both;
}

@keyframes ifToastIn {
    from { opacity: 0; transform: translateY(12px) scale(.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ifToastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100px); }
}

.if-toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.if-toast.info    .if-toast-dot { background: #60A5FA; }
.if-toast.success .if-toast-dot { background: var(--if-green-400, #4ADE80); }
.if-toast.warning .if-toast-dot { background: #FBBF24; }
.if-toast.error   .if-toast-dot { background: #F87171; }

.if-toast-msg { flex: 1; }

.if-toast-close {
    width: 24px; height: 24px;
    border: none; border-radius: 5px;
    background: transparent;
    color: rgba(255,255,255,.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color .12s;
}
.if-toast-close:hover { color: rgba(255,255,255,.8); }


/* ===== PROGRESS (.if-progress, .if-spinner) ===== */
.if-progress {
    width: 100%;
    height: 4px;
    background: var(--if-border-light, #EEF1EE);
    border-radius: 2px;
    overflow: hidden;
}

.if-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--if-green-400), var(--if-green-600));
    border-radius: 2px;
    transition: width .3s ease;
}

.if-progress-bar.indeterminate {
    width: 40%;
    animation: ifProgressSlide 1.5s ease infinite;
}

@keyframes ifProgressSlide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.if-spinner {
    display: inline-block;
    border-radius: 50%;
    border: 2.5px solid var(--if-border, #E2E8E3);
    border-top-color: var(--if-green-600, #16A34A);
    animation: ifSpin .6s linear infinite;
}
.if-spinner       { width: 20px; height: 20px; }
.if-spinner.sm    { width: 16px; height: 16px; border-width: 2px; }
.if-spinner.lg    { width: 28px; height: 28px; border-width: 3px; }


/* ===== DROPDOWN (.if-dropdown) ===== */
.if-dropdown-wrap {
    position: relative;
    display: inline-flex;
}

.if-dropdown-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.if-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 500;
    min-width: 180px;
    background: var(--if-surface, white);
    border: 1px solid var(--if-border, #E2E8E3);
    border-radius: var(--if-radius-sm, 10px);
    box-shadow: var(--if-shadow-elevated);
    padding: 4px;
    animation: ifDropIn .15s ease both;
}
.if-dropdown.right { left: auto; right: 0; }

@keyframes ifDropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.if-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--if-on-surface-2, #374839);
    cursor: pointer;
    transition: background .08s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.if-dropdown-item:hover {
    background: var(--if-border-faint, #F5F7F5);
}
.if-dropdown-item.danger { color: #DC2626; }
.if-dropdown-item.danger:hover { background: #FEF2F2; }

.if-dropdown-sep {
    height: 1px;
    background: var(--if-border-light, #EEF1EE);
    margin: 4px 0;
}


/* ===== SCREEN READER ONLY ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}
