:root {
    --bg: #f4f6f5;
    --card: #ffffff;
    --text: #17201c;
    --muted: #68736d;
    --border: #e1e7e3;

    --green: #087f5b;
    --green-dark: #06694c;
    --green-light: #e9f7f1;

    --orange: #f59f00;
    --danger: #c92a2a;

    --shadow:
        0 8px 30px rgba(0,0,0,.07);

    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);

    padding:
        max(14px, env(safe-area-inset-top))
        18px
        14px;
}

.brand {
    max-width: 620px;
    margin: auto;

    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    border-radius: 13px;

    background: var(--green);
    color: white;

    font-size: 23px;
    font-weight: 800;
}

.brand-name {
    font-size: 19px;
    font-weight: 800;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
}

.app {
    max-width: 620px;
    margin: auto;

    padding:
        22px
        16px
        calc(40px + env(safe-area-inset-bottom));
}

.hero {
    text-align: center;
    padding: 18px 8px 22px;
}

.hero-icon {
    font-size: 40px;
}

.hero h1 {
    margin: 10px 0 10px;

    font-size: clamp(32px, 9vw, 45px);
    line-height: 1.03;
    letter-spacing: -1.5px;
}

.hero p {
    max-width: 440px;
    margin: auto;

    color: var(--muted);
    line-height: 1.5;
}

.card,
.product-card,
.store-card,
.beta-info {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card {
    padding: 18px;
}

.location-status {
    display: flex;
    align-items: center;
    gap: 9px;

    margin-bottom: 13px;

    color: var(--muted);
    font-size: 13px;
}

.status-dot {
    width: 9px;
    height: 9px;

    flex: 0 0 9px;

    border-radius: 50%;
    background: #adb5bd;
}

.location-status.ok .status-dot {
    background: var(--green);
}

.location-status.ok {
    color: var(--green-dark);
}

.button {
    width: 100%;

    border: 0;
    border-radius: 15px;

    padding: 15px 17px;

    font-weight: 750;
}

.button-primary {
    background: var(--green);
    color: white;

    font-size: 17px;
}

.button-primary:active {
    background: var(--green-dark);
}

.button-secondary {
    background: var(--green-light);
    color: var(--green-dark);
}

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

    margin: 18px 0;

    color: #9aa39f;
    font-size: 12px;
}

.separator::before,
.separator::after {
    content: "";
    height: 1px;
    background: var(--border);
    flex: 1;
}

.manual {
    margin-top: 17px;
}

