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

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #f5f5f5;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #0366d6;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: white;
    border-bottom: 1px solid #e1e4e8;
    padding: 20px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand-user-group,
.nav-links,
.nav-actions {
    display: inline-flex;
    align-items: center;
}

.brand-user-group {
    flex: 0 0 auto;
    gap: 12px;
    position: relative;
}

.nav-links {
    flex: 1 1 auto;
    justify-content: center;
    gap: 30px;
}

.nav-actions {
    flex: 0 0 170px;
    justify-content: flex-end;
    gap: 30px;
    margin-left: auto;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
}

.brand-logo {
    display: block;
    width: auto;
    max-width: 220px;
    height: 44px;
    object-fit: contain;
}

.brand-text {
    display: none;
}

.user-name {
    color: #666;
    font-weight: 600;
    white-space: nowrap;
}

.user-menu {
    display: grid;
    gap: 2px;
    padding-left: 12px;
    border-left: 1px solid #e1e4e8;
}

.user-link-button {
    justify-self: start;
    border: 0;
    background: transparent;
    color: #0366d6;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    padding: 0;
}

.user-link-button:hover {
    text-decoration: underline;
}

.change-password-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 240px;
    z-index: 200;
    display: grid;
    gap: 8px;
    width: 260px;
    padding: 12px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    background: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.change-password-panel input {
    width: 100%;
    margin-bottom: 0;
    padding: 8px 10px;
}

.change-password-actions {
    display: flex;
    gap: 8px;
}

.change-password-actions .button {
    flex: 1;
    padding: 8px 10px;
}

.change-password-message,
.change-password-error {
    font-size: 12px;
    font-weight: 600;
}

.change-password-message {
    color: #176f2c;
}

.change-password-error {
    color: #cb2431;
}

nav a {
    color: #333;
    font-weight: 500;
    transition: color 0.2s;
}

nav a:hover,
.nav-button:hover {
    color: #0366d6;
    text-decoration: none;
}

.nav-button {
    border: 0;
    background: transparent;
    color: #333;
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    padding: 0;
}

.cart-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cart-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background-color: #0366d6;
    color: white;
    font-size: 12px;
    font-weight: 700;
}

footer {
    background-color: #f6f8fa;
    border-top: 1px solid #e1e4e8;
    padding: 40px 0;
    margin-top: auto;
    color: #666;
    text-align: center;
}

main {
    flex: 1 0 auto;
    display: flex;
    padding: 40px 0;
}

main > .container {
    width: 100%;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 30px;
    color: #333;
}

