﻿/* ======================================================
   THEME VARIABLES
====================================================== */

:root {
    /* Motion tokeni (jedini izvor). motion.css ih gasi za prefers-reduced-motion. */
    --motion-duration-fast: 120ms;
    --motion-duration-base: 180ms;
    --motion-duration-emphasis: 240ms;
    --motion-duration-exit: 140ms;
    --motion-ease-standard: cubic-bezier(0.2, 0.8, 0.25, 1);
    --motion-ease-emphasis: cubic-bezier(0.16, 1, 0.3, 1);
    --motion-ease-exit: cubic-bezier(0.4, 0, 1, 1);
    --motion-duration-state: 220ms;
    --motion-ease-state: cubic-bezier(0.2, 0, 0, 1);
    --motion-spin-duration: 0.8s;
    --app-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bs-font-sans-serif: var(--app-font-family);
    --bs-body-font-family: var(--app-font-family);
    --color-primary: #253965;
    --color-primary-rgb: 37, 57, 101;
    --color-on-primary: #ffffff;
    --color-text: #333333;
    --color-link: #006bb7;
    --color-bg: #ffffff;
    --color-bg-soft: #f8f9fa;
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;
    --color-surface-muted: #f4f6fb;
    --color-border: #dee2e6;
    --color-border-strong: #cbd5e1;
    --color-success: #34a36f;
    --color-success-dark: #2c8c5d;
    --color-warning: #d4920a;
    --color-info: #2b67c2;
    --color-danger: #dc2626;
    --color-error-bg: #fef2f2;
    --color-error-border: #fecaca;
    --color-error-text: #dc2626;
    --color-table-header-bg: #f8f9fa;
    --color-btn-primary: #253965;
    --color-btn-primary-border: #1e2f52;
    --color-primary-soft: #eef3fa;
    --modal-backdrop-opacity: 0.5;
    --color-text-muted: #6c757d;
    --color-text-strong: #111827;
    --color-hover: #f4f6fb;
    --color-app-shell: #eef0f4;
    --color-topbar: #253965;
    --color-topbar-text: #ffffff;
    --color-accent: #f59e0b;
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-floating: 0 16px 42px rgba(19, 29, 53, 0.18);
    --focus-ring: 0 0 0 3px rgba(37, 57, 101, 0.12);
    --status-success-bg: #dcfce7;
    --status-success-text: #15803d;
    --status-warning-bg: #fef3c7;
    --status-warning-text: #b45309;
    --status-danger-bg: #fde2e2;
    --status-danger-text: #c62828;
    --status-info-bg: #e0f2fe;
    --status-info-text: #0369a1;
    /* Button palette */
    --btn-add: #2d6a4f;
    --btn-add-hover: #1b4332;
    --btn-add-active: #14352a;
    --btn-save: #40916c;
    --btn-save-hover: #2d6a4f;
    --btn-save-active: #1b4332;
    --btn-delete: #d62828;
    --btn-delete-hover: #ba181b;
    --btn-delete-active: #a4161a;
    --btn-cancel: #6c757d;
    --btn-cancel-hover: #5c636a;
    --btn-cancel-active: #565e64;
    --btn-download: #264653;
    --btn-download-hover: #1d3540;
    --btn-download-active: #162a33;
    --btn-print: #2a9d8f;
    --btn-print-hover: #238176;
    --btn-print-active: #1c6b61;
    --btn-edit: #e76f51;
    --btn-edit-hover: #d35d3f;
    --btn-edit-active: #bf4b2e;
    --btn-export: #059669;
    --btn-export-hover: #047857;
    --btn-export-active: #065f46;
    --btn-refresh: var(--color-primary, #1e2e52);
    --btn-refresh-hover: var(--color-primary-hover, var(--color-btn-primary-border, #16223f));
    --btn-refresh-active: var(--color-primary-hover, var(--color-btn-primary-border, #16223f));
}

/* ======================================================
   THEMES
====================================================== */

.theme-light {
    --color-bg: #ffffff;
    --color-bg-soft: #f8f9fa;
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;
    --color-surface-muted: #f4f6fb;
    --color-text: #333333;
    --color-text-strong: #111827;
    --color-text-muted: #6c757d;
    --color-primary: #253965;
    --color-primary-rgb: 37, 57, 101;
    --color-on-primary: #ffffff;
    --color-link: #006bb7;
    --color-table-header-bg: #f8f9fa;
    --color-border: #dee2e6;
    --color-border-strong: #cbd5e1;
    --color-hover: #f4f6fb;
    --color-app-shell: #eef0f4;
    --color-topbar: #253965;
    --color-topbar-text: #ffffff;
    --color-accent: #f59e0b;
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-floating: 0 16px 42px rgba(19, 29, 53, 0.18);
    color-scheme: light;
}

.theme-midnight,
.theme-dark {
    --color-primary: #6e8cd9;
    --color-primary-rgb: 110, 140, 217;
    --color-on-primary: #ffffff;
    --color-primary-soft: #1f2b4d;
    --color-link: #8fb3ff;
    --color-bg: #0d1424;
    --color-bg-soft: #111b2f;
    --color-surface: #131c30;
    --color-surface-elevated: #17233b;
    --color-surface-muted: #1f2b4d;
    --color-border: #233054;
    --color-border-strong: #34456e;
    --color-text: #e5ebf5;
    --color-text-strong: #ffffff;
    --color-text-muted: #8a98b6;
    --color-table-header-bg: #111b2f;
    --color-hover: #1b2742;
    --color-app-shell: #0b1220;
    --color-topbar: #0d1424;
    --color-topbar-text: #e5ebf5;
    --color-accent: #ffbf24;
    --color-success: #4ade80;
    --color-success-dark: #22c55e;
    --color-warning: #ffbf24;
    --color-info: #60a5fa;
    --color-danger: #f87171;
    --color-error-bg: rgba(248, 113, 113, 0.12);
    --color-error-border: rgba(248, 113, 113, 0.35);
    --color-error-text: #fca5a5;
    --color-btn-primary: #6e8cd9;
    --color-btn-primary-border: #8aa6e8;
    --modal-backdrop-opacity: 0.65;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(110, 140, 217, 0.06);
    --shadow-floating: 0 18px 54px rgba(0, 0, 0, 0.38);
    --focus-ring: 0 0 0 3px rgba(110, 140, 217, 0.20);
    --status-success-bg: rgba(74, 222, 128, 0.16);
    --status-success-text: #86efac;
    --status-warning-bg: rgba(255, 191, 36, 0.18);
    --status-warning-text: #fde68a;
    --status-danger-bg: rgba(248, 113, 113, 0.16);
    --status-danger-text: #fecaca;
    --status-info-bg: rgba(96, 165, 250, 0.16);
    --status-info-text: #93c5fd;
    --btn-add: #22c55e;
    --btn-add-hover: #16a34a;
    --btn-save: #4ade80;
    --btn-save-hover: #22c55e;
    --btn-delete: #ef4444;
    --btn-delete-hover: #dc2626;
    --btn-cancel: #64748b;
    --btn-download: #60a5fa;
    --btn-print: #38bdf8;
    --btn-edit: #ffbf24;
    --btn-export: #4ade80;
    --btn-refresh: #60a5fa;
    color-scheme: dark;
}

.theme-fresh {
    --color-primary: #0f766e;
    --color-primary-rgb: 15, 118, 110;
    --color-on-primary: #ffffff;
    --color-primary-soft: #d1f0ec;
    --color-link: #0369a1;
    --color-bg: #ffffff;
    --color-bg-soft: #f1f7f7;
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;
    --color-surface-muted: #f1f7f7;
    --color-border: #d6e4e4;
    --color-border-strong: #b8d2d0;
    --color-text: #0f2424;
    --color-text-strong: #061616;
    --color-text-muted: #5e6b6e;
    --color-table-header-bg: #f1f7f7;
    --color-hover: #e3f4f2;
    --color-app-shell: #eef7f6;
    --color-topbar: #0f766e;
    --color-topbar-text: #ffffff;
    --color-accent: #ff7316;
    --color-success: #15803d;
    --color-success-dark: #166534;
    --color-warning: #b45309;
    --color-info: #0369a1;
    --color-danger: #b91c1c;
    --color-error-bg: #fde2e2;
    --color-error-border: #f7b7b7;
    --color-error-text: #b91c1c;
    --color-btn-primary: #0f766e;
    --color-btn-primary-border: #0b5f59;
    --modal-backdrop-opacity: 0.45;
    --shadow-card: 0 1px 3px rgba(15, 36, 36, 0.04), 0 10px 24px rgba(15, 118, 110, 0.08);
    --shadow-floating: 0 18px 44px rgba(15, 36, 36, 0.16);
    --focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.16);
    --status-success-bg: #d8f8df;
    --status-success-text: #166534;
    --status-warning-bg: #fff0c7;
    --status-warning-text: #92400e;
    --status-danger-bg: #fde2e2;
    --status-danger-text: #991b1b;
    --status-info-bg: #dff1fb;
    --status-info-text: #075985;
    --btn-add: #0f766e;
    --btn-add-hover: #0b5f59;
    --btn-save: #15803d;
    --btn-save-hover: #166534;
    --btn-delete: #b91c1c;
    --btn-delete-hover: #991b1b;
    --btn-cancel: #5e6b6e;
    --btn-download: #0369a1;
    --btn-print: #0f766e;
    --btn-edit: #ff7316;
    --btn-export: #15803d;
    --btn-refresh: #0369a1;
    color-scheme: light;
}

/* ======================================================
   BASE
====================================================== */

html,
body,
.layout {
    font-family: var(--app-font-family, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    font-size: var(--app-font-size, 16px);
    line-height: 1.5;
    background: var(--color-app-shell);
    color: var(--color-text);
}

.font-family-inter {
    --app-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bs-font-sans-serif: var(--app-font-family);
    --bs-body-font-family: var(--app-font-family);
}

.font-family-geist {
    --app-font-family: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bs-font-sans-serif: var(--app-font-family);
    --bs-body-font-family: var(--app-font-family);
}

.font-family-system {
    --app-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bs-font-sans-serif: var(--app-font-family);
    --bs-body-font-family: var(--app-font-family);
}

button,
input,
select,
textarea {
    font-family: inherit;
}

h1, h2, h3 {
    font-weight: 600;
}

table, input, select {
    font-size: 13px;
}

.label, .field-label {
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

a, .btn-link {
    color: var(--color-link);
}

.content {
    padding-top: 1.1rem;
    background: var(--color-app-shell);
    color: var(--color-text);
}

h1:focus {
    outline: none;
}

/* ======================================================
   BUTTONS
====================================================== */

.btn-primary {
    color: var(--color-on-primary);
    background-color: var(--color-btn-primary);
    border-color: var(--color-btn-primary-border);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--color-surface), var(--focus-ring);
}

/* FIX: dodao zarez koji je nedostajao — focus-visible se sad ispravno primenjuje */
.btn-link:focus,
.btn-link:active,
.btn-link:hover,
.btn-link:focus-visible {
    box-shadow: none;
    outline: none;
}

.btn-link:hover {
    color: var(--color-primary) !important;
    font-weight: 500;
}

/* ======================================================
   VALIDATION
====================================================== */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--color-success);
}

.invalid {
    outline: 1px solid var(--color-danger);
}

.validation-message {
    color: var(--color-danger);
}

/* ======================================================
   BLAZOR ERROR
====================================================== */

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+...) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

/* ======================================================
   TABLES
====================================================== */

table thead,
.table thead {
    background-color: var(--color-table-header-bg) !important;
    color: var(--color-primary) !important;
}

    table thead th,
    .table thead th {
        background-color: var(--color-table-header-bg) !important;
        color: var(--color-primary) !important;
        font-weight: 600;
        font-size: 0.875rem;
        padding: 10px 8px;
        border-bottom: 2px solid var(--color-border) !important;
        border-top: 1px solid var(--color-border) !important;
        text-align: left;
    }

table tbody tr,
.table tbody tr {
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

    table tbody tr:hover,
    .table tbody tr:hover {
        background-color: var(--color-bg-soft);
    }

table tbody td,
.table tbody td {
    padding: 12px 8px;
    color: var(--color-text);
    font-size: 0.875rem;
    vertical-align: middle;
}

.table-bordered thead th,
.table-bordered thead td {
    border-color: var(--color-border) !important;
}

/* ======================================================
   ACTION BUTTON BAR
====================================================== */

.action-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

        .action-buttons button {
            width: 100%;
        }
}

/* ======================================================
   INPUT COMPONENT
====================================================== */

.input-wrapper {
    margin-bottom: 10px;
}

.input-label {
    display: block;
    font-weight: 500;
    font-size: 12.5px;
    color: var(--color-text);
    margin-bottom: 4px;
    line-height: 1.15;
    transition: color var(--motion-duration-fast) var(--motion-ease-standard);
}

.input-wrapper:has(.input-inner:focus-within) .input-label {
    color: var(--color-primary);
}

.input-wrapper:has(.input-inner.invalid) .input-label {
    color: var(--color-error-text);
}

.required-mark {
    color: var(--color-error-text);
    margin-left: 2px;
}

/* ─── Input inner wrapper ─── */
.input-inner {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    border: 1px solid var(--field-border, var(--color-border));
    border-radius: 10px;
    background: var(--field-fill, var(--color-bg-soft));
    transition: border-color var(--motion-duration-fast) var(--motion-ease-standard), background-color var(--motion-duration-fast) var(--motion-ease-standard), box-shadow var(--motion-duration-fast) var(--motion-ease-standard);
}

    .input-inner:hover:not(:has(input:disabled)):not(:has(input:read-only)) {
        border-color: var(--color-text-muted);
    }

    .input-inner:focus-within:not(:has(input:disabled)):not(:has(input:read-only)) {
        border-color: var(--field-focus-border, var(--color-primary));
    }

    .input-inner.invalid {
        border-color: var(--color-error-border);
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    }

        .input-inner.invalid:focus-within {
            border-bottom-color: var(--color-error-border);
        }

/* ─── Prefix icon ─── */
.input-icon.prefix {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    background-color: transparent;
    border: 0;
    border-radius: 0;
    color: var(--color-text-muted);
    flex-shrink: 0;
    pointer-events: none;
}

.input-inner:focus-within .input-icon.prefix {
    color: var(--color-primary);
}

.input-inner.invalid .input-icon.prefix {
    color: var(--color-error-text);
}

/* ─── Input field ─── */
:root {
    --app-field-height: 40px;
}

.input-field {
    flex: 1;
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--field-child-fill, var(--field-fill, var(--color-bg-soft)));
    border: none;
    outline: none;
    min-height: var(--app-field-height);
    min-width: 0;
}

    .input-field::placeholder {
        color: var(--color-text-muted);
        opacity: 0.7;
    }

    /* FIX: jedna deklaracija za disabled (sa opacity) — uklonjen duplikat */
    .input-field:disabled {
        background-color: var(--color-bg-soft);
        color: var(--color-text-muted);
        cursor: not-allowed;
        opacity: 0.6;
    }

    /* ReadOnly */
    .input-field:read-only:not(:disabled) {
        background-color: transparent;
        cursor: default;
        color: var(--color-text);
    }

.input-inner:has(input:read-only:not(:disabled)) {
    border-bottom-style: solid;
}

    .input-inner:has(input:read-only:not(:disabled)):hover,
    .input-inner:has(input:read-only:not(:disabled)):focus-within {
        border-color: var(--color-border);
    }

/* ─── Suffix ─── */
.input-suffix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: transparent;
    border-left: none;
    color: var(--color-text-muted);
    font-size: 14px;
    cursor: default;
    pointer-events: none;
}

    .input-suffix.static {
        border-left: none;
        background: var(--color-bg-soft);
        cursor: default;
        pointer-events: none;
    }

