:root {
    --cereal-accent:  #15803d;
    --cereal-mid:     #16a34a;
    --cereal-light:   #f0fdf4;
    --cereal-border:  #86efac;

    --agro-accent:    #b45309;
    --agro-mid:       #d97706;
    --agro-light:     #fffbeb;
    --agro-border:    #fcd34d;

    --ink:        #0d1117;
    --text:       #1c1c1e;
    --text-mid:   #3a3a3c;
    --text-soft:  #6e6e73;
    --text-mute:  #aeaeb2;
    --border:     #e5e5ea;
    --border-mid: #d1d1d6;
    --surface:    #ffffff;
    --bg:         #f2f2f7;
    --bg-mid:     #e5e5ea;

    --red:        #c0392b;
    --red-light:  #fff1f0;
    --green:      #15803d;
    --green-light:#f0fdf4;
    --blue:       #0040dd;
    --blue-light: #f0f4ff;
    --amber:      #b45309;
    --amber-light:#fffbeb;

    --r-lg: 16px;
    --r:    12px;
    --r-sm: 8px;
    --r-xs: 5px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
    --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
    --shadow:    0 4px 16px rgba(0,0,0,.10);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.18);
}

body.shop-cereal {
    --accent:        #15803d;
    --accent-mid:    #16a34a;
    --accent-light:  #f0fdf4;
    --accent-border: #86efac;
}
body.shop-agro {
    --accent:        #b45309;
    --accent-mid:    #d97706;
    --accent-light:  #fffbeb;
    --accent-border: #fcd34d;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html { font-size: 16px; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    padding-bottom: 72px;
    -webkit-font-smoothing: antialiased;
}

/* ─── TOPBAR ─────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    height: 52px;
    background: #0d1117;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid #21262d;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-mid);
    flex-shrink: 0;
}

.topbar-name {
    font-size: 14px;
    font-weight: 700;
    color: #f5f5f7;
    letter-spacing: -.01em;
    line-height: 1.1;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.topbar-date {
    font-size: 10px;
    color: #636366;
    margin-top: 1px;
}

.topbar-logout {
    font-size: 11px;
    font-weight: 600;
    color: #636366;
    text-decoration: none;
    padding: 5px 11px;
    border: 1px solid #30363d;
    border-radius: 99px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: color .15s;
}

.topbar-logout:hover { color: #aeaeb2; }

/* ─── BOTTOM NAV ─────────────────────── */
.bottomnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #e5e5ea;
    display: flex;
    align-items: stretch;
    box-shadow: 0 -1px 8px rgba(0,0,0,.06);
}

.botnav-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #aeaeb2;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -.01em;
    font-family: 'Plus Jakarta Sans', sans-serif;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}

.botnav-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.botnav-label { pointer-events: none; }

/* ─── LAYOUT ─────────────────────────── */
.main-content {
    padding: 16px 14px;
    max-width: 580px;
    margin: 0 auto;
}

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

.page-header h1 {
    font-size: 22px;
    font-weight: 800;
    color: #0d1117;
    letter-spacing: -.03em;
    line-height: 1;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.page-header p {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 3px;
    font-weight: 500;
}

/* ─── STAT GRID ──────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.stat-card {
    background: #ffffff;
    border-radius: var(--r);
    padding: 13px 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.stat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 6px;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
    line-height: 1;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.stat-value.green { color: #15803d; }
.stat-value.amber { color: #b45309; }
.stat-value.red   { color: #c0392b; }
.stat-value.blue  { color: #0040dd; }

.stat-sub {
    font-size: 10px;
    color: var(--text-mute);
    margin-top: 4px;
    font-weight: 500;
}

/* ─── CARDS ──────────────────────────── */
.card {
    background: #ffffff;
    border-radius: var(--r);
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-xs);
}

.card-title {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ─── FORMS ──────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.form-group label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    background: #ffffff;
    outline: none;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder { color: var(--text-mute); font-weight: 400; }
.form-group input[readonly] { background: var(--bg); color: var(--text-soft); }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ─── AUTOCOMPLETE ───────────────────── */
.autocomplete-wrap { position: relative; }

.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1.5px solid var(--accent);
    border-radius: var(--r-sm);
    box-shadow: 0 8px 32px rgba(0,0,0,.14);
    z-index: 400;
    max-height: 230px;
    overflow-y: auto;
    display: none;
}

.autocomplete-list.open { display: block; }

.autocomplete-item {
    padding: 11px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: var(--accent-light); }

