:root {
    --color-primary: #2d709d;
    --color-primary-dark: #215a80;
    --color-surface: #ffffff;
    --color-page: #f5f7f9;
    --color-border: #dfe5ea;
    --color-text: #1f2933;
    --color-muted: #667785;
    --color-danger: #b3261e;
    --color-success: #146c43;
    --shadow-1: 0 1px 2px rgba(31, 41, 51, 0.08), 0 1px 3px rgba(31, 41, 51, 0.12);
    --shadow-2: 0 8px 24px rgba(31, 41, 51, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--color-page);
    color: var(--color-text);
    font-family: Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.panel,
.dashboard-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow-1);
}

.login-card {
    width: min(100%, 420px);
    padding: 32px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    border-radius: 8px;
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: var(--shadow-2);
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 28px;
    font-weight: 500;
}

h2 {
    margin-bottom: 18px;
    font-size: 24px;
    font-weight: 500;
}

h3 {
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 500;
}

.muted {
    color: var(--color-muted);
}

.field {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.field label {
    color: var(--color-muted);
    font-size: 14px;
    font-weight: 500;
}

.input {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--color-text);
    font: inherit;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 112, 157, 0.14);
}

.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    border: 0;
    border-radius: 6px;
    background: var(--color-primary);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    transition: background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.button:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-1);
}

.button:active {
    transform: translateY(1px);
}

.button-secondary {
    background: transparent;
    color: var(--color-primary);
}

.button-secondary:hover {
    background: rgba(45, 112, 157, 0.08);
    box-shadow: none;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 14px;
}

.alert-error {
    border-color: rgba(179, 38, 30, 0.24);
    background: rgba(179, 38, 30, 0.08);
    color: var(--color-danger);
}

.alert-success {
    border-color: rgba(20, 108, 67, 0.24);
    background: rgba(20, 108, 67, 0.08);
    color: var(--color-success);
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #ffffff;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-1);
}

.topbar-inner {
    max-width: 1120px;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 0 auto;
    padding: 0 24px;
}

.app-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.app-title .material-symbols-outlined {
    color: var(--color-primary);
}

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 12px;
    border-radius: 6px;
    color: var(--color-muted);
    font-weight: 500;
}

.nav a:hover,
.nav a.is-active {
    background: rgba(45, 112, 157, 0.08);
    color: var(--color-primary);
}

.main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.dashboard-card {
    display: grid;
    gap: 12px;
    padding: 20px;
    transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.dashboard-card:hover {
    border-color: rgba(45, 112, 157, 0.42);
    box-shadow: var(--shadow-2);
    transform: translateY(-2px);
}

.dashboard-card .icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(45, 112, 157, 0.1);
    color: var(--color-primary);
}

.panel {
    max-width: 620px;
    padding: 24px;
}

.settings-panel {
    margin-bottom: 20px;
}

.settings-panel + .panel {
    margin-top: 20px;
}

.switch-field {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text);
    cursor: pointer;
    font-weight: 500;
}

.switch-field input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch {
    width: 48px;
    height: 28px;
    position: relative;
    border-radius: 999px;
    background: var(--color-border);
    transition: background 150ms ease;
}

.switch::after {
    content: "";
    width: 22px;
    height: 22px;
    position: absolute;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: var(--shadow-1);
    transition: transform 150ms ease;
}

.switch-field input:checked + .switch {
    background: var(--color-primary);
}

.switch-field input:checked + .switch::after {
    transform: translateX(20px);
}

.settings-help {
    margin: 10px 0 0;
    font-size: 14px;
}

.empty-state {
    max-width: none;
    display: grid;
    justify-items: start;
    gap: 8px;
}

.empty-state > .material-symbols-outlined {
    color: var(--color-primary);
    font-size: 38px;
}

.orders-list {
    display: grid;
    gap: 16px;
}

.order-card {
    max-width: none;
}