.input-inner:focus-within .input-suffix {
    border-color: var(--color-primary);
}

.input-inner.invalid .input-suffix {
    border-color: var(--color-error-border);
}

/* ─── Legacy input group ─── */
.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    background-color: var(--color-bg-soft);
    border: 1px solid var(--color-border);
    border-right: none;
    border-radius: 6px 0 0 6px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.input-field.with-icon {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.input-group:focus-within .input-icon {
    border-color: var(--color-primary);
}

.input-group:has(.input-field.invalid) .input-icon {
    border-color: var(--color-error-border);
}

/* ─── Validation ─── */
.input-field.invalid,
.input-field.invalid:focus {
    border-color: var(--color-error-border);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

    .input-field.invalid.with-icon {
        border-left: none;
    }

.error-message {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-error-text);
}

.help-text {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.2;
    color: var(--color-text-muted);
}

/* ======================================================
   USER APPEARANCE - FORM FIELD STYLES
====================================================== */

html[data-field-text="underline"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 10px;
    background: var(--field-fill, var(--color-surface));
}

html[data-field-text="outlined"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 8px;
    background: var(--field-fill, var(--color-surface));
    overflow: hidden;
}

html[data-field-text="outlined"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner:hover:not(:has(input:disabled)):not(:has(input:read-only)) {
    border-color: var(--field-focus-border, var(--color-primary));
}

html[data-field-text="outlined"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner:focus-within:not(:has(input:disabled)):not(:has(input:read-only)) {
    border-color: var(--field-focus-border, var(--color-primary));
    box-shadow: var(--focus-ring);
}

html[data-field-text="outlined"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-field {
    min-height: var(--app-field-height);
    background: var(--field-child-fill, var(--field-fill, var(--color-surface)));
}

html[data-field-text="filled"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 10px;
    background: var(--field-fill, var(--color-bg-soft));
    overflow: hidden;
}

html[data-field-text="filled"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner:focus-within:not(:has(input:disabled)):not(:has(input:read-only)) {
    border-color: var(--field-focus-border, var(--color-primary));
}

html[data-field-text="filled"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-field {
    min-height: var(--app-field-height);
    background: var(--field-child-fill, var(--field-fill, var(--color-bg-soft)));
}

html[data-field-text="floating"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) {
    position: relative;
}

html[data-field-text="floating"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-label {
    position: absolute;
    z-index: 1;
    left: 12px;
    top: 6px;
    margin: 0;
    padding: 0 4px;
    background: var(--color-surface);
    color: var(--color-primary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

html[data-field-text="floating"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 8px;
    background: var(--field-fill, var(--color-surface));
    overflow: hidden;
}

html[data-field-text="floating"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-inner:focus-within:not(:has(input:disabled)):not(:has(input:read-only)) {
    border-color: var(--field-focus-border, var(--color-primary));
    box-shadow: var(--focus-ring);
}

html[data-field-text="floating"] .input-wrapper:not(.has-date-picker):not(:has(.select-display)):not(:has(input[type="date"])) .input-field {
    min-height: var(--app-field-height);
    padding-top: 16px;
    background: var(--field-child-fill, var(--field-fill, var(--color-surface)));
}

html[data-field-select="outlined"] .input-wrapper:has(.select-display) .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 8px;
    background: var(--field-fill, var(--color-surface));
    overflow: hidden;
}

html[data-field-select="outlined"] .input-wrapper:has(.select-display) .input-inner:focus-within,
html[data-field-select="outlined"] .input-wrapper:has(.select-display) .input-inner:hover {
    border-color: var(--field-focus-border, var(--color-primary));
}

html[data-field-select="outlined"] .input-wrapper:has(.select-display) .select-display {
    min-height: var(--app-field-height);
    background: var(--field-child-fill, var(--field-fill, var(--color-surface)));
}

html[data-field-select] .select-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

html[data-field-select] .select-display::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    opacity: .7;
    flex: 0 0 auto;
}

html[data-field-select="filled"] .input-wrapper:has(.select-display) .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 10px;
    background: var(--field-fill, var(--color-bg-soft));
    overflow: hidden;
}

html[data-field-select="filled"] .input-wrapper:has(.select-display) .input-inner:focus-within,
html[data-field-select="filled"] .input-wrapper:has(.select-display) .input-inner:hover {
    border-color: var(--field-focus-border, var(--color-primary));
}

html[data-field-select="filled"] .input-wrapper:has(.select-display) .select-display {
    min-height: var(--app-field-height);
    background: var(--field-child-fill, var(--field-fill, var(--color-bg-soft)));
}

html[data-field-select="pill"] .input-wrapper:has(.select-display) .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border));
    border-radius: 999px;
    background: var(--field-fill, var(--color-surface));
    overflow: hidden;
}

html[data-field-select="pill"] .input-wrapper:has(.select-display) .input-inner:focus-within,
html[data-field-select="pill"] .input-wrapper:has(.select-display) .input-inner:hover {
    border-color: var(--field-focus-border, var(--color-primary));
    box-shadow: var(--focus-ring);
}

html[data-field-select="pill"] .input-wrapper:has(.select-display) .select-display {
    min-height: var(--app-field-height);
    background: var(--field-child-fill, var(--field-fill, var(--color-surface)));
}

html[data-field-select="pill"] .select-dropdown {
    border-radius: 14px;
}

html[data-field-checkbox="square"] .cb-filled .cb-box,
html[data-field-checkbox="square"] .cb-card .cb-box {
    border-radius: 4px;
}

html[data-field-checkbox="rounded"] .cb-filled .cb-box,
html[data-field-checkbox="rounded"] .cb-card .cb-box {
    border-radius: 999px;
}

html[data-field-checkbox="switch"] .cb-filled .cb-box,
html[data-field-checkbox="switch"] .cb-card .cb-box {
    width: 36px;
    height: 20px;
    border-radius: 999px;
    border-color: var(--color-border-strong);
    background: var(--color-border-strong);
    position: relative;
}

html[data-field-checkbox="switch"] .cb-filled .cb-box::before,
html[data-field-checkbox="switch"] .cb-card .cb-box::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: transform var(--motion-duration-state) var(--motion-ease-state);
}

html[data-field-checkbox="switch"] .cb-filled.cb-checked .cb-box,
html[data-field-checkbox="switch"] .cb-card.cb-checked .cb-box {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

html[data-field-checkbox="switch"] .cb-filled.cb-checked .cb-box::before,
html[data-field-checkbox="switch"] .cb-card.cb-checked .cb-box::before {
    transform: translateX(16px);
}

html[data-field-checkbox="switch"] .cb-filled .cb-check-svg,
html[data-field-checkbox="switch"] .cb-card .cb-check-svg {
    display: none;
}

html[data-field-date="icon"] .input-wrapper:has(input[type="date"]) .input-inner,
html[data-field-date="icon"] .input-wrapper.has-date-picker .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 8px;
    background: var(--field-fill, var(--color-surface));
    overflow: hidden;
}

html[data-field-date="icon"] .input-wrapper:has(input[type="date"]) .input-inner::before,
html[data-field-date="icon"] .input-wrapper.has-date-picker .input-inner::before {
    content: "";
    width: 15px;
    height: 15px;
    margin-left: 12px;
    align-self: center;
    border: 1.5px solid var(--color-primary);
    border-radius: 4px;
    box-shadow: inset 0 4px 0 color-mix(in srgb, var(--color-primary) 18%, transparent);
    flex: 0 0 auto;
}

html[data-field-date="icon"] .input-wrapper:has(input[type="date"]) .input-field,
html[data-field-date="icon"] .input-wrapper.has-date-picker .dt-field {
    min-height: var(--app-field-height);
    background: var(--field-child-fill, var(--field-fill, var(--color-surface)));
}

html[data-field-date="filled"] .input-wrapper:has(input[type="date"]) .input-inner,
html[data-field-date="filled"] .input-wrapper.has-date-picker .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 8px;
    background: var(--field-fill, var(--color-bg-soft));
    overflow: hidden;
}

html[data-field-date="filled"] .input-wrapper:has(input[type="date"]) .input-inner:focus-within,
html[data-field-date="filled"] .input-wrapper.has-date-picker .input-inner:focus-within {
    border-color: var(--field-focus-border, var(--color-primary));
}

html[data-field-date="filled"] .input-wrapper:has(input[type="date"]) .input-field,
html[data-field-date="filled"] .input-wrapper.has-date-picker .dt-field {
    min-height: var(--app-field-height);
    background: var(--field-child-fill, var(--field-fill, var(--color-bg-soft)));
}

html[data-field-date="segmented"] .input-wrapper:has(input[type="date"]) .input-inner,
html[data-field-date="segmented"] .input-wrapper.has-date-picker .input-inner {
    border: 1px var(--field-line-style, solid) var(--field-border, var(--color-border-strong));
    border-radius: 8px;
    background:
        linear-gradient(90deg, transparent 0 32%, var(--color-border) 32% 33%, transparent 33% 65%, var(--color-border) 65% 66%, transparent 66% 100%),
        var(--field-fill, var(--color-surface));
    overflow: hidden;
}

html[data-field-date="segmented"] .input-wrapper:has(input[type="date"]) .input-inner:focus-within,
html[data-field-date="segmented"] .input-wrapper.has-date-picker .input-inner:focus-within {
    border-color: var(--field-focus-border, var(--color-primary));
    box-shadow: var(--focus-ring);
}

html[data-field-date="segmented"] .input-wrapper:has(input[type="date"]) .input-field,
html[data-field-date="segmented"] .input-wrapper.has-date-picker .dt-field {
    min-height: var(--app-field-height);
    background: transparent;
    text-align: center;
    font-weight: 700;
    letter-spacing: .04em;
}

/* ======================================================
   UTILITY
====================================================== */

.bg-success-soft {
    background-color: rgba(25, 135, 84, 0.1);
}

.bg-danger-soft {
    background-color: rgba(220, 53, 69, 0.1);
}

.text-success-strong {
    color: #146c43;
}

.text-danger-strong {
    color: #b02a37;
}

.shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    50% {
        transform: translateX(3px);
    }

    75% {
        transform: translateX(-3px);
    }

    100% {
        transform: translateX(0);
    }
}

.spin {
    animation: spin var(--motion-spin-duration) linear infinite;
}

/* Jedini spin keyframe u aplikaciji; scoped CSS ga koristi preko imena "spin". */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ======================================================
   DOCUMENTS — Invoice status bar
====================================================== */

.invoice-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: var(--color-surface);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-bottom: 2px solid;
}

