:root {
  --sidebar-width: 220px;
  --sidebar-bg: #1a2332;
  --sidebar-hover: #253347;
  --sidebar-active: #2d6bcf;
  --sidebar-text: #a8b8cc;
  --sidebar-text-active: #fff;
  --primary: #2d6bcf;
  --primary-hover: #2459b0;
  --primary-light: #e8f0fe;
  --success: #28a745;
  --success-light: #d4edda;
  --danger: #dc3545;
  --danger-light: #f8d7da;
  --warning: #f0c246;
  --warning-bg: #fff8e1;
  --warning-border: #ffe082;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #333;
  --text-muted: #777;
  --border: #e0e0e0;
  --green-bg: #00e676;
  --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
}
.sidebar-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: all .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: #5ba3ff;
}
.sidebar-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
}
.sidebar-nav .nav-divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 8px 18px;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
}
.sidebar-footer .user-name { color: #fff; font-weight: 600; }
.sidebar-footer .user-role { color: var(--sidebar-text); font-size: 11px; }
.sidebar-footer .btn-logout {
  display: block;
  margin-top: 8px;
  background: rgba(255,255,255,.1);
  border: none;
  color: var(--sidebar-text);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  width: 100%;
  text-align: center;
  transition: background .15s;
}
.sidebar-footer .btn-logout:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ===== MAIN CONTENT ===== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: 24px 30px 0;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.main-content {
  padding: 20px 30px 30px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ===== INFO BANNER ===== */
.info-banner {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.info-banner.warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: #8a6d00;
}
.info-banner.info {
  background: var(--primary-light);
  border: 1px solid #bbdefb;
  color: #1565c0;
}

/* ===== LOGIN PAGE ===== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--sidebar-bg);
  margin-left: 0;
}
.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
  width: 400px;
  max-width: 95vw;
}
.login-card h2 { text-align: center; margin-bottom: 6px; color: var(--sidebar-bg); font-size: 20px; }
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-group select,
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  font-family: var(--font);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,207,.12);
}

.form-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ===== BARCODE GENERATOR LAYOUT ===== */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Selection Mode */
.selection-mode {
  display: flex;
  gap: 20px;
  padding: 10px 0;
}
.selection-mode label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0;
}

/* Hierarchy form grid */
.hierarchy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.hierarchy-grid .form-group.full-width { grid-column: 1 / -1; }

/* Brand search row */
.brand-row { display: flex; gap: 8px; }
.brand-row select { flex: 1; }
.brand-row .btn { flex-shrink: 0; margin-top: 0; }

/* Barcode display */
.barcode-output { text-align: center; }
.barcode-display {
  background: var(--green-bg);
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 20px;
  font-weight: 700;
  color: #000;
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 12px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.price-display {
  background: var(--green-bg);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  display: inline-block;
}

.barcode-image-area {
  margin-top: 16px;
  text-align: center;
  min-height: 80px;
}
.barcode-image-area svg, .barcode-image-area canvas { max-width: 100%; }

.action-buttons { display: flex; gap: 10px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0;
  font-size: 13px;
  justify-content: center;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 8px 18px;
  border: none;
  background: #e8e8e8;
  cursor: pointer;
  font-size: 13px;
  border-radius: 6px;
  font-family: var(--font);
  font-weight: 500;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: #d8d8d8; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c82333; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #218838; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f5f5f5; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 10px 28px; font-size: 15px; }

/* ===== TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.data-table th:first-child { border-radius: 6px 0 0 0; }
.data-table th:last-child { border-radius: 0 6px 0 0; }
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.data-table tr:hover { background: #f8fafd; }
.data-table .actions { white-space: nowrap; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  font-size: 13px;
}
.pagination button {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
}
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== MODALS ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 28px;
  width: 460px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
}
.modal h3 { margin-bottom: 18px; color: var(--sidebar-bg); font-size: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ===== FILTERS BAR ===== */
.filters-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters-bar .form-group { margin-bottom: 0; flex: none; }
.filters-bar .form-group label { font-size: 12px; }
.filters-bar input, .filters-bar select { width: 160px; }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  padding: 10px 22px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: -2px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== ALERTS ===== */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}
.alert-error { background: var(--danger-light); color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: var(--success-light); color: #155724; border: 1px solid #c3e6cb; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-admin { background: #e8eaf6; color: #283593; }
.badge-user { background: #e8f5e9; color: #2e7d32; }
.badge-viewer { background: #fff3e0; color: #e65100; }
.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #ffebee; color: #c62828; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed var(--border);
  padding: 30px;
  text-align: center;
  border-radius: 8px;
  margin-bottom: 16px;
  transition: all .15s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone p { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }

/* ===== PRINT STYLES (2" x 1" barcode label) ===== */
@media print {
  @page {
    size: 2in 1in;
    margin: 0;
  }
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 2in;
    height: 1in;
    overflow: hidden;
  }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area {
    position: fixed;
    left: 0;
    top: 0;
    width: 2in;
    height: 1in;
    padding: 2px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .print-area .label-brand {
    font-size: 6pt;
    font-weight: 700;
    text-align: center;
    line-height: 1;
    margin-bottom: 1px;
    max-width: 1.9in;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .print-area .label-barcode-img {
    text-align: center;
    line-height: 0;
  }
  .print-area .label-barcode-img svg {
    width: 1.7in !important;
    height: 0.5in !important;
  }
  .print-area .label-price {
    font-size: 8pt;
    font-weight: 700;
    text-align: center;
    line-height: 1;
    margin-top: 1px;
  }
  .print-area .label-barcode-text { display: none; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-header h1, .sidebar-badge, .sidebar-nav a span, .sidebar-footer .user-name, .sidebar-footer .user-role { display: none; }
  .sidebar-nav a { justify-content: center; padding: 12px; }
  .main-wrapper { margin-left: 60px; }
  .generator-grid { grid-template-columns: 1fr; }
  .page-header, .main-content { padding-left: 16px; padding-right: 16px; }
}