.order-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.order-card-header h2 {
    margin-bottom: 4px;
    font-size: 22px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.status-success {
    background: rgba(20, 108, 67, 0.1);
    color: var(--color-success);
}

.status-error {
    background: rgba(179, 38, 30, 0.1);
    color: var(--color-danger);
}

.order-meta,
.order-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.order-meta {
    margin: 14px 0;
}

.order-meta span,
.order-items span {
    padding: 6px 10px;
    border-radius: 6px;
    background: #f8fafc;
    color: var(--color-muted);
    font-size: 14px;
}

.orders-panel,
.orders-table-panel {
    max-width: none;
    margin-bottom: 18px;
}

.orders-toolbar {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.orders-search-field {
    flex: 1 1 320px;
    margin-bottom: 0;
}

.orders-result-count {
    margin: 12px 0 0;
    font-size: 14px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.orders-table {
    width: 100%;
    min-width: 880px;
    border-collapse: collapse;
}

.orders-table th,
.orders-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: middle;
}

.orders-table th {
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 700;
}

.orders-table tbody tr:last-child td {
    border-bottom: 0;
}

.order-row {
    cursor: pointer;
}

.order-row:hover,
.order-row:focus {
    background: rgba(45, 112, 157, 0.06);
    outline: none;
}

.table-subtext {
    display: block;
    margin-top: 2px;
    color: var(--color-muted);
    font-size: 13px;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
}

.sort-link .material-symbols-outlined {
    font-size: 18px;
}

.sort-link.is-active {
    color: var(--color-primary);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.pagination-current {
    color: var(--color-muted);
    font-weight: 500;
}

.order-modal {
    width: min(920px, calc(100vw - 32px));
    max-height: min(760px, calc(100vh - 32px));
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow-2);
}

.order-modal::backdrop {
    background: rgba(31, 41, 51, 0.48);
}

.order-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--color-border);
}

.order-modal-header h2 {
    margin-bottom: 4px;
    font-size: 22px;
}

.order-modal-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}

.order-modal-summary span {
    min-width: 0;
    color: var(--color-text);
    font-size: 14px;
}

.order-modal-summary strong {
    display: block;
    margin-bottom: 2px;
    color: var(--color-muted);
    font-size: 12px;
    text-transform: uppercase;
}

.order-modal-items {
    display: grid;
    gap: 0;
    max-height: 430px;
    overflow: auto;
}

.order-modal-items-head,
.order-modal-item {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 88px 120px 120px;
    gap: 14px;
    align-items: center;
}

