:root {
    --blue: #1877f2;
    --blue2: #0b5ed7;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #111827;
    --muted: #64748b;
    --line: #e5e7eb;
    --green: #16a34a;
    --red: #dc2626;
    --orange: #f97316;
    --shadow: 0 12px 34px rgba(15, 23, 42, .08);
    --soft-shadow: 0 1px 2px rgba(0, 0, 0, .10);
    --radius: 18px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

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

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
}

main {
    width: 100%;
    max-width: 1260px;
    margin: 0 auto;
    padding: 18px;
}

/* Topbar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    max-width: 100%;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 18px;
    padding-top: max(10px, env(safe-area-inset-top));
    box-shadow: 0 4px 20px rgba(0, 0, 0, .04);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    white-space: nowrap;
    font-weight: 900;
    font-size: 20px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #70a8ff);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 22px;
}

.top-search {
    flex: 1;
    display: flex;
    max-width: 520px;
    min-width: 220px;
}

.top-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: #f1f5f9;
    border-radius: 999px 0 0 999px;
    padding: 13px 16px;
    outline: none;
}

.top-search button {
    border: 0;
    background: var(--blue);
    color: white;
    border-radius: 0 999px 999px 0;
    padding: 0 18px;
    font-weight: 800;
    cursor: pointer;
}

.top-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
}

.top-actions a {
    flex: 0 0 auto;
    padding: 9px 11px;
    border-radius: 999px;
    color: #334155;
    font-weight: 800;
    white-space: nowrap;
}

.top-actions a:hover {
    background: #eff6ff;
    color: var(--blue);
}

.top-actions b {
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    padding: 2px 6px;
}

/* Common */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.alert {
    max-width: 1260px;
    margin: 14px auto;
    padding: 14px 18px;
    border-radius: 14px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.alert.success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}

.alert.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 10px 15px;
    font-weight: 900;
    cursor: pointer;
    color: #334155;
    text-align: center;
    line-height: 1.2;
}

.btn.primary {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}

.btn.primary:hover {
    background: var(--blue2);
}

