:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --bg-body: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem; /* Default mobile padding */
}

@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }
}

/* Header & Typography */
h1 { font-size: clamp(1.25rem, 5vw, 1.875rem); font-weight: 800; color: var(--primary); letter-spacing: -0.025em; }
h2 { font-size: 1.25rem; font-weight: 700; color: var(--primary); }

.muted { color: var(--text-muted); font-size: 0.875rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2); }

.btn-outline { background: white; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-body); border-color: var(--text-muted); }

.btn-danger { background: #fff1f2; color: var(--danger); border-color: #fecdd3; }
.btn-danger:hover { background: var(--danger); color: white; }

/* Cards */
.card {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .card { padding: 2rem; }
}

/* Form Elements */
.input-group { margin-bottom: 1.25rem; }
.input-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.875rem; color: var(--primary); }

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 1rem; /* Prevents auto-zoom on iOS */
    transition: var(--transition);
    background: #ffffff;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem; /* Pull back on mobile */
}

@media (min-width: 768px) {
    .table-responsive { margin: 0; }
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px; /* Force scroll on small mobile */
}

th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.status-in-stock { background: #dcfce7; color: #166534; }
.status-low-stock { background: #fef9c3; color: #854d0e; }
.status-out-of-stock { background: #fee2e2; color: #991b1b; }

/* Scanner UI */
#reader {
    width: 100% !important;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border) !important;
}

/* Modal UI */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

@media (min-width: 768px) {
    .modal { padding: 2.5rem; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.payment-summary {
    background: var(--bg-body);
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.summary-row.total {
    border-top: 2px dashed var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--accent);
}

.change-display {
    text-align: center;
    padding: 1.5rem;
    background: #f0fdf4;
    border-radius: 12px;
    border: 2px solid #dcfce7;
}

.change-amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: #166534;
}

/* Helper Classes */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) {
    .grid-2 { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
}

.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

code {
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 0.875rem;
    color: var(--accent);
}