.order-modal-items-head {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 24px;
    border-bottom: 1px solid var(--color-border);
    background: #ffffff;
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.order-modal-item {
    padding: 14px 24px;
    border-bottom: 1px solid var(--color-border);
}

.order-modal-item:last-child {
    border-bottom: 0;
}

.order-modal-product {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    min-width: 0;
}

.order-modal-item .product-thumb {
    width: 56px;
    height: 56px;
}

.order-modal-item .product-thumb img {
    max-height: 100%;
}

.order-modal-item-main {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.order-modal-item-main strong,
.order-modal-item-main span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-modal-price {
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.order-modal-quantity {
    white-space: nowrap;
}

.order-modal-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: #f8fafc;
}

.order-modal-total span {
    color: var(--color-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.order-modal-total strong {
    font-size: 20px;
}

.order-modal-total-value {
    display: grid;
    gap: 2px;
    justify-items: end;
}

.order-modal-total-value small {
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 500;
}

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

.order-sidebar {
    display: grid;
    gap: 20px;
}

.order-panel {
    max-width: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.csv-upload {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.csv-upload .muted {
    margin-bottom: 0;
    font-size: 14px;
}

.csv-status {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    background: #f8fafc;
    color: var(--color-muted);
    font-size: 14px;
}

.csv-status[hidden] {
    display: none;
}

.csv-status[data-type="success"] {
    background: rgba(20, 108, 67, 0.08);
    color: var(--color-success);
}

.csv-status[data-type="warning"] {
    background: rgba(45, 112, 157, 0.08);
    color: var(--color-primary-dark);
}

.csv-status[data-type="error"] {
    background: rgba(179, 38, 30, 0.08);
    color: var(--color-danger);
}

.selected-panel {
    display: grid;
    gap: 18px;
}

.selected-panel h2 {
    margin-bottom: 0;
}

.selected-tools {
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr);
    gap: 14px;
    align-items: start;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--color-border);
}

.selected-tools .field {
    margin-bottom: 0;
}

.selected-tools .product-search {
    min-width: 0;
}

.shipping-form {
    display: grid;
    gap: 0;
}

.address-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
}

.submit-order {
    width: 100%;
    min-height: 52px;
    font-size: 16px;
}

.submit-order-mobile {
    display: none;
    margin-top: 18px;
}

.submit-order:disabled {
    cursor: progress;
    opacity: 0.72;
}

.product-search {
    position: relative;
}

.product-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 20;
    max-height: 430px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow-2);
}

.product-result,
.selected-product {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 12px;
    align-items: center;
}

.product-result {
    width: 100%;
    padding: 12px;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    background: #ffffff;
    color: var(--color-text);
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.product-result:last-child {
    border-bottom: 0;
}

.product-result:hover {
    background: rgba(45, 112, 157, 0.07);
}

.product-thumb {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--color-muted);
}

.product-thumb img {
    width: 100%;
    max-height: 2rem;
    object-fit: contain;
}

.product-result-text,
.selected-product-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.product-result-text span,
.selected-product-main span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-product-main .mid-stock {
    color: var(--color-muted);
    font-size: 13px;
    white-space: normal;
}

.product-result-empty {
    padding: 16px;
    color: var(--color-muted);
}

.search-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: -6px;
    margin-bottom: 8px;
    color: var(--color-muted);
    font-size: 14px;
}

.search-loading[hidden] {
    display: none;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(45, 112, 157, 0.18);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.selected-products {
    display: grid;
    gap: 12px;
}

.selected-product {
    grid-template-columns: 40px 1fr 118px 44px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #ffffff;
}

.quantity-field {
    display: grid;
    gap: 4px;
}

.quantity-field span {
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 500;
}

.quantity-field .input {
    min-height: 40px;
    padding: 8px 10px;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
}

.icon-button:hover {
    background: rgba(179, 38, 30, 0.08);
    color: var(--color-danger);
}

.actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.setup-error {
    max-width: 780px;
    margin: 48px auto;
    padding: 24px;
}

@media (max-width: 720px) {
    .topbar-inner {
        align-items: flex-start;
        flex-direction: column;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .nav {
        width: 100%;
    }

    .nav a {
        flex: 1 1 auto;
    }

    .login-card {
        padding: 24px;
    }

    .page-header-actions,
    .order-layout {
        grid-template-columns: 1fr;
    }

    .page-header-actions {
        display: grid;
    }

    .orders-toolbar {
        align-items: stretch;
    }

    .orders-toolbar .button,
    .orders-toolbar .button-secondary {
        width: 100%;
    }

    .order-modal-summary {
        grid-template-columns: 1fr;
    }

    .order-modal-items-head {
        display: none;
    }

    .order-modal-item {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .order-modal-product {
        grid-column: 1 / 3;
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .order-modal-item .product-thumb {
        width: 48px;
        height: 48px;
    }

    .order-modal-quantity::before,
    .order-modal-price::before {
        display: block;
        color: var(--color-muted);
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
    }

    .order-modal-quantity::before {
        content: "Darab";
    }

    .order-modal-price:nth-of-type(2)::before {
        content: "Egységár";
    }

    .order-modal-price:nth-of-type(3)::before {
        content: "Összesen";
    }

    .order-modal-price {
        text-align: left;
    }

    .selected-product {
        grid-template-columns: 40px 1fr 44px;
    }

    .quantity-field {
        grid-column: 2 / 4;
    }

    .address-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .selected-tools {
        grid-template-columns: 1fr;
    }

    .submit-order-desktop {
        display: none;
    }

    .submit-order-mobile {
        display: inline-flex;
    }
}