.left-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.invoice-id {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
    color: var(--color-text-muted);
}

.efaktura-icon {
    height: 18px;
}

.right-section {
    display: flex;
    gap: 0.5rem;
}

/* ─── Nav wrapper ─── */
.nav-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-surface-muted);
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
}

/* ─── Nav buttons ─── */
.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 0.6rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-text);
    border-radius: 6px;
    white-space: nowrap;
    user-select: none;
    transition: background-color var(--motion-duration-fast) var(--motion-ease-standard), color var(--motion-duration-fast) var(--motion-ease-standard), transform var(--motion-duration-fast) var(--motion-ease-standard), box-shadow var(--motion-duration-fast) var(--motion-ease-standard);
}

.nav-btn__label {
    display: inline-block;
}

.nav-btn__icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2; /* FIX: zarez → tačka */
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    transition: transform var(--motion-duration-fast) var(--motion-ease-standard);
}

.nav-btn:hover:not(:disabled) {
    background: var(--color-hover);
    color: var(--color-primary);
    box-shadow: var(--shadow-card);
}

.nav-btn--prev:hover:not(:disabled) .nav-btn__icon {
    transform: translateX(-2px);
}

.nav-btn--next:hover:not(:disabled) .nav-btn__icon {
    transform: translateX(2px);
}