.card {
    background-color: white;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.login-form {
    min-height: 100%;
    display: flex;
}

.login-panel {
    display: grid;
    grid-template-columns: minmax(320px, 450px) minmax(320px, 400px);
    align-items: center;
    justify-content: center;
    gap: 36px;
    width: 100%;
    min-height: 100%;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.login-brand img {
    width: auto;
    max-width: 100%;
    height: 300px;
    object-fit: contain;
}

.login-card {
    width: 100%;
    margin-bottom: 0;
}

.button {
    display: inline-block;
    padding: 10px 20px;
    background-color: #0366d6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.button:hover {
    background-color: #0256c7;
    text-decoration: none;
}

.button:disabled {
    background-color: #8c959f;
    cursor: not-allowed;
    opacity: 0.65;
}

.button-secondary:disabled {
    background-color: #e6ebf1;
    color: #6a737d;
    border-color: #d0d7de;
}

.button-secondary {
    background-color: #f6f8fa;
    color: #333;
    border: 1px solid #e1e4e8;
}

.button-secondary:hover {
    background-color: #e6ebf1;
}

input,
textarea,
select {
    padding: 10px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    max-width: 500px;
    margin-bottom: 10px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.product-card {
    background-color: white;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 14px;
    transition: box-shadow 0.2s;
}

.product-card:hover {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
}

.product-image-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 5 / 4;
    margin-bottom: 12px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    background-color: #fafbfc;
    overflow: hidden;
}

.product-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-card h3 {
    margin-bottom: 6px;
    color: #333;
    font-size: 16px;
}

.product-card p {
    color: #666;
    margin-bottom: 8px;
    font-size: 13px;
}

.price {
    font-size: 16px;
    font-weight: 600;
    color: #0366d6;
}

.product-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 24px;
    margin-bottom: 12px;
}

.in-cart-badge {
    flex: 0 0 auto;
    padding: 3px 8px;
    border: 1px solid #f0b8bd;
    border-radius: 999px;
    background-color: #fff1f2;
    color: #cb2431;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.item-code {
    color: #333;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.product-actions {
    display: flex;
    gap: 10px;
    align-items: end;
}

.product-actions .button {
    flex: 1;
    padding: 9px 12px;
}

.quantity-field {
    display: grid;
    gap: 4px;
    width: 72px;
    flex: 0 0 72px;
    color: #333;
    font-size: 12px;
    font-weight: 600;
}

.quantity-field input {
    width: 100%;
    max-width: none;
    margin-bottom: 0;
    padding: 8px;
    text-align: center;
}

.pricing-import-panel {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 240px 180px;
    gap: 16px;
    align-items: end;
}

.pricing-import-panel input[type="file"] {
    width: 100%;
}

.pricing-preview-note-wrap {
    grid-column: 1 / -1;
    justify-content: center;
}

.pricing-preview-note {
    display: block;
    text-align: center;
}

.selected-file {
    margin-top: 6px;
    color: #666;
    font-size: 12px;
}

.field-note {
    max-width: 500px;
    margin-top: 4px;
    color: #666;
    font-size: 12px;
}

.admin-actions {
    display: flex;
    gap: 10px;
}

.pricing-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 20px 0;
    padding: 12px 0;
    border-top: 1px solid #e1e4e8;
    border-bottom: 1px solid #e1e4e8;
}

.pricing-table-wrap {
    overflow-x: auto;
}

.pricing-table th,
.pricing-table td {
    white-space: nowrap;
}

.pricing-table td:nth-child(3) {
    min-width: 320px;
    white-space: normal;
}

.cart-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 20px;
    align-items: start;
}

.cart-table th,
.cart-table td {
    vertical-align: middle;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-thumb-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 44px;
    flex: 0 0 54px;
    border: 1px solid #e1e4e8;
    border-radius: 4px;
    background-color: #fafbfc;
    overflow: hidden;
}

.cart-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.line-note {
    display: block;
    margin-top: 3px;
    color: #666;
    font-size: 12px;
    white-space: pre-line;
}

.cart-quantity {
    width: 76px;
    max-width: none;
    margin-bottom: 0;
    text-align: center;
}

.order-summary {
    position: sticky;
    top: 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e1e4e8;
}

.summary-total {
    font-size: 18px;
    border-bottom: none;
}

.order-total-row {
    font-size: 18px;
    font-weight: 700;
}

.checkout-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.row-warning {
    background-color: #fff8e5;
}

.import-confirmation {
    border-color: #c8e1ff;
}

.import-confirmation h3 {
    margin-bottom: 8px;
}

.import-confirmation p {
    margin-bottom: 14px;
}

.mark-sent-panel {
    margin-top: 16px;
    border-color: #c8e1ff;
}

.mark-sent-panel h3 {
    margin-bottom: 6px;
}

.mark-sent-panel p {
    margin-bottom: 14px;
}

.receive-panel {
    margin-top: 16px;
    border-color: #c8e1ff;
}

.receive-panel h3 {
    margin-bottom: 6px;
}

.receive-panel p {
    margin-bottom: 14px;
}

.receive-quantity-input {
    width: 90px;
    margin-bottom: 0;
    text-align: right;
}

.receive-all-button {
    justify-content: flex-end;
    margin-bottom: 4px;
    color: #0366d6;
    font-size: 13px;
}

