:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-2: #eef4fb;
    --text: #101828;
    --muted: #667085;
    --line: #d7e1ee;
    --primary: #1264d8;
    --primary-dark: #0b3f8a;
    --accent: #cf1f35;
    --ink: #0b1220;
    --green: #16794c;
    --green-bg: #e8f7ef;
    --amber: #a15c00;
    --amber-bg: #fff4dc;
    --red: #b42318;
    --red-bg: #ffe9e7;
    --shadow: 0 12px 30px rgba(17, 24, 39, .08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

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

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

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}

textarea {
    min-height: 104px;
    resize: vertical;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}

label input,
label select,
label textarea {
    color: var(--text);
    font-weight: 400;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td small,
.topbar small,
.muted {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 280px;
    padding: 18px;
    background: var(--ink);
    color: #fff;
    transform: translateX(-105%);
    transition: transform .2s ease;
}

body.sidebar-open .sidebar {
    transform: translateX(0);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-weight: 800;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: #23a36b;
    color: #fff;
    font-size: 13px;
}

.brand-logo {
    display: block;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    object-fit: contain;
    flex: 0 0 auto;
}

.nav {
    display: grid;
    gap: 6px;
    margin-top: 18px;
}

.nav a {
    min-height: 42px;
    display: flex;
    align-items: center;
    border-radius: var(--radius);
    padding: 10px 12px;
    color: #d8dee8;
}

.nav a:hover {
    background: rgba(255, 255, 255, .09);
    color: #fff;
}

.main-shell {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    min-height: 66px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
}

.content {
    display: grid;
    gap: 16px;
    padding: 14px;
}

.panel,
.auth-panel,
.stat-card,
.report-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 14px;
}

.section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.section-heading h2,
.panel h2 {
    margin: 0;
    font-size: 18px;
}

.btn,
.icon-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 800;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

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

