* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --surface: #ffffff;
    --soft: #f8fafc;
    --page: #f3f6fa;
    --success: #15803d;
    --success-bg: #f0fdf4;
    --error: #b91c1c;
    --error-bg: #fef2f2;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: Arial, sans-serif;
    color: var(--text);
    background: var(--page);
}


/* =========================================
   AUTH PAGES
   ========================================= */

.auth-container {
    width: 100%;
    max-width: 450px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.logo {
    text-align: center;
    margin-bottom: 25px;
}

.logo h1 {
    margin: 0;
    color: var(--text);
}

.logo p {
    margin-top: 8px;
    color: var(--muted);
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-weight: bold;
    color: #374151;
}

input {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    background: #ffffff;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow:
        0 0 0 3px rgba(
            37,
            99,
            235,
            0.1
        );
}

button {
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

#message {
    display: none;
    margin-bottom: 18px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

.success {
    display: block !important;
    background: var(--success-bg);
    color: #166534;
}

.error {
    display: block !important;
    background: var(--error-bg);
    color: #991b1b;
}

.register-link,
.login-link {
    margin-top: 20px;
    text-align: center;
    color: var(--muted);
}

.register-link a,
.login-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: bold;
}

.register-link a:hover,
.login-link a:hover {
    text-decoration: underline;
}


/* =========================================
   DASHBOARD
   ========================================= */

.dashboard-page {
    display: block;
    padding: 0;
    background: var(--page);
}

.dashboard-header {
    position: sticky;
    top: 0;
    z-index: 10;

    min-height: 76px;
    padding: 14px 5%;

    background: rgba(
        255,
        255,
        255,
        0.96
    );

    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    backdrop-filter: blur(8px);
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;

    display: grid;
    place-items: center;

    border-radius: 12px;
    background: var(--primary);
    color: #ffffff;

    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.dashboard-header h1 {
    margin: 0;
    color: var(--text);
    font-size: 20px;
    line-height: 1.2;
}

.dashboard-label {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.logout-button {
    width: auto;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid #fecaca;
    color: var(--danger);
}

.logout-button:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

.logout-button:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    border-color: #d1d5db;
}

.dashboard-content {
    width: 92%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 34px 0 60px;
}

.welcome-card {
    margin-bottom: 24px;
    padding: 26px 28px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;

    box-shadow:
        0 8px 24px rgba(
            15,
            23,
            42,
            0.05
        );

    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.welcome-copy {
    min-width: 0;
}

.welcome-badge {
    display: inline-block;
    margin-bottom: 8px;

    padding: 5px 9px;

    border-radius: 999px;

    background: #eff6ff;
    color: var(--primary);

    font-size: 12px;
    font-weight: 700;
}

.welcome-card h2 {
    margin: 0;
    color: var(--text);
    font-size: 27px;
    line-height: 1.2;
}

.welcome-card p {
    margin: 9px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.account-info {
    min-width: 220px;
    padding: 14px 16px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--soft);
}

.account-label {
    display: block;
    margin-bottom: 5px;

    color: var(--muted);

    font-size: 12px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#user-email {
    display: block;
    overflow: hidden;

    color: var(--primary);
    font-weight: 700;

    text-overflow: ellipsis;
    white-space: nowrap;
}

#dashboard-message {
    margin-top: 15px;
    color: var(--danger);
    font-size: 14px;
}


/* =========================================
   DASHBOARD GRID
   ========================================= */

.dashboard-grid {
    display: grid;

    grid-template-columns:
        minmax(320px, 0.9fr)
        minmax(420px, 1.1fr);

    gap: 24px;

    align-items: start;
}

.dashboard-panel {
    padding: 26px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 16px;

    box-shadow:
        0 8px 24px rgba(
            15,
            23,
            42,
            0.05
        );
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 15px;
    margin-bottom: 8px;
}

.panel-kicker {
    display: block;
    margin-bottom: 4px;

    color: var(--primary);

    font-size: 12px;
    font-weight: 800;

    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.product-form h3,
.products-section h3 {
    margin: 0;
    color: var(--text);
    font-size: 21px;
}

.panel-number {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 800;
}

.panel-description {
    margin: 0 0 22px;

    color: var(--muted);

    font-size: 14px;
    line-height: 1.6;
}


/* =========================================
   PRODUCT FORM
   ========================================= */

.product-form {
    margin: 0;
    padding: 0;
    border: 0;
}

.product-form .form-group {
    margin-bottom: 17px;
}

.product-form label {
    margin-bottom: 7px;
    color: #374151;
    font-size: 13px;
}

.product-form input,
.product-form select {
    width: 100%;

    padding: 12px 13px;

    border: 1px solid #d1d5db;
    border-radius: 9px;

    background: #ffffff;
    color: var(--text);

    font-size: 14px;
}

.product-form input::placeholder {
    color: #9ca3af;
}

.product-form input:focus,
.product-form select:focus {
    outline: none;

    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(
            37,
            99,
            235,
            0.1
        );
}

.form-row {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 14px;
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 4px;
}

.primary-button,
.secondary-button {
    width: 100%;
    min-height: 44px;

    padding: 11px 16px;

    font-size: 14px;
}

.primary-button {
    background: var(--primary);
    color: #ffffff;

    box-shadow:
        0 5px 12px rgba(
            37,
            99,
            235,
            0.16
        );
}

.primary-button:hover {
    background: var(--primary-dark);
}

.secondary-button {
    background: #f3f4f6;
    color: #374151;

    border: 1px solid #d1d5db;
}

.secondary-button:hover {
    background: #e5e7eb;
}

#product-message {
    min-height: 20px;

    margin-top: 14px;

    font-size: 14px;
    line-height: 1.5;
}

#product-message.success {
    color: var(--success);
}

#product-message.error {
    color: var(--error);
}


