body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: #f5f7fa;
}

.page-wrap {
    margin-top: 60px;
    padding: 2rem;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.page-header {
    background: white;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-header-icon { font-size: 2rem; }
.page-header h1 { margin: 0 0 0.25rem; font-size: 1.6rem; color: #1a1a1a; }
.page-header p { margin: 0; color: #666; font-size: 0.9rem; }

/* SOURCE CARDS */
.source-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
    .source-cards { grid-template-columns: 1fr; }
}

.source-card {
    background: white;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    border: 2px solid #e1e8ed;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.source-card:hover { border-color: #2563eb; background: #f0f5ff; }
.source-card.active { border-color: #2563eb; background: #eff6ff; }
.source-card .icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
.source-card h3 { margin: 0 0 0.25rem; font-size: 0.95rem; color: #1a1a1a; }
.source-card p { margin: 0; font-size: 0.8rem; color: #666; }

/* LOADED SOURCE BANNER */
.source-banner {
    display: none;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: #1d4ed8;
    align-items: center;
    gap: 0.75rem;
}

.source-banner.visible { display: flex; }
.source-banner strong { font-weight: 600; }

/* SECTION CARD */
.section-card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

/* FORM GRID */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1.25rem; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.four { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-grid.full { grid-template-columns: 1fr; }

@media (max-width: 900px) { .form-grid.four { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) {
    .form-grid, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-label { font-size: 0.8rem; font-weight: 600; color: #374151; }
.form-label .req { color: #dc2626; }

.form-input {
    padding: 0.55rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.prefilled { background: #f0fdf4; border-color: #86efac; pointer-events: auto; }
.form-input.missing { background: #fef2f2; border-color: #fca5a5; }

select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    appearance: none;
    padding-right: 2rem;
}

.eori-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.eori-row .form-input { flex: 1; }

.btn-save-eori {
    padding: 0.55rem 0.85rem;
    background: #059669;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.btn-save-eori:hover { background: #047857; }
.btn-save-eori:disabled { background: #9ca3af; cursor: not-allowed; }

/* ITEMS TABLE */
.items-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.items-table th {
    background: #f9fafb;
    color: #374151;
    font-weight: 600;
    padding: 0.3rem 0.5rem;
    text-align: left;
    border-bottom: 2px solid #e5e7eb;
}
.items-table td { padding: 0.25rem 0.35rem; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.items-table tr:hover td { background: #f9fafb; }
.items-table input { width: 100%; padding: 0.22rem 0.4rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.8rem; box-sizing: border-box; }
.items-table input:focus { outline: none; border-color: #2563eb; }

.stop-word-warning {
    display: none;
    font-size: 0.74rem;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    padding: 0.18rem 0.45rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.stop-word-warning.visible { display: block; }
.item-opis.stop-word-hit { border-color: #f59e0b !important; background: #fffbeb !important; }

.translation-badge {
    display: none;
    font-size: 0.74rem;
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    border-radius: 4px;
    padding: 0.18rem 0.45rem;
    margin-top: 2px;
    cursor: pointer;
}
.translation-badge.visible { display: block; }
.translation-badge:hover { background: #d1fae5; }

/* ── Rječnik modal ── */
.rjecnik-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    z-index: 10000; display: flex; align-items: flex-start;
    justify-content: center; padding-top: 60px;
}
.rjecnik-dialog {
    background: white; border-radius: 14px;
    width: 760px; max-width: 96vw;
    max-height: calc(100vh - 80px);
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.rjecnik-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.2rem 1.5rem 0.75rem;
    border-bottom: 1px solid #e1e8ed;
}
.rjecnik-header h2 { margin: 0; font-size: 1.1rem; color: #1a1a1a; }
.rjecnik-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #666; padding: 0.25rem 0.5rem; border-radius: 6px; line-height: 1; }
.rjecnik-close:hover { background: #f3f4f6; color: #111; }
.rjecnik-tabs { display: flex; gap: 0; padding: 0.75rem 1.5rem 0; border-bottom: 2px solid #e1e8ed; }
.rjecnik-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    margin-bottom: -2px; padding: 0.5rem 1.1rem; font-size: 0.88rem;
    cursor: pointer; color: #6b7280; font-weight: 500;
    display: flex; align-items: center; gap: 0.4rem;
}
.rjecnik-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.rjecnik-tab:hover:not(.active) { color: #374151; }
.rjecnik-tab-content { padding: 1rem 1.5rem; overflow-y: auto; flex: 1; }
.rjecnik-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.rjecnik-list { display: flex; flex-direction: column; gap: 0.4rem; }
.rjecnik-loading { color: #6b7280; font-size: 0.88rem; padding: 1rem 0; }
.rjecnik-empty { color: #6b7280; font-size: 0.88rem; padding: 1rem 0; font-style: italic; }
.rjecnik-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 0.85rem; border-radius: 8px;
    border: 1px solid #e5e7eb; background: #fafafa;
    font-size: 0.84rem;
}
.rjecnik-row:hover { background: #f0f5ff; border-color: #bfdbfe; }
.rjecnik-row-ba { flex: 1; color: #374151; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rjecnik-arrow { color: #9ca3af; flex-shrink: 0; }
.rjecnik-row-en { flex: 1; color: #065f46; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rjecnik-usage { font-size: 0.74rem; color: #9ca3af; flex-shrink: 0; background: #f3f4f6; padding: 0.1rem 0.45rem; border-radius: 10px; min-width: 2rem; text-align: center; }
.rjecnik-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.rjecnik-btn { background: none; border: 1px solid #e5e7eb; border-radius: 5px; padding: 0.2rem 0.5rem; font-size: 0.76rem; cursor: pointer; color: #6b7280; }
.rjecnik-btn:hover { background: #f3f4f6; color: #111; }
.rjecnik-btn.danger:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

.sw-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 0.85rem; border-radius: 8px;
    border: 1px solid #e5e7eb; background: #fafafa;
    font-size: 0.84rem;
}
.sw-row:hover { background: #fef2f2; border-color: #fca5a5; }
.sw-row.inactive { opacity: 0.45; }
.sw-phrase { flex: 1; color: #374151; }
.sw-badge-active { font-size:0.72rem; padding:0.1rem 0.45rem; border-radius:10px; background:#dcfce7; color:#166534; }
.sw-badge-inactive { font-size:0.72rem; padding:0.1rem 0.45rem; border-radius:10px; background:#f3f4f6; color:#6b7280; }

.btn-add-item {
    padding: 0.35rem 0.85rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    vertical-align: middle;
}
.btn-add-item:hover { background: #1d4ed8; }

.btn-del-item {
    padding: 0.2rem 0.45rem;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
}
.btn-del-item:hover { background: #fecaca; }

/* PREVOZNIK 4-col row */
.prevoznik-row { display: grid; grid-template-columns: 2fr 2fr 2fr 1fr; gap: 0.75rem 1.25rem; }
@media (max-width: 900px) { .prevoznik-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .prevoznik-row { grid-template-columns: 1fr; } }

/* ROUTING TAGS */
#routingList .routing-tag {
    display: inline-flex !important;
    align-items: center;
    gap: 0.4rem;
    background: #dbeafe !important;
    color: #1d4ed8 !important;
    border: 1px solid #93c5fd !important;
    border-radius: 20px;
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: default;
}
#routingList .routing-tag button {
    background: none !important;
    border: none;
    cursor: pointer;
    color: #60a5fa;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1;
    margin-left: 2px;
}
#routingList .routing-tag button:hover { color: #1d4ed8; }
#routingList .routing-tag + .routing-tag::before {
    content: '→';
    color: #9ca3af;
    font-weight: 400;
    margin-right: 0.4rem;
    font-size: 0.85rem;
}

/* ACTIONS */
.actions-bar {
    background: white;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn-generate {
    padding: 0.7rem 2rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-generate:hover { background: #1d4ed8; }
.btn-generate:disabled { background: #9ca3af; cursor: not-allowed; }

.btn-secondary {
    padding: 0.7rem 1.25rem;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { border-color: #2563eb; color: #2563eb; }

/* XML OUTPUT */
.xml-output-wrap { display: none; }
.xml-output-wrap.visible { display: block; }

.xml-pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre;
}

.xml-actions { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }

.btn-copy-xml, .btn-download-xml {
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
}
.btn-copy-xml { background: #374151; color: white; }
.btn-copy-xml:hover { background: #1f2937; }
.btn-download-xml { background: #059669; color: white; }
.btn-download-xml:hover { background: #047857; }

/* Upload zone */
.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}
.upload-zone:hover, .upload-zone.dragover { border-color: #2563eb; background: #eff6ff; color: #2563eb; }
.upload-zone input[type=file] { display: none; }

/* Toast */
.ics2-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: white;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.ics2-toast.show { opacity: 1; pointer-events: auto; }
.ics2-toast.success { background: #059669; }
.ics2-toast.error { background: #dc2626; }
.ics2-toast.info { background: #2563eb; }

/* Feature blocked */
.feature-blocked {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.feature-blocked .icon { font-size: 3rem; margin-bottom: 1rem; }
.feature-blocked h2 { color: #1a1a1a; margin-bottom: 0.5rem; }
.feature-blocked p { color: #666; }

/* Loading state */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9000;
    align-items: center;
    justify-content: center;
}
.loading-overlay.show { display: flex; }
.loading-spinner {
    background: white;
    border-radius: 12px;
    padding: 2rem 3rem;
    text-align: center;
    font-size: 0.95rem;
    color: #374151;
}

/* Desktop nav-dropdown hover */
@media (min-width: 769px) {
    .nav-dropdown { position: relative; display: inline-block; }
    .nav-dropdown-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        background: white;
        min-width: 260px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-radius: 4px;
        margin-top: 5px;
        z-index: 1000;
        padding: 8px 0;
    }
    .nav-dropdown:hover .nav-dropdown-menu { display: block; }
    .nav-dropdown-item {
        display: block;
        padding: 10px 20px;
        color: #2c3e50;
        text-decoration: none;
        font-size: 0.88rem;
        transition: background 0.2s;
        white-space: nowrap;
    }
    .nav-dropdown-item:hover { background: #f5f5f5; }
    .nav-dropdown-item.active { background: #e3f2fd; color: #1976d2; border-left: 3px solid #1976d2; }
}
