:root {
    --bg: #f5f1ef;
    --surface: #ffffff;
    --surface-alt: #f0e5e2;
    --text: #1f2340;
    --muted: #68708b;
    --primary: #9e6f71;
    --primary-dark: #7f5658;
    --border: #e4d6d3;
    --success: #2b8a5b;
    --error: #c24848;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea {
    font: inherit;
    border-radius: 12px;
    border: 1px solid var(--border);
}
button, .button-link {
    background: var(--primary);
    color: #fff;
    padding: 0.9rem 1.2rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
}
.button-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.8rem 1rem;
}
.button-danger {
    background: #b84343;
    color: #fff;
    border: none;
    padding: 0.8rem 1rem;
}
.button-small {
    padding: 0.55rem 0.8rem;
    font-size: 0.92rem;
}
.button-link--block { width: 100%; }
.container { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }
.site-header {
    background: #b78384;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}
.brand { font-size: 1.6rem; font-weight: 800; }
.brand span { font-weight: 500; }
.main-nav { display: flex; gap: 1rem; }
.cart-badge {
    background: rgba(255,255,255,0.18);
    padding: 0.7rem 1rem;
    border-radius: 999px;
    font-weight: 700;
}
.cart-badge span {
    background: #fff;
    color: var(--primary-dark);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
}
.page-shell { padding: 2rem 0 4rem; }
.checkout-layout, .cart-layout, .admin-grid, .product-showcase { display: grid; gap: 1.5rem; }
.summary-card, .panel-card, .success-card, .auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.5rem;
}
.page-heading h1, .page-heading h2 { margin-bottom: 0.25rem; }
.page-heading p { color: var(--muted); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }
.product-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
}
.product-card img, .product-showcase__image img, .cart-item img { border-radius: 18px; aspect-ratio: 1 / 1; object-fit: cover; }
.product-showcase { grid-template-columns: 1.1fr 1fr; align-items: start; }
.product-showcase__content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}
.product-showcase__delivery {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.product-showcase__delivery .delivery-info-card { margin: 0; }
.page-delivery-info {
    margin-top: 1.5rem;
}
.page-delivery-info .delivery-info-card { margin: 0; }
.delivery-info-card {
    display: grid;
    gap: 0.75rem;
    margin: 0 0 1.5rem;
    padding: 1rem 1rem 1rem 1.15rem;
    background: linear-gradient(180deg, #fff 0%, #f8f0ee 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(159, 111, 113, 0.07);
    position: relative;
    overflow: hidden;
}
.delivery-info-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, #25d366 0%, #128c7e 100%);
}
.delivery-info-card__header {
    display: grid;
    gap: 0.2rem;
}
.delivery-info-card__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: fit-content;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(37, 211, 102, 0.12);
    color: #128c7e;
    font-size: 0.74rem;
    font-weight: 700;
}
.delivery-info-card__header small {
    color: var(--primary-dark);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
}
.delivery-info-card__header h2,
.delivery-info-card__text,
.delivery-info-card__footer { margin: 0; }
.delivery-info-card__header h2 {
    margin-top: 0;
    font-size: 1.1rem;
}
.delivery-info-card__body {
    display: grid;
    gap: 0.25rem;
}
.delivery-info-card__text,
.delivery-info-card__footer {
    font-size: 0.94rem;
    line-height: 1.45;
}
.delivery-info-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.delivery-contact-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.92rem;
    color: #fff;
    box-shadow: 0 8px 18px rgba(18, 140, 126, 0.16);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.delivery-contact-link:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 10px 22px rgba(18, 140, 126, 0.2);
}
.delivery-contact-link__icon {
    width: 0.82rem;
    height: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}