.nav-btn:active:not(:disabled) {
    background: var(--color-border);
    transform: translateY(1px);
    box-shadow: none;
}

.nav-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: var(--color-text-muted);
}

.nav-id {
    font-family: "SF Mono", Consolas, "Courier New", monospace;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-text-strong);
    padding: 0.25rem 0.6rem;
    background: var(--color-surface);
    border-radius: 6px;
    border: 1px solid var(--color-border);
    line-height: 1.2;
    user-select: none;
}

/* ─── Status boje ─── */
.invoice-status-bar.status-info {
    border-bottom-color: var(--color-info);
    color: var(--color-info);
}

.invoice-status-bar.status-success {
    border-bottom-color: var(--color-success);
    color: var(--color-success);
}

.invoice-status-bar.status-danger {
    border-bottom-color: var(--color-danger);
    color: var(--color-danger);
}

.invoice-status-bar.status-warning {
    border-bottom-color: var(--color-warning);
    color: var(--color-warning);
}

.invoice-status-bar.status-neutral {
    border-bottom-color: var(--color-text-muted);
    color: var(--color-text-muted);
}

/* ─── Invoice cards ─── */
.invoice-header-card,
.invoice-supplier-card,
.invoice-sef-card {
    padding: 1.25rem 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-card);
}

.invoice-header-label,
.invoice-supplier-label,
.invoice-sef-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--color-primary);
    text-transform: uppercase;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.invoice-header-field {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--color-border);
}

    .invoice-header-field:last-child {
        border-bottom: none;
    }

.invoice-header-field-label {
    flex: 0 0 180px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.invoice-header-field-value {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-strong);
}

.invoice-header-input {
    flex: 1;
    margin-bottom: 0 !important;
}

    .invoice-header-input .input-wrapper {
        margin-bottom: 0;
    }

    .invoice-header-input .input-label {
        display: none;
    }

.invoice-supplier-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text-strong);
    margin-bottom: 0.75rem;
}

.invoice-supplier-details {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.88rem;
    color: var(--color-text);
}

.supplier-detail-row {
    display: flex;
    gap: 0.5rem;
}

.supplier-detail-label {
    font-weight: 600;
    color: var(--color-text-muted);
    min-width: 110px;
}

.totals-bar {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    background-color: var(--color-surface-muted);
    border-top: 2px solid var(--color-primary);
    border-radius: 0 0 6px 6px;
    font-size: 0.875rem;
    color: var(--color-text);
}

    .totals-bar strong {
        color: var(--color-primary);
    }

/* ======================================================
   STAVKE — Unos forme
====================================================== */

.stavka-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stavka-section-optional {
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    font-size: 10px;
    opacity: 0.7;
}

/* ─── Computed (readonly) polja ─── */
.input-computed .input-field,
.input-computed input {
    background: var(--color-bg-soft) !important;
    color: var(--color-text-muted) !important;
    font-weight: 600;
    cursor: default;
    border-bottom-color: transparent !important;
    border-bottom-style: solid !important;
}

.input-computed .input-inner {
    border-bottom-color: transparent !important;
    background: var(--color-bg-soft);
    border-radius: 3px;
}

/* Highlighted computed — Vrednost sa PDV */
.input-computed--highlight .input-field,
.input-computed--highlight input {
    color: var(--color-primary) !important;
    background: var(--color-primary-soft) !important;
    font-size: 1rem;
}

.input-computed--highlight .input-inner {
    border-bottom-color: var(--color-primary) !important;
    background: var(--color-primary-soft);
}

/* ─── Stavka akcije ─── */
.stavka-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding-top: 6px;
}

.btn-stavka-reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: var(--color-bg-soft);
    color: var(--color-text-muted);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--motion-duration-fast) var(--motion-ease-standard), color var(--motion-duration-fast) var(--motion-ease-standard);
}

    .btn-stavka-reset:hover {
        background: var(--color-border);
        color: var(--color-text);
    }

.btn-stavka-dodaj {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: var(--color-success);
    color: #fff;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--motion-duration-fast) var(--motion-ease-standard), transform 80ms var(--motion-ease-standard);
}

    .btn-stavka-dodaj:hover {
        background: var(--color-success-dark);
    }

    .btn-stavka-dodaj:active {
        transform: translateY(1px);
    }

.btn-stavka-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--btn-delete);
    background: transparent;
    color: var(--btn-delete);
    border-radius: 6px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    transition: background var(--motion-duration-fast) var(--motion-ease-standard), color var(--motion-duration-fast) var(--motion-ease-standard);
}

    .btn-stavka-delete:hover {
        background: var(--btn-delete);
        color: white;
    }

.toast-container {
    position: fixed;
    z-index: 2147483647 !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: min(420px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    isolation: isolate;
}

.app-drawer.uf-repromaterijal-drawer .app-drawer-body {
    padding: 8px 8px 12px;
    overflow-x: visible;
}

.app-drawer.uf-prijemnica-drawer.uf-prijemnica-drawer-compact .app-drawer-body {
    padding: 0 !important;
    overflow: hidden !important;
    scrollbar-width: none;
}

.app-drawer.uf-prijemnica-drawer.uf-prijemnica-drawer-compact .app-drawer-body::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none;
}

.toast-container > * {
    pointer-events: auto;
    z-index: inherit;
}

.toast-bar,
.toast-bar * {
    pointer-events: auto;
}

.toast-bar {
    position: relative;
    z-index: inherit;
}

    .toast-container.toast-top-left {
        top: max(16px, env(safe-area-inset-top));
        left: max(16px, env(safe-area-inset-left));
        align-items: flex-start;
    }

    .toast-container.toast-top-left .toast-text {
        white-space: pre-line;
    }

    .toast-container.toast-top-center {
        top: max(16px, env(safe-area-inset-top));
        left: 50%;
        transform: translateX(-50%);
        align-items: center;
    }

    .toast-container.toast-top-right {
        top: max(16px, env(safe-area-inset-top));
        right: max(16px, env(safe-area-inset-right));
        align-items: flex-end;
    }

    .toast-container.toast-bottom-left {
        bottom: 20px;
        left: 20px;
        align-items: flex-start;
        flex-direction: column-reverse;
    }

    .toast-container.toast-bottom-center {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        align-items: center;
        flex-direction: column-reverse;
    }

    .toast-container.toast-bottom-right {
        bottom: 20px;
        right: 20px;
        align-items: flex-end;
        flex-direction: column-reverse;
    }