.autocomplete-item .item-name { font-weight: 700; font-size: 14px; }
.autocomplete-item .item-meta { font-size: 11px; color: var(--text-soft); margin-top: 1px; }
.autocomplete-item .item-stock { font-size: 11px; color: #15803d; font-weight: 700; text-align: right; }
.autocomplete-item .item-stock.low { color: #c0392b; }

/* ─── BUTTONS ────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: var(--r-sm);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
    -webkit-appearance: none;
    letter-spacing: -.01em;
}

.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:active { filter: brightness(.9); transform: scale(.98); }
.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: var(--accent-light); }
.btn-danger  { background: #c0392b; color: #ffffff; }
.btn-ghost   { background: var(--bg); color: var(--text-mid); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-mid); }
.btn-sm  { padding: 7px 13px; font-size: 12px; }
.btn-lg  { padding: 14px 24px; font-size: 15px; }
.btn-block { width: 100%; }

/* ─── QTY PRESETS ────────────────────── */
.qty-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

.qty-preset {
    padding: 6px 13px;
    border: 1.5px solid var(--border);
    border-radius: 99px;
    background: #ffffff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-soft);
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: all .12s;
}

.qty-preset:hover,
.qty-preset.selected { border-color: var(--accent); background: var(--accent); color: #ffffff; }

/* ─── PAYMENT ────────────────────────── */
.payment-methods { display: flex; gap: 8px; margin-bottom: 12px; }

.payment-btn {
    flex: 1;
    padding: 11px 6px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    background: #ffffff;
    cursor: pointer;
    text-align: center;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-soft);
    transition: all .12s;
}

.payment-btn.selected { border-color: var(--accent); background: var(--accent); color: #ffffff; }

/* ─── CART ───────────────────────────── */
.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-left { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-meta { font-size: 11px; color: var(--text-soft); margin-top: 2px; }
.cart-item-profit { font-size: 11px; color: #15803d; margin-top: 1px; font-weight: 600; }
.cart-item-right { text-align: right; padding-left: 10px; flex-shrink: 0; }
.cart-item-total { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.cart-remove {
    background: #fff1f0; border: none; color: #c0392b;
    cursor: pointer; font-size: 13px; padding: 4px 8px;
    border-radius: var(--r-xs); margin-left: 8px;
    font-weight: 700; font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ─── TOTALS ─────────────────────────── */
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13px; }
.total-row.grand { border-top: 2px solid #0d1117; padding-top: 12px; margin-top: 4px; }
.total-row .label { color: var(--text-soft); font-weight: 600; }
.total-row .value { font-weight: 800; font-variant-numeric: tabular-nums; }
.total-row.grand .label { font-size: 15px; color: var(--text); }
.total-row.grand .value { font-size: 22px; color: var(--accent); letter-spacing: -.02em; }
.total-row.profit .value { color: #15803d; }

/* ─── PREVIEWS ───────────────────────── */
.profit-preview {
    background: var(--accent-light);
    border: 1px solid var(--accent-border);
    border-radius: var(--r-sm);
    padding: 9px 13px;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-mid);
    display: none;
}
.profit-preview.show { display: block; }

.price-alert {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--r-sm);
    padding: 10px 13px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-mid);
}

/* ─── TABLES ─────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
    background: var(--bg);
    padding: 8px 12px;
    text-align: left;
    font-size: 10px;
    font-weight: 800;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--accent-light); }
.stock-row { cursor: pointer; }

/* ─── BADGES ─────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.badge-green { background: #f0fdf4; color: #15803d; }
.badge-amber { background: #fffbeb; color: #b45309; }
.badge-red   { background: #fff1f0; color: #c0392b; }
.badge-blue  { background: #f0f4ff; color: #0040dd; }
.badge-gray  { background: var(--bg-mid); color: var(--text-soft); }

/* ─── ALERTS ─────────────────────────── */
.alert {
    padding: 11px 14px;
    border-radius: var(--r-sm);
    font-size: 13px;
    margin-bottom: 10px;
    font-weight: 600;
    border-left: 3px solid;
}
.alert-success { background: #f0fdf4; color: #15803d; border-color: #15803d; }
.alert-warning { background: #fffbeb; color: #b45309; border-color: #b45309; }
.alert-error   { background: #fff1f0; color: #c0392b; border-color: #c0392b; }

/* ─── MODAL ──────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 500;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    padding: 8px 18px 36px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 -4px 32px rgba(0,0,0,.16);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-handle {
    width: 36px; height: 4px;
    background: var(--border-mid);
    border-radius: 2px;
    margin: 8px auto 16px;
}

.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 3px; letter-spacing: -.02em; font-family: 'Plus Jakarta Sans', sans-serif; }
.modal-sub { font-size: 12px; color: var(--text-soft); margin-bottom: 18px; font-weight: 500; }

.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: var(--bg); border: none;
    width: 28px; height: 28px; border-radius: 50%;
    cursor: pointer; font-size: 13px; color: var(--text-soft);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}

/* ─── RECEIPT ────────────────────────── */
.receipt { font-size: 12px; }
.receipt-header { text-align: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border-mid); }
.receipt-header .shop-name { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; font-family: 'Plus Jakarta Sans', sans-serif; }
.receipt-header .receipt-sub { font-size: 11px; color: var(--text-soft); margin-top: 3px; }
.receipt-line { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12px; }
.receipt-items { margin: 10px 0; padding: 10px 0; border-top: 1px dashed var(--border-mid); border-bottom: 1px dashed var(--border-mid); }
.receipt-total { font-weight: 700; font-size: 13px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-mid); }
.receipt-footer { text-align: center; margin-top: 12px; font-size: 11px; color: var(--text-soft); padding-top: 10px; border-top: 1px dashed var(--border-mid); }

/* ─── LOGIN ──────────────────────────── */
.login-page {
    min-height: 100vh;
    background: #0d1117;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
}

.login-wrap { width: 100%; max-width: 380px; }

.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 26px; font-weight: 800; color: #f5f5f7; letter-spacing: -.04em; font-family: 'Plus Jakarta Sans', sans-serif; }
.login-header p  { color: #636366; font-size: 13px; margin-top: 8px; font-weight: 500; }

.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px 22px;
    box-shadow: 0 24px 64px rgba(0,0,0,.5);
}

/* ─── HISTORY ────────────────────────── */
.history-entry {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.history-entry:last-child { border-bottom: none; }

/* ─── UTILS ──────────────────────────── */
.mono { font-variant-numeric: tabular-nums; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-soft   { color: var(--text-soft); }
.text-green  { color: #15803d; }
.text-red    { color: #c0392b; }
.text-amber  { color: #b45309; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 800; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-mute); font-size: 13px; font-weight: 500; }

@media (min-width: 580px) {
    .main-content { padding: 22px; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .modal { border-radius: 16px; }
    .modal-overlay { align-items: center; padding: 20px; }
}