.btn.success {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.btn.warning {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.btn.danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.btn.ghost {
    background: #f8fafc;
}

.btn.full {
    width: 100%;
}

.btn.small {
    padding: 7px 10px;
    font-size: 13px;
}

.pill {
    display: inline-flex;
    background: #e8f1ff;
    color: #0b5ed7;
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 900;
    font-size: 13px;
}

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

.empty {
    text-align: center;
    color: var(--muted);
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 18px 0;
}

/* Facebook style homepage */

.fb-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 280px;
    gap: 18px;
    align-items: start;
}

.left-rail,
.right-rail {
    position: sticky;
    top: 76px;
}

.left-rail {
    display: grid;
    gap: 8px;
}

.left-rail a,
.dash-menu a {
    display: block;
    padding: 12px;
    border-radius: 12px;
    font-weight: 850;
}

.left-rail a:hover,
.dash-menu a:hover {
    background: #eff6ff;
    color: var(--blue);
}

.feed {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.hero-card {
    display: grid;
    grid-template-columns: 1.4fr .8fr;
    gap: 20px;
    background: linear-gradient(135deg, #fff, #eef6ff);
}

.hero-card h1 {
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.05;
    margin: 14px 0;
}

.hero-card p {
    font-size: 17px;
    color: #475569;
    line-height: 1.6;
}

.hero-actions,
.post-actions,
.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hero-stats {
    display: grid;
    gap: 12px;
}

.hero-stats strong {
    font-size: 24px;
    color: var(--blue);
}

.hero-stats span {
    color: var(--muted);
}

.composer {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #6ea8fe);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
}

.fake-input {
    flex: 1;
    min-width: 0;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 13px 16px;
    color: #64748b;
}

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

.story {
    height: 130px;
    border-radius: 18px;
    background: linear-gradient(160deg, #1877f2, #0f172a);
    color: #fff;
    display: flex;
    align-items: flex-end;
    padding: 14px;
    font-weight: 900;
    box-shadow: var(--shadow);
}

.post-card {
    padding: 0;
    overflow: hidden;
}

.post-head {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 16px;
}

.post-head small {
    display: block;
    color: var(--muted);
}

.post-img {
    width: 100%;
    height: 360px;
    object-fit: cover;
    background: #e2e8f0;
}

.post-body {
    padding: 18px;
}

.post-body h2 {
    margin: 0 0 8px;
}

.post-meta,
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
}

.post-meta strong,
.price strong {
    font-size: 22px;
    color: #0f172a;
}

.post-meta del,
.price del {
    color: #94a3b8;
}

/* Products */

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.product-card {
    padding: 0;
    overflow: hidden;
}

.product-card img {
    height: 220px;
    width: 100%;
    object-fit: cover;
    background: #e2e8f0;
}

.product-info {
    padding: 16px;
}

.product-info h2 {
    font-size: 18px;
    min-height: 44px;
}

.product-info small {
    color: var(--blue);
    font-weight: 900;
}

.product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.detail-img {
    height: 520px;
    width: 100%;
    object-fit: cover;
    border-radius: 16px;
    background: #e2e8f0;
}

.detail-copy h1 {
    font-size: clamp(30px, 4vw, 40px);
    margin: 14px 0;
}

.big strong {
    font-size: 34px;
    color: var(--blue);
}

.buy-row {
    display: flex;
    gap: 12px;
    margin: 18px 0;
}

.buy-row input,
.qty {
    width: 90px;
}

.share-box {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.share-box input,
.link-input {
    flex: 1;
    min-width: 220px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px;
}

/* Pages / forms */

.page-head {
    margin-bottom: 16px;
}

.page-head h1 {
    margin: 0 0 8px;
}

.checkout-grid {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 18px;
}

.form-card label {
    display: grid;
    gap: 7px;
    font-weight: 800;
    margin-bottom: 13px;
}

.form-card input,
.form-card textarea,
.form-card select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    font: inherit;
}

.form-card textarea {
    min-height: 100px;
}

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

.narrow {
    max-width: 520px;
    margin: 0 auto;
}

.summary-card {
    position: sticky;
    top: 80px;
}

.summary-row.total {
    font-size: 22px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.success-card {
    text-align: center;
    max-width: 620px;
    margin: 30px auto;
}

.success-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #dcfce7;
    color: #15803d;
    font-size: 45px;
    font-weight: 900;
    margin: 0 auto 14px;
}

.timeline {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.step {
    display: grid;
    gap: 8px;
    justify-items: center;
    text-align: center;
    color: #94a3b8;
    font-weight: 800;
}

.step span {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #cbd5e1;
}

.step.on {
    color: #166534;
}

.step.on span {
    background: #22c55e;
}

/* Dashboard / Admin */

.dashboard-grid,
.admin-shell {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.admin-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    padding: 18px 14px 90px;
}

.dash-menu,
.admin-nav {
    position: sticky;
    top: 76px;
    align-self: start;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.stat span {
    display: block;
    color: var(--muted);
    font-weight: 800;
}

.stat strong {
    font-size: 26px;
    word-break: break-word;
}

.table-card {
    overflow: hidden;
}

.table-wrap,
.table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

th {
    color: #475569;
    background: #f8fafc;
}

tr:hover td {
    background: #fbfdff;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    text-transform: capitalize;
}

.badge.good {
    background: #dcfce7;
    color: #166534;
}

.badge.wait {
    background: #fef3c7;
    color: #92400e;
}

.badge.bad {
    background: #fee2e2;
    color: #991b1b;
}

.badge.neutral {
    background: #eef2ff;
    color: #3730a3;
}

/* Cart / Auth / Install / Footer */

.cart-total {
    text-align: right;
    font-size: 22px;
    padding: 16px;
}

.auth-wrap {
    padding: 30px 0;
}

.install-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.footer {
    max-width: 1260px;
    margin: 20px auto;
    padding: 22px 18px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    color: #64748b;
}

.footer a {
    display: inline-block;
    margin: 0 10px;
    font-weight: 800;
}

/* Mobile fix */

.mobile-admin-nav {
    display: none;
}

@media (max-width: 980px) {
    main {
        padding: 12px;
    }

    .topbar {
        position: sticky;
        top: 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .brand {
        width: 100%;
        font-size: 20px;
    }

    .top-search {
        order: 2;
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .top-actions {
        order: 3;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .top-actions::-webkit-scrollbar {
        display: none;
    }

    .top-actions a {
        background: #f8fafc;
    }

    .fb-shell,
    .checkout-grid,
    .product-detail {
        grid-template-columns: 1fr;
    }

    .hide-sm,
    .right-rail,
    .left-rail {
        display: none !important;
    }

    .dashboard-grid,
    .admin-shell {
        display: block;
        padding: 12px 10px 90px;
    }

    .dashboard-grid > .dash-menu,
    .admin-shell > .dash-menu,
    .admin-shell > aside,
    .admin-shell > nav,
    .admin-shell .admin-nav {
        position: static !important;
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-height: none;
        margin: 0 0 12px;
        padding: 10px;
        border-radius: 16px;
        background: #fff;
        border: 1px solid var(--line);
        box-shadow: var(--soft-shadow);
        scrollbar-width: none;
    }

    .dashboard-grid > .dash-menu::-webkit-scrollbar,
    .admin-shell > .dash-menu::-webkit-scrollbar,
    .admin-shell > aside::-webkit-scrollbar,
    .admin-shell > nav::-webkit-scrollbar,
    .admin-shell .admin-nav::-webkit-scrollbar {
        display: none;
    }

    .dashboard-grid > .dash-menu a,
    .admin-shell > .dash-menu a,
    .admin-shell > aside a,
    .admin-shell > nav a,
    .admin-shell .admin-nav a {
        flex: 0 0 auto;
        white-space: nowrap;
        background: #f0f2f5;
        border-radius: 999px;
        padding: 9px 13px;
    }

    .mobile-admin-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 0 12px;
        padding: 10px;
        border-radius: 16px;
        background: #fff;
        border: 1px solid var(--line);
        box-shadow: var(--soft-shadow);
        scrollbar-width: none;
    }

    .mobile-admin-nav::-webkit-scrollbar {
        display: none;
    }

    .mobile-admin-nav a {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 9px 13px;
        border-radius: 999px;
        background: #f0f2f5;
        color: #0f172a;
        font-weight: 900;
        white-space: nowrap;
    }

    .mobile-admin-nav a.active {
        background: var(--blue);
        color: #fff;
    }

    .hero-card {
        grid-template-columns: 1fr;
    }

    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid,
    .install-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quick-actions,
    .hero-actions,
    .post-actions,
    .form-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .quick-actions .btn,
    .hero-actions .btn,
    .post-actions .btn,
    .form-actions .btn {
        width: 100%;
    }

    .summary-card {
        position: static;
    }
}

@media (max-width: 620px) {
    .topbar {
        padding-left: 10px;
        padding-right: 10px;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .hero-card h1,
    .detail-copy h1 {
        font-size: 30px;
    }

    .stories {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .story {
        height: 118px;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }

    .post-img {
        height: 260px;
    }

    .form-grid,
    .stats-grid,
    .install-grid,
    .timeline {
        grid-template-columns: 1fr;
    }

    .footer {
        display: block;
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
    }

    .footer a {
        margin: 0 8px 8px 0;
    }

    .card {
        padding: 14px;
        border-radius: 16px;
    }

    .detail-img {
        height: 320px;
    }

    .buy-row {
        display: grid;
        grid-template-columns: 90px 1fr;
    }

    .share-box input,
    .link-input {
        min-width: 0;
        width: 100%;
    }

    .cart-total {
        text-align: left;
    }

    table {
        min-width: 720px;
    }
}