.manual label {
    display: block;

    margin-bottom: 7px;

    color: var(--muted);
    font-size: 12px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.input-row input {
    width: 100%;
    min-width: 0;

    border: 1px solid #ccd5d0;
    border-radius: 13px;

    padding: 13px;

    background: #fff;

    outline: none;
}

.input-row input:focus {
    border-color: var(--green);
}

.small-button {
    border: 0;
    border-radius: 13px;

    padding: 0 15px;

    background: #17201c;
    color: white;

    font-weight: 700;
}

.message {
    margin-top: 16px;

    padding: 14px 16px;

    border-radius: 14px;

    background: #fff4e6;
    border: 1px solid #ffe0b2;

    line-height: 1.4;
}

.message.error {
    color: var(--danger);

    background: #fff5f5;
    border-color: #ffc9c9;
}

.loading {
    margin: 20px 0;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;

    color: var(--muted);
}

.spinner {
    width: 24px;
    height: 24px;

    border-radius: 50%;

    border: 3px solid #d8dfdb;
    border-top-color: var(--green);

    animation: spin .7s linear infinite;
}

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

.product-card {
    margin-top: 18px;
    padding: 18px;
}

.product-top {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
}

.product-image {
    width: 100px;
    height: 100px;

    object-fit: contain;

    background: #fff;

    border: 1px solid var(--border);
    border-radius: 16px;
}

.product-placeholder {
    width: 100px;
    height: 100px;

    display: grid;
    place-items: center;

    background: var(--bg);

    border-radius: 16px;

    font-size: 35px;
}

.product-brand {
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.product-name {
    margin: 4px 0 5px;

    font-size: 21px;
    line-height: 1.15;
}

.product-meta {
    color: var(--muted);
    font-size: 13px;
}

.best-price {
    margin-top: 18px;

    padding: 17px;

    border-radius: 17px;

    background: var(--green-light);
}

.best-price-label {
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 700;
}

.price-value {
    margin: 2px 0;

    color: var(--green-dark);

    font-size: 35px;
    font-weight: 850;
    letter-spacing: -1px;
}

.store-name {
    font-weight: 750;
}

.store-address,
.store-distance {
    margin-top: 3px;

    color: var(--muted);
    font-size: 13px;
}

.section-title {
    margin: 20px 0 9px;

    font-size: 16px;
}

.store-card {
    margin-top: 9px;
    padding: 14px 15px;

    box-shadow: none;
}

.store-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.store-price {
    white-space: nowrap;

    color: var(--green-dark);
    font-weight: 850;
}

.no-price {
    margin-top: 18px;

    padding: 17px;

    border-radius: 17px;

    background: #fff8e6;
    border: 1px solid #ffe3a3;
}

.no-price strong {
    display: block;
    margin-bottom: 5px;
}

.add-price-disabled {
    width: 100%;

    margin-top: 15px;
    padding: 13px;

    border: 1px dashed #b8c2bd;
    border-radius: 13px;

    background: #f6f8f7;
    color: #68736d;

    font-weight: 700;
}

.beta-info {
    margin-top: 20px;
    padding: 15px 17px;

    color: var(--muted);

    box-shadow: none;

    font-size: 12px;
    line-height: 1.45;
}

.beta-info strong {
    color: var(--text);
}

.beta-info p {
    margin: 4px 0 0;
}

.hidden {
    display: none !important;
}


/* Scanner */

.scanner-modal {
    position: fixed;
    inset: 0;

    z-index: 9999;

    display: flex;
    flex-direction: column;

    background: #050706;
    color: white;
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding:
        max(14px, env(safe-area-inset-top))
        18px
        14px;
}

.scanner-header button {
    width: 42px;
    height: 42px;

    border: 0;
    border-radius: 50%;

    background: rgba(255,255,255,.15);
    color: white;

    font-size: 29px;
}

.scanner-body {
    position: relative;

    flex: 1;

    display: flex;
    flex-direction: column;
    justify-content: center;

    overflow: hidden;
}

#scannerVideo {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: cover;
}

.scanner-frame {
    position: relative;
    z-index: 2;

    width: min(82vw, 460px);
    height: 180px;

    margin: auto;

    border: 3px solid white;
    border-radius: 20px;

    box-shadow:
        0 0 0 9999px rgba(0,0,0,.35);
}

#scannerMessage {
    position: absolute;
    z-index: 3;

    left: 20px;
    right: 20px;
    bottom:
        calc(35px + env(safe-area-inset-bottom));

    text-align: center;

    font-size: 14px;
}

@media (min-width: 700px) {

    .app {
        padding-top: 35px;
    }

    .card {
        padding: 23px;
    }
}


/* ==========================================================
   BETA WRITE v0.6
   ========================================================== */

.select-store-button {
    width: 100%;
    margin-top: 12px;
    padding: 11px 13px;
    border: 1px solid var(--green);
    border-radius: 12px;
    background: #fff;
    color: var(--green-dark);
    font-weight: 750;
}

.select-store-button.selected {
    background: var(--green-light);
}

.store-card.store-selected {
    border-color: var(--green);
}

.price-form {
    margin-top: 18px;
    padding: 17px;
    border: 1px solid var(--green);
    border-radius: 17px;
    background: var(--green-light);
}

.price-form-title {
    font-size: 19px;
    font-weight: 850;
}

.price-form-store {
    margin: 4px 0 15px;
    color: var(--muted);
    font-size: 13px;
}

.price-form label {
    display: block;
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 700;
}

.price-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.price-input-row input {
    width: 100%;
    min-width: 0;
    padding: 14px;
    border: 1px solid #b9c9c1;
    border-radius: 13px;
    background: #fff;
    font-size: 22px;
    font-weight: 800;
    outline: none;
}

.price-input-row input:focus {
    border-color: var(--green);
}

.price-input-row span {
    color: var(--green-dark);
    font-weight: 800;
}

.price-form-note {
    margin-top: 10px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

#savePriceButton:disabled {
    opacity: .6;
    cursor: wait;
}
