:root {
    --bg: #f6f7fb;
    --card: #fff;
    --text: #1a1d26;
    --muted: #6b7280;
    --primary: #2563eb;
    --border: #e5e7eb;
    --error: #dc2626;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.topbar nav a { margin-left: 1rem; }
.brand { font-weight: 700; color: var(--text); }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.container.narrow { max-width: 420px; padding-top: 4rem; }

.hero h1 { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1rem 0;
}

.btn {
    display: inline-block;
    padding: .5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}
.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.actions { margin-top: 1rem; display: flex; gap: .75rem; }

.form label { display: block; margin-bottom: 1rem; }
.form input,
.form select,
.form textarea {
    width: 100%;
    margin-top: .35rem;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
}

.form textarea {
    display: block;
    min-height: 4.5rem;
    resize: vertical;
}

.alert.error {
    background: #fef2f2;
    color: var(--error);
    padding: .75rem;
    border-radius: 8px;
}

.badge {
    font-size: .75rem;
    padding: .15rem .5rem;
    border-radius: 999px;
}
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #f3f4f6; color: var(--muted); }

.module-list { list-style: none; padding: 0; }
.module-list li {
    display: flex;
    justify-content: space-between;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 720px) {
    .grid-2 { grid-template-columns: 1fr; }
}

.perm-list { font-size: .85rem; max-height: 240px; overflow: auto; }

/* Admin shell (back.localhost) */
.admin-body { margin: 0; }
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: #111827;
    color: #e5e7eb;
    padding: 1.25rem 1rem;
    flex-shrink: 0;
}
.sidebar .brand { color: #fff; display: block; margin-bottom: 1.5rem; font-weight: 700; }
.sidebar-nav a {
    display: block;
    color: #d1d5db;
    padding: .45rem .5rem;
    border-radius: 6px;
    margin-bottom: .25rem;
}
.sidebar-nav a:hover { background: #1f2937; text-decoration: none; color: #fff; }
.sidebar-nav hr { border: none; border-top: 1px solid #374151; margin: 1rem 0; }
.admin-main { flex: 1; display: flex; flex-direction: column; }
.admin-top {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
}
.page-title { margin: 0; font-size: 1.25rem; }
.admin-content { padding: 1.5rem; max-width: 1100px; }
.toolbar { margin-bottom: 1rem; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.data-table th, .data-table td {
    padding: .65rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th { background: #f9fafb; font-size: .8rem; text-transform: uppercase; color: var(--muted); }
.alert.success { background: #ecfdf5; color: #065f46; padding: .75rem; border-radius: 8px; }
.btn.danger { background: #fef2f2; border-color: #fecaca; color: var(--error); }
.btn.small { padding: .25rem .5rem; font-size: .8rem; }
.form select { width: 100%; padding: .6rem; border-radius: 8px; border: 1px solid var(--border); }
.checkbox { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.checkbox input { width: auto; }
.inline-upload { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.media-card img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; }
.media-placeholder {
    height: 120px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 700;
    color: var(--muted);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page-content { max-width: 720px; margin: 0 auto; }
.page-content h1 { margin-top: 0; }
.page-content .lead { font-size: 1.125rem; color: var(--muted); margin-bottom: 1.5rem; }
.page-featured { margin-bottom: 1.5rem; }
.page-featured img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; }
.page-body { line-height: 1.7; }
.service-price { font-size: 1.25rem; color: var(--accent, #2563eb); margin: 1rem 0; }
.slim-pagecontent fieldset.custom-fields { border: 1px solid #e9ecef; padding: 1rem; margin: 1rem 0; border-radius: 3px; }

.shop-categories { display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding: 1rem; }
.shop-categories a { padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.shop-categories a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin: 1rem 0; }
.product-card { margin: 0; }
.product-card img { width: 100%; height: 180px; object-fit: cover; border-radius: 8px; }
.product-card h2 { font-size: 1rem; margin: .5rem 0 0; }
.price { font-weight: 600; }
.price-lg { font-size: 1.5rem; font-weight: 700; }
.product-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.product-detail-image { width: 100%; max-height: 400px; object-fit: cover; border-radius: 12px; }
.product-gallery-thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.product-thumb-btn { padding: 2px; border: 2px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.product-thumb-btn.active { border-color: var(--primary); }
.product-thumb-btn img { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.variant-picker { margin: 1rem 0; }
.variant-option-group { margin-bottom: .75rem; }
.variant-option-label { display: block; font-weight: 600; margin-bottom: .35rem; }
.variant-option-values { display: flex; flex-wrap: wrap; gap: .35rem; }
.variant-value-btn.active { border-color: var(--primary); background: rgba(0, 102, 204, .08); }
.coupon-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.coupon-form label { flex: 1; min-width: 10rem; }
@media (max-width: 640px) {
    .product-detail-grid { grid-template-columns: 1fr; }
}

.account-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    margin-bottom: 1rem;
}
.account-nav a {
    padding: .35rem .75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}
.account-nav a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.account-auth { max-width: 420px; margin: 0 auto; }
.address-list { list-style: none; padding: 0; margin: 0; }
.address-list .nested { margin-bottom: .75rem; }
.badge.on {
    display: inline-block;
    font-size: .75rem;
    padding: .15rem .5rem;
    border-radius: 4px;
    background: #dbeafe;
    color: #1d4ed8;
    margin-right: .35rem;
}
.btn.danger {
    border-color: #fecaca;
    color: var(--error);
}
.alert.success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: .75rem 1rem;
    border-radius: 8px;
}
.alert.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--error);
    padding: .75rem 1rem;
    border-radius: 8px;
}

.form-section-title { font-size: 1.1rem; margin: 1.25rem 0 .75rem; }
.card.nested { margin-bottom: 1rem; padding: 1rem; background: var(--bg); }
.invoice-type { border: none; padding: 0; margin: 0 0 1rem; }
.invoice-type legend { font-weight: 600; margin-bottom: .5rem; }
.invoice-type .radio { display: block; margin: .35rem 0; }
.hidden,
[hidden] {
    display: none !important;
}

.invoice-panel[hidden] { display: none; }
.field-has-error input,
.field-has-error select,
.field-has-error textarea { border-color: var(--error); }
.field-error { display: block; color: var(--error); font-size: .8125rem; margin-top: .25rem; }
.tr-address-cascade { display: grid; gap: .75rem; }
@media (min-width: 640px) {
    .tr-address-cascade { grid-template-columns: 1fr 1fr; }
    .tr-address-cascade .field:nth-child(n+4) { grid-column: 1 / -1; }
}

.legal-consents { border: 1px solid var(--border, #e5e7eb); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.legal-consent-row { display: block; margin: .5rem 0; }
.btn-link.legal-doc-open { background: none; border: none; padding: 0; color: var(--primary, #2563eb); cursor: pointer; text-decoration: underline; font-size: inherit; }

.site-footer { margin-top: 2rem; padding: 1.5rem 0; border-top: 1px solid #e5e7eb; }
.site-footer .footer-legal { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.75rem; }
.legal-page .legal-doc-body { line-height: 1.6; }
.legal-page .legal-doc-table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem; }
.legal-page .legal-doc-table td { border: 1px solid #e5e7eb; padding: 0.35rem 0.5rem; vertical-align: top; }
.legal-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.legal-modal[hidden] { display: none !important; }
.legal-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.legal-modal-panel { position: relative; background: #fff; max-width: 640px; width: 100%; max-height: 85vh; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.2); display: flex; flex-direction: column; }
.legal-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border, #e5e7eb); }
.legal-modal-header h2 { margin: 0; font-size: 1.1rem; }
.legal-modal-close { background: none; border: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: #666; }
.legal-modal-body { padding: 1rem 1.25rem; overflow: auto; font-size: .92rem; }
.legal-modal-body h3 { margin: 1rem 0 .5rem; font-size: 1rem; }
.legal-doc-table { width: 100%; border-collapse: collapse; margin: .5rem 0; font-size: .88rem; }
.legal-doc-table td { border: 1px solid var(--border, #e5e7eb); padding: .35rem .5rem; }
body.legal-modal-open { overflow: hidden; }
.order-consent-list { list-style: none; padding: 0; margin: 0; }
.order-consent-list li { padding: .5rem 0; border-bottom: 1px solid var(--border, #e5e7eb); }
.order-consent-list li:last-child { border-bottom: none; }

.order-tracking h1 { margin-top: 0; }
.order-tracking-status { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.order-tracking .order-timeline { padding-left: 1.25rem; margin: 0 0 1rem; }
.order-tracking .alert.info { background: #eff6ff; color: #1e40af; padding: .75rem; border-radius: 8px; margin-bottom: 1rem; }