.delivery-contact-link__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}
.delivery-contact-link--group { background: #25d366; }
.delivery-contact-link--secretary { background: #128c7e; }
.inline-form, .stack-form { display: grid; gap: 1rem; }
.inline-form label, .stack-form label { display: grid; gap: 0.45rem; }
.inline-checkbox {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
}
.inline-checkbox input { width: auto; }
input, select, textarea { width: 100%; padding: 0.9rem 1rem; background: #fff; }
.cart-layout, .checkout-layout, .admin-grid { grid-template-columns: 2fr 1fr; align-items: start; }
.cart-list, .summary-item, .summary-row { display: grid; gap: 0.75rem; }
.cart-item {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    padding: 1rem;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.cart-item__content {
    display: grid;
    gap: 0.75rem;
    min-width: 0;
}
.cart-item__content h3 {
    margin: 0;
}
.cart-item__unit-price {
    margin: 0;
    color: var(--muted);
}
.cart-item__quantity-form {
    gap: 0.5rem;
}
.cart-item__quantity-label {
    gap: 0.35rem !important;
}
.cart-item__actions {
    display: grid;
    justify-items: end;
    gap: 0.75rem;
    align-self: center;
}
.cart-item__line-total {
    font-size: 1.05rem;
    white-space: nowrap;
}
.cart-item__remove-form {
    margin: 0;
}
.quantity-control {
    display: grid;
    grid-template-columns: 40px minmax(58px, 72px) 40px;
    gap: 0.35rem;
    align-items: center;
}
.quantity-control__button {
    padding: 0.55rem;
    min-height: 40px;
}
.quantity-control input {
    text-align: center;
    padding: 0.6rem 0.35rem;
}
.summary-row, .summary-item { grid-template-columns: 1fr auto; align-items: center; }
.action-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.summary-note { color: var(--muted); font-size: 0.95rem; }
.payment-waiting {
    display: grid;
    gap: 1rem;
}
.payment-status-panel {
    display: grid;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 18px;
}
.payment-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 700;
}
.payment-status-badge--pending { background: rgba(158, 111, 113, 0.12); color: var(--primary-dark); }
.payment-status-badge--info { background: rgba(31, 35, 64, 0.08); color: var(--text); }
.payment-status-badge--success { background: rgba(43, 138, 91, 0.12); color: var(--success); }
.payment-status-badge--error { background: rgba(194, 72, 72, 0.12); color: var(--error); }
.flash {
    border-radius: 16px;
    padding: 0.95rem 1rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
}
.flash--success { border-color: rgba(43, 138, 91, 0.35); color: var(--success); }
.flash--error { border-color: rgba(194, 72, 72, 0.35); color: var(--error); }
.empty-state { padding: 2rem; background: var(--surface); border-radius: 24px; border: 1px solid var(--border); text-align: center; }
.success-card { max-width: 720px; }

.admin-body { background: #efe7e4; }
.admin-layout { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.admin-grid--single { grid-template-columns: 1fr; }
.admin-grid--3col { grid-template-columns: repeat(3, 1fr); }
.sidebar {
    background: #2a2e51;
    color: #fff;
    padding: 2rem 1.2rem;
    display: grid;
    align-content: start;
    gap: 1rem;
}
.sidebar nav { display: grid; gap: 0.35rem; }
.sidebar nav a, .brand--admin { padding: 0.8rem 0.9rem; border-radius: 12px; }
.nav-group-label { padding: 0.6rem 0.9rem 0.2rem; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.5; margin-top: 0.5rem; }
.sidebar nav a:hover, .brand--admin:hover { background: rgba(255,255,255,0.1); }
.sidebar-user { padding: 1rem 0.9rem; background: rgba(255,255,255,0.08); border-radius: 16px; }
.admin-content { padding: 2rem; }
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: 22px;
    border: 1px solid var(--border);
    display: grid;
    gap: 0.35rem;
}
.stats-grid--summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card strong { font-size: 1.8rem; }
.stat-card small { color: var(--muted); }
.delivery-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.delivery-summary-card {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
}
.delivery-summary-card__header {
    display: grid;
    gap: 0.15rem;
}
.delivery-summary-card__header h2 {
    margin: 0;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
}
.delivery-summary-card__header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
}
.delivery-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
}
.delivery-summary-card .stat-card {
    padding: 0.85rem;
    gap: 0.2rem;
    border-radius: 16px;
}
.delivery-summary-card .stat-card span {
    font-size: 0.8rem;
}
.delivery-summary-card .stat-card strong {
    font-size: 1.35rem;
    line-height: 1.1;
}
.delivery-summary-card .stat-card small {
    font-size: 0.72rem;
    line-height: 1.25;
}
.stat-card--paid {
    background: rgba(43, 138, 91, 0.1);
    border-color: rgba(43, 138, 91, 0.2);
    color: #2b8a5b;
}
.stat-card--delivered {
    background: rgba(31, 111, 178, 0.1);
    border-color: rgba(31, 111, 178, 0.2);
    color: #1f6fb2;
}
.stat-card--sold {
    background: rgba(122, 92, 213, 0.1);
    border-color: rgba(122, 92, 213, 0.2);
    color: #7a5cd5;
}
.panel-card__header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.85rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.table-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.table-actions form { margin: 0; }
.panel-card__header--stack { flex-direction: column; align-items: stretch; }
.filter-form { display: grid; gap: 1rem; }
.filter-form--compact { gap: 0.75rem; }
.filter-form__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}
.filter-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.table-meta {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}
.form-help {
    margin: -0.2rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}
.permission-fieldset {
    display: grid;
    gap: 0.85rem;
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-alt);
}
.permission-fieldset legend {
    padding: 0 0.35rem;
    font-weight: 700;
}
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}
.permission-card {
    display: grid !important;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 0.75rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
}
.permission-card input {
    width: auto;
    margin-top: 0.2rem;
}
.permission-card strong {
    display: block;
    margin-bottom: 0.2rem;
}
.permission-card small,
.user-table__identity small,
.user-security-note,
.screen-tag-list small {
    color: var(--muted);
}
.user-table__identity {
    display: grid;
    gap: 0.15rem;
    min-width: 200px;
}
.screen-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.screen-tag,
.user-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.32rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}
.screen-tag {
    background: rgba(42, 46, 81, 0.08);
    color: #2a2e51;
}
.user-pill--role {
    background: rgba(122, 92, 213, 0.12);
    color: #7a5cd5;
}
.user-pill--active {
    background: rgba(43, 138, 91, 0.12);
    color: #2b8a5b;
}
.user-pill--inactive {
    background: rgba(194, 72, 72, 0.12);
    color: #c24848;
}
.user-form-note {
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: rgba(42, 46, 81, 0.06);
    color: var(--text);
}
.user-form-note strong {
    display: block;
    margin-bottom: 0.25rem;
}
.product-image-library {
    display: grid;
    gap: 0.75rem;
}
.product-image-library__header,
.product-image-library__actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.product-image-library__panel {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: 18px;
    background: var(--surface-alt);
}
.product-image-library__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}
.product-image-option {
    display: grid;
    gap: 0.5rem;
    padding: 0.65rem;
    background: #fff;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    border: 1px solid var(--border);
}
.product-image-option img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.product-image-option span {
    font-size: 0.82rem;
    color: var(--muted);
    word-break: break-word;
}
.product-image-option.is-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(158, 111, 113, 0.15);
}
.image-preview-box {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: 18px;
    background: var(--surface-alt);
}
.image-preview {
    width: min(180px, 100%);
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 18px;
    border: 1px solid var(--border);
}
.image-preview-path {
    margin: 0;
    word-break: break-all;
}
.table-product {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 0.75rem;
    align-items: center;
    min-width: 240px;
}
.table-product__image {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
    padding: 0.35rem;
}
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.pagination__info {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}
.pagination__links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.delivery-order-link {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    color: #2a2e51;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.delivery-order-link:hover {
    color: #1f6fb2;
}
.delivery-row--priority td {
    background: rgba(255, 196, 61, 0.12);
}
.delivery-row--priority td:first-child {
    box-shadow: inset 4px 0 0 #f0a202;
}
.delivery-priority-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0.5rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(240, 162, 2, 0.16);
    color: #a56400;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.delivery-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: #524a48;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}