.lookup-spinner-icon {
    animation: spin var(--motion-spin-duration) linear infinite;
}

/* =========================
   CHIP SELECTOR CONTAINER
========================= */
.chip-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* =========================
   TITLE
========================= */
.chip-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

/* =========================
   TOOLBAR
========================= */
.chip-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}

.chip-search {
    flex: 1;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    font-size: 0.85rem;
    background: var(--color-surface);
    color: var(--color-text);
    transition: background-color var(--motion-duration-fast), border-color var(--motion-duration-fast), color var(--motion-duration-fast), box-shadow var(--motion-duration-fast), opacity var(--motion-duration-fast), transform var(--motion-duration-fast);
}

    .chip-search:focus {
        outline: none;
        border-color: var(--color-primary);
        box-shadow: var(--focus-ring);
    }

/* BUTTONS */
.chip-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: var(--color-on-primary);
    cursor: pointer;
    transition: var(--motion-duration-fast);
}

    .chip-btn:hover {
        background: color-mix(in srgb, var(--color-primary) 84%, #000);
    }

    .chip-btn.ghost {
        background: transparent;
        color: var(--color-primary);
    }

/* =========================
   GRID LAYOUT (🔥 KLJUČ)
========================= */
.role-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}


/* =========================
   CHIP BASE
========================= */
.role-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    gap: 0.45rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    cursor: pointer;
    transition: background-color var(--motion-duration-fast) var(--motion-ease-standard), border-color var(--motion-duration-fast) var(--motion-ease-standard), color var(--motion-duration-fast) var(--motion-ease-standard), box-shadow var(--motion-duration-fast) var(--motion-ease-standard), opacity var(--motion-duration-fast) var(--motion-ease-standard), transform var(--motion-duration-fast) var(--motion-ease-standard);
}

    /* HOVER */
    .role-chip:hover {
        border-color: var(--color-primary);
        color: var(--color-primary);
        background: var(--color-hover);
        transform: translateY(-1px);
    }

    /* =========================
   ACTIVE
========================= */
    .role-chip.active {
        background: var(--color-primary);
        border-color: var(--color-primary);
        color: var(--color-on-primary) !important;
        box-shadow: var(--focus-ring);
        transform: scale(1.03);
    }

        .role-chip.active * {
            color: var(--color-on-primary) !important;
        }

    /* ICON */
    .role-chip i {
        font-size: 0.85rem;
        opacity: 0.85;
    }

    .role-chip.active i {
        opacity: 1;
    }

    /* =========================
   VARIANTS (only when NOT active)
========================= */
    .role-chip.role:not(.active) {
        background: var(--color-surface-muted);
    }

    .role-chip.org:not(.active) {
        background: color-mix(in srgb, var(--color-success) 8%, var(--color-surface));
    }

    .role-chip.app:not(.active) {
        background: var(--color-primary-soft);
        border-color: color-mix(in srgb, var(--color-primary) 22%, var(--color-border));
    }

    .role-chip.module:not(.active) {
        background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
    }

    /* =========================
   FOCUS (keyboard)
========================= */
    .role-chip.focused {
        outline: 2px solid var(--color-primary);
    }

/* =========================
   EMPTY STATE
========================= */
.empty-state {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    padding: 0.5rem 0;
}

/* =========================
   CARD SPACING
========================= */
.collapsable-card + .collapsable-card {
    margin-top: 0.7rem;
}

.page-error-state {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--color-error-border);
    border-radius: 16px;
    background: linear-gradient(135deg, var(--color-error-bg) 0%, var(--color-surface) 100%);
    color: var(--color-error-text);
    box-shadow: var(--shadow-card);
}

.page-error-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    background: var(--color-error-bg);
    color: var(--color-error-text);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.page-error-state__copy {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.2rem;
}

.page-error-state__copy span {
    color: var(--color-error-text);
    font-size: 0.92rem;
}

.page-error-state__action {
    border: none;
    border-radius: 10px;
    background: var(--color-primary);
    color: var(--color-on-primary);
    padding: 0.65rem 0.9rem;
    font-weight: 600;
}

/* =========================
   BEX INTEGRATION
========================= */
.bex-api-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bex-api-callout,
.bex-api-empty-state,
.bex-api-error-state {
    border: 1px solid color-mix(in srgb, var(--color-primary) 16%, var(--color-border));
    border-radius: 18px;
    padding: 0.9rem 1.1rem;
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 6%, var(--color-surface)) 0%, var(--color-surface) 100%);
    color: var(--color-primary);
    line-height: 1.55;
}

.bex-api-error-state {
    border-color: color-mix(in srgb, var(--color-danger) 26%, var(--color-border));
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-danger) 8%, var(--color-surface)) 0%, var(--color-surface) 100%);
    color: var(--color-danger);
}

.bex-api-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

.bex-env-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.7rem;
}

.bex-env-list code {
    border: 1px solid color-mix(in srgb, var(--color-primary) 16%, var(--color-border));
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    background: var(--color-surface);
    color: var(--color-primary);
    font-size: 0.82rem;
}

.bex-api-status-card {
    border: 1px solid color-mix(in srgb, var(--color-primary) 14%, var(--color-border));
    border-radius: 18px;
    padding: 1rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.bex-api-status-card span,
.bex-api-meta-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.bex-api-status-card strong {
    display: block;
    color: var(--color-text-strong);
    font-size: 1.05rem;
}

.bex-api-status-card small {
    display: block;
    margin-top: 0.35rem;
    color: var(--color-text-muted);
}

.bex-api-checkbox,
.bex-api-checkbox-row {
    width: 100%;
}

.bex-api-checkbox-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.bex-inline-actions,
.bex-drawer-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.65rem;
}

.bex-label-print-drawer {
    width: min(520px, 100vw);
}

.bex-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.bex-row-actions .danger-action {
    color: var(--color-danger);
}

.bex-row-actions .disabled-action {
    opacity: 0.4;
}

.bex-json-grid,
.bex-sifarnik-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.bex-json-box {
    min-height: 220px;
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1rem;
    background: #0f172a;
    color: #dbeafe;
    font-size: 0.84rem;
    white-space: pre-wrap;
}

/* ======================================================
   THEME BRIDGE — common legacy surfaces
====================================================== */

.theme-midnight .invoice-status-bar,
.theme-midnight .invoice-header-card,
.theme-midnight .invoice-supplier-card,
.theme-midnight .invoice-sef-card,
.theme-midnight .nav-wrapper,
.theme-midnight .nav-id,
.theme-midnight .totals-bar,
.theme-midnight .role-chip,
.theme-midnight .chip-search,
.theme-midnight .page-error-state,
.theme-midnight .bex-api-callout,
.theme-midnight .bex-api-empty-state,
.theme-midnight .bex-api-status-card,
.theme-midnight .bex-env-list code,
.theme-midnight .bex-api-status-card,
.theme-midnight .bex-json-box,
.theme-dark .invoice-status-bar,
.theme-dark .invoice-header-card,
.theme-dark .invoice-supplier-card,
.theme-dark .invoice-sef-card,
.theme-dark .nav-wrapper,
.theme-dark .nav-id,
.theme-dark .totals-bar,
.theme-dark .role-chip,
.theme-dark .chip-search,
.theme-dark .page-error-state,
.theme-dark .bex-api-callout,
.theme-dark .bex-api-empty-state,
.theme-dark .bex-api-status-card,
.theme-dark .bex-env-list code,
.theme-dark .bex-json-box {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
    box-shadow: var(--shadow-card);
}

.theme-midnight .invoice-header-label,
.theme-midnight .invoice-supplier-label,
.theme-midnight .invoice-sef-label,
.theme-midnight .invoice-supplier-name,
.theme-midnight .invoice-header-field-value,
.theme-midnight .supplier-detail-label,
.theme-midnight .bex-api-status-card strong,
.theme-dark .invoice-header-label,
.theme-dark .invoice-supplier-label,
.theme-dark .invoice-sef-label,
.theme-dark .invoice-supplier-name,
.theme-dark .invoice-header-field-value,
.theme-dark .supplier-detail-label,
.theme-dark .bex-api-status-card strong {
    color: var(--color-text-strong);
}