.btn-light,
.icon-btn {
    background: var(--surface-2);
    border-color: var(--line);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.btn-large {
    min-height: 54px;
    font-size: 16px;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-panel {
    max-width: 980px;
}

.grid-2,
.grid-3,
.filters-grid,
.stats-grid,
.report-grid {
    display: grid;
    gap: 12px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    padding-top: 10px;
    background: var(--surface);
}

.finance-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.finance-preview div {
    display: grid;
    gap: 4px;
}

.finance-preview span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.finance-preview strong {
    font-size: 17px;
}

.search-form {
    display: flex;
    flex: 1;
    gap: 8px;
    min-width: 240px;
}

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

.actions {
    width: 1%;
    white-space: nowrap;
}

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

.product-thumb,
.product-photo-preview,
.company-logo-preview,
.company-logo-thumb {
    display: block;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.product-thumb {
    width: 58px;
    height: 58px;
}

.product-thumb-empty {
    display: inline-grid;
    place-items: center;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.product-photo-preview {
    width: 160px;
    height: 120px;
}

.company-logo-preview {
    width: 180px;
    height: 120px;
    object-fit: contain;
    padding: 10px;
}

.company-logo-thumb {
    width: 52px;
    height: 52px;
    object-fit: contain;
    padding: 6px;
    flex: 0 0 auto;
}

.company-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.stat-card {
    padding: 16px;
}

.stat-card span,
.report-card span {
    color: var(--muted);
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.stat-card.warning {
    border-color: #f2c76b;
    background: var(--amber-bg);
}

.stat-card.danger,
.report-card.danger {
    border-color: #ffb4ae;
    background: var(--red-bg);
}

.stock-badge,
.pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 800;
}

.stock-badge.normal,
.pill.entry {
    background: var(--green-bg);
    color: var(--green);
}

.stock-badge.low,
.pill.correction {
    background: var(--amber-bg);
    color: var(--amber);
}

.stock-badge.negative,
.pill.exit {
    background: var(--red-bg);
    color: var(--red);
}

.alert {
    border-radius: var(--radius);
    padding: 12px 14px;
    font-weight: 800;
}

.alert-success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid #a6e7c4;
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid #ffb4ae;
}

.autocomplete {
    position: relative;
}

.suggestions {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 40;
    display: none;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.suggestions.is-open {
    display: block;
}

.suggestion {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.suggestion:hover {
    background: var(--surface-2);
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 18px;
    background:
        linear-gradient(90deg, rgba(243, 246, 251, .94), rgba(243, 246, 251, .76)),
        url("../img/optical-hero.png") center / cover no-repeat;
}

.auth-shell {
    width: min(100%, 420px);
}

.auth-panel {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.auth-panel h1 {
    margin: 0;
}

.auth-brand {
    color: var(--text);
}

.muted-link,
.reset-link {
    color: var(--primary);
    font-weight: 800;
}

.link-button {
    display: inline;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    text-decoration: underline;
}

.reset-link {
    overflow-wrap: anywhere;
}

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

.report-card {
    display: grid;
    gap: 8px;
    padding: 16px;
}

.prescription-grid {
    display: grid;
    gap: 12px;
}

.prescription-eye {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    background: #fbfdff;
}

.prescription-eye + .prescription-eye {
    border-left-color: var(--accent);
}

.prescription-eye strong {
    color: var(--text);
}

.grid-4 {
    display: grid;
    gap: 12px;
}

.public-page {
    background: #fff;
}

.public-hero {
    min-height: 64vh;
    display: grid;
    align-content: space-between;
    padding: 18px;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(11, 18, 32, .92) 0%, rgba(11, 18, 32, .78) 40%, rgba(11, 18, 32, .08) 100%),
        url("../img/optical-hero.png") center / cover no-repeat;
}

.public-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.public-brand {
    min-width: 0;
}

.public-nav-actions,
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-copy {
    width: min(100%, 620px);
    padding: 56px 0 42px;
}

.hero-copy h1 {
    margin: 0;
    font-size: 46px;
    line-height: .95;
}

.hero-copy p {
    width: min(100%, 500px);
    margin: 18px 0 0;
    color: #dbeafe;
    font-size: 19px;
    line-height: 1.5;
}

.hero-actions {
    margin-top: 24px;
}

.public-flash {
    position: fixed;
    z-index: 60;
    top: 14px;
    left: 50%;
    width: min(94vw, 720px);
    transform: translateX(-50%);
}

.public-content {
    padding: 24px 18px 44px;
}

.signup-shell {
    min-height: 100vh;
    display: grid;
    place-items: start center;
    padding-top: 28px;
    background:
        linear-gradient(90deg, rgba(243, 246, 251, .96), rgba(243, 246, 251, .84)),
        url("../img/optical-hero.png") center / cover no-repeat;
}

.signup-panel {
    width: min(100%, 760px);
}

.signup-brand {
    margin-bottom: 10px;
}

.signup-panel h1 {
    margin: 0;
    font-size: 28px;
}

.catalog-section {
    width: min(1160px, 100%);
    margin: 0 auto;
}

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

.store-card {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 14px;
    align-items: center;
    min-height: 116px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 10px 24px rgba(16, 24, 40, .07);
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.store-card:hover {
    border-color: var(--primary);
    box-shadow: 0 16px 32px rgba(16, 24, 40, .11);
    transform: translateY(-2px);
}

.store-logo {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.store-logo img {
    max-width: 62px;
    max-height: 62px;
    object-fit: contain;
}

.store-card h3 {
    margin: 0;
    font-size: 18px;
}

.store-card p {
    margin: 5px 0 0;
    color: var(--muted);
    line-height: 1.35;
}

.public-empty {
    grid-column: 1 / -1;
}

.storefront-hero {
    min-height: 42vh;
    display: grid;
    align-content: space-between;
    gap: 42px;
    padding: 18px;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(11, 18, 32, .94), rgba(11, 18, 32, .76)),
        url("../img/optical-hero.png") center / cover no-repeat;
}

.storefront-heading {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 18px;
    align-items: center;
    width: min(100%, 980px);
}

.storefront-logo {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .96);
}

.storefront-logo img {
    max-width: 78px;
    max-height: 78px;
    object-fit: contain;
}

.storefront-heading h1 {
    margin: 0;
    font-size: 38px;
    line-height: 1;
}

.storefront-heading p {
    margin: 10px 0 0;
    color: #dbeafe;
}

.storefront-share {
    display: inline-block;
    margin-top: 10px;
    color: #fff;
    font-weight: 800;
    overflow-wrap: anywhere;
}

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

.storefront-search {
    max-width: 440px;
}

.public-product-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.public-product-card {
    display: grid;
    grid-template-rows: 180px 1fr auto;
    min-height: 390px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 10px 24px rgba(16, 24, 40, .07);
}

.public-product-photo {
    display: grid;
    place-items: center;
    background: var(--surface-2);
}

.public-product-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.public-product-photo img[src$=".svg"] {
    width: 92px;
    height: 92px;
    object-fit: contain;
}

.public-product-info {
    display: grid;
    align-content: start;
    gap: 7px;
    padding: 14px;
}

.public-product-info span,
.public-product-info small,
.public-product-footer small {
    color: var(--muted);
    font-weight: 800;
}

.public-product-info span {
    font-size: 12px;
    text-transform: uppercase;
}

.public-product-info h3 {
    margin: 0;
    font-size: 18px;
}

.public-product-info p {
    margin: 0;
    color: var(--muted);
    line-height: 1.4;
}

.public-product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--line);
}

.public-product-footer strong {
    color: var(--primary-dark);
    font-size: 19px;
}

@media (min-width: 760px) {
    .grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

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

    .hero-copy h1 {
        font-size: 64px;
    }

    .filters-grid {
        grid-template-columns: repeat(6, minmax(130px, 1fr));
        align-items: end;
    }

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

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

@media (min-width: 1024px) {
    .app-shell {
        display: grid;
        grid-template-columns: 280px 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        transform: none;
    }

    .icon-btn {
        display: none;
    }

    .topbar {
        grid-template-columns: 1fr auto;
    }

    .content {
        padding: 22px;
    }

    .public-hero {
        padding: 24px 42px;
    }

    .storefront-hero {
        padding: 24px 42px 42px;
    }

    .hero-copy h1 {
        font-size: 76px;
    }
}
