body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    color: #333;
}

header {
    background-color: #007bff;
    color: white;
    padding: 1rem 1rem 0.5rem 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

h1 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    letter-spacing: 0.5px;
}

#category-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 10px;
    gap: 10px;
    justify-content: flex-start;
}

#category-nav::-webkit-scrollbar {
    display: none;
}

#category-nav button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 8px 18px;
    border-radius: 25px;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.3s;
}

#category-nav button.active {
    background: white;
    color: #007bff;
}

#category-nav button:hover:not(.active) {
    background: rgba(255, 255, 255, 0.3);
}

main {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    min-height: 80vh;
}

/* Admin Panel */
#admin-panel {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-left: 5px solid #007bff;
}

.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-weight: 500;
    color: #666;
}

.tab-btn.active {
    color: #007bff;
    border-bottom: 2px solid #007bff;
}

#admin-panel h3 {
    margin-top: 0;
    color: #333;
    font-size: 1.1rem;
}

#add-firm-form, #add-category-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#add-firm-form input, #add-firm-form select, #add-category-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}

#add-firm-form button, #add-category-form button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.admin-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9rem;
}

.admin-list-item button {
    background: #ff4d4d;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

#search-container {
    margin: 1rem 0 1.5rem 0;
}

#searchInput {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    box-sizing: border-box;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    outline: none;
}

.firms-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.firm-card {
    background: white;
    padding: 1.2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.firm-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.firm-category {
    font-size: 0.75rem;
    color: #007bff;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.firm-info {
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.firm-info a {
    color: #28a745;
    text-decoration: none;
    font-weight: 500;
}

.admin-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
}

.delete-btn, .edit-btn {
    padding: 6px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
}

.delete-btn {
    background: #fff0f0;
    color: #dc3545;
}

.edit-btn {
    background: #fff9e6;
    color: #856404;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 2rem;
    border-radius: 20px;
    width: 85%;
    max-width: 350px;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #ccc;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#login-form h2 {
    margin: 0 0 10px 0;
    text-align: center;
    font-size: 1.4rem;
}

#login-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
}

#login-form button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 5px;
}

#all-cats-btn {
    background: #ffc107;
    color: #212529;
    border: none;
    min-width: 40px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Category Grid Modal */
.category-grid-content {
    max-width: 500px !important;
    width: 95% !important;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
}

.grid-item {
    background: #f8f9fa;
    border: 1px solid #eee;
    padding: 15px 10px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.grid-item:hover {
    background: #e9ecef;
    border-color: #007bff;
    transform: translateY(-2px);
}

.grid-item .cat-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: #333;
}

.grid-item .cat-count {
    font-size: 0.75rem;
    color: #007bff;
    font-weight: bold;
}

footer {
    text-align: center;
    padding: 3rem 1rem;
    background: #fff;
    margin-top: 2rem;
}

footer p {
    color: #aaa;
    margin-bottom: 1rem;
}

.admin-link-container a {
    color: #ccc;
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.3s;
}

.admin-link-container a:hover {
    color: #007bff;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: #aaa;
}
