* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.screen {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

#loginForm {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

#loginForm input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

#loginForm input:focus {
    outline: none;
    border-color: #667eea;
}

#loginForm button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

#loginForm button:hover {
    background: #5568d3;
}

/* Header */
header {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem 2rem;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #667eea;
    font-size: 1.8rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.icon-btn:hover {
    background: #e0e0e0;
}

/* Main Content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.add-item-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.add-item-container h2 {
    color: #333;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.url-input-group {
    display: flex;
    gap: 0.5rem;
}

.url-input-group input {
    flex: 1;
}

.url-input-group button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

.url-input-group button:hover {
    background: #5568d3;
}

.form-actions {
    display: flex;
    gap: 1rem;
}

.primary-btn {
    flex: 1;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.primary-btn:hover {
    background: #5568d3;
}

.secondary-btn {
    flex: 1;
    padding: 12px;
    background: #e0e0e0;
    color: #333;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.secondary-btn:hover {
    background: #d0d0d0;
}

/* Items List */
.items-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.items-container h2 {
    color: #333;
    margin-bottom: 1.5rem;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.item-card {
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.item-card[draggable="true"] {
    cursor: move;
}

.item-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.rank-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.drag-handle {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 1.2rem;
    cursor: grab;
    z-index: 10;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.item-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #e0e0e0;
}

.item-details {
    padding: 1rem;
}

.item-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-price {
    font-size: 1.2rem;
    color: #667eea;
    font-weight: 700;
    margin-bottom: 1rem;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

.item-actions a {
    flex: 1;
    padding: 8px;
    background: #667eea;
    color: white;
    text-decoration: none;
    text-align: center;
    border-radius: 5px;
    font-weight: 600;
    transition: background 0.3s;
}

.item-actions a:hover {
    background: #5568d3;
}

.item-actions button {
    padding: 8px 12px;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.item-actions .edit-btn {
    background: #ff9800;
}

.item-actions .edit-btn:hover {
    background: #f57c00;
}

.item-actions .delete-btn {
    background: #f44336;
}

.item-actions .delete-btn:hover {
    background: #d32f2f;
}

.empty-message {
    text-align: center;
    color: #999;
    font-size: 1.1rem;
    padding: 3rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-btn:hover {
    color: #333;
}

/* Messages */
.error {
    color: #f44336;
    margin-top: 1rem;
}

.success {
    color: #4caf50;
    margin-top: 1rem;
}

.loading {
    color: #667eea;
    margin-top: 1rem;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    main {
        padding: 1rem;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }

    .url-input-group {
        flex-direction: column;
    }

    .form-actions {
        flex-direction: column;
    }
}