.theme-midnight .invoice-id,
.theme-midnight .invoice-supplier-details,
.theme-midnight .invoice-header-field-label,
.theme-midnight .bex-api-status-card small,
.theme-midnight .bex-api-status-card span,
.theme-dark .invoice-id,
.theme-dark .invoice-supplier-details,
.theme-dark .invoice-header-field-label,
.theme-dark .bex-api-status-card small,
.theme-dark .bex-api-status-card span {
    color: var(--color-text-muted);
}


.theme-midnight .badge-info,
.theme-dark .badge-info {
    background: var(--status-info-bg);
    color: var(--status-info-text);
}

.theme-midnight .badge-success,
.theme-dark .badge-success {
    background: var(--status-success-bg);
    color: var(--status-success-text) !important;
}

.theme-midnight .role-chip.active,
.theme-dark .role-chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #ffffff !important;
}

.theme-midnight .badge-warning,
.theme-dark .badge-warning {
    background: var(--status-warning-bg);
    color: var(--status-warning-text);
}

.theme-midnight .badge-danger,
.theme-dark .badge-danger {
    background: var(--status-danger-bg);
    color: var(--status-danger-text);
}

/* ======================================================
   DESKTOP VIEWPORT GUARD
====================================================== */

.desktop-viewport-content {
    min-height: 100vh;
}

.desktop-viewport-warning {
    display: none;
}

/* Tablet je podržan u oba smera. Guard ostaje samo za uske telefonske ekrane. */
@media (max-width: 575.98px) {
    html,
    body {
        min-width: 0;
        overflow: hidden;
    }

    .desktop-viewport-content {
        display: none !important;
    }

    .desktop-viewport-warning {
        position: fixed;
        inset: 0;
        z-index: 2147483000;
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 22px;
        background:
            radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--color-primary) 18%, transparent), transparent 44%),
            linear-gradient(180deg, var(--color-app-shell), var(--color-bg-soft));
    }

    /* Javni marketinški sajt je mobile-first; desktop guard važi samo za ERP radni prostor. */
    html:has(.landing-page), html:has(.pub-page),
    body:has(.landing-page), body:has(.pub-page) {
        overflow: auto;
    }

    body:has(.landing-page) .desktop-viewport-content,
    body:has(.pub-page) .desktop-viewport-content {
        display: block !important;
    }

    body:has(.landing-page) .desktop-viewport-warning,
    body:has(.pub-page) .desktop-viewport-warning {
        display: none !important;
    }

    .desktop-viewport-warning-card {
        width: min(520px, 100%);
        padding: 28px;
        border: 1px solid var(--color-border);
        border-radius: 24px;
        background: var(--color-surface);
        color: var(--color-text);
        box-shadow: var(--shadow-floating);
        text-align: center;
    }

    .desktop-viewport-warning-logo {
        width: min(220px, 80%);
        height: auto;
        display: block;
        margin: 0 auto 20px;
        padding: 18px 22px;
        border-radius: 20px;
        background: linear-gradient(160deg, var(--color-primary), var(--color-btn-primary-border));
        box-shadow: 0 16px 32px color-mix(in srgb, var(--color-primary) 24%, transparent);
    }

    .desktop-viewport-warning-kicker {
        display: inline-flex;
        margin-bottom: 10px;
        color: var(--color-text-muted);
        font-size: 11px;
        font-weight: 900;
        letter-spacing: 0.13em;
        text-transform: uppercase;
    }

    .desktop-viewport-warning-card h1 {
        margin: 0 0 12px;
        color: var(--color-text-strong);
        font-size: clamp(24px, 7vw, 34px);
        line-height: 1.08;
        letter-spacing: -0.04em;
    }

    .desktop-viewport-warning-card p {
        margin: 0 auto 18px;
        max-width: 420px;
        color: var(--color-text-muted);
        font-size: 15px;
        line-height: 1.55;
    }

    .desktop-viewport-warning-card strong {
        display: inline-flex;
        padding: 9px 13px;
        border: 1px solid color-mix(in srgb, var(--color-primary) 18%, var(--color-border));
        border-radius: 999px;
        background: color-mix(in srgb, var(--color-primary) 7%, var(--color-surface));
        color: var(--color-primary);
        font-size: 12px;
        font-weight: 800;
    }

    .desktop-viewport-mobile-link {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 48px;
        width: 100%;
        margin: 0 auto 18px;
        border-radius: 12px;
        background: var(--color-primary);
        color: #fff;
        font-size: 15px;
        font-weight: 800;
        text-decoration: none;
    }

    .desktop-viewport-mobile-link:hover,
    .desktop-viewport-mobile-link:focus-visible {
        color: #fff;
        background: var(--color-btn-primary-border);
    }
}

@media print {
    .desktop-viewport-warning {
        display: none !important;
    }

    .desktop-viewport-content {
        display: block !important;
    }
}

/* Login/profile login intentionally ignore user-selected filled fields. */
.login-form .input-inner,
.login-form .input-field,
.login-form .login-input-white,
.inline-login .input-inner,
.inline-login .input-field {
    background-color: #ffffff !important;
}

