:root {
    --primary-blue: #0061ff;
    --dark-blue: #040d21;
    --accent-blue: #005596;
    --bg-light: #ffffff;
    --bg-soft: #f4f7f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --content-width: 1200px;
}

.certificate-system-container {
    width: 100%;
    margin: 0 auto;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
}

.coch-wrapper {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 20px;
}

@media (max-width: 600px) {
    .coch-wrapper {
        padding: 0 12px;
    }
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-up {
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Improved Lang Toggle */
.lang-toggle {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 0;
}

.lang-btn {
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 50px;
    background: #f1f5f9;
    color: var(--text-muted);
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.lang-btn:hover {
    background: #e2e8f0;
    color: var(--dark-blue);
}

.lang-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    box-shadow: 0 4px 10px rgba(0, 97, 255, 0.3);
}

/* Redesigned Search Section */
.coch-search-section {
    background: linear-gradient(145deg, #001A3D 0%, #0056D2 100%);
    border-radius: 2rem;
    padding: 4rem;
    margin: 1rem 0 3rem 0;
    color: white;
    box-shadow: 0 25px 50px -12px rgba(0, 86, 210, 0.25);
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: auto 1fr;
    /* Let logo take its natural width, search takes rest */
    align-items: flex-start;
    gap: 1.5rem;
    /* Reduced gap - logo zaraz obok pola */
}

@media (max-width: 900px) {
    .coch-search-section {
        padding: 2.5rem 1.5rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .search-logo-container {
        margin-bottom: 1.5rem;
        text-align: center;
        max-width: 120px;
    }

    .search-logo-container img {
        padding-bottom: 0 !important;
    }

    .search-field-container {
        width: 100%;
        min-width: 100%;
    }

    .btn-search-main {
        width: 100%;
        justify-content: center;
        padding: 1.25rem 2rem;
    }
}

.search-logo-container {
    width: auto;
    max-width: 160px;
    /* Limit absolute size */
    display: flex;
    align-items: flex-start;
    /* Align to top to match input */
    justify-content: flex-start;
    /* No extra padding - let flex-start do the alignment */
    /* Match the vertical position of the input */
}

.search-logo-container img {
    max-width: 100%;
    height: auto;
    padding-bottom: 145px;
}

.coch-search-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
}

/* FULL WIDTH Input and Box */
.search-field-container {
    flex: 1;
    min-width: 300px;
    position: relative;
    z-index: 2;
}

@media (max-width: 600px) {
    .search-field-container {
        min-width: 100%;
    }

    .search-input-modern {
        font-size: 1rem !important;
        padding: 1.1rem 1.25rem 1.1rem 3rem !important;
    }

    .search-icon-inside {
        font-size: 1.25rem !important;
        left: 1rem !important;
    }

    .btn-search-main {
        margin-top: 1.25rem !important;
        padding: 1rem !important;
        font-size: 1rem !important;
    }

    .coch-search-section {
        padding: 2rem 1.25rem !important;
        margin-bottom: 2rem !important;
    }
}

.search-input-modern {
    width: 100%;
    box-sizing: border-box;
    /* Crucial for full width */
    padding: 1.4rem 1.75rem 1.4rem 3.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 1rem;
    font-size: 1.2rem;
    background: #ffffff;
    color: var(--dark-blue);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input-modern:focus {
    outline: none;
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2), 0 0 0 5px rgba(255, 255, 255, 0.2);
}

.search-icon-inside {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 5;
}

/* Modernized Buttons */
.btn-search-main {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    color: var(--dark-blue) !important;
    padding: 1.25rem 4rem;
    border-radius: 0.75rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    margin-top: 2rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-search-main:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25);
}

.btn-white-link {
    color: white !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.8;
    transition: all 0.2s;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
    padding-bottom: 2px;
}

.btn-white-link:hover {
    opacity: 1;
    border-bottom-style: solid;
    border-bottom-color: white;
}

.action-bar {
    display: flex;
    gap: 1rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .action-bar {
        justify-content: center;
    }

    .btn-white-link {
        font-size: 0.85rem;
    }
}

/* Admin Dashboard Specifics */
.admin-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.admin-card-gold {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
}

.admin-card-gold:hover {
    transform: translateY(-5px);
}

.admin-action-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-admin-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    border-radius: 1rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    color: var(--dark-blue);
}

.btn-admin-tool i {
    font-size: 2.2rem;
    color: var(--primary-blue);
}

.btn-admin-tool:hover {
    background: white;
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.admin-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--bg-soft);
}

.admin-stats-row:last-child {
    border-bottom: none;
}

.stats-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 1.05rem;
}

.stats-value {
    font-weight: 800;
    color: var(--dark-blue);
    background: var(--bg-soft);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 1.1rem;
}

/* Help Box Styling - STACKED and FULL WIDTH */
.help-box-minimal {
    grid-column: 1 / -1;
    /* Takes full width of the grid (logo + search) */
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 1.5rem;
    padding: 2.5rem;
    margin-top: 1rem;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
}

