*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.15);
}

html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

.hidden { display: none !important; }

/* Navbar */
.navbar { background: var(--primary); color: #fff; padding: 0 1rem; display: flex; align-items: center; position: sticky; top: 0; z-index: 100; height: 56px; box-shadow: var(--shadow-lg); }
.nav-brand { display: flex; align-items: center; gap: .5rem; }
.brand-text { font-weight: 700; font-size: 1.1rem; }
.nav-menu { display: flex; gap: .25rem; margin-left: 1.5rem; align-items: center; flex-wrap: nowrap; overflow-x: auto; }
.nav-link { color: rgba(255,255,255,.85); text-decoration: none; padding: .5rem .75rem; border-radius: var(--radius); font-size: .85rem; white-space: nowrap; transition: background .2s; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.2); color: #fff; }
.nav-logout { color: #fca5a5; }
.btn-icon { background: none; border: none; color: inherit; font-size: 1.3rem; cursor: pointer; padding: .25rem; }

/* Content */
.content { max-width: 1200px; margin: 0 auto; padding: 1rem; }

/* Cards */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .75rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; gap: .5rem; }
.card-title { font-size: 1.1rem; font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border: none; border-radius: var(--radius); font-size: .85rem; font-weight: 500; cursor: pointer; transition: all .2s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-fab { position: fixed; bottom: 1.5rem; right: 1.5rem; width: 56px; height: 56px; border-radius: 50%; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); z-index: 50; }

/* Forms */
.form-group { margin-bottom: .75rem; }
.form-label { display: block; font-size: .8rem; font-weight: 500; color: var(--text-muted); margin-bottom: .25rem; }
.form-control { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; background: #fff; color: var(--text); transition: border-color .2s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
select.form-control { appearance: auto; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-inline { display: flex; gap: .5rem; align-items: end; }

/* Badges */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 12px; font-size: .75rem; font-weight: 600; color: #fff; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; }
tr:hover { background: #f8fafc; }

/* Page Header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem; }
.page-title { font-size: 1.3rem; font-weight: 700; }

/* Search */
.search-bar { position: relative; margin-bottom: 1rem; }
.search-bar input { width: 100%; padding: .6rem 1rem .6rem 2.5rem; }
.search-bar::before { content: '🔍'; position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); font-size: .9rem; }

/* Batch Card */
.batch-card { cursor: pointer; transition: box-shadow .2s; border-left: 4px solid var(--primary); }
.batch-card:hover { box-shadow: var(--shadow-lg); }
.batch-card .batch-meta { display: flex; gap: 1rem; font-size: .8rem; color: var(--text-muted); flex-wrap: wrap; }
.batch-card .batch-type { display: inline-block; padding: .1rem .4rem; border-radius: 4px; font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.batch-card .batch-type.china { background: #fef3c7; color: #92400e; }
.batch-card .batch-type.paraguay { background: #dbeafe; color: #1e40af; }
.batch-products { margin-top: .5rem; }
.batch-product-item { padding: .3rem 0; font-size: .85rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; border-bottom: 1px dashed var(--border); }
.batch-product-item:last-child { border-bottom: none; }

/* Product Detail */
.detail-grid { display: grid; gap: .75rem; }
.detail-field { }
.detail-label { font-size: .75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: .15rem; }
.detail-value { font-size: .9rem; cursor: pointer; padding: .3rem .5rem; border-radius: 4px; min-height: 1.5rem; border: 1px solid transparent; transition: border-color .2s; }
.detail-value:hover { border-color: var(--border); background: #f8fafc; }
.detail-value.editing { border-color: var(--primary); background: #fff; }

/* Documents */
.doc-list { list-style: none; }
.doc-item { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.doc-item:last-child { border-bottom: none; }
.doc-name { flex: 1; min-width: 0; }
.doc-name input { width: 100%; border: 1px solid var(--border); border-radius: 4px; padding: .25rem .5rem; font-size: .85rem; }
.doc-actions { display: flex; gap: .25rem; }

/* Tracking */
.tracking-card { border-left: 4px solid var(--info); }

/* Toast */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 1000; display: flex; flex-direction: column; gap: .5rem; }
.toast { padding: .75rem 1rem; border-radius: var(--radius); color: #fff; font-size: .85rem; box-shadow: var(--shadow-lg); animation: slideIn .3s; min-width: 250px; max-width: 400px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--card-bg); border-radius: var(--radius); width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.1rem; }
.modal-body { padding: 1rem; }
.modal-footer { padding: .75rem 1rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

/* Autocomplete */
.autocomplete-wrapper { position: relative; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); max-height: 200px; overflow-y: auto; z-index: 50; box-shadow: var(--shadow-lg); }
.autocomplete-item { padding: .5rem .75rem; cursor: pointer; font-size: .85rem; }
.autocomplete-item:hover, .autocomplete-item.selected { background: var(--primary); color: #fff; }

/* Login */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { text-align: center; margin-bottom: 1.5rem; color: var(--primary); }

/* Product row in batch form */
.product-row { background: #f8fafc; border-radius: var(--radius); padding: .75rem; margin-bottom: .5rem; position: relative; border: 1px solid var(--border); }
.product-row .remove-product { position: absolute; top: .5rem; right: .5rem; }

/* Upload area */
.upload-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.5rem; text-align: center; cursor: pointer; transition: border-color .2s; color: var(--text-muted); }
.upload-area:hover { border-color: var(--primary); color: var(--primary); }
.upload-area input { display: none; }

/* Tags */
.tag { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .5rem; background: #e2e8f0; border-radius: 12px; font-size: .75rem; margin: .1rem; }
.tag a { color: var(--primary); text-decoration: none; }

/* Filters bar */
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { padding: .4rem .6rem; font-size: .8rem; border: 1px solid var(--border); border-radius: var(--radius); }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tab { padding: .5rem 1rem; cursor: pointer; font-size: .85rem; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: all .2s; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state p { font-size: 1.1rem; margin-bottom: 1rem; }

/* Section */
.section { margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; padding-bottom: .35rem; border-bottom: 2px solid var(--primary); display: inline-block; }

/* Responsive: Mobile (default) */
@media (max-width: 767px) {
    .nav-menu { position: fixed; top: 56px; left: 0; right: 0; background: var(--primary-dark); flex-direction: column; padding: .5rem; gap: 0; margin: 0; display: none; box-shadow: var(--shadow-lg); }
    .nav-menu.open { display: flex; }
    .nav-link { padding: .75rem 1rem; border-radius: 0; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .detail-grid { grid-template-columns: 1fr; }
    .modal { margin: .5rem; max-height: 95vh; }
    .btn-fab { bottom: 1rem; right: 1rem; }
}

/* Tablet */
@media (min-width: 768px) {
    #menu-toggle { display: none; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
}

/* Desktop */
@media (min-width: 1024px) {
    .detail-grid { grid-template-columns: 1fr 1fr 1fr; }
    .content { padding: 1.5rem 2rem; }
}