.delivery-status__dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: #8a817e;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04);
}
.delivery-status--paid {
    color: #2b8a5b;
}
.delivery-status--paid .delivery-status__dot {
    background: #2b8a5b;
}
.delivery-status--awaiting-payment {
    color: #c24848;
}
.delivery-status--awaiting-payment .delivery-status__dot {
    background: #c24848;
}
.delivery-status--delivered {
    color: #1f6fb2;
}
.delivery-status--delivered .delivery-status__dot {
    background: #1f6fb2;
}
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.auth-card { width: min(480px, 100%); }
.login-tip { margin-top: 1rem; padding: 1rem; background: var(--surface-alt); border-radius: 18px; display: grid; gap: 0.25rem; }

@media (max-width: 900px) {
    .checkout-layout, .cart-layout, .admin-grid, .product-showcase, .admin-layout { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .delivery-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .delivery-summary-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cart-item { grid-template-columns: 90px 1fr; }
    .cart-item__actions {
        grid-column: 2;
        justify-items: start;
    }
    .quantity-control { grid-template-columns: 38px minmax(54px, 68px) 38px; }
    .main-nav { display: none; }
    .pagination { align-items: flex-start; }
}

@media (max-width: 600px) {
    .header-inner { flex-wrap: wrap; }
    .stats-grid { grid-template-columns: 1fr; }
    .delivery-summary-grid, .delivery-summary-stats { grid-template-columns: 1fr; }
    .table-product { grid-template-columns: 1fr; }
}