/* =========================================
   PRODUCTS LIST
   ========================================= */

.products-panel {
    min-width: 0;
}

#products-list {
    display: flex;
    flex-direction: column;
    gap: 12px;

    min-height: 80px;
}

.product-item {
    padding: 17px;

    background: #fbfdff;

    border: 1px solid var(--border);
    border-radius: 12px;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
}

.product-item:hover {
    border-color: #cbd5e1;

    box-shadow:
        0 6px 18px rgba(
            15,
            23,
            42,
            0.06
        );
}

.product-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 14px;
}

.product-info {
    min-width: 0;
}

.product-item h4 {
    margin: 0;

    overflow-wrap: anywhere;

    color: var(--text);

    font-size: 16px;
    line-height: 1.35;
}

.category-badge {
    display: inline-block;

    margin-top: 6px;
    padding: 4px 8px;

    border-radius: 999px;

    background: #eff6ff;
    color: #1d4ed8;

    font-size: 11px;
    font-weight: 700;
}

.product-id {
    flex: 0 0 auto;

    color: #94a3b8;

    font-size: 11px;
    font-weight: 700;
}

.product-meta {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 10px;

    margin-top: 15px;
}

.meta-item {
    padding: 10px 11px;

    background: #f8fafc;

    border: 1px solid #edf0f3;
    border-radius: 9px;
}

.meta-label {
    display: block;

    margin-bottom: 3px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.meta-value {
    display: block;

    color: var(--text);

    font-size: 14px;
    font-weight: 700;
}

.product-actions {
    display: flex;
    gap: 9px;

    margin-top: 13px;
}

.edit-product-button,
.delete-product-button {
    width: auto;

    min-width: 80px;

    padding: 9px 13px;

    border-radius: 8px;

    color: #ffffff;

    font-size: 13px;
}

.edit-product-button {
    background: var(--primary);
}

.edit-product-button:hover {
    background: var(--primary-dark);
}

.delete-product-button {
    background: var(--danger);
}

.delete-product-button:hover {
    background: var(--danger-dark);
}

.empty-products,
.loading-products {
    padding: 30px 18px;

    border: 1px dashed #cbd5e1;
    border-radius: 11px;

    background: #f8fafc;
    color: var(--muted);

    text-align: center;
}

.empty-products strong {
    display: block;

    margin-bottom: 5px;

    color: var(--text);

    font-size: 14px;
}

.empty-products span {
    display: block;
    font-size: 13px;
}

.empty-products-icon {
    width: 32px;
    height: 32px;

    margin: 0 auto 9px;

    display: grid;
    place-items: center;

    border-radius: 9px;

    background: #eff6ff;
    color: var(--primary);

    font-size: 20px;
    font-weight: 700;
}


/* =========================================
   MOBILE RESPONSIVE
   ========================================= */

@media (max-width: 900px) {

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .products-panel {
        order: 2;
    }

    .product-editor-panel {
        order: 1;
    }
}

@media (max-width: 640px) {

    body {
        padding: 0;
    }

    .dashboard-header {
        position: static;

        min-height: 70px;

        padding: 12px 4%;
    }

    .brand-mark {
        width: 38px;
        height: 38px;

        flex-basis: 38px;

        border-radius: 10px;
    }

    .dashboard-header h1 {
        font-size: 17px;
    }

    .dashboard-label {
        font-size: 11px;
    }

    .logout-button {
        padding: 9px 12px;
        font-size: 13px;
    }

    .dashboard-content {
        width: 92%;

        padding: 22px 0 40px;
    }

    .welcome-card {
        padding: 20px;

        display: block;
    }

    .welcome-card h2 {
        font-size: 23px;
    }

    .account-info {
        min-width: 0;

        margin-top: 18px;
    }

    .dashboard-panel {
        padding: 20px;
    }

    .panel-heading {
        margin-bottom: 7px;
    }

    .product-form h3,
    .products-section h3 {
        font-size: 19px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .product-meta {
        grid-template-columns:
            1fr 1fr;
    }

    .product-actions {
        display: grid;

        grid-template-columns:
            1fr 1fr;
    }

    .edit-product-button,
    .delete-product-button {
        width: 100%;
    }
}

@media (max-width: 420px) {

    .dashboard-header {
        gap: 10px;
    }

    .dashboard-header h1 {
        font-size: 15px;
    }

    .dashboard-label {
        display: none;
    }

    .logout-button {
        padding: 8px 10px;
        font-size: 12px;
    }

    .dashboard-content {
        width: 94%;
    }

    .welcome-card,
    .dashboard-panel {
        padding: 17px;

        border-radius: 13px;
    }

    .product-meta {
        grid-template-columns: 1fr;
    }

    .product-actions {
        grid-template-columns: 1fr;
    }

    .edit-product-button,
    .delete-product-button {
        min-width: 0;
    }
}