.login-form .input-field:disabled,
.login-form .login-input-white:disabled,
.inline-login .input-field:disabled {
    background-color: #ffffff !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   BETA OBAVEŠTENJE (javne strane: /, /novosti, /baza-znanja)
   Globalno, a ne u scoped CSS-u, jer se traka sakriva klasom na <html>
   koju inline skripta iz App.razor postavlja pre prvog iscrtavanja.
   ══════════════════════════════════════════════════════════════════════════ */
:root { --beta-bar-h: 44px; }
html.beta-hidden { --beta-bar-h: 0px; }
html.beta-hidden .beta-bar { display: none; }

.beta-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 60;
    color: rgba(255, 255, 255, .82);
    background: linear-gradient(90deg, #16274d, #27406f 55%, #16274d);
    /* inset senka umesto border-a: visina trake ostaje tačno 44px kao u inline skripti */
    box-shadow: inset 0 -1px 0 rgba(245, 158, 11, .38);
    font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.beta-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(1180px, calc(100% - 32px));
    min-height: 44px;
    margin-inline: auto;
    padding-block: 4px;
}

.beta-bar-tag {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    color: #17284b;
    background: #f59e0b;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .1em;
    line-height: 1;
}

.beta-bar-text {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: .8rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.beta-bar-text strong { color: #fff; font-weight: 750; }
.beta-bar-long { color: rgba(255, 255, 255, .78); }

.beta-bar-link {
    flex: 0 0 auto;
    color: #ffc65f;
    font-size: .76rem;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.beta-bar-link:hover { color: #ffdd9c; }

.beta-bar-close {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 9px;
    color: #fff;
    background: rgba(255, 255, 255, .07);
    cursor: pointer;
    font-size: .82rem;
    transition: background var(--motion-duration-base) var(--motion-ease-standard), border-color var(--motion-duration-base) var(--motion-ease-standard);
}

.beta-bar-close:hover { border-color: rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .17); }
.beta-bar a:focus-visible, .beta-bar button:focus-visible { outline: 3px solid rgba(245, 158, 11, .65); outline-offset: 2px; }

/* BETA bedž pored logotipa i u footeru */
.beta-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 7px;
    border: 1px solid rgba(245, 158, 11, .55);
    border-radius: 6px;
    color: #ffc65f;
    background: rgba(245, 158, 11, .16);
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .12em;
    line-height: 1;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .beta-bar-long { display: none; }
}

@media (max-width: 560px) {
    .beta-bar-link { display: none; }
    .beta-bar-inner { width: calc(100% - 24px); gap: 9px; }
    .beta-bar-text { font-size: .74rem; }
}

@media print {
    .beta-bar { display: none; }
}

/* Naslovi kroz aplikaciju koriste sentence case; poslovne skraćenice ostaju u izvornom obliku. */
:is(
    [class*="-title"],
    [class*="__title"],
    [class*="-heading"],
    [class*="__heading"],
    [class*="-eyebrow"],
    [class*="__eyebrow"],
    [class*="-kicker"],
    [class*="__kicker"]
) {
    text-transform: none !important;
}

:is([class*="-header"], [class*="__header"]) > :is(h1, h2, h3, h4, h5, h6) {
    text-transform: none !important;
}

/* Glatko skrolovanje samo na javnim stranama — scoped CSS ne može da cilja <html>. */
@media (prefers-reduced-motion: no-preference) {
    html:has(.landing-page), html:has(.pub-page) { scroll-behavior: smooth; }
}

/* Jedinstven izgled operativnih zaglavlja prema Home baneru. */
.dc-home-style-hero {
    position: relative !important;
    isolation: isolate;
    min-height: 132px;
    padding: 20px 24px !important;
    overflow: hidden;
    color: var(--color-text-strong) !important;
    border: 1px solid color-mix(in srgb, var(--color-primary) 18%, var(--color-border)) !important;
    border-radius: 14px !important;
    background: linear-gradient(120deg, var(--color-surface) 0%, color-mix(in srgb, var(--color-primary) 7%, var(--color-surface)) 60%, color-mix(in srgb, var(--color-primary) 12%, var(--color-surface)) 100%) !important;
    box-shadow: none !important;
}

.dc-home-style-hero::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    z-index: 0;
    top: 50% !important;
    right: -140px !important;
    width: 520px !important;
    height: 520px !important;
    border: 1.5px solid color-mix(in srgb, var(--color-primary) 14%, transparent) !important;
    border-radius: 50% !important;
    transform: translateY(-50%) !important;
    pointer-events: none;
    background:
      radial-gradient(circle, #f59e0b 0 12px, color-mix(in srgb, #f59e0b 12%, transparent) 13px 34px, transparent 35px),
      radial-gradient(circle, transparent 0 89px, color-mix(in srgb, var(--color-primary) 14%, transparent) 90px 91px, transparent 92px),
      radial-gradient(circle, transparent 0 159px, color-mix(in srgb, var(--color-primary) 10%, transparent) 160px 161px, transparent 162px) !important;
}

.dc-home-style-hero::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    z-index: 0;
    top: calc(50% - 4px) !important;
    right: 276px !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: var(--color-primary) !important;
    transform-origin: 164px 4px;
    /* Jedan krug pa miruje: dekoracija na radnim ekranima ne sme stalno da se kreće. */
    animation: dc-page-planet 18s linear 1;
    pointer-events: none;
}

@keyframes dc-page-planet { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dc-home-style-hero::after { animation: none; } }

.dc-home-style-hero > * { position: relative; z-index: 1; }
.dc-home-style-hero h1 { color: var(--color-text-strong) !important; font-size: 24px !important; font-weight: 650 !important; letter-spacing: -.5px; }
.dc-home-style-hero p { color: var(--color-text-muted) !important; font-size: 13px; }
.dc-home-style-hero :is([class*="-eyebrow"], [class*="-kicker"]) { color: var(--color-primary) !important; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.dc-home-style-hero :is([class*="-hero-icon"], [class*="-hero-mark"], [class*="-warranty-icon"], [class*="-item-icon"]) {
    color: var(--color-primary) !important;
    background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface)) !important;
    border: 1px solid color-mix(in srgb, var(--color-primary) 12%, var(--color-border)) !important;
    box-shadow: none !important;
    border-radius: 9px !important;
}

.dc-home-style-hero :is([class*="-hero-stats"], [class*="-hero-total"], [class*="-hero-count"], [class*="-hero-status"]) {
    color: var(--color-text-strong);
}
.dc-home-style-hero :is([class*="-hero-stats"], [class*="-hero-total"], [class*="-hero-count"]) > :is(div, button),
.dc-home-style-hero.year-close-hero .year-close-status {
    border-color: color-mix(in srgb, var(--color-primary) 14%, var(--color-border));
    background: color-mix(in srgb, var(--color-surface) 90%, transparent);
}
.dc-home-style-hero.year-close-hero.ready { border-left: 3px solid var(--color-success) !important; }
.dc-home-style-hero.year-close-hero.blocked { border-left: 3px solid var(--color-warning) !important; }

@media (max-width: 620px) {
    .dc-home-style-hero { padding: 16px !important; min-height: 118px; }
    .dc-home-style-hero::before { right: -300px !important; }
    .dc-home-style-hero::after { display: none !important; }
}


/* ───────── Ponovno povezivanje (components-reconnect-modal, App.razor) ───────── */
.fin-reconnect {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 40, .45);
}
.fin-reconnect.components-reconnect-show,
.fin-reconnect.components-reconnect-retrying,
.fin-reconnect.components-reconnect-failed,
.fin-reconnect.components-reconnect-rejected,
.fin-reconnect.components-reconnect-paused,
.fin-reconnect.components-reconnect-resume-failed,
.fin-reconnect[data-state="show"],
.fin-reconnect[data-state="retrying"],
.fin-reconnect[data-state="failed"],
.fin-reconnect[data-state="rejected"],
.fin-reconnect[data-state="paused"],
.fin-reconnect[data-state="resume-failed"] {
    display: flex;
}
.fin-reconnect.components-reconnect-hide,
.fin-reconnect[data-state="hide"] {
    display: none;
}
.fin-reconnect-card {
    max-width: 440px;
    width: 100%;
    padding: 24px;
    border-radius: 12px;
    background: var(--color-surface, #fff);
    color: var(--color-text, #0f1728);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.fin-reconnect-card h2 { font-size: 18px; margin: 12px 0 8px; }
.fin-reconnect-card p { font-size: 14px; margin: 0 0 16px; color: var(--color-text-muted, #5d6679); }
.fin-reconnect-actions { display: flex; gap: 8px; justify-content: center; }
.fin-reconnect-spinner {
    width: 32px; height: 32px; margin: 0 auto;
    border: 3px solid var(--color-border, #e3e7f0);
    border-top-color: var(--color-primary, #1e2e52);
    border-radius: 50%;
    animation: spin var(--motion-spin-duration) linear infinite;
}
@media (prefers-reduced-motion: reduce) { .fin-reconnect-spinner { animation: none; } }

/* Prikaz poruka po stanju: podrazumevano se vidi poruka za ponovni pokušaj. */
.fin-reconnect .fin-reconnect-msg-failed,
.fin-reconnect .fin-reconnect-msg-rejected { display: none; }
.fin-reconnect:is(.components-reconnect-failed, .components-reconnect-resume-failed, [data-state="failed"], [data-state="resume-failed"]) .fin-reconnect-msg-retry,
.fin-reconnect:is(.components-reconnect-rejected, [data-state="rejected"]) .fin-reconnect-msg-retry,
.fin-reconnect:is(.components-reconnect-failed, .components-reconnect-resume-failed, .components-reconnect-rejected, [data-state="failed"], [data-state="resume-failed"], [data-state="rejected"]) .fin-reconnect-spinner { display: none; }
.fin-reconnect:is(.components-reconnect-failed, .components-reconnect-resume-failed, [data-state="failed"], [data-state="resume-failed"]) .fin-reconnect-msg-failed { display: inline; }
.fin-reconnect:is(.components-reconnect-rejected, [data-state="rejected"]) .fin-reconnect-msg-rejected { display: inline; }
.fin-reconnect-actions .fin-reconnect-msg-failed,
.fin-reconnect-actions .fin-reconnect-msg-rejected { display: none; }
.fin-reconnect:is(.components-reconnect-failed, .components-reconnect-resume-failed, [data-state="failed"], [data-state="resume-failed"]) .fin-reconnect-actions .fin-reconnect-msg-failed { display: inline-flex; }
.fin-reconnect:is(.components-reconnect-rejected, [data-state="rejected"]) .fin-reconnect-actions .fin-reconnect-msg-rejected { display: inline-flex; }

/* ───────── 404 (Routes.razor) ───────── */
.not-found-page { max-width: 520px; margin: 64px auto; text-align: center; }
.not-found-page h1 { font-size: 22px; margin-bottom: 8px; }
.not-found-page p { color: var(--color-text-muted, #5d6679); margin-bottom: 16px; }

/* ───────── Čuvanje forme (EditPageShell + SaveButton) ─────────
   Zamenjuje overlay loader tokom čuvanja. Stanja dolaze iz SaveFeedbackPhase.
   Selektori su duplirani (.is-saved.is-saved) da bi nadjačali stil dugmeta
   u PageCommandBar-u, koji koristi !important. */
.fin-save-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    box-sizing: border-box;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: -2px;
    animation: spin var(--motion-spin-duration) linear infinite;
}

.action-btn.btn-save.is-saving.is-saving,
.page-command-bar .command-page-buttons .action-btn.command-role-save.is-saving.is-saving {
    opacity: 1 !important;
    cursor: progress;
}

.action-btn.btn-save.is-saved.is-saved,
.page-command-bar .command-page-buttons .action-btn.command-role-save.is-saved.is-saved {
    background: var(--color-success-text, #11704b) !important;
    border-color: var(--color-success-text, #11704b) !important;
    color: #fff !important;
    opacity: 1 !important;
    transition: background-color var(--motion-duration-base) var(--motion-ease-standard), border-color var(--motion-duration-base) var(--motion-ease-standard);
}

.action-btn.btn-save.is-saved i,
.action-btn.btn-save.is-saved .command-icon {
    animation: fin-save-pop .2s cubic-bezier(.2, 0, 0, 1);
}

.action-btn.btn-save.is-error.is-error,
.page-command-bar .command-page-buttons .action-btn.command-role-save.is-error.is-error {
    background: var(--color-danger, #c53030) !important;
    border-color: var(--color-danger, #c53030) !important;
    color: #fff !important;
    transition: background-color var(--motion-duration-emphasis) var(--motion-ease-standard), border-color var(--motion-duration-emphasis) var(--motion-ease-standard);
}

/* Traka stanja čuvanja na donjoj ivici komandnog panela.
   Dugme nije pozicionirano, pa se ::after kači za .page-command-bar (position: relative). */
.page-command-bar .action-btn.btn-save.is-saving::after,
.page-command-bar .action-btn.btn-save.is-saved::after,
.page-command-bar .action-btn.btn-save.is-error::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    pointer-events: none;
    z-index: 2;
}
.page-command-bar .action-btn.btn-save.is-saving::after {
    background: linear-gradient(90deg, transparent 0%, var(--color-primary, #1e2e52) 35%, var(--color-primary, #1e2e52) 50%, transparent 85%);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    animation: fin-save-edge-run 1.1s ease-in-out infinite;
}
.page-command-bar .action-btn.btn-save.is-saved::after {
    background: var(--color-success-text, #11704b);
    animation: fin-save-edge-fill .35s ease-out, fin-save-fade .5s ease-in 1.2s forwards;
    transform-origin: left center;
}
.page-command-bar .action-btn.btn-save.is-error::after {
    background: var(--color-danger, #c53030);
    animation: fin-save-fade .5s ease-in 3s forwards;
}
/* Shake bi pomerio traku zajedno sa dugmetom; u panelu greška se vidi po traci i boji dugmeta. */
.page-command-bar .command-page-buttons .action-btn.command-role-save.is-error.is-error { animation: none; }
@keyframes fin-save-edge-run { 0% { background-position: -40% 0; } 100% { background-position: 140% 0; } }

/* Učitavanje zapisa iz baze: ista traka na ivici komandnog panela.
   EditPageShell nosi data-record-load (loading | loaded | error); panel je van forme, pa se veže preko :has. */
body:has([data-record-load="loading"]) .page-command-bar::before,
body:has([data-record-load="loaded"]) .page-command-bar::before,
body:has([data-record-load="error"]) .page-command-bar::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    pointer-events: none;
    z-index: 2;
}
body:has([data-record-load="loading"]) .page-command-bar::before {
    background: linear-gradient(90deg, transparent 0%, var(--color-primary, #1e2e52) 35%, var(--color-primary, #1e2e52) 50%, transparent 85%);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    opacity: 0;
    /* kratko kašnjenje: brza učitavanja ne trepću */
    animation: fin-load-edge-in .15s ease .25s forwards, fin-save-edge-run 1.1s ease-in-out .25s infinite;
}
body:has([data-record-load="loaded"]) .page-command-bar::before {
    background: var(--color-primary, #1e2e52);
    transform-origin: left center;
    animation: fin-save-edge-fill .3s ease-out, fin-save-fade .4s ease-in .35s forwards;
}
body:has([data-record-load="error"]) .page-command-bar::before {
    background: var(--color-danger, #c53030);
    animation: fin-save-fade .5s ease-in 3s forwards;
}
@keyframes fin-load-edge-in { to { opacity: 1; } }

/* Forma se posle kostura pojavi kratkim prelazom (samo kad je učitavanje trajalo duže od 0,2 s). */
[data-form-reveal="true"] form {
    animation: fin-form-reveal .2s ease-out both;
}
@keyframes fin-form-reveal { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { [data-form-reveal="true"] form { animation: none; } }
@keyframes fin-save-edge-fill { from { transform: scaleX(.6); } to { transform: scaleX(1); } }

/* Dugme za cuvanje ne menja sirinu kad se promeni stanje (Sacuvaj / Cuvanje / Sacuvano). */
@media (min-width: 768px) {
    .page-command-bar .command-page-buttons .action-btn.command-role-save {
        min-width: 104px;
        justify-content: center;
    }
}

.action-btn.btn-save.is-clean.is-clean,
.page-command-bar .command-page-buttons .action-btn.command-role-save.is-clean.is-clean {
    background: var(--color-surface-muted, #f4f6fb) !important;
    border-color: var(--color-border-strong, #c8d0e0) !important;
    color: var(--color-text-muted, #5d6679) !important;
    box-shadow: none !important;
    opacity: 1 !important;
}

/* Tanka traka na vrhu forme umesto overlay-a.
   Nije sticky: ostaje na vrhu kartice i ne „lebdi" preko sadržaja pri skrolovanju. */
.fin-save-progress {
    position: relative;
    z-index: 5;
    height: 3px;
    margin-bottom: -3px;
    overflow: hidden;
    pointer-events: none;
}

.fin-save-progress span {
    display: block;
    height: 100%;
    width: 30%;
    border-radius: 0 2px 2px 0;
    background: var(--color-primary, #1e2e52);
}

.fin-save-progress.is-saving span { animation: fin-save-indeterminate 1.1s ease-in-out infinite; }
.fin-save-progress.is-saved span { width: 100%; background: var(--color-success-text, #11704b); animation: fin-save-fill .35s ease-out, fin-save-fade .5s ease-in 1.1s forwards; }
/* Greška samo kratko bljesne; trajno stanje pokazuje crveno dugme „Pokušaj ponovo". */
.fin-save-progress.is-error span { width: 100%; background: var(--color-danger, #c53030); animation: fin-save-fade .4s ease-in 1.2s forwards; }

/* Forma ostaje vidljiva, ali se ne može menjati dok traje čuvanje */
[data-save-phase="saving"] form {
    opacity: .72;
    pointer-events: none;
    transition: opacity var(--motion-duration-base) var(--motion-ease-standard);
}

@keyframes fin-save-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fin-save-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes fin-save-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
@keyframes fin-save-fill { from { width: 60%; } to { width: 100%; } }
@keyframes fin-save-fade { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .fin-save-spinner,
    .fin-save-progress span,
    .action-btn.btn-save.is-saved i,
    .action-btn.btn-save.is-saved .command-icon,
    .action-btn.btn-save.is-error.is-error {
        animation: none !important;
    }

    .fin-save-spinner { border-top-color: rgba(255, 255, 255, .35); }
    .fin-save-progress.is-error { display: none; }
    .page-command-bar .action-btn.btn-save.is-saving::after { animation: none; background: var(--color-primary, #1e2e52); }
    .page-command-bar .action-btn.btn-save.is-saved::after { animation: fin-save-fade 0s 1.2s forwards; }
    body:has([data-record-load="loading"]) .page-command-bar::before { animation: fin-load-edge-in 0s .25s forwards; background: var(--color-primary, #1e2e52); }
    body:has([data-record-load="loaded"]) .page-command-bar::before { animation: fin-save-fade 0s .4s forwards; }
}


/* ───────── Dugme dok priprema štampu ili PDF (BaseButton.is-invoking) ─────────
   Spinner se pojavljuje posle 300 ms, širina dugmeta ostaje ista. */
.action-btn.is-invoking {
    position: relative;
    cursor: progress;
    opacity: 1 !important;
}

    .action-btn.is-invoking > * {
        animation: fin-btn-content-out .15s ease .3s forwards;
    }

    .action-btn.is-invoking::after {
        content: "";
        position: absolute;
        left: 50%;
        top: 50%;
        width: 14px;
        height: 14px;
        margin: -7px 0 0 -7px;
        box-sizing: border-box;
        border: 2px solid currentColor;
        border-right-color: transparent;
        border-radius: 50%;
        opacity: 0;
        animation: fin-btn-spinner-in .15s ease .3s forwards, spin var(--motion-spin-duration) linear infinite;
    }

@keyframes fin-btn-content-out { to { opacity: 0; } }
@keyframes fin-btn-spinner-in { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .action-btn.is-invoking > * { animation: none; opacity: .35; }
    .action-btn.is-invoking::after { animation: none; opacity: 1; }
}