.help-grid {
    display: flex;
    flex-direction: column;
    /* Stacked under each other */
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.help-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.help-item h5 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
}

.help-item p {
    font-size: 0.95rem;
    opacity: 0.85;
    line-height: 1.6;
    margin: 0;
}

/* Results Display - High-End Aesthetic */
.results-area {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.custom-table-container {
    background: #ffffff;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
}

.custom-table th {
    background: #f8fafc;
    padding: 1.25rem;
    text-align: left;
    color: var(--accent-blue);
    font-weight: 800;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--bg-soft);
}

.custom-table td {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.custom-table tr:hover td {
    background: #f9fbff;
}

/* Responsive Table / Cards for Mobile */
@media (max-width: 768px) {

    .custom-table,
    .custom-table thead,
    .custom-table tbody,
    .custom-table th,
    .custom-table td,
    .custom-table tr {
        display: block;
    }

    .custom-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .custom-table tr {
        border-bottom: 1px solid #edf2f7;
        padding: 1rem 0;
        position: relative;
    }

    .custom-table tr:last-child {
        border-bottom: none;
    }

    .custom-table td {
        border: none;
        position: relative;
        padding: 0.75rem 1rem 0.75rem 45% !important;
        text-align: right;
        min-height: 3rem;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .custom-table td::before {
        position: absolute;
        top: 50%;
        left: 1rem;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        transform: translateY(-50%);
        text-align: left;
        font-weight: 800;
        font-size: 0.75rem;
        color: var(--text-muted);
        content: attr(data-label);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .custom-table td .cert-id {
        font-size: 1.05rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .admin-card-gold {
        padding: 1.5rem !important;
        border-radius: 1rem;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Formatting tools */
.cert-id {
    font-weight: 800;
    color: var(--accent-blue);
    font-size: 1.2rem;
}

.owner-info {
    font-weight: 600;
    color: var(--text-main);
    display: block;
    margin-bottom: 0.25rem;
}

.sub-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 700;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-transform: uppercase;
}

.badge-success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #10b98120;
}

.badge-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #ef444420;
}

/* Form Layouts */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 3rem;
}

.form-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--dark-blue);
    margin: 0;
}

.form-subtitle {
    color: var(--text-muted);
    margin: 0.5rem 0 0 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 2rem 3rem;
}

.form-field label {
    display: block;
    font-weight: 700;
    color: var(--dark-blue);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.form-actions {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 2px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 768px) {
    .form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    .form-title {
        font-size: 1.8rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 1.5rem;
        padding-top: 2rem;
        margin-top: 2.5rem;
    }

    .form-actions a,
    .form-actions button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

.form-section-header {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    margin: 3rem 0 2rem 0;
    color: var(--accent-blue);
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid var(--primary-blue);
}

.form-section-header i {
    font-size: 1.4rem;
    opacity: 0.8;
}

@media (max-width: 768px) {
    .form-section-header {
        margin: 2rem 0 1.5rem 0;
        font-size: 1rem;
        padding: 0.8rem 1.25rem;
    }
}

.alert-error {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #f43f5e20;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #22c55e20;
}

#suggestions-list {
    position: absolute;
    z-index: 1000;
    background: white;
    width: 100%;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: 0.5rem;
    margin-top: 0.5rem;
    display: none;
    border: 1px solid var(--border-color);
}

#suggestions-list li {
    padding: 0.8rem 1.25rem;
    cursor: pointer;
    border-radius: 0.5rem;
    color: var(--text-main);
    font-weight: 500;
    transition: all 0.2s;
}

@media (max-width: 600px) {
    #suggestions-list {
        padding: 0.25rem;
    }

    #suggestions-list li {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

#suggestions-list li:hover {
    background: #f1f5f9;
    color: var(--primary-blue);
}

/* Admin and Footer link */
.admin-footer {
    margin-top: 5rem;
    padding: 3rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.btn-admin-access {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
    background: #f8fafc;
    border: 1px solid var(--border-color);
}

.btn-admin-access:hover {
    background: #f1f5f9;
    color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Action Buttons - Search Results Style */
.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.6rem 1.25rem;
    border-radius: 0.8rem;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-modern-edit {
    background: #ffffff;
    color: var(--primary-blue);
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.btn-modern-edit:hover {
    background: #f8fbff;
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.15);
}

.btn-modern-delete {
    background: #ffffff;
    color: var(--danger-color);
    border: 1px solid #fee2e2;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.btn-modern-delete:hover {
    background: #fffcfc;
    border-color: var(--danger-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.15);
}

/* QR Modal Styles */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 17, 51, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.qr-modal.active {
    opacity: 1;
    visibility: visible;
}

.qr-modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 2rem;
    max-width: 400px;
    width: 90%;
    position: relative;
    transform: scale(0.85);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

@media (max-width: 480px) {
    .qr-modal-content {
        padding: 1.5rem;
        border-radius: 1.5rem;
    }
}

.qr-modal.active .qr-modal-content {
    transform: scale(1);
}

.qr-modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-modal-close:hover {
    background: #e2e8f0;
    color: var(--danger-color);
    transform: rotate(90deg);
}