/* ============================================================
   Nammamane - shared design system
   This is the ONE stylesheet for every page (customer + admin) so the
   whole site looks like index.php: same palette, same topbar/hero/Ruchi
   widget, same toast system, same buttons and cards.
   ============================================================ */

:root {
    --bg: #FFF8F0;
    --card-bg: #FFFFFF;
    --primary: #D44000;
    --primary-light: #FF6B35;
    --accent: #2D6A4F;
    --accent-rgb: 45, 106, 79;
    --text: #2C1810;
    --text-light: #6B5B4F;
    --border: #E8D5C4;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --ra-bg: #FFF5EC;
    --gold: #F4A261;
    --ra-image-bg: #FFFFFF;
    --toast-bg: #2D6A4F;
    --toast-text: #FFFFFF;
    --radius: 16px;
    --danger: #FF4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3 { color: var(--text); margin: 0 0 .3em; }
a { color: var(--primary); }
button { font-family: inherit; cursor: pointer; }

.container { max-width: 1200px; margin: 0 auto; padding: 30px 40px; }
@media (max-width: 768px) { .container { padding: 20px; } }

/* ---------- topbar ---------- */
.topbar {
    background: #FFFFFF;
    padding: 16px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 12px;
}
.brand-logo { display: flex; align-items: center; gap: 12px; }
.brand-logo img { height: 64px; width: 64px; object-fit: cover; border-radius: 50%; }
.brand-text { display: flex; flex-direction: column; }
.brand { font-size: 22px; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }
.kannada { font-size: 12px; color: var(--text-light); font-weight: 400; }

nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
nav a {
    text-decoration: none; color: var(--text); font-weight: 500;
    padding: 8px 18px; border-radius: 25px; transition: all .3s ease; font-size: 14px;
}
nav a:hover { background: var(--ra-bg); color: var(--primary); }
nav a.primary-link { background: var(--accent); color: white; }
nav a.primary-link:hover { background: #236A42; transform: translateY(-1px); }
nav button[data-install-app] {
    display: none; align-items: center; gap: 6px;
    text-decoration: none; font-weight: 500; font-family: inherit;
    padding: 8px 18px; border-radius: 25px; transition: all .3s ease; font-size: 14px;
    background: var(--ra-bg); border: 2px solid var(--primary); color: var(--primary); cursor: pointer;
}
nav button[data-install-app]:hover { background: var(--primary); color: #fff; }

@media (max-width: 768px) {
    .topbar { flex-direction: column; gap: 12px; padding: 15px; }
    nav { flex-wrap: wrap; justify-content: center; }
}

/* ---------- hero + Ruchi widget ---------- */
.hero {
    background: linear-gradient(135deg, #FFF5EC 0%, #FFE8D6 100%);
    padding: 40px 40px;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 40px;
    align-items: center;
    border-bottom: 3px solid var(--gold);
}
@media (max-width: 768px) { .hero { grid-template-columns: 1fr; padding: 30px 20px; text-align: center; } }

.hero h1 {
    font-size: 34px; font-weight: 800; line-height: 1.2; margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p { font-size: 16px; color: var(--text-light); margin-bottom: 18px; }

.ra-widget {
    background: var(--ra-bg); border-radius: 24px; padding: 22px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; align-items: center; gap: 14px; border: 2px solid var(--border);
}
.ra-frame {
    width: 150px; height: 150px; border-radius: 50%; background: var(--ra-image-bg);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    box-shadow: 0 8px 25px rgba(212, 64, 0, 0.2); border: 3px solid var(--gold);
    position: relative; animation: squirrelBounce 2s ease-in-out infinite;
}

@keyframes squirrelBounce { 
    0%,100% { transform: translateY(0); } 
    30% { transform: translateY(-3px); } 
    50% { transform: translateY(0); } 
    70% { transform: translateY(-2px); } 
}
.ra-frame.speaking { animation: squirrelTalk .6s ease-in-out infinite; }
.ra-frame.listening { animation: squirrelListen 1.5s ease-in-out infinite; border-color: var(--accent); }
@keyframes squirrelTalk { 
    0%,100% { transform: scale(1) rotate(0deg); } 
    25% { transform: scale(1.05) rotate(-2deg); } 
    75% { transform: scale(1.05) rotate(2deg); } 
}
@keyframes squirrelListen { 
    0%,100% { transform: scale(1); border-color: var(--gold); } 
    50% { transform: scale(1.03); border-color: var(--accent); } 
}
.ra-frame img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; background: var(--ra-image-bg); }

.ra-controls { display: flex; gap: 10px; }
.ra-btn { 
    padding: 10px 20px; border: none; border-radius: 25px; font-weight: 600; 
    cursor: pointer; transition: all .3s ease; font-size: 14px; 
    display: flex; align-items: center; gap: 6px; 
}
.ra-btn.hear { background: var(--accent); color: white; }
.ra-btn.hear:hover { background: #236A42; transform: translateY(-2px); }
.ra-btn.hear.active { background: var(--danger); animation: recordingPulse 1.5s ease-in-out infinite; }
@keyframes recordingPulse { 
    0%,100% { box-shadow: 0 0 0 0 rgba(255,68,68,.4); } 
    50% { box-shadow: 0 0 0 12px rgba(255,68,68,0); } 
}
.ra-btn.stop { background: var(--border); color: var(--text); }
.ra-btn.stop:hover { background: #D4C4B0; }
.ra-btn.thalis { background: var(--primary); color: white; width: 100%; justify-content: center; }
.ra-btn.thalis:hover { background: var(--primary-light); transform: translateY(-2px); }

.ra-status { 
    text-align: center; font-size: 13px; color: var(--text-light); font-style: italic; 
    min-height: 30px; display: flex; align-items: center; justify-content: center; 
}
.ra-status.talking { color: var(--accent); font-style: normal; font-weight: 600; }
.ra-status.listening { color: var(--primary); font-style: normal; font-weight: 600; }

.wallet-pill { 
    display: inline-block; background: white; padding: 10px 22px; border-radius: 25px; 
    font-weight: 600; font-size: 15px; box-shadow: var(--shadow); 
    border: 2px solid var(--accent); color: var(--accent); 
}
.wallet-pill.negative { border-color: var(--danger); color: var(--danger); }

/* ---------- Ruchi chat log ---------- */
.ra-chat { 
    background: white; border-radius: var(--radius); padding: 18px; 
    margin: 20px 0; box-shadow: var(--shadow); border: 1px solid var(--border); 
}
.ra-log { 
    height: 190px; overflow-y: auto; padding: 14px; background: #FAFAFA; 
    border-radius: 12px; margin-bottom: 14px; border: 1px solid var(--border); 
    display: flex; flex-direction: column; gap: 4px; 
}
.ra-log .message, .ra-log .ra-msg { 
    padding: 9px 14px; margin-bottom: 8px; border-radius: 12px; 
    max-width: 80%; font-size: .92rem; line-height: 1.4; animation: slideIn .3s ease; 
}
@keyframes slideIn { 
    from { opacity: 0; transform: translateY(8px); } 
    to { opacity: 1; transform: translateY(0); } 
}
.ra-log .message.user, .ra-log .ra-msg.user { background: var(--primary); color: white; margin-left: auto; }
.ra-log .message.agent, .ra-log .ra-msg.anna { 
    background: var(--ra-bg); color: var(--text); border: 1px solid var(--border); 
}
.ra-input-row { display: flex; gap: 8px; }
.ra-input-row input { 
    flex: 1; padding: 11px 18px; border: 2px solid var(--border); 
    border-radius: 25px; font-size: 14px; outline: none; font-family: inherit; 
}
.ra-input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(212,64,0,.1); }
.ra-input-row button { 
    padding: 11px 26px; background: var(--primary); color: white; 
    border: none; border-radius: 25px; font-weight: 600; font-size: 14px; 
}
.ra-input-row button:hover { background: var(--primary-light); }

/* ---------- buttons ---------- */
.btn {
    display: inline-block; width: 100%; padding: 13px; background: var(--primary); color: white;
    border: none; border-radius: 12px; font-weight: 600; font-size: 15px; cursor: pointer;
    transition: all .3s ease; text-align: center; text-decoration: none; box-shadow: var(--shadow);
}
.btn:hover { background: var(--primary-light); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(212,64,0,.3); }
.btn.secondary { background: transparent; color: var(--primary); border: 2px solid var(--primary); box-shadow: none; }
.btn.secondary:hover { background: var(--ra-bg); transform: none; }
.btn.accent { background: var(--accent); width: auto; padding: 14px 32px; font-size: 16px; display: inline-block; }
.btn.accent:hover { background: #236A42; }
.btn.danger { background: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn.small { width: auto; padding: 6px 14px; font-size: .78rem; border-radius: 8px; box-shadow: none; margin-right: 6px; margin-bottom: 4px; }

/* ---------- meal / section tabs ---------- */
.meal-tabs { 
    display: flex; gap: 10px; margin: 24px 0 24px; background: white; 
    padding: 8px; border-radius: 30px; box-shadow: var(--shadow); 
    width: fit-content; flex-wrap: wrap; 
}
.meal-tabs button { 
    padding: 11px 24px; border: none; background: transparent; color: var(--text-light); 
    font-weight: 600; cursor: pointer; border-radius: 25px; transition: all .3s ease; font-size: 14px; 
}
.meal-tabs button.active { 
    background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(212,64,0,.3); 
}

/* ---------- standard menu / snack grid ---------- */
.menu-grid { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(270px,1fr)); 
    gap: 22px; margin-top: 10px; 
}
.menu-card { 
    background: var(--card-bg); border-radius: var(--radius); overflow: hidden; 
    box-shadow: var(--shadow); transition: all .3s ease; border: 1px solid var(--border); 
    display: flex; flex-direction: column; 
}
.menu-card:hover { transform: translateY(-4px); box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.menu-card img { width: 100%; height: 180px; object-fit: cover; background: var(--border); }
.menu-card .body { padding: 18px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.menu-card h3 { font-size: 18px; font-weight: 700; }
.menu-card .includes { color: var(--text-light); font-size: 13px; margin-bottom: 10px; flex: 1; }
.menu-card .price { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }

/* ---------- toast ---------- */
.toast-container { 
    position: fixed; top: 20px; right: 20px; z-index: 10000; 
    display: flex; flex-direction: column; gap: 10px; 
}
.toast { 
    background: var(--toast-bg); color: var(--toast-text); padding: 15px 22px; 
    border-radius: 12px; box-shadow: 0 8px 25px rgba(0,0,0,.2); 
    display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 420px; 
    animation: toastSlideIn .5s ease, toastSlideOut .5s ease 3.5s forwards; 
    font-weight: 500; 
}
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }
.toast.info { background: #FF8C00; }
.toast-icon { font-size: 22px; flex-shrink: 0; }
.toast-message { flex: 1; font-size: 14px; line-height: 1.4; }
.toast-close { 
    background: none; border: none; color: white; cursor: pointer; 
    font-size: 17px; opacity: .7; padding: 4px; flex-shrink: 0; 
}
.toast-close:hover { opacity: 1; }
@keyframes toastSlideIn { 
    from { transform: translateX(100%); opacity: 0; } 
    to { transform: translateX(0); opacity: 1; } 
}
@keyframes toastSlideOut { 
    from { transform: translateX(0); opacity: 1; } 
    to { transform: translateX(100%); opacity: 0; } 
}
@media (max-width: 768px) { 
    .toast { min-width: 220px; max-width: 320px; } 
}

/* ---------- thali builder ---------- */
.builder-wrap { 
    display: grid; grid-template-columns: 1fr 300px; 
    gap: 24px; padding: 10px 0 24px; 
}
@media (max-width: 820px) { 
    .builder-wrap { grid-template-columns: 1fr; } 
}

/* Horizontal scrolling palette */
.item-palette-scroll {
    position: relative;
    overflow: hidden;
    margin: 0 -4px;
    padding: 0 20px;
}

.item-palette {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 8px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.item-palette::-webkit-scrollbar {
    display: none;
}

/* Palette Item Cards */
.palette-item {
    flex: 0 0 calc((100% - 3 * 12px) / 4);
    min-width: calc((100% - 3 * 12px) / 4);
    max-width: calc((100% - 3 * 12px) / 4);
    background: white;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    text-align: center;
}

.palette-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.palette-item:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.palette-item.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

.palette-item img {
    width: 100%;
    max-width: 100%;
    height: 120px;
    min-height: 120px;
    max-height: 120px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--border);
    display: block;
}

.palette-item .item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.palette-item .name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--text);
}

.palette-item .price {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 700;
}

.palette-item .drag-hint {
    font-size: 0.7rem;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* Scroll Arrow Buttons */
.palette-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
    color: var(--text);
}

.palette-scroll-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-50%) scale(1.1);
}

.palette-scroll-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.palette-scroll-btn.left {
    left: 0;
}

.palette-scroll-btn.right {
    right: 0;
}

/* Tray and compartments */
.tray-container { 
    position: relative; width: 100%; max-width: 620px; height: 340px; margin: 0 auto; 
}
.tray { 
    position: absolute; inset: 0; 
    background: linear-gradient(#fff, var(--ra-bg)); 
    border-radius: 22px; 
    box-shadow: inset 0 6px 10px rgba(255,255,255,.6), inset 0 -10px 16px rgba(0,0,0,.08), var(--shadow); 
    display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; 
    gap: 12px; padding: 18px; border: 2px solid var(--gold); 
}
.compartment { 
    background: radial-gradient(circle at 40% 30%, #fff, #FFF0DE 85%); 
    border-radius: 16px; border: 2px solid var(--border); 
    display: flex; flex-wrap: wrap; align-content: center; justify-content: center; 
    gap: 4px; position: relative; min-height: 0; padding: 6px; 
    transition: box-shadow .15s; 
}
.compartment.dragover { 
    border-color: var(--accent) !important; 
    background: rgba(var(--accent-rgb), 0.05) !important; 
    box-shadow: inset 0 0 0 3px var(--primary); 
}
.compartment .empty-hint { 
    font-size: .7rem; color: #9b9484; position: absolute; pointer-events: none; 
}
.compartment.middle { grid-column: 2; grid-row: 1 / span 2; }
.tray-chip { 
    background: #fff; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.15); 
    padding: 4px 8px; display: flex; align-items: center; gap: 6px; 
    font-size: .72rem; font-weight: 700; 
}
.tray-chip img { width: 22px; height: 22px; object-fit: cover; border-radius: 5px; }
.tray-chip .qty-btn { 
    background: var(--accent); color: #fff; border: none; width: 16px; height: 16px; 
    border-radius: 50%; font-size: .65rem; line-height: 1; padding: 0; 
}
.tray-chip .remove { color: var(--primary); font-weight: 800; cursor: pointer; margin-left: 2px; }

/* Clone for touch drag */
.palette-item.clone {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.9;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    transform: rotate(-5deg);
    width: 150px;
}

/* For mobile drag clone */
@media (max-width: 768px) {
    .palette-item.clone {
        width: 100%;
        height: auto;
    }
    .palette-item.clone .item-info {
        display: none;
    }
    .palette-item.clone img {
        height: 200px;
        width: 100%;
        margin-bottom: 0;
    }
}

.order-summary { 
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); 
    padding: 18px; height: fit-content; border: 1px solid var(--border); 
}
.order-summary h3 { font-size: 1.05rem; }
.order-summary ul { list-style: none; padding: 0; margin: 0 0 12px; font-size: .88rem; }
.order-summary li { 
    padding: 5px 0; border-bottom: 1px dashed var(--border); 
    display: flex; justify-content: space-between; 
}
.order-summary .total-row { 
    display: flex; justify-content: space-between; font-size: 1.15rem; 
    font-weight: 700; margin: 10px 0; color: var(--primary); 
}
.discount-banner { 
    background: #FFF6E0; border: 1.5px dashed var(--gold); border-radius: 10px; 
    padding: 8px 10px; font-size: .82rem; margin: 10px 0; color: #7a5a00; 
}

/* ---------- snack cart ---------- */
.snack-grid { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); 
    gap: 20px; margin-top: 10px; 
}
.snack-card { 
    background: var(--card-bg); border-radius: var(--radius); overflow: hidden; 
    box-shadow: var(--shadow); border: 1px solid var(--border); 
    display: flex; flex-direction: column; 
}
.snack-card img { width: 100%; height: 140px; object-fit: cover; background: var(--border); }
.snack-card .body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.snack-card h4 { font-size: 15px; }
.snack-card .desc { font-size: 12px; color: var(--text-light); flex: 1; }
.snack-card .price { font-size: 18px; font-weight: 700; color: var(--primary); }
.snack-card .qty-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.snack-card .qty-row button { 
    width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--primary); 
    background: white; color: var(--primary); font-weight: 700; font-size: 16px; line-height: 1; 
}
.snack-card .qty-row .qty-val { font-weight: 700; min-width: 20px; text-align: center; }
.snack-card .add-btn { margin-top: 10px; }

.cart-panel { 
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); 
    padding: 18px; height: fit-content; border: 1px solid var(--border); 
    position: sticky; top: 90px; 
}
.cart-panel h3 { font-size: 1.1rem; }
.cart-list { list-style: none; padding: 0; margin: 10px 0; max-height: 320px; overflow-y: auto; }
.cart-list li { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; gap: 8px; 
}
.cart-list .cart-item-name { flex: 1; }
.cart-list .cart-remove { color: var(--danger); font-weight: 800; cursor: pointer; padding: 0 4px; }
.cart-empty { color: var(--text-light); font-size: .85rem; text-align: center; padding: 20px 0; }
.snack-orders-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.snack-order-card { 
    background: #fff; border-radius: 12px; box-shadow: var(--shadow); 
    padding: 12px 16px; border: 1px solid var(--border); font-size: .86rem; 
}

/* ---------- calendar ---------- */
.calendar-grid { 
    display: grid; grid-template-columns: repeat(7,1fr); gap: 8px; margin-top: 16px; 
}
.cal-day { 
    background: #fff; border-radius: 12px; padding: 10px 6px; text-align: center; 
    box-shadow: 0 2px 8px rgba(0,0,0,.08); font-size: .8rem; position: relative; 
    min-height: 78px; display: flex; flex-direction: column; justify-content: space-between; 
    border: 1px solid var(--border); 
}
.cal-day .dnum { font-weight: 700; font-size: 1rem; }
.cal-day.sunday { opacity: .4; }
.cal-day .tag { font-size: .62rem; font-weight: 700; padding: 2px 6px; border-radius: 8px; background: var(--bg); }
.cal-day .tag.paid { background: #d8ecd7; color: #245a24; }
.cal-day .tag.due { background: #fbe3e3; color: var(--primary); }
.cal-day button { border: none; background: none; font-size: .65rem; font-weight: 700; color: var(--primary); padding: 0; }

/* ---------- forms ---------- */
.form-card { 
    max-width: 420px; margin: 40px auto; background: #fff; border-radius: var(--radius); 
    box-shadow: var(--shadow); padding: 28px; border: 1px solid var(--border); 
}
.form-card input { 
    width: 100%; padding: 11px 13px; border: 2px solid var(--border); 
    border-radius: 10px; margin-bottom: 12px; font-size: .95rem; font-family: inherit; 
}
.form-card select { 
    width: 100%; padding: 11px 13px; border: 2px solid var(--border); 
    border-radius: 10px; margin-bottom: 12px; font-size: .95rem; font-family: inherit; background: #fff; 
}
.form-card .btn { width: 100%; text-align: center; }
.form-error { color: var(--primary); font-size: .85rem; margin: -6px 0 12px; }
.form-switch { font-size: .85rem; text-align: center; margin-top: 10px; }

/* ---------- admin ---------- */
.admin-table { 
    width: 100%; border-collapse: collapse; background: #fff; 
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); 
}
.admin-table th, .admin-table td { 
    padding: 10px 12px; text-align: left; font-size: .86rem; border-bottom: 1px solid var(--border); 
}
.admin-table th { background: var(--accent); color: #fff; }
.badge { padding: 3px 9px; border-radius: 10px; font-size: .72rem; font-weight: 700; }
.badge.due { background: #fbe3e3; color: var(--primary); }
.badge.paid { background: #d8ecd7; color: #245a24; }

.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 26px 0 18px; }
.tab-btn { 
    background: #fff; border: 2px solid var(--border); border-radius: 10px; 
    padding: 9px 16px; font-weight: 700; font-size: .85rem; color: var(--text-light); 
}
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-panel { margin-bottom: 40px; }

.panel-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.panel-row label { 
    font-size: .82rem; font-weight: 700; color: var(--text-light); 
    display: flex; flex-direction: column; gap: 4px; 
}
.panel-row input, .panel-row select { 
    padding: 8px 10px; border-radius: 8px; border: 2px solid var(--border); font-family: inherit; 
}

.inline-form { 
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center; 
    background: #fff; padding: 14px; border-radius: var(--radius); 
    box-shadow: var(--shadow); margin: 14px 0 20px; 
}
.inline-form input, .inline-form select { 
    padding: 9px 11px; border-radius: 8px; border: 2px solid var(--border); 
    font-family: inherit; font-size: .85rem; 
}

/* ---------- modals ---------- */
.modal-backdrop { 
    position: fixed; inset: 0; background: rgba(44,24,16,.55); z-index: 1000; 
    display: flex; align-items: center; justify-content: center; padding: 20px; 
}
.modal-card { 
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); 
    padding: 24px; max-width: 480px; width: 100%; max-height: 88vh; overflow: auto; 
}
.modal-card label { 
    display: block; font-size: .82rem; font-weight: 700; 
    color: var(--text-light); margin: 10px 0 4px; 
}
.modal-card input, .modal-card select { 
    width: 100%; padding: 10px 12px; border-radius: 8px; 
    border: 2px solid var(--border); font-family: inherit; 
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- report grid ---------- */
.report-grid { 
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); 
    gap: 14px; margin: 16px 0 24px; 
}
.report-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
.report-card .label { font-size: .78rem; color: var(--text-light); font-weight: 700; }
.report-card .value { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.report-card.positive .value { color: #245a24; }
.report-card.negative .value { color: var(--primary); }
.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .report-cols { grid-template-columns: 1fr; } }

/* ---------- responsive: tablet ---------- */
@media (max-width: 900px) {
    .admin-table { 
        display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; 
    }
    .admin-table thead, .admin-table tbody, .admin-table tr { display: table; width: 100%; }
    .report-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- responsive: tablet palette (exactly 3 per row) ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
    .palette-item {
        flex: 0 0 calc((100% - 2 * 12px) / 3);
        min-width: calc((100% - 2 * 12px) / 3);
        max-width: calc((100% - 2 * 12px) / 3);
    }
    .palette-item img {
        height: 100px;
        min-height: 100px;
        max-height: 100px;
    }
}

/* ---------- responsive: phones (horizontal swipe, one item per view) ---------- */
@media (max-width: 768px) {
    .item-palette-scroll {
        padding: 0;
        overflow: hidden;
        margin: 0;
    }

    .item-palette {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 8px 0;
    }

    .item-palette::-webkit-scrollbar {
        display: none;
    }

    .palette-item {
        flex: 0 0 100%;
        min-width: 100%;
        max-width: 100%;
        scroll-snap-align: start;
        margin: 0;
        padding: 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        text-align: center;
        box-sizing: border-box;
    }

    .palette-item img {
        width: 100%;
        max-width: 100%;
        height: 200px;
        min-height: 200px;
        max-height: 200px;
        object-fit: cover;
        object-position: center;
        border-radius: 8px;
        margin-bottom: 0;
        display: block;
    }

    .palette-item .item-info {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }

    .palette-item .name {
        font-size: 1rem;
        margin-bottom: 2px;
    }

    .palette-item .price {
        font-size: 0.9rem;
    }

    .palette-item .drag-hint {
        display: none;
    }

    /* Hide scroll buttons (swipe is natural) */
    .palette-scroll-btn {
        display: none !important;
    }
}

/* Very small phones: adjust image height */
@media (max-width: 480px) {
    .palette-item img {
        height: 150px;
        min-height: 150px;
        max-height: 150px;
    }
}

/* ---------- touch-friendly tap targets ---------- */
@media (pointer: coarse) {
    .ra-btn, .btn, nav a, .tab-btn, .qty-btn, .cart-remove, .snack-card .qty-row button {
        min-height: 38px;
    }
    .palette-item { touch-action: pan-x; } /* allow horizontal swipe */
}