.received-quantity-short {
    color: #cb2431;
    font-weight: 600;
}

.user-admin-panel {
    display: grid;
    gap: 14px;
}

.user-form-grid,
.product-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: start;
}

.product-admin-panel {
    display: grid;
    gap: 14px;
    scroll-margin-top: 120px;
}

.product-admin-table-wrap tr {
    scroll-margin-top: 120px;
}

.product-admin-panel-editing {
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

.product-admin-table-wrap {
    overflow-x: auto;
}

.admin-product-image-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 110px;
    border: 1px solid #e1e4e8;
    border-radius: 4px;
    background-color: #fafbfc;
    overflow: hidden;
}

.admin-product-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-image-upload-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.product-image-actions {
    margin-top: 12px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.35);
}

.modal-panel {
    display: grid;
    gap: 14px;
    width: min(420px, 100%);
    padding: 20px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    background-color: white;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.modal-panel h3 {
    margin: 0;
}

.modal-panel p {
    margin: 0;
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 39px;
    font-weight: 500;
}

.checkbox-field input {
    width: auto;
    margin-bottom: 0;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions .button {
    padding: 7px 10px;
}

.orders-toolbar {
    margin-bottom: 16px;
}

.orders-search {
    display: grid;
    gap: 6px;
    max-width: 420px;
    font-weight: 500;
}

.orders-search input {
    max-width: none;
    margin-bottom: 0;
}

.stats-filter-panel {
    display: grid;
    grid-template-columns: 180px 180px auto;
    gap: 16px;
    align-items: end;
}

.stats-filter-panel .form-group,
.stats-filter-panel input {
    margin-bottom: 0;
}

.stats-filter-panel .admin-actions {
    align-items: flex-end;
}

.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    display: grid;
    gap: 6px;
}

.stat-card strong {
    font-size: 24px;
}

.stat-label {
    color: #666;
    font-weight: 600;
}

.section-heading {
    margin-top: 28px;
    margin-bottom: 14px;
}

.stats-table {
    table-layout: fixed;
}

.stats-col-primary {
    width: 68%;
}

.stats-col-code {
    width: 22%;
}

.stats-col-description {
    width: 46%;
}

.stats-col-count {
    width: 12%;
}

.stats-col-value {
    width: 20%;
}

@media (max-width: 800px) {
    .login-panel {
        grid-template-columns: 1fr;
        gap: 22px;
        min-height: 0;
    }

    .login-brand {
        justify-content: center;
        min-height: 150px;
    }

    .login-brand img {
        max-width: 180px;
        height: auto;
    }

    .login-card {
        max-width: 400px;
        margin: 0 auto;
    }

    .pricing-import-panel {
        grid-template-columns: 1fr;
    }

    .stats-filter-panel {
        grid-template-columns: 1fr;
    }

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

    .cart-layout,
    .checkout-grid {
        grid-template-columns: 1fr;
    }

    .order-summary {
        position: static;
    }
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-info {
    background-color: #e7f2ff;
    color: #0366d6;
    border: 1px solid #c8e1ff;
}

.alert-error {
    background-color: #ffeaea;
    color: #cb2431;
    border: 1px solid #ffcccc;
}

.alert-success {
    background-color: #e6ffed;
    color: #28a745;
    border: 1px solid #c3fac3;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e1e4e8;
}

th {
    background-color: #f6f8fa;
    font-weight: 600;
    color: #333;
}

.table-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    text-align: left;
    cursor: pointer;
}

th.text-right .table-sort-button {
    justify-content: flex-end;
    text-align: right;
}

.table-sort-button:hover {
    color: #0366d6;
}

.table-sort-button:focus-visible {
    outline: 2px solid #0366d6;
    outline-offset: 2px;
}

tr:hover {
    background-color: #f6f8fa;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: #666;
}

#blazor-error-ui {
    background: #ffffe0;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 12px 20px;
    position: fixed;
    right: 0;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 12px;
    top: 10px;
}
