:root {
    --brand: #6b4226;
    --brand-light: #a9714d;
    --bg: #f6f1ea;
    --card: #ffffff;
    --border: #e3d9cc;
    --text: #33261c;
    --muted: #8a7a68;
    --success: #3c8c5c;
    --danger: #c0392b;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--brand); text-decoration: none; }

/* ---------------- Topbar ---------------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    background: var(--brand);
    color: #fff;
    padding: 10px 20px;
    flex-wrap: wrap;
}
.topbar-brand { font-weight: 700; font-size: 1.1rem; }
.topbar-nav { display: flex; gap: 14px; flex: 1; }
.topbar-nav a { color: #f2e6d8; padding: 6px 10px; border-radius: 6px; }
.topbar-nav a.active, .topbar-nav a:hover { background: rgba(255,255,255,.18); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.topbar-user em { opacity: .8; font-style: normal; }
.btn-link { color: #fff; text-decoration: underline; }

.page { padding: 18px; max-width: 1400px; margin: 0 auto; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px; }

/* ---------------- Generic components ---------------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
h1, h2, h3 { color: var(--brand); margin-top: 0; }

.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: .95rem;
    cursor: pointer;
}
.btn:hover { background: var(--brand-light); }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: .92rem; }
table th { color: var(--muted); font-weight: 600; }

input, select, textarea {
    font-size: .95rem;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
}
label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
.alert.error { background: #fbe4e1; color: var(--danger); }
.alert.success { background: #e3f2e8; color: var(--success); }

/* ---------------- Login ---------------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; }
.login-box h1 { text-align: center; }

/* ---------------- POS layout ---------------- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: flex-start; }
.categories { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.categories button {
    background: #fff; border: 1px solid var(--border); padding: 8px 14px;
    border-radius: 20px; cursor: pointer; font-size: .85rem;
}
.categories button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.product-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px; cursor: pointer; text-align: left;
}
.product-card:hover { border-color: var(--brand-light); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.product-card .pname { font-weight: 600; font-size: .88rem; min-height: 40px; }
.product-card .pprice { color: var(--brand); font-weight: 700; margin-top: 6px; }

/* Cart panel */
.cart-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: sticky; top: 12px; }
.cart-lines { max-height: 300px; overflow-y: auto; margin: 10px 0; }
.cart-line { border-bottom: 1px solid var(--border); padding: 8px 0; font-size: .87rem; }
.cart-line .lname { font-weight: 600; }
.cart-line .lmeta { color: var(--muted); font-size: .78rem; }
.cart-line .lrow { display: flex; justify-content: space-between; align-items: center; }
.cart-line .remove { color: var(--danger); cursor: pointer; font-size: .78rem; }
.totals-row { display: flex; justify-content: space-between; font-size: .9rem; margin: 4px 0; }
.totals-row.grand { font-size: 1.15rem; font-weight: 700; color: var(--brand); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }

/* Modal */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); align-items: center; justify-content: center; z-index: 50; }
.modal-backdrop.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 20px; width: 420px; max-height: 85vh; overflow-y: auto; }
.modal-box h3 { margin-bottom: 4px; }
.option-group { margin-bottom: 14px; }
.option-group .opt { display: inline-flex; align-items: center; gap: 6px; margin: 4px 8px 4px 0; }
.qty-stepper { display: flex; align-items: center; gap: 10px; }
.qty-stepper button { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* Receipt */
.receipt { max-width: 380px; margin: 0 auto; font-family: 'Courier New', monospace; font-size: .85rem; }
.receipt h2 { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #999; }
.receipt table td { border: none; padding: 2px 0; }

/* Production slip */
.production-slip .station-heading { margin: 10px 0 6px; text-align: center; letter-spacing: 1px; }
.production-slip .category-label {
    font-weight: 700; text-transform: uppercase; font-size: .78rem;
    color: var(--muted); border-bottom: 1px dashed #ccc; margin: 8px 0 2px; padding-bottom: 2px;
}
.production-slip .qty-col { width: 34px; vertical-align: top; font-weight: 700; }
.production-slip .sub-item { padding-left: 10px; color: var(--muted); font-size: .82rem; }

@media print {
    .no-print { display: none !important; }
    .topbar, .footer { display: none !important; }
}

@media (max-width: 900px) {
    .pos-layout { grid-template-columns: 1fr; }
    .cart-panel { position: static; }